Ionut Daniel
Ionut Daniel

Reputation: 312

CDialog object not created

I have a problem with an MFC project. The project has recently been converted to an window less project, meaning the window it is still created but it is hidden. It worked fine, no problems.

Now it has a problem, the object created by a class that derives CDialog is not created.

class CCRViewerDlg : public CDialog

And the problem occures here :

CCRViewerDlg dlg; //here hWnd = 0x000000

if( dlg.Create( CCRViewerDlg::IDD )) 
{
    dlg.ShowWindow( SW_HIDE );
    m_pMainWnd = &dlg;
    INT_PTR nResponse = dlg.RunModalLoop();
}

The code is not entering the if loop, and hWnd remains unaddressed.

The code above is in the first line's of the BOOL CCRViewerApp::InitInstance()

Could you help me identify the cause of this problem ?

Thanks.

Upvotes: 0

Views: 577

Answers (1)

Zrn-dev
Zrn-dev

Reputation: 169

In my case, I had Custom Control in CMydlg, but without any initialization/linking through message map.

and when I created dlg I got this error as you:

myDlg.Create(IDD_DIALOG_MY, this);     // myDlg.m_hwnd = 0x000000
printf("GetLastErr - %d\n", GetLastError()); // err : 0

what I did is:

just removed custom control from dlg for now

in order to create dlg first

Upvotes: 1

Related Questions