Difference between CDialog and CDialogEx

2019-06-21 02:52发布

What is the difference between CDialog and CDialogEx? I decided to use CDialog because I can't assign m_pMainWnd to Dlg if Dlg is derived from CDialogEx.

BOOL CPreparationApp::InitInstance()
{
    MyClass2 Dlg; //derived from CDialog 
    m_pMainWnd = &Dlg;
    Dlg.DoModal();
    return TRUE;
}

What kind of problems I might fave by not using CDialogEx like form wizard was offering?

How to assign m_pMainWnd variable derived from CDialogEx?

3条回答
我命由我不由天
2楼-- · 2019-06-21 03:38

CDialogEX is derived from CDialog, so, setting m_pMainWnd to a CDialogEx derived object should not be a problem. CDialogEx provides the abillity to set the background color or image of the dialog.

查看更多
叼着烟拽天下
3楼-- · 2019-06-21 03:38

I had a case where a menu button was not working properly and the MFC source code recommended to replace CDialog by CDialogEx:

CMFCMenuButton does not close

And after I did it, everything worked right!

查看更多
地球回转人心会变
4楼-- · 2019-06-21 03:51

CDialogEX is used for setting background color, background images on dialog, If you want to set background images or color then your class will be derived from CDialogEX,but keep in mind If you are using CDialaogEX then you should use method of that class like CreateEX,If you are trying to derive class from CDilaogEX and use CDialog Method,then you will got Error..

查看更多
登录 后发表回答