Jump to content
  • Advertisement
Sign in to follow this  
Portishead

[c++] MDI client & windows

This topic is 3410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using this tutorial: http://www.winprog.org/tutorial/app_four.html, but I can't understand what he did when he created the MDI client window. This is the code from the tutorial that I'm talking about:
 CLIENTCREATESTRUCT ccs;

    ccs.hWindowMenu  = GetSubMenu(GetMenu(hwnd), 2);
    ccs.idFirstChild = ID_MDI_FIRSTCHILD;

    g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL,
        WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
        hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);


He gave the MDI client menu handle the handle of the menu that he wants the MDI client child windows to appear in[As a list with V's next to the one that's active].. I don't get if this is something built-in with MDI's, and do I always have to give the MDI a handle to the program's menu? There's another piece in that part that I didn't understand, but maybe if I'll understand this piece, I will understand the other one too. Thanks for any helpers, Portishead.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
I don't get if this is something built-in with MDI's, and do I always have to give the MDI a handle to the program's menu?

If you check how MDI works, you'll notice the documents (which you're creating here) do not have a menu. However the MDI frame window (the "container") has a menu which changes depending on which document has focus, which is why it needs to know about that menu...
Your MDI documents don't need any menus?
edit: I'm just too slow

Share this post


Link to post
Share on other sites
I suppose you could add a menu to the MDI document itself but that'd look kind of weird since it's normally not done that way (an important thing to do when designing a user interface for an application is to stick to the standards of the system you target)...

Share this post


Link to post
Share on other sites
There's anoter piece of code on MDI there that I didn't understand:

default:
{
if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
{
DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
}
else
{
HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
if(hChild)
{
SendMessage(hChild, WM_COMMAND, wParam, lParam);
}
}
}



If I'm right, he passes the message that came from a child window, to the active child window, but wouldn't the child window procedure already handle the messages?
And he knows that LOWORD(wParam) < ID_MDI_FIRST_CHILD is a message from a child window, because he already took care of all the other ID's with switch cases, right?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!