Timer messages
1, Wm_timer
Automatically sends a timer message wm_timer to the window according to the time period set by the timer. Relatively low priority level
Low timer accuracy, millisecond level, and low message generation time
2. Messages and Functions
WM_TIMER: Message ID
ID of the WParam timer
Processing function of LParam timer
SetTimer : Setting a Timer
Uint_ptr SetTimer ( hwnd hwnd, //Handle to window handle can be null uint_ptr nidevent , Timer identifier Timer ID 0 is not preset ID UINT uelapse, / /time-out value timer interval timerproc lptimerfunc //Timer Procedure Timer processing function, can be null);
Returns a created Timer ID
KillTimer : End a timer
BOOL KillTimer (HWND hwnd,/ /handle to window handle Uint_ PTR uidevent //Timer identifier Timer ID);
Timerproc: Timer handler function
VOID CALLBACK Timerproc (hwnd hwnd, //Handle to window handle UINT umsg , Wm_timer messagewm_timer messages ID uint_ptr idevent , //Timer identifier Timer ID DWORD dwtime // current system time );
3. How to use
3.1 Creating Timers
3.1.1 Specifies the window handle HWND so the Timerproc parameter can be empty, then the WM_TIMER message will be sent to the specified window.
If not specified, the Timerproc cannot be empty and a timer handler must be specified.
3.1.2 If the timer ID settimer will create a timer based on this ID, if not specified, it will return a create timer ID
3.2 Processing Timer messages
can be processed separately according to the message incoming timer ID number
3.3 End Timer
KillTimer End timer when not in use
Menu
1. Menu Basics
Menu-Each menu will have a hmenu handle
menu item: Each menu item will have an ID number that can perform different actions depending on the ID.
2. Menu creation
2. Creation of the 1 menu
Createmenu-menu Menu
Createpopupmenu-popupmenu Pop-up menu
AppendMenu-Add menu item
BOOL appendmenu ( HMENU HMENU, //Handle to menu handle UINT uflags , Menu-item Options menu item Identification uint_ptr uidnewitem//identifier, menu, The ID of the Or submenu menu item or the self- lpctstr lpnewitem //menu-item content the name of the menu item );
Uflags
Mf_string-lpnewitem is a string
Mf_popup-uidnewitem is a sub-menu handle
Mf_separator-Adding split items
Mf_checket/mf_unchecked-Set and cancel the checkmark for a menu item
Mf_disabled/mf_enable-menu item forbidden and allowed states
2.2 Menu Command Response
2.2.1 Wm_conmand message
When a user taps a menu, button control, and so on, the system sends a WM_COMMAND message to the window.
Identification of the WPARAM:HIWORD notification message
LOWORD Generate Message ID number/or something else
LPARAM: Handle to the control, empty for menu
2.2.2 Command Processing
Processing according to the ID number of the message item
2.3 Status of the menu item
2.3.1 Wm_initmenupopup News
When the user clicks the menu to display the pop-up menu, the same will be sent to the window Wm_initmenupopup
WPARAM is a menu handle
Lparam:loword Menu Location
Whether the HiWord is a system menu
2.3.2 Command Processing