CDialog类


CDialog类是MFC对话框基类

对话框有两类:模态对话框和非模态对话框。模态对话框在应用继续进行之前必须关闭,非模态则不需要

 

CDialog重载了三个构造函数

 

CDialog();//缺省构造函数

CDialog(UINT nlDTemplate,CWnd*pParentWnd=NULL);//从指定的对话模板资源ID创建

CDialog(LPCTSTR lpszTemplateName,CWnd*pParentWnd=NULL);//从指定的对话框模板资源名称创建

 

成员方法:

 

消息响应函数:

 

 

 

 CDialogEx是CDialog的扩展类,具备基类全部功能,并根据新系统需要增加了一些界面美化功能,例如修改对话框背景颜色,标题栏颜色等。

 

成员方法:

 

class CDialog : public CWnd { DECLARE_DYNAMIC(CDialog) // Modeless construct
public: CDialog(); void Initialize(); virtual BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL); virtual BOOL Create(UINT nIDTemplate, CWnd* pParentWnd = NULL); virtual BOOL CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd = NULL, void* lpDialogInit = NULL); virtual BOOL CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd = NULL); // Modal construct
public: explicit CDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL); explicit CDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL); BOOL InitModalIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd = NULL, void* lpDialogInit = NULL); BOOL InitModalIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd = NULL); // Attributes
public: void MapDialogRect(LPRECT lpRect) const; void SetHelpID(UINT nIDR); // Operations
public: // modal processing
    virtual INT_PTR DoModal(); // support for passing on tab control - use 'PostMessage' if needed
    void NextDlgCtrl() const; void PrevDlgCtrl() const; void GotoDlgCtrl(CWnd* pWndCtrl); // default button access
    void SetDefID(UINT nID); DWORD GetDefID() const; // termination
    void EndDialog(int nResult); // Overridables (special message map entries)
    virtual BOOL OnInitDialog(); virtual void OnSetFont(CFont* pFont); protected: virtual void OnOK(); virtual void OnCancel(); // Implementation
public: virtual ~CDialog(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif
    virtual BOOL PreTranslateMessage(MSG* pMsg); virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); virtual BOOL CheckAutoCenter(); protected: UINT m_nIDHelp; // Help ID (0 for none, see HID_BASE_RESOURCE) // parameters for 'DoModal'
    LPCTSTR m_lpszTemplateName;     // name or MAKEINTRESOURCE
    HGLOBAL m_hDialogTemplate;      // indirect (m_lpDialogTemplate == NULL)
    LPCDLGTEMPLATE m_lpDialogTemplate;  // indirect if (m_lpszTemplateName == NULL)
    void* m_lpDialogInit;           // DLGINIT resource data
    CWnd* m_pParentWnd;             // parent/owner window
    HWND m_hWndTop;                 // top level parent window (may be disabled)
    BOOL m_bClosedByEndDialog;        // indicates that the dialog was closed by calling EndDialog method
 _AFX_OCC_DIALOG_INFO* m_pOccDialogInfo; virtual BOOL SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo); virtual _AFX_OCC_DIALOG_INFO* GetOccDialogInfo(); virtual void PreInitDialog(); // implementation helpers
 HWND PreModal(); void PostModal(); BOOL CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd, void* lpDialogInit, HINSTANCE hInst); BOOL CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd, HINSTANCE hInst); protected: afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam); afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM); afx_msg void OnSetFont(CFont* pFont, BOOL bRedraw); afx_msg void OnPaint(); afx_msg BOOL OnQueryEndSession(); afx_msg void OnEndSession(BOOL bEnding); DECLARE_MESSAGE_MAP() };

 

 

BEGIN_MESSAGE_MAP(CDialog, CWnd) ON_COMMAND(IDOK, &CDialog::OnOK) ON_COMMAND(IDCANCEL, &CDialog::OnCancel) ON_MESSAGE(WM_COMMANDHELP, &CDialog::OnCommandHelp) ON_MESSAGE(WM_HELPHITTEST, &CDialog::OnHelpHitTest) ON_MESSAGE(WM_INITDIALOG, &CDialog::HandleInitDialog) ON_WM_SETFONT() ON_WM_PAINT() ON_WM_QUERYENDSESSION() ON_WM_ENDSESSION() END_MESSAGE_MAP()

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM