coolscroll.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #ifndef _COOLSBLIB_INCLUDED
  2. #define _COOLSBLIB_INCLUDED
  3. #include <windows.h>
  4. // To complement the exisiting SB_HORZ, SB_VERT, SB_BOTH
  5. // scrollbar identifiers
  6. #define COOLSB_NONE (-1)
  7. #define SB_INSBUT (-2)
  8. //
  9. // Arrow size defines
  10. //
  11. #define SYSTEM_METRIC (-1)
  12. //
  13. // general scrollbar styles
  14. //
  15. // use the standard ESB_DISABLE_xxx flags to represent the
  16. // enabled / disabled states. (defined in winuser.h)
  17. //
  18. #define CSBS_THUMBALWAYS 4
  19. #define CSBS_VISIBLE 8
  20. //cool scrollbar styles for Flat scrollbars
  21. #define CSBS_NORMAL 0
  22. #define CSBS_FLAT 1
  23. #define CSBS_HOTTRACKED 2
  24. //
  25. // Button mask flags for indicating which members of SCROLLBUT
  26. // to use during a button insertion / modification
  27. //
  28. #define SBBF_TYPE 0x0001
  29. #define SBBF_ID 0x0002
  30. #define SBBF_PLACEMENT 0x0004
  31. #define SBBF_SIZE 0x0008
  32. #define SBBF_BITMAP 0x0010
  33. #define SBBF_ENHMETAFILE 0x0020
  34. //#define SBBF_OWNERDRAW 0x0040 //unused at present
  35. #define SBBF_CURSOR 0x0080
  36. #define SBBF_BUTMINMAX 0x0100
  37. #define SBBF_STATE 0x0200
  38. //button styles (states)
  39. #define SBBS_NORMAL 0
  40. #define SBBS_PUSHED 1
  41. #define SBBS_CHECKED SBBS_PUSHED
  42. //
  43. // scrollbar button types
  44. //
  45. #define SBBT_PUSHBUTTON 1 //standard push button
  46. #define SBBT_TOGGLEBUTTON 2 //toggle button
  47. #define SBBT_FIXED 3 //fixed button (non-clickable)
  48. #define SBBT_FLAT 4 //blank area (flat, with border)
  49. #define SBBT_BLANK 5 //blank area (flat, no border)
  50. #define SBBT_DARK 6 //dark blank area (flat)
  51. #define SBBT_OWNERDRAW 7 //user draws the button via a WM_NOTIFY
  52. #define SBBT_MASK 0x1f //mask off low 5 bits
  53. //button type modifiers
  54. #define SBBM_RECESSED 0x0020 //recessed when clicked (like Word 97)
  55. #define SBBM_LEFTARROW 0x0040
  56. #define SBBM_RIGHTARROW 0x0080
  57. #define SBBM_UPARROW 0x0100
  58. #define SBBM_DOWNARROW 0x0200
  59. #define SBBM_RESIZABLE 0x0400
  60. #define SBBM_TYPE2 0x0800
  61. #define SBBM_TYPE3 0x1000
  62. #define SBBM_TOOLTIPS 0x2000 //currently unused (define COOLSB_TOOLTIPS in userdefs.h)
  63. //button placement flags
  64. #define SBBP_LEFT 1
  65. #define SBBP_RIGHT 2
  66. #define SBBP_TOP 1 //3
  67. #define SBBP_BOTTOM 2 //4
  68. //
  69. // Button command notification codes
  70. // for sending with a WM_COMMAND message
  71. //
  72. #define CSBN_BASE 0
  73. #define CSBN_CLICKED (1 + CSBN_BASE)
  74. #define CSBN_HILIGHT (2 + CSBN_BASE)
  75. //
  76. // Minimum size in pixels of a scrollbar thumb
  77. //
  78. #define MINTHUMBSIZE_NT4 8
  79. #define MINTHUMBSIZE_2000 6
  80. //define some more hittest values for our cool-scrollbar
  81. #define HTSCROLL_LEFT (SB_LINELEFT)
  82. #define HTSCROLL_RIGHT (SB_LINERIGHT)
  83. #define HTSCROLL_UP (SB_LINEUP)
  84. #define HTSCROLL_DOWN (SB_LINEDOWN)
  85. #define HTSCROLL_THUMB (SB_THUMBTRACK)
  86. #define HTSCROLL_PAGEGUP (SB_PAGEUP)
  87. #define HTSCROLL_PAGEGDOWN (SB_PAGEDOWN)
  88. #define HTSCROLL_PAGELEFT (SB_PAGELEFT)
  89. #define HTSCROLL_PAGERIGHT (SB_PAGERIGHT)
  90. #define HTSCROLL_NONE (-1)
  91. #define HTSCROLL_NORMAL (-1)
  92. #define HTSCROLL_INSERTED (128)
  93. #define HTSCROLL_PRE (32 | HTSCROLL_INSERTED)
  94. #define HTSCROLL_POST (64 | HTSCROLL_INSERTED)
  95. /*
  96. Public interface to the Cool Scrollbar library
  97. */
  98. BOOL WINAPI InitializeCoolSB(HWND hwnd);
  99. HRESULT WINAPI UninitializeCoolSB (HWND hwnd);
  100. BOOL WINAPI CoolSB_SetMinThumbSize(HWND hwnd, UINT wBar, UINT size);
  101. BOOL WINAPI CoolSB_IsThumbTracking(HWND hwnd);
  102. BOOL WINAPI CoolSB_IsCoolScrollEnabled(HWND hwnd);
  103. //
  104. BOOL WINAPI CoolSB_EnableScrollBar (HWND hwnd, int wSBflags, UINT wArrows);
  105. BOOL WINAPI CoolSB_GetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi);
  106. int WINAPI CoolSB_GetScrollPos (HWND hwnd, int nBar);
  107. BOOL WINAPI CoolSB_GetScrollRange (HWND hwnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos);
  108. //
  109. int WINAPI CoolSB_SetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
  110. int WINAPI CoolSB_SetScrollPos (HWND hwnd, int nBar, int nPos, BOOL fRedraw);
  111. int WINAPI CoolSB_SetScrollRange (HWND hwnd, int nBar, int nMinPos, int nMaxPos, BOOL fRedraw);
  112. BOOL WINAPI CoolSB_ShowScrollBar (HWND hwnd, int wBar, BOOL fShow);
  113. //
  114. // Scrollbar dimension functions
  115. //
  116. BOOL WINAPI CoolSB_SetSize (HWND hwnd, int wBar, int nLength, int nWidth);
  117. //
  118. // Set the visual nature of a scrollbar (flat, normal etc)
  119. //
  120. BOOL WINAPI CoolSB_SetStyle (HWND hwnd, int wBar, UINT nStyle);
  121. BOOL WINAPI CoolSB_SetThumbAlways (HWND hwnd, int wBar, BOOL fThumbAlways);
  122. //
  123. // Scrollbar button structure, for inserted buttons only
  124. //
  125. typedef struct
  126. {
  127. UINT fMask; //which members are in use
  128. UINT uPlacement; //is this button to the left/right (above/below) of the scrollbar??
  129. UINT uCmdId; //command identifier (WM_COMMAND value to send)
  130. UINT uButType; //
  131. UINT uState; //toggled etc
  132. int nSize; //size in pixels. -1 for autosize
  133. HBITMAP hBmp; //handle to a bitmap to use as the button face
  134. HENHMETAFILE hEmf; //handle to an enhanced metafile
  135. HCURSOR hCurs; //handle to a user-supplied mouse cursor to apply
  136. //to this button
  137. int nSizeReserved; //internal variable used for resizing
  138. int nMinSize; //min size
  139. int nMaxSize; //max size
  140. } SCROLLBUT;
  141. BOOL WINAPI CoolSB_InsertButton(HWND hwnd, int wSBflags, UINT nPos, SCROLLBUT *psb);
  142. BOOL WINAPI CoolSB_ModifyButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb);
  143. BOOL WINAPI CoolSB_RemoveButton(HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd);
  144. BOOL WINAPI CoolSB_GetButton (HWND hwnd, int wSBflags, UINT uItem, BOOL fByCmd, SCROLLBUT *psb);
  145. void WINAPI CoolSB_SetESBProc(void *proc);
  146. typedef struct
  147. {
  148. NMHDR hdr;
  149. DWORD dwDrawStage;
  150. HDC hdc;
  151. RECT rect;
  152. UINT uItem;
  153. UINT uState;
  154. UINT nBar;
  155. } NMCSBCUSTOMDRAW;
  156. typedef struct
  157. {
  158. NMHDR hdr;
  159. RECT rect;
  160. POINT pt;
  161. UINT uCmdId;
  162. UINT uState;
  163. int nBar;
  164. } NMCOOLBUTMSG;
  165. /*
  166. typedef struct
  167. {
  168. NMHDR hdr;
  169. DWORD dwDrawStage;
  170. HDC hdc;
  171. RECT rect;
  172. UINT uCmdId;
  173. UINT uState;
  174. } NMCOOLBUTTON_CUSTOMDRAW;
  175. */
  176. //
  177. // Define the WM_NOTIFY code value for cool-scrollbar custom drawing
  178. //
  179. #define NM_COOLSB_CUSTOMDRAW (0-0xfffU)
  180. #endif