home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / vcoledb / consumer / multiread / multidlg.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  1KB  |  51 lines

  1. // MultiDlg.cpp : Implementation of CMultiDlg
  2. #include "stdafx.h"
  3. #include "MultiDlg.h"
  4. #include "DBRead.h"
  5.  
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CMultiDlg
  8.  
  9. CMultiDlg::CMultiDlg()
  10. {
  11. }
  12.  
  13. CMultiDlg::~CMultiDlg()
  14. {
  15. }
  16.  
  17. LRESULT CMultiDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  18. {
  19.     CenterWindow();
  20.     return 1;  // Let the system set the focus
  21. }
  22.  
  23. LRESULT CMultiDlg::OnRun(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  24. {
  25.     TCHAR   szMsg[256];
  26.     long    nThreads = GetDlgItemInt(IDC_THREADS);
  27.     DWORD   dwTime, dwRows;
  28.  
  29.     if (nThreads < 1 || nThreads > MAXIMUM_WAIT_OBJECTS)
  30.     {
  31.         wsprintf(szMsg, _T("Must have between 1 and %d threads."), MAXIMUM_WAIT_OBJECTS);
  32.         MessageBox(szMsg, _T("Error"), 0);
  33.         return 0;
  34.     }
  35.  
  36.     // Clear text first so we know when it's finished
  37.     SetDlgItemText(IDC_MESSAGE, _T(""));
  38.     ReadRecords(nThreads, &dwTime, &dwRows);
  39.  
  40.     wsprintf(szMsg, _T("%d records in %ld ms"), dwRows, dwTime);
  41.     SetDlgItemText(IDC_MESSAGE, szMsg);
  42.  
  43.     return 0;
  44. }
  45.  
  46. LRESULT CMultiDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  47. {
  48.     EndDialog(wID);
  49.     return 0;
  50. }
  51.