I want to move a trackbar by sending messages to the dialog...
I'm not sure exactly how I'm supposed to use it.
I know from used spy++ that when I move the bar the it gets the msgs WM_HSCROLL npos:0-1000
scrollbar (window) styles:
by default, the range of a scroll bar is 0 (top or left) through 100 (bottom or right), but it's easy to change the range to something that is more convenient for the program:
you can use SetScrollPos( ) to set a new thumb position withing a scroll bar range:
SetScrollRange(hwnd, iBar, iMin, iMax, bRedraw);
SetScrollPos(hwnd, iBar, iPos, bRedraw);
General Strategy for Scrollbar Implementation
Two general methods for repainting a window after scrollbar movement. The first way, is to repaint the window only once.. after the user has completed movement of the scrollbar thumb. This method basically sucks, because the user has to guess the correct location of where they wish to scroll.
The second method (and most popular) is the repaint the window as the user is moving the scrollbar. This involves real-time processing of WM_VSCROLL and WM_HSCROLL messages. The wParam is divided into a low word and high word. The low word of wParam is a number that indicates what the mouse is doing to the scroll bar:
Here are some additional thoughts to consider:
Window's responsibility for scrollbar maintenance
- Provide a reverse-video "flash" when the user clicks the scroll bar
- Move the thumb as the user drags the thumb within the scroll bar
- Send scroll bar message to the window procedure of the window containing the scroll bar
Responsibilities of your program:
- Initialize the range and position of the scroll bar
- Process the scroll bar messages to the window procedure
- Update the position of the scroll bar thumb
- Change the contents of the client area in response to a change in the scroll bar.
Here is some example code that you can examine that may add some inside on scrollbar implementation. Here is the header file, and here is the .c driver program. (yes it is a .c file, but it's all winapi) Basically, the program will display all the "system metrics" of your computer.. but more importantly, it introduces scrollbar concept.