- Can't create MDI child window
- Posted by Squid Seven on April 12th, 2005
I am a moderately experienced c++ programmer trying to learn the windows
API - specifically the MDI at the moment. I am trying to get a
program from a tutorial to work. When the following function is
executed, the if selection structure is activated and no child window
results. This function is called in WinMain after successful creation
of the client window ( a handle to which is passed to the function as
hMDIClient) and successful registration of the globally defined
WNDCLASSEX object g_szChildClassName, which is also used to create the
client window. Can anyone tell me what I am doing wrong, or suggest an
approach I could use to solve the problem?
HWND CreateNewMDIChild(HWND hMDIClient)
{
MDICREATESTRUCT mcs;
HWND hChild;
mcs.szTitle = "[Untitled]";
mcs.szClass = g_szChildClassName;
mcs.hOwner = GetModuleHandle(NULL);
mcs.x = mcs.cx = CW_USEDEFAULT;
mcs.y = mcs.cy = CW_USEDEFAULT;
mcs.style = MDIS_ALLCHILDSTYLES;
hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
if(!hChild)
{
MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
MB_ICONEXCLAMATION | MB_OK);
}
return hChild;
}
In the windows procedure for hMDIClient, the WM_MDICREATE message is not
explicitly handled, but rather passed off to:
default:
return DefMDIChildProc( hwnd, msg, wParam, lParam );
- Posted by Alex Blekhman on April 12th, 2005
Squid Seven wrote:
I didn't try your code, but MSDN says about WM_MDICREATE that
MDIS_ALLCHILDSTYLES style is for MDI *client*, not for MDI child.
Also, try to call CreateMDIWindow function instead of sending
WM_MDICREATE, and if it fails look what GetLastError returns.
- Posted by Squid Seven on April 13th, 2005
Tried doing same with CreateMDIWindow function and got same results -
also read bit about MDIS_ALLCHILDSTYLES and tried variations. Don't
know how to display value returned by GetLastError - was working on when
posted to this group and still haven't figured out - am noobie to
windows api. can you lay a piece of code on me to output value returned
by GetLastError to my MessageBox?
-thanks for help
Alex Blekhman wrote:
- Posted by Alex Blekhman on April 13th, 2005
Squid Seven wrote:
Here's example how to do that:
"Retrieving the Last-Error Code"
http://msdn.microsoft.com/library/en...error_code.asp
- When an mdi child window is closed is the frame window notified? (Development Resources) by Eric Lilja
- When an MDI child window is destroyed, is the frame window notified? (Development Resources) by William Payne
- Scroll in child window (Development Resources) by Wojtek
- Steps to create WDM Child Display Driver (Drivers) by Mahesh
- The proper way to create rebar and toolbar child windows? (Development Resources) by Bill Holt

