Win32 Windows programming Eight

Source: Internet
Author: User

First, the System menu

1 executes commands from the system-provided window, such as maximize, close, and so on. Essentially the same as the normal menu, so we can also use this menu in the program

2 use of the system menu

2.1 Getting the System menu

GetSystemMenu

HMENU GetSystemMenu (

HWND hwnd,//window handle to get

BOOL Brevert; Get Reset Identity

);

Brevert:true Reset FALSE does not reset

When True, resets the menu to the default state and returns the menu handle, false to not reset, gets the status of the current system menu

2.2 Modify the system menu, such as Add, delete

AppendMenu

InsertMenu

Added a location for inserting menu items than AppendMenu

Removemenu

Delete a menu item

2.3 Response commands for the System menu

System Menu Response Command, really wm_syscommand in

Wparam-loword (WPARAm) to increase the ID of the menu

Second, right-click menu

1 popup menu when right button is clicked in window.

2 use of the right-click menu

2.1 Creating a Menu

Createpopmenu

2.2 Menu Additions

Appendmenu/insertmenu

2.3 Display of the menu

TrackPopupMenu

BOOL TrackPopupMenu (  HMENU  HMENU,         //Handle to shortcut menu  UINT uflags ,          Options  int  x,               //Horizontal position  int  y  ,               //Vertical position  int  nreserved,       //Reserved , must is zero  hwnd  hwnd,           //Handle to owner window  CONST RECT  * prcrect  //ignored); 


2.4 Menu command handling

Wm_command

2.5 Where to use the right-click menu

Add menu creation and display in 2.5.1 Wm_rbuttonup

Right-click Message coordinates are converted to screen coordinates using-clienttoscreen

2.5.2 Wm_contextmenu

Message to display the right-click menu

WPARAM-the corresponding window handle when the right button is lifted

LPARAM-screen coordinates when the right button is lifted

2.5.3 Wm_rbuttonup and Wm_contextmenu contrast

1) coordinate system, Wm_rbuttonup client area coordinates wm_contextmenu screen coordinates

2) Wm_rbuttonup prior to wm_contextmenu execution


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.