Learn the Windows Programming day2 scroll bar using

Source: Internet
Author: User

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

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.