//ProgressDialog.h class CProgressDialog : public CDialog { // Construction public: CProgressDialog(LPCSTR caption, BOOL enableCancel=TRUE, CWnd* pParent = NULL); // standard constructor virtual ~CProgressDialog(void); // Dialog Data //{{AFX_DATA(CProgressDialog) enum { IDD = IDD_PROGRESS_DIALOG }; CStatic m_MessageStatic; //进程条标题 CButton m_CancelButton; //中止按钮控键 CProgressCtrl m_ProgressCtrl; //}}AFX_DATA CString m_Caption; //对话框标题 BOOL m_EnableCancel; //中止按钮显示开关 BOOL m_IsCancel; //中止按钮是否按下开关 HANDLE m_Thread; //线程句柄 static DWORD WINAPI ThreadProc(CProgressDialog* dlg); //静态线程 void SetProgress(int percent) //设置进程位置 { m_ProgressCtrl.SetPos(percent);} void SetMessage(LPCSTR msg) //设置进程条标题 { m_MessageStatic.SetWindowText(msg);} BOOL IsCancel(void) { return m_IsCancel;} virtual DWORD ProgressProc()=0;//线程过程纯虚函数 // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CProgressDialog) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CProgressDialog) virtual BOOL OnInitDialog(); virtual void OnCancel(); virtual void OnOK(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; class CMyProgressDialog:public CProgressDialog { public: CMyProgressDialog(LPCSTR caption):CProgressDialog(caption) {} virtual DWORD ProgressProc(); //继承过程 }; // ProgressDialog.cpp #include "stdafx.h" #include "ProgressTest.h" #include "ProgressDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif |