Many things have appeared in my main application window, so I need a vertical scrollbar to fit all within the client area. I encoded a scrollbar control, WM_VSCROLL messages such as SB_LINEDOWN are processed, and the scrollbar moves perfectly. The last part is to make the contents of the main window move along with the thumb of the scroll bar, and for me this seems a little difficult task. This is my best attempt:
int dy = -( CurrPos - si.nPos ); RECT rctMainWindowArea = { 0, 0, 1000, main_window.bottom }; ScrollWindowEx( hwndMainWindow, 0, dy,( CONST RECT * ) &rctMainWindowArea,( CONST RECT * ) NULL,( HRGN ) NULL,( LPRECT ) NULL, SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE ); UpdateWindow( hwndMainWindow );
It works while I scroll down. When I scroll back again, everything becomes spoiled. I have been looking for this problem for a while, and it seems to me that I need to redraw the lost client area of ββthe main window. However, I have no idea how to do this. I found only examples on the Internet where the text scrolls inside the edit control. I need to scroll through the main window, which has several different basic controls, some BMP graphics, some other graphics, such as TextOut (), RoundRect (), etc.
I need code examples on how to solve my problem or at least a simple explanation (I'm an amateur programmer). Many thanks!
source share