Application is getting crashed when I drag the dialog box created through MFC because of DDX mechanism

128 views Asked by At

I am able to fix the bug I got but I am interested in the reason behind the bug.

I used my combo box (which was created using DDX mechanism) pointer as argument in one of my method.

For example:

bool CMyStuff::FillCombo(CComboBox* combo_ctrl)

But my combo box is generated by drag and drop, MFC by default created an object instead of pointer. As I required a pointer to send, I changed that member variable to a pointer.

But after this I got compilation error as DDX does not takes pointer as an input. So changed my DDX code from:

    DDX_Control(pDX, IDC_COMBO1, m_ptr_combo1);

to

    DDX_Control(pDX, IDC_COMBO1, *m_ptr_combo1);

Now application compiled successfully and when I launch my application the dialog has also shown properly. (Note: usually dialog will be shown at the center of the desktop but this time it shown at the left top corner).

Now when I drag my dialog or do anything, application is getting crashed.

When I changed this whole declaration and sent a reference instead of pointer, my application is working properly. Can anybody explain the reasons behind this behavior?

0

There are 0 answers