Tag: Use a client message that requires a mouse pos Windows programming BSP INT
Related functions:
Setscrollrange,setscrollpos,getscrollrange,getscrollpos
What we need to do when using the scroll bar:
1. Initialize scroll bar range and position
The wm_create response can be completed when the window is created
00, TRUE);
2. Handling scroll bar messages for window procedures
Handling when responding to Wm_vscroll
Switch(LoWord (WParam)) { Casesb_lineup: .... Break; Casesb_linedown: .... Break; Casesb_pageup: .... Break; Casesb_pagedown: .... Break; Casesb_thumbtrack: .... Break; Casesb_thumbposition: .... Break;}
Note You can get the mouse action on the scrollbar by using the LoWord (WParam) in the low 16 bits of the WParam parameter.
When the scrollbar action is sb_thumbposition or sb_thumbtrack, the position can be obtained in the high 16 bits of the WParam parameter HiWord (wParam)
3. Update the slider position
SetScrollPos (hwnd, Sb_vert, XXX, TRUE);
4. Update client content based on scroll bar changes
You can set global parameters when processing a scrollbar message, and respond to an update when the WM_PAINT response is made
To update client content in a timely manner
can use
InvalidateRect (hwnd, NULL, TRUE);
Sends a message to the message queue WM_PAINT, which is placed behind the message queue, knowing that other messages have been processed before responding
or use
UpdateWindow (HWND);
Non-queued messages, skipping the message loop mechanism to process the update window directly
Learn the Windows Programming day2 scroll bar using