Win32 API creating menus

This is a discussion on Win32 API creating menus within the Windows Programming forums, part of the Platform Specific Boards category; okay so I'm in the middle of the forgers winapi book and I've pretty much got everthing to this point ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    106

    Win32 API creating menus

    okay so I'm in the middle of the forgers winapi book and I've pretty much got everthing to this point down, but now I'm at the part for creating menus and it says to open your resource file and put this code in it but there is no resource file... So I tried creating one and putting the code in but it did not work... Am I missing something?

  2. #2
    Grey Wizard C_Sparky's Avatar
    Join Date
    Sep 2009
    Posts
    50
    What compiler are you using?

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    11

    Setting up a Menu Resource file

    Hi Jamort,

    I will try to outline how you can set up a resource file for a menu.

    1. Go to your WinMain and locate the section where you set up the windows class.

    wcl.lpszMenuName = "MyMenu"

    You can use your windowclass name in place of the wcl. and what ever
    you call your menu will go in place of the "MyMenu".

    2. If you have accelerators keys you will need to go to the line
    that looks something like this --

    hAccel = LoadAccelerators(hThisInst, "MyMenu");

    Here you will put the MyMenu or your menu name here.

    3. If you have accelerators keys you will most likely have the
    following line in your message loop.

    if(!TranslateAccelerator(hwnd, hAccel, &msg))

    Here you will need to place the handle returned from LoadAccelerators.

    4. The Name of the Resource text file does not matter but you
    can name it what ever your main source code file is.

    filename.rc

    The important thing here is the *.rc ending since that is what
    the system looks for. The resource file will need to be complied
    into a *.res file that can then be linked in with every thing else.
    Microsoft Visual C++ 2010 Express and Borland C++ X IDE systems take care of this automatically. If your system is different you will need to find out how to compile the *.rc file and make a *.res file.
    You might note that Microsoft Visual C++ 2010 Express does not have
    a resource editor so just use a text editor to make *.rc text file.

    Inside of the *.rc file you will most likely have a #include "*.h"
    and possibly other includes at the top of the file. The next item
    should be:

    MyMenu MENU
    {
    WHAT EVERY GOES IN THE *.RC FILE
    }

    The important thing is the MyMenu or what ever you called it must
    go here because this is what ties it back to the WinMain when linking.

    I hope this helps.

    Good Luck

    Bill
    Last edited by Bill Agnor; 06-25-2010 at 11:04 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 10:38 AM
  2. Domain for Win32 API
    By maxorator in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-28-2006, 11:16 AM
  3. Replies: 7
    Last Post: 09-18-2005, 09:11 PM
  4. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 06:57 PM
  5. Win32 API Tutorials?
    By c++_n00b in forum C++ Programming
    Replies: 9
    Last Post: 05-09-2002, 04:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21