Click to See Complete Forum and Search --> : MDI Client Window Creation


Erik Wiggins
March 22nd, 2004, 10:23 AM
Ok I'm really strugelling with MDI creation. So I'm going to take it one step at a time. I know that my Frame window works because when I run it as a stand alone window it works fine. When I try to add Client window creation into the picture everything compiles right but nothing shows on the screen. My first question is with the Client Create Struncture.

I have my Frame window created and it's handle is hWnd. It has a Menu IDR_Menu1. IDR_MENU1 has to drop down menu's File and Window.

First, am I correct in assuming that you must have a menu with a Window submenu assigned to the Framewindow class?

Second, with the given information is this correct?

hWindowMenu = GetSubMenu(GetMenu(hWnd),1)


Third, idFirstChild where does it come from. How do I use it right? I've tried a define statment

#define ID_FIRSTCHILD 5000
WM_CREATE
{
CLIENTCREATESTRUCT ccs;
ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd),1)
ccs.idFirstChild = ID_FIRSTCHILD;

CreateWindowEx(
WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT,
"MDICLIENT",
(LPCTSTR) NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT0,
hWnd,
NULL,
hInst,
(LPSTR) &ccs
);
}
brake;

I've even tried adding it as a menu item and assigning it to the menu ID. What is the correct way to do this?

At this point I'm not sure I've done anything right and trial and error don't seem to be working. I've tried creating the child window using CreateWindowEx. Iv'e tried to do it by sendinf a WM_MDICREATE message to the client window. I've also tried the CreateMDIWindow function. I've tried doing all these from the WM_CREATE for the frame window and from WinMain it's self. Nothing seems to work. I finally tried skipping the child window all together and just making a frame and client window. At which point I get the same resault the program compiles properly. When I try to exacute I get nothing, No window appaers what so ever. TaskManager however does show the program runing underprocess and I have to end task to recompile my code. All of the toturials are adding so much extra to the source code that I can't desifer what is base code and what is for all the extra stuff. MSDN leave alot of stuff out assuming you already know stuff you are tring to learn. So please I need someone to hold my hand and walk me through creating a simple MDI that does nothing exsept for open and close windows. At this point I'd settle for a well anoatated workspace as long as it only does the very basics.

NoHero
March 24th, 2004, 02:32 PM
i tried it and it worked if you make the main loop as described in the msdn, just look at "MDI windows [win 32]" artice. Somewhere here it is specified that you must call a function in the mainloop ... *searching* ...

ng

Erik Wiggins
March 26th, 2004, 10:28 PM
Ok I've finally got it to work and found out why all this time I have had so much problems with it. For some reason the client window must be created inside the frame windows WM_CREATE message and it must be with the HWND parameter passed to the WinProc of the frame window. I can learn to leave with this however I am a little perplexed about why it is like that. My first thaught was that it's because the HWND changes and the value passed to the WinProc is differant then the value returned by the CreateWindow function. However I tried moving the CreateWindow function into the WinMain function and then setting the HWND variable to the value of the HWND parameter passed to the WinProc and that still did not work. Can anyone tell me why the CreateWindow function for the Client window has to be Inside the WM_CREATE message of the frame windows WinProc?

ikk
December 20th, 2005, 02:40 PM
because all CreateWindow procedures must be in same thread as message loop