Scrollbar

xiaoxiao2021-03-06  37

Scrollbar scroll bar is mainly used to select quickly and efficiently from a predefined value range. Two types of rolling strips and horizontal scroll bars. There is a rolling box in the scroll bar to indicate the current value. Click the roll with the mouse to move the scroll box to a page, the scope of the roller bar can move the scroll box, or directly drag the scroll box. Many windows controls are rolled with scroll strips such as list boxes and combo boxes. The Win32 scroll strip supports the proportional scroll box, that is, the size of the scroll box is used to reflect the size of the page relative to the entire range.

When CreateWindowEx creates a scroll bar, its style constant is a horizontal scroll bar, without SBS_VERT or SBS_horz is a vertical scroll bar.

The various parameters of the scroll bar should be initialized when creating a control.

The application can set the various parameters of the control by calling the SendMessage to send the following message to the control.

DESCRIPTION SBM_ENABLE_ARROWSESB_DISABLE_BOTH0 prohibited uMsgwParamlParam scroll both shear head ESB_DISABLE_DOWN0 prohibited scroll down haircut ESB_DISABLE_LTUP0 prohibit rolling up and left cutting head cutting head ESB_DISABLE_LEFT0 prohibited scroll left, scroll right and down is prohibited ESB_DISABLE_RTDN0 haircut ESB_DISABLE_UP0 scroll up prohibition allows a bidirectional cutting head ESB_ENABLE_BOTH0 Scrolls (undoing various prohibited) SBM_SETPOS Specify location true Set the scroll position, and redraw the control FALSE Set the rolling frame position, no redraw the control SBM_SETRANGE minimum maximum value sets the change range of the rolling frame position SBM_setRangeredRAW minimum value setting scroll The change range of the frame position, and redraw the control SBM_SETSCROLLINFOTRUE or FALSESCROLLINFO structure refers to the multi-parameter of the control through a scrollInfo structure to simultaneously specify the various parameters of the control, specify which parameters are determined by the Fmask member in the structure. WPARAM Specifies whether to redraw controls, see "ScrollInfo Structure" When the user performs various operations on the scroll bar control, the parent window will receive a WM_HSCROLL or WM_VSCROLL notification message, while the low 16-bit message as the following table. Code (NScrollCode), WPARAM's high 16-bit tape scroll box specified location (NPOS), which is valid when the message code is equal to SB_thumbPosition or SB_THUMBTRACK. LPARAM with control piece handle (HWNDScrollbar).

The application can do the corresponding operation according to the message code, reset the rolling frame position, the control itself does not change the rolling frame position.

The message code action response SB_LineUpsb_LineLeft user clicked the up (left) number of scroll box positions, and the client window rolled up (left). Note: These two code values ​​are equal, so they can be mixed and the same. SB_LINEDOWNSB_LINERIGHT users click on the down (right) scope rolling box position plus one, and the customer window is scrolling one line down (right). SB_PAGEUPSB_PAGELEFT users click on the scroll box (left) tip roller rolling box position to subtract a large unit, scroll up the page up (left). SB_PAGEDOWNSB_PAGERIGHT Users Click on the scroll box (right) cutting rod scroll box position plus a large unit, and the customer window scrolls the page down (right). SB_THUMBPSITION users drag and release the scroll box to the specified location to set the scroll box to the specified location. The customer window scrolls to the specified location. SB_THUMBTRACK users are dragging the scroll box to set the scroll box to the specified location. The customer window scrolls to the specified location. If the application needs to quickly browse the window, you can respond to this message to redraw the window. If you don't need to quickly browse, you can wait for the SB_thumbPosition message to redraw the window. SB_ENDSCROLL users release the mouse that presses the scope or cutting rod without any response application can send the following message to the control by calling the SendMessage to get the following messages to obtain various parameters of the current control. UMSGWParamlParam Description SBM_GETPOS00 returns the current location of the scroll box. SBM_GETRANGE minimum address pointer maximum address pointer Fill in the 32-bit rolling box position in the specified address SBM_GETSCROLLINFO0SCROLLINFO structure pointer returns a variety of parameters of the control in a scrollInfo structure, and must set the FMASK member of the structure in advance to determine the specific What parameters are to be obtained. See "ScrollInfo Structure" as described in the control when the control needs to be redrawn, send a WM_CTLCOLORSCROLLBAR message to each parent window while the control handle (HDC), and the control handle in the LPARAM in WPARAM. If the application responds to this message and returns a brush (brush) handle, the control will draw a background color according to this handle.

ScrollInfo structure:

ScrollInfo Struct

CBSIZE DWORD?

FMask DWORD?

Nmin DWORD?

NMAX DWORD?

NPAGE DWORD?

NPOS DWORD?

NTRACKPOS DWORD?

ScrollInfo Ends Member Description:

CBSIZE: ScrollInfo Structure Length bytes, which must be filled in when setting up and query parameters.

Fmask: Which members of the specified structure are valid, which has the following five options, which can be selected to be combined with "OR", which must be filled in when setting up and query parameters.

SIF_ALL: The entire structure is effective

SIF_DISABLENSCROLL: This value is only used when the parameter is set, and the need for the contents of the control parameter will be hiented.

SIF_PAGE: NPAGE member is valid

SIF_POS: NPOS member is valid

SIF_RANGE: NMIN and NMAX members are valid

Nmin: Strip range minimum

Nmax: maximum rolling range

NPAGE: page size, used to determine the size of the proportional scroll box

NPOS: The position of the scroll box

NTRACKPOS: When dragging the position of the scroll box, this parameter can only query and cannot be set.

转载请注明原文地址:https://www.9cbs.com/read-62882.html

New Post(0)