Jump to content
  • Advertisement

Archived

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

Add menu??

This topic is 6024 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

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!!!

Share this post


Link to post
Share on other sites
Advertisement
Try this:

  
// 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

IDM_MENU1, //A 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

}


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.

Share this post


Link to post
Share on other sites
Sorry, stupid of me...here''s the adjusted code:

  
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

LoadMenu(hInstance,(LPCTSTR)IDM_MENU1), // 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

}


lol...should work...

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

I finally got it all together...
...and then forgot where I put it.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!