Results 1 to 5 of 5

Thread: WinAPI menu

  1. #1
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    13

    WinAPI menu

    I've written a C++ program in Visual Studio 2008 using OpenGL, GLUT, and GLUI. I wish to add a winAPI menu to the top of the window (not the popup ones). I'm wondering how I should go about in doing this? Thanks!

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    4

    Re: WinAPI menu

    what do you mean by not the pop up ones?

  3. #3
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    13

    Re: WinAPI menu

    Like I want the ones that appear on top of the window instead of the right click or middle click menus.

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    4

    Re: WinAPI menu

    lol ok

    1- create a resource for the menu, goto resource view and create a menu into the project. Editing the menu is simple

    2- make sure resource.h is included in where you are creating the window

    3- where you create and register the class add the name of the menu resource ( for example where iv bolded )
    Code :
    m_hInst = instance;
     
    	// Register your window "class" with Windows
    	WNDCLASS wc;
    	//wc.cbSize = sizeof(WNDCLASSEX);
    	wc.cbClsExtra = 0;
    	wc.cbWndExtra = 0;
    	wc.hbrBackground = 0;
    	wc.hCursor = LoadCursor(0, IDC_ARROW);
    	wc.hIcon = 0;
    	wc.hInstance = instance;
    	wc.lpfnWndProc = wndproc;
    	wc.lpszClassName = L"name";
    	wc.lpszMenuName = MAKEINTRESOURCE([B]IDR_MENU1[/B]);
    	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    	if ( 0 == RegisterClass( &wc ) )
    		throw std::runtime_error( "RegisterClass failed" );

    4- in callback do
    Code :
     
    switch ( msg )
    	{
    	case WM_COMMAND:
    		{
    			wmId    = LOWORD(wParam);
    			wmEvent = HIWORD(wParam);
    			// Parse the menu selections:
    			switch (wmId)
    			{
    			case **menu button id**:
    				{
                                     // code here for button
                                    }
                                     break;
                             }
    }
    }

  5. #5
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    13

    Re: WinAPI menu

    Thank you, that's just what I needed

Similar Threads

  1. WinAPI with OpenGL
    By Mukund in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-31-2010, 12:45 PM
  2. GLUT, How to add menu entries into the sub menu??
    By Asura in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-15-2006, 08:27 AM
  3. winAPI functions
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-08-2006, 06:43 PM
  4. WinAPI menu and OpenGL
    By The Wolf in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-24-2003, 11:06 PM
  5. OpenGL & WinApi
    By imported_Douglas in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 03-26-2001, 11:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean