I am doing an MFC application in which I am trying to create a dialog box.
Here is my code snippet:
// GLobals:
CWnd* parent;
CRect rect3;
virtual BOOL OnInitDialog()
{
...
GetDlgItem(IDC_OPENGL)->GetWindowRect(rect3);
/
ScreenToClient(rect3);
parent = (CWnd*) GetDlgItem(IDC_OPENGL)->GetParent();
Create(rect3,parent); // i tried using Create(rect3, this);
...
}
void Create(CRect rect, CWnd *parent)
{
CString className = AfxRegisterWndClass(
CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
NULL,
(HBRUSH)GetStockObject(BLACK_BRUSH),
NULL);
CreateEx(
0,
className,
"OpenGL",
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
rect,
parent,
0);
}
However the CreateEx fails and Debug Assertion Failed window pops up (...\src\mfc\wincore.cpp). My initial guess that it is problem with the pointer to the parent dialog box.
Once I comment the CreateEx inside the Create function, everything works fine.
Can anybody please help me?