Win32 windows programming menu bar

Source: Internet
Author: User

As it is necessary to do things, we try to implement the menu bar.

First, add the menu item options (buttons) in (resource. h)

// "Edit menu"
# Define idm_editcopy 211 // copy.
# Define idm_editpaste 212 // Paste
// Help menu
# Define idm_about 221 // about
# Define idm_game1 222 // games
# Define idm_game2 223 //
# Define idm_game3 224

Add the following code to the resource file (the file ending with. Rc:

 

// Define menu resources below
Menuappmenu menu discardable // menu identifier
Begin
Popup "file (& F )"
Begin
Menuitem "New (& n)", idm_new
Menuitem separator // separator bar
Menuitem "exit (& X)", idm_exit
End
Popup "Edit (& E )"
Begin
Menuitem "Copy (& C)", idm_editcopy
Menuitem Separator
Menuitem "paste (& P)", idm_editpaste, grayed

// The start is gray and unavailable
End
Popup "games (& S )"
Begin
Menuitem "game1 (g)", idm_game1
Menuitem "game2 (m)", idm_game2
Menuitem "game3 (E)", idm_game3
End
Popup "Help (& H )"
Begin
Menuitem "about (& A)... \ TF1", idm_about
End
End

However, to display the menu items, add the following to the CPP file (winmain:

Wndclass. lpszmenuname = "menuappmenu"; if you do not want to display the menu, you can

Wndclass. lpszmenuname = NULL;

---- Record the details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.