Custom Scrollbars - Reference


8 minute read  • 

win32

SCROLLBUT

Specifies the attributes of a button which has been inserted into a window’s scrollbar. This structure is used by the CoolSB_InsertButton, CoolSB_ModifyButton and CoolSB_RemoveButton API calls.

typedef struct 
{
  UINT         fMask;          /* which members are in use */
  UINT         uPlacement;     /* which side of the scrollbar to insert */
  UINT         uCmdId;         /* command identifier (WM\_COMMAND value to send)*/
  UINT         uButType;       /* type of button to insert */
  UINT         uState;         /* what state the button is in (i.e. pressed) */
  int          nSize;          /* size in pixels. -1 for autosize */
  HBITMAP      hBmp;           /* handle to a bitmap to use as the button face */  
  HENHMETAFILE hEmf;           /* handle to an enhanced metafile */
  HCURSOR      hCurs;          /* handle to a mouse cursor to use */

  int          nSizeReserved;  /* private to the coolscroll library */  
  int          nMinSize;       /* minimum size of a resizable button */
  int          nMaxSize;       /* maximum size of a resizable button */

} SCROLLBUT;

Members

fMask is a set of flags OR’d together which specify which of the SCROLLBUT members contain valid information. This member can have one or more of the following values set:

ValueDescription
SBBF_TYPEThe nButType member contans valid data
SBBF_IDThe nCmdId member contains a valid command identifier for the button
SBBF_STATEThe nState member contains a valid state identifier
SBBF_PLACEMENTThe nPlacement member contains valid data
SBBF_SIZEThe nSize member contains valid data
SBBF_BITMAPThe hBmp member is a valid handle to a Bitmap resource
SBBF_ENHMETAFILEThe hEmf member is a calid handle to a Enhanced Metafile
SBBF_CURSORThe hCurs member is a valid handle to a cursor resource
SBBF_BUTMINMAXThe nMinSize and nMaxSize members contain valid thumb sizes

uButType specifies what type of button will be inserted into the scrollbar. This member can be set to just one of the following values:

ValueDescription
SBBT_PUSHBUTTONThe button is a standard pushbutton, with the same look and feel as a normal scrollbar button arrow.
SBBT_TOGGLEBUTTONThe button can be toggled between an up and down state
SBBT_FIXEDThe button does not respond to mouse clicks
SBBT_FLATThe button has no 3d-look
SBBT_BLANKThe button is a blank area, and does not respond to clicks
SBBT_DARKAnother type of blank area, but is dark int colour
SBBT_OWNERDRAWAn NM_CUSTOMDRAW message will be sent to the window to paint the button.

In addtion to the above button types, you can also include one of the following button type modifiers by OR’ing it together with the button type:

ValueDescription
SBBM_RECESSEDThe button has a recessed look when it is being depressed
SBBM_LEFTARROWThe button has the standard left arrow bitmap
SBBM_RIGHTARROWThe button has the standard right arrow bitmap
SBBM_UPARROWThe button has the standard up arrow bitmap
SBBM_DOWNARROWThe button has the standard down arrow bitmap
SBBM_RESIZABLEThe button can be resized using the mouse
SBBM_TYPE2The button uses a different 3d-look
SBBM_TYPE3The button uses a different 3d-look

uCmdId specifies a command identifier which is used in the form of a WM_COMMAND message, which is sent whenever the button is clicked with the mouse.

uState specifies an initial state for the button, if it is a push-button or toggle-button. Valid values are defined below.

ValueDescription
SBBS_NORMALThe button is in its default, un-pushed state
SBBS_PUSHEDThe button is in a depressed or “clicked” state.

nSize specifies the size of the button. For a button inserted into the horizontal scrollbar, nSize represents the width of the button, in pixels. For a button inserted into the vertical scrollbar, nSize represents the height of the button. A non-negative value is used to specify an exact size, in pixels. A negative number can be used to specify the size in multiples of the standard scrollbar button size. A value of -1 produces a button the same size as a scrollbar arrow. A value of -2 gives a button twice the size of a scrollbar button, and so on.

uPlacement specifies which side of the scrollbar the button should be inserted. This can be one of the following values. The default is SBBP_LEFT or SBBP_ABOVE, if nPlacement is not specified.

ValueDescription
SBBP_LEFTThe button is inserted to the left of a horizontal scrollbar
SBBP_RIGHTThe button is inserted to the right of a horizontal scrollbar
SBBP_ABOVEThe button is inserted above of a vertical scrollbar
SBBP_BELOWThe button is inserted below of a vertical scrollbar

hBmp is a handle to a bitmap, which is used as the button’s image. The bitmap is centered in the button. If no bitmap is defined, then the button is left blank. Ownership of the bitmap is the responsibility of the user.

hEmf is a handle to an Enhanced Metafile, which is used as the button’s image when a bitmap hasn’t been supplied. Ownership of the metafile is the responsibility of the user.

hCurs is a handle to mouse cursor. This cursor is used whenever the mouse passes over the button. The standard mouse cursor is used if no cursor is specified.

nMinSize is the minimum size, in pixels, of a resizable button. The uButType member must include the SBBM_RESIZABLE flag.

hCurs is the maximum size, in pixels, of a resizable button. The uButType member must include the SBBM_RESIZABLE flag.

Remarks

This structure could be subject to change in future versions of the cool scrollbar library.

Back to the Cool Scrollbar Reference

NMCOOLBUTMSG

Specifies a mouse event notification on an inserted scrollbar button. Currently, only NM_CLICK notifications are supported

typedef struct
{
   NMHDR   hdr;         /* standard WM\_NOTIFY header */
   RECT	   rect;        /* window-relative coordinates of button */
   POINT   pt;          /* coordinates of the mouse cursor */
   UINT	   uCmdId;      /* command identifier of the button */
   UINT	   uState;      /* item state (clicked / disable etc) */
   UINT	   nBar;        /* which scrollbar (SB\_HORZ / SB\_VERT) */
	
} NMCSBCUSTOMDRAW;

Members

hdr is the standard NMHDR structure used in all WM_NOTIFY messages. The code member of this structure will NMCUSTOMDRAW for this message type.

rect specifies the coordinates of the item to draw. These coordinates are relative to the upper-left corner of the window’s non-client area.

pt specifies the screen coordinates of the cursor, in pixels.

uCmdId specifies which the command identifier of the scrollbar button.

uState this member is not currently used.

nBar specifies which of the window’s two scrollbars the button belongs to. This can be either SB_HORZ or SB_VERT.

Remarks

This structure could be subject to change in future versions of the cool scrollbar library.

Back to the Cool Scrollbar Reference

NMCSBCUSTOMDRAW

Specifies a Custom Draw structure specific to the cool scrollbar libary.

typedef struct
{
   NMHDR   hdr;             /* standard WM\_NOTIFY header */
   DWORD   dwDrawStage;     /* PREPAINT / POSTPAINT etc */
   HDC     hdc;             /* handle to a device context to draw into */
   RECT	   rect;            /* window-relative coordinates of item to draw */
   UINT	   uItem;           /* item id to draw */
   UINT	   uState;          /* item state (clicked / disable etc) */
   UINT	   nBar;            /* which scrollbar (SB\_HORZ / SB\_VERT) */
	
} NMCSBCUSTOMDRAW;

Members

hdr is the standard NMHDR structure used in all WM_NOTIFY messages. The code member of this structure will NMCUSTOMDRAW for this message type.

dwDrawStage specifies what the current stage of the custom draw is. The cool scrollbar library supports three possible values for this member:

ValueDescription
CDDS_PREPAINTThe scrollbars are just about to be painted. Only the nBar and hdc members contain valid information. You could use this message to select a palette into the device context, for example. You can return either CDRF_DODEFAULT to let the cool scrollbar paint itself, or CDRF_SKIPDEFAULT to completely take over drawing of the specified scrollbar.
CDDS_POSTPAINTThe scrollbars have finished painting. Only the nBar and hdc members contain valid information. You should restore the device context to its original state if you selected any palettes into it. The return value of this message is not used.
CDDS_ITEMPREPAINTAn item needs to be painted. An item could be a scrollbar arrow, the scroll-thumb or a scrollbar margin. Currently, the cool scrollbar library expects all items to be painted by the user if CDRF_SKIPDEFAULT was returned in the pre-paint message. So, the return value of this message is not currently used.

Currently, no other drawing stage notifications are sent.

hdc specifies a device context which should be drawn into. This device context does not have any clipping regions defined.

rect specifies the coordinates of the item to draw. These coordinates are relative to the upper-left corner of the window’s non-client area.

uItem specifies which scrollbar item needs to be drawn. This can be one of the following values:

ValueDescription
HTSCROLL_LEFT / HTSCROLL_UPThe left or up arrow button, depending on the value of nBar
HTSCROLL_RIGHT / HTSCROLL_DOWNThe right or down arrow button
HTSCROLL_PAGELEFT / HTSCROLL_PAGEUPThe left or upper scrollbar margin, before the scroll thumb.
HTSCROLL_PAGERIGHT / HTSCROLL_PAGEDOWNThe right or lower scrollbar margin.
HTSCROLL_THUMBThe scrollbar thumb.

uState defines the current state of the item to be painted. This can be one of the following values:

ValueDescription
CDIS_HOTThe item is currently under the mouse pointer (“hot”).
CDIS_DISABLEDThe item is disabled.
CDIS_SELECTEDThe item is being activated by the mouse (clicked down on).
CDIS_DEFAULTThe item is in its normal state.

nBar specifies which of the window’s two scrollbars the item belongs to. This will be one of four values.
The SB_HORZ and SB_VERT identifiy that the item to draw is part of a horizontal or vertical scrollbar, respectively.
The SB_BOTH value is used when the scrollbar dead area (the size-grip area) needs to be painted. No pre-paint or post-paint notifications are sent when the gripper-area needs to be painted, because this is always a one-off message.
Lastly, the SB_INSBUT value is used when an inserted button needs to be painted. In this case, the uItem member specifies the command identifier of the inserted button. Only a CDDS_ITEMPREPAINT notification is sent, and the inserted button must have the SBBT_OWNERDRAW type set.

Remarks

This structure could be subject to change in future versions of the cool scrollbar library.

Back to the Cool Scrollbar Reference