///////////////////////////////////////////////////////////////////////////// // dialogDemoDlg2.h - Demonstrate use of UI and worker threads // // Jim Fawcett, CSE778 - Advanced Windows Programming, Summer 2003 // Version 1.0 : 07 July 2003 // - revised signatures of user defined message handlers so // will compile under Visual Studio C++, version 7.0 // - replaced Win32 threads with MFC's CWinThread class // - used CCriticalSection to synchronize access to a shared // integer count instead of sending as a message parameter ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_DIALOGDEMODLG_H__9E25AF00_EC72_42CB_B0D4_C7B507EC0B3D__INCLUDED_) #define AFX_DIALOGDEMODLG_H__9E25AF00_EC72_42CB_B0D4_C7B507EC0B3D__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "afxmt.h" ///////////////////////////////////////////////////////////////////////////// // CDialogDemoDlg - dialog class class CDialogDemoDlg; struct tArgs { int count; CDialogDemoDlg* pDlg; }; class CDialogDemoDlg : public CDialog { // Construction public: CDialogDemoDlg(CWnd* pParent = NULL); // standard constructor ~CDialogDemoDlg(); void SetCount(int i) { count = i; } void SetLock() { pCs->Lock(); } void SetUnlock() { pCs->Unlock(); } // Dialog Data //{{AFX_DATA(CDialogDemoDlg) enum { IDD = IDD_DIALOGDEMO_DIALOG }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDialogDemoDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // // Implementation protected: HICON m_hIcon; // Generated message map functions //{{AFX_MSG(CDialogDemoDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnChangeEdit1(); afx_msg void OnNo(); afx_msg void OnYes(); virtual void OnOK(); afx_msg void OnStop(); afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSetCount(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSetIter(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSetFocus(WPARAM wParam, LPARAM lParam); afx_msg void OnHighest(); afx_msg void OnNormal(); afx_msg void OnLowest(); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: bool workerThread; enum Prior { Lowest, Normal, Highest } workerThreadPriority; int count; CWinThread* pThread; CCriticalSection* pCs; int CurrCount; }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DIALOGDEMODLG_H__9E25AF00_EC72_42CB_B0D4_C7B507EC0B3D__INCLUDED_)