CDialogEx是VS2003之后出现的,VC++6.0没有。
CDialogEx = CDialog Extend
Extend的意思是扩展,即扩展的CDialog!
这个类是CDialog的扩展类,基类就是CDialog,具备基类全部功能,并根据新系统需要增加了一些界面美化的功能。
比如修改对话框的背景颜色,标题栏的颜色,标题栏的位图,标题栏字体的位置和颜色,包括激活和非激活状态,对话框边界的颜色,对话框字体等。
如果使用的是VS2005之后的版本,推荐使用CDialogEx,好看一些,VC++6就不要想了,老实用CDialog吧。
两个在基础功能上没什么区别,但因为版本不同,MFC向导生成的类模板差异较大。
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
/ // CDialogEx dialog class CDialogEx : public CDialog { friend class CMFCPopupMenu; friend class CMFCDropDownListBox; friend class CContextMenuManager; DECLARE_DYNAMIC(CDialogEx) // Construction public : CDialogEx(); CDialogEx(UINT nIDTemplate, CWnd *pParent = NULL ); CDialogEx(LPCTSTR lpszTemplateName, CWnd *pParentWnd = NULL ); protected : void CommonConstruct(); // Attributes: public : enum BackgroundLocation { BACKGR_TILE, BACKGR_TOPLEFT, BACKGR_TOPRIGHT, BACKGR_BOTTOMLEFT, BACKGR_BOTTOMRIGHT, }; protected : HBITMAP m_hBkgrBitmap; CSize m_sizeBkgrBitmap; CBrush m_brBkgr; BackgroundLocation m_BkgrLocation; CDialogImpl m_Impl; BOOL m_bAutoDestroyBmp; // Operations: public : void SetBackgroundColor(COLORREF color, BOOL bRepaint = TRUE); void SetBackgroundImage(HBITMAP hBitmap, BackgroundLocation location = BACKGR_TILE, BOOL bAutoDestroy = TRUE, BOOL bRepaint = TRUE); BOOL SetBackgroundImage(UINT uiBmpResId, BackgroundLocation location = BACKGR_TILE, BOOL bRepaint = TRUE); // Overrides public : virtual BOOL PreTranslateMessage(MSG* pMsg); protected : virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); // Implementation protected : //{{AFX_MSG(CDialogEx) afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized); afx_msg BOOL OnNcActivate(BOOL bActive); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnDestroy(); afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); afx_msg void OnSysColorChange(); afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); //}}AFX_MSG DECLARE_MESSAGE_MAP() void SetActiveMenu(CMFCPopupMenu* pMenu); }; |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
/ // CDialog - a modal or modeless dialog class CDialog : public CWnd { DECLARE_DYNAMIC(CDialog) // Modeless construct public : CDialog(); 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) #ifndef _AFX_NO_OCC_SUPPORT _AFX_OCC_DIALOG_INFO* m_pOccDialogInfo; virtual BOOL SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo); virtual _AFX_OCC_DIALOG_INFO* GetOccDialogInfo(); #endif 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(CDialog) afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam); afx_msg LRESULT HandleInitDialog(WPARAM, LPARAM); afx_msg LRESULT HandleSetFont(WPARAM, LPARAM); afx_msg void OnPaint(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; // all CModalDialog functionality is now in CDialog #define CModalDialog CDialog |
CDialogEx=CDialog ExtendExtend的意思是扩展,即扩展的CDialog