Archived

This topic is now archived and is closed to further replies.

Russell

MDI Child Window

Recommended Posts

I am working on the GUI for my chess program, and I''m trying to get some child windows to open up for things like the move list and other things like that. Everything appears to be working fine (the main window and the MDI Client are both created, as well as the MDI child window), but the MDI child window is not visible. I used Spy++ to verify that the MDI child window was in fact created, but it simply is not visible on the screen. If you have any ideas or would like to see my code, I''d be happy to hear your ideas or post the code. Thanks, Russell

Share this post


Link to post
Share on other sites
- make sure that you are calling DefFrameProc instead of DefWindowProc in your main WndProc

- make sure you call DefMDIChildProc for your MDI child WndProc

- when you create MDI child window, use flag VISIBLE or then call ShowWindow(, SW_SHOW)

- for a start try to eliminate all the possibble WM_x that you have in MDI child WndProc, and ALWAYS return DefMDIChildProc, (not like in WndProc)

- use flag VISIBLE or ShowWindow() with your MDICLient window too ofcourse

Share this post


Link to post
Share on other sites
Ok, I was using DefWindowProc instead of DefFrameProc, so that fixed that. But now I have another problem. If I minimize of maximize the MDI child window, it goes off the screen. The MDI Client also looks a little weird, like it has a small border that makes the border of the main window look a little odd. Here''s a screenshot of what the MDI client looks like inside of the main window.

Share this post


Link to post
Share on other sites
Ok, all is working well. I figured out the problem, in case anyone would like to know for future reference.

I got rid of the small border around the MDI client by calling CreateWindow instead of CreateWindowEx. The reason that my child windows weren''t working correctly, is because in my WindowProc and ChildWindowProc message handling functions, I had "return 0;" inside of each case statement after handling each message. The problem is, that with MDI, you need to return the proper default message handling function so that MDI can handle it''s messages properly. For your main window message processing function, you need to call DefFrameProc, and for your child window message processing function, you need to call DefMDIChildProc. By doing a "return 0;" in each case statement, DefFrameProc and DefMDIChildProc were never getting called. I removed all of the "return 0;" lines and everything works like a charm

In learning MDI over the last 24 hours, I have learned that the most important thing is making sure that your messages get where they need to go. Like the main window gets it''s messages, the MDI client get''s it''s messages, and the child window''s messages get passed to it.

Share this post


Link to post
Share on other sites