Add menu??

Started by
2 comments, last by joey81 22 years, 5 months ago
This is the code from the tutorials: // Create The Window if (!(hWnd=CreateWindowEx(dwExStyle, "joey", //ClassName title, //WindowTitle dStyle | // Defined Window Style WS_CLIPSIBLINGS |// Required Window Style WS_CLIPCHILDREN, // Required Window Style 0, 0, // Window Position WindowRect.right-WindowRect.left, // Calculate Window Width WindowRect.bottom-WindowRect.top, // Calculate Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE { KillGLWindow(); // Reset The Display MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if i want to include a menu in this window, How do i change the code? what if there is a parent window available? How do i change the code? Thanks for reading through the code.... Any help is appreciated!!!
Advertisement
Try this:

  // Create The Windowif (!(hWnd=CreateWindowEx(dwExStyle, "joey", //ClassNametitle, //WindowTitledStyle | // Defined Window StyleWS_CLIPSIBLINGS |// Required Window StyleWS_CLIPCHILDREN, // Required Window Style 0, 0, // Window PositionWindowRect.right-WindowRect.left,// Calculate Window WidthWindowRect.bottom-WindowRect.top, // Calculate Window HeightNULL, // No Parent WindowIDM_MENU1, //A MenuhInstance, // InstanceNULL)))// Dont Pass Anything To WM_CREATE{KillGLWindow(); // Reset The DisplayMessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE; // Return FALSE}  


You will have to create a menu called IDM_MENU1 for this to work. I use VC++6, and it seems to work fine on that.

Hope this helps.

---------------

I finally got it all together...
...and then forgot where I put it.
Sorry, stupid of me...here''s the adjusted code:

  if (!(hWnd=CreateWindowEx(dwExStyle, "joey", //ClassNametitle, //WindowTitledStyle | // Defined Window StyleWS_CLIPSIBLINGS |// Required Window StyleWS_CLIPCHILDREN, // Required Window Style 0, 0, // Window PositionWindowRect.right-WindowRect.left,// Calculate Window WidthWindowRect.bottom-WindowRect.top, // Calculate Window HeightNULL, // No Parent WindowLoadMenu(hInstance,(LPCTSTR)IDM_MENU1), // No MenuhInstance, // InstanceNULL)))// Dont Pass Anything To WM_CREATE{KillGLWindow(); // Reset The DisplayMessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);return FALSE; // Return FALSE}  


lol...should work...

---------------

I finally got it all together...
...and then forgot where I put it.
I think the first code was right... The parameter for menus is an LPCTSTR value, not an HMENU. If you wanna specify an HMENU you specify it in your CreateWindow() call.

This topic is closed to new replies.

Advertisement