|
Question : Creating a child window
|
|
I want to create a simple child. For this purpose I created a new class derived from CWnd. I wrote a new Create method: RECT WindowRect; WindowRect.left=0; WindowRect.top=0; WindowRect.right=400; WindowRect.bottom=400; if(CWnd::Create(NULL,"AviWindow",WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE|WS_CHILD,WindowRect,AfxGetMainWnd(),NULL,NULL)) { return(1); }
But I do not get a visible new child window when I call this method. I can call the program but nothing happens despite the fact that I get a warning: Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called. What is wrong ?
|
|
Answer : Creating a child window
|
|
You're not creating the window correctly. The code below will create a window but it's not a very useful one. What are you trying to do in the window?
RECT WindowRect; WindowRect.left=0; WindowRect.top=0; WindowRect.right=400; WindowRect.bottom=400;
CWnd *myWnd = new CWnd(); if(!myWnd->Create(NULL, "AviWindow", WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE | WS_CHILD,WindowRect,AfxGetMainWnd(),NULL,NULL)){ AfxMessageBox("Error in Create", MB_OK); delete myWnd; } myWnd->ShowWindow(SW_SHOWNORMAL);
|
|
|
|