#pragma once // CMsgDlg 对话框 #define MSG_BOX_TIP 0x00 #define MSG_BOX_QUESTION 0x01 #define MSG_BOX_WARNING 0x02 #define MSG_BOX_ERROR 0x03 #define MSG_BOX_SUCCEED 0x04 #define WM_MSGDLG_SET_TITLE (WM_APP + 400) #define WM_MSGDLG_SET_MESSAGE (WM_APP + 401) #define WM_MSGDLG_SET_ICON (WM_APP + 402) #define WM_MSGDLG_SET_MARQUEE (WM_APP + 403) #define WM_MSGDLG_DELAY_CLOSE (WM_APP + 404) #define WM_MSGDLG_SET_COMPLETE (WM_APP + 405) class CMsgDlg : public CDialogEx { DECLARE_DYNAMIC(CMsgDlg) public: CMsgDlg(CWnd* pParent = nullptr); // 标准构造函数 CMsgDlg(CString strTitle, CString strMessage); CMsgDlg(int nIcon, CString strTitle, CString strMessage); virtual ~CMsgDlg(); public: void BeginThread(AFX_THREADPROC pfnThreadProc); void SetIcon(int nIcon); void SetTitle(CString strTitle); void SetMessage(CString strMessage); void DelayClose(int nDelay); void SetMarquee(_In_ BOOL fMarqueeMode, _In_ int nInterval); void ShowCloseButton(BOOL bVisible); void SetCompleteCode(int code); int GetCompleteCode(); void SetData(DWORD_PTR dwData); DWORD_PTR GetData(); void SetDataEx(DWORD_PTR dwData); DWORD_PTR GetDataEx(); private: void Resize(); void UpdateIcon(); bool IsUiThread() const; LRESULT OnMsgSetTitle(WPARAM wParam, LPARAM lParam); LRESULT OnMsgSetMessage(WPARAM wParam, LPARAM lParam); LRESULT OnMsgSetIcon(WPARAM wParam, LPARAM lParam); LRESULT OnMsgSetMarquee(WPARAM wParam, LPARAM lParam); LRESULT OnMsgDelayClose(WPARAM wParam, LPARAM lParam); LRESULT OnMsgSetComplete(WPARAM wParam, LPARAM lParam); private: COLORREF m_crBkgnd; CBrush m_brBkgnd; int m_nIcon; CString m_strTitle; CString m_strMessage; COLORREF m_crTitle; COLORREF m_crMessage; CFont m_fontTitle; CFont m_fontMsg; int m_nCompleteCode; DWORD_PTR m_dwData; DWORD_PTR m_dwDataEx; BOOL m_bDelayClose; DWORD m_uiThreadId; // 对话框数据 #ifdef AFX_DESIGN_TIME enum { IDD = IDD_DIALOG_MSG }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: virtual BOOL OnInitDialog(); afx_msg void OnTimer(UINT_PTR nIDEvent); virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); afx_msg void OnSize(UINT nType, int cx, int cy); };