Difference between CDialog and CDialogEx
Asked Answered
C

4

8

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 might I have, by not using CDialogEx like form wizard was offering?

How to assign m_pMainWnd variable derived from CDialogEx?

Chlodwig answered 3/4, 2014 at 13:29 Comment(1)
What type is m_pMainWnd?Bursary
V
9

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.

Vincenzovincible answered 3/4, 2014 at 13:42 Comment(0)
S
7

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 that if you are using CDialogEx, then you should use methods of that class (like CreateEx). And, if you are trying to derive a class from CDialogEx and use a CDialog method, then you will get an error.

Spree answered 3/8, 2015 at 7:11 Comment(0)
D
0

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!

Downgrade answered 14/8, 2015 at 11:33 Comment(0)
A
0

CDialogEx to create a back ground menu, button or they called it dialog box If you program a button when it pressed to prompt a window frame. To interact with the window frame, u need to use CDialog.

This is because CDialog directly inherits from CWnd.

Amorino answered 11/9, 2020 at 1:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.