Progress frames and windows show both scrollbars or none.
It would be better if the scrollbars were shown independently.
The procedure ShowScrollbarsWhenNeeded is to be called 'on end-size' or during initialize.
The procedure HideScrollbars does simply that: hide both scrollbars whether or not the virtual size is larger than the actual size. The procedure is mainly a demonstration of the {&SB_BOTH} constant.
{windows.i} PROCEDURE ShowScrollbarsWhenNeeded : /* purpose : to be called from "on end-size" or whenever. */ DEFINE INPUT PARAMETER hFrame AS HANDLE. DEFINE VARIABLE retval AS INTEGER NO-UNDO. IF hFrame:VIRTUAL-WIDTH-PIXELS > hFrame:WIDTH-PIXELS THEN RUN ShowScrollBar IN hpApi (hFrame:HWND, {&SB_HORZ}, -1, OUTPUT retval). ELSE RUN ShowScrollBar IN hpApi (hFrame:HWND, {&SB_HORZ}, 0, OUTPUT retval). IF hFrame:VIRTUAL-HEIGHT-PIXELS > hFrame:HEIGHT-PIXELS THEN RUN ShowScrollBar IN hpApi (hFrame:HWND, {&SB_VERT}, -1, OUTPUT retval). ELSE RUN ShowScrollBar IN hpApi (hFrame:HWND, {&SB_VERT}, 0, OUTPUT retval). END PROCEDURE. PROCEDURE HideScrollbars : /* purpose : hide both scrollbars */ DEFINE INPUT PARAMETER hFrame AS HANDLE. DEFINE VARIABLE retval AS INTEGER NO-UNDO. RUN ScrollUpperLeft(hFrame). RUN ShowScrollBar IN hpApi (hFrame:HWND, {&SB_BOTH}, 0, OUTPUT retval). END PROCEDURE. PROCEDURE ScrollUpperLeft : /* purpose : move both scrollbars to their 0% position */ DEFINE INPUT PARAMETER hFrame AS HANDLE. DEFINE VARIABLE wParam AS INTEGER NO-UNDO. DEFINE VARIABLE nPos AS INTEGER NO-UNDO. DEFINE VARIABLE RetVal AS INTEGER NO-UNDO. nPos = 0. wParam = (nPos * 256) + {&SB_THUMBPOSITION}. RUN SendMessage{&A} IN hpApi (hFrame:HWND, {&WM_HSCROLL}, wParam, 0, OUTPUT RetVal). RUN SendMessage{&A} IN hpApi (hFrame:HWND, {&WM_VSCROLL}, wParam, 0, OUTPUT RetVal). END PROCEDURE.
In procedure ScrollUpperleft, wParam has SB_THUMBPOSITION in its low byte to let windows know that you want to do something with the thumb position. The wanted position (nPos=0) is placed in the high byte by multiplying it by 256.
Frankly I only tried the value nPos=0 so I might as well have assigned
wParam = {&SB_THUMBPOSITION}.
For any other value for nPos you should test if the factor '256' is adequate for both 16-bits and 32-bits versions! (I guess not).
{windows.i} DEFINE VARIABLE RetVal AS INTEGER NO-UNDO. &GLOBAL-DEFINE SB_PAGEUP 2 &GLOBAL-DEFINE SB_PAGEDOWN 3 &GLOBAL-DEFINE SB_TOP 6 PROCEDURE ScrollUpperLeft : /* purpose : move both scrollbars to their 0% position */ DEFINE INPUT PARAMETER hFrame AS HANDLE. RUN SendMessage{&A} IN hpApi (hFrame:HWND, {&WM_HSCROLL}, {&SB_TOP}, 0, OUTPUT RetVal). RUN SendMessage{&A} IN hpApi (hFrame:HWND, {&WM_VSCROLL}, {&SB_TOP}, 0, OUTPUT RetVal). END PROCEDURE. PROCEDURE PageDown : DEFINE INPUT PARAMETER hFrame AS HANDLE. RUN SendMessage{&A} IN hpApi (hFrame:HWND, {&WM_VSCROLL}, {&SB_PAGEDOWN}, 0, OUTPUT RetVal). END PROCEDURE. PROCEDURE PageUp : DEFINE INPUT PARAMETER hFrame AS HANDLE. RUN SendMessage{&A} IN hpApi (hFrame:HWND, {&WM_VSCROLL}, {&SB_PAGEUP}, 0, OUTPUT RetVal). END PROCEDURE.