internal.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #pragma once
  2. /////////////////////////////////////////////////////////////////
  3. //
  4. // Header file : skinsb.h
  5. //
  6. // Descrption : Skin scrollbar library Version 1.0
  7. //
  8. // Auhor : LiJun
  9. //
  10. // E-Mail : notoldtree@126.com
  11. //
  12. // History :
  13. //
  14. // 2008-12-24
  15. // 问题描述:由于RichEdit控件在拖动滑块时滑块没有反应,原因是发送滚动消息给
  16. // RichEdit控件并没有反应
  17. //
  18. // 解决方案:在SkinSB_TrackThumb在函数中发送滚消息不要使用SB_THUMBTRACK标记,而
  19. // 应该使用SB_THUMBPOSITION标记.
  20. /////////////////////////////////////////////////////////////////
  21. #ifdef __cplusplus
  22. extern "C"{
  23. #endif
  24. #include <windows.h>
  25. #include <windowsx.h>
  26. #include <commctrl.h>
  27. // Min thumb size
  28. #define SB_MINTHUMB_SIZE 10
  29. // The scroll timer ID
  30. #define SB_TIMER_DELAY 65533
  31. #define SB_TIMER_SCROLL 65534
  32. // Startup scroll timer delay
  33. #define SB_SCROLL_DELAY 300
  34. #define SB_SCROLL_INTERVAL 40
  35. // Hittest code
  36. #define HTSCROLL_NONE 0x00000000L
  37. #define HTSCROLL_LINEUP 0x00000001L
  38. #define HTSCROLL_LINEDOWN 0x00000002L
  39. #define HTSCROLL_THUMB 0x00000003L
  40. #define HTSCROLL_PAGEUP 0x00000004L
  41. #define HTSCROLL_PAGEDOWN 0x00000005L
  42. #define HTSCROLL_SIZEBOX 0x00000006L
  43. // status...
  44. #define SB_STATE_DEFAULT 0x00000000L
  45. #define SB_STATE_NORMAL 0x00000001L
  46. #define SB_STATE_HOTTRACKED 0x00000002L
  47. #define SB_STATE_PRESSED 0x00000003L
  48. #define SB_STATE_DISABLED 0x00000004L
  49. // Send scroll message
  50. #define DoScrollMsg(hwnd, cmd, pos, fvert) \
  51. SendMessage((hwnd), (fvert) ? WM_VSCROLL : WM_HSCROLL, MAKEWPARAM((cmd), (pos)), 0);
  52. // ScrollBar data sturcture
  53. typedef struct tagSB {
  54. HWND hwnd; // The window handle
  55. UINT flags; // Scrollbar disable flags
  56. DWORD style; // The window style
  57. SCROLLINFO Horz; // Horizontal scroll
  58. SCROLLINFO Vert; // Vertical scroll
  59. WNDPROC pfnOldProc; // The originally window procedure
  60. BOOL fLeftScrollBar; // Left scrollbar style
  61. BOOL fPreventStyleChange; // Prevent window style change
  62. BOOL fMouseTracking;
  63. BOOL fTracking; // Is tracking ?
  64. BOOL fTrackVert; // Tracking target whether vertical scrollbar
  65. BOOL fRichEdit; // Whether richedit control
  66. int nTrackCode; // Tracking hittest item code
  67. int nTrackPos; // Tracking thumb position
  68. int nOffsetPoint; // Tracking the thumb of mouse point offset
  69. UINT nScrollTimerMsg; // 32 bit value, low-word -> message, high-word -> scroll command
  70. UINT nLastCode; // Last HitTest code
  71. BOOL fLastVert; // Last HitTest is vertical scrollbar ?
  72. HBITMAP hBmp;
  73. } SB, *LPSB;
  74. // Scrollbar size calculate struct
  75. typedef struct tagSBCALC {
  76. int pxLeft;
  77. int pxTop;
  78. int pxRight;
  79. int pxBottom;
  80. union {
  81. int pxUpArrow;
  82. int pxLeftArrow;
  83. };
  84. union {
  85. int pxDownArrow;
  86. int pxRightArrow;
  87. };
  88. union {
  89. int pxThumbTop;
  90. int pxThumbLeft;
  91. };
  92. union {
  93. int pxThumbBottom;
  94. int pxThumbRight;
  95. };
  96. } SBCALC, *LPSBCALC;
  97. // Internal functions
  98. LPSB SkinSB_GetSB(HWND hwnd);
  99. BOOL SkinSB_SetSBParms(LPSCROLLINFO psi, SCROLLINFO si, BOOL* pfScroll, int* plres, BOOL bOldPos);
  100. BOOL SkinSB_IsScrollInfoActive(LPCSCROLLINFO lpsi);
  101. void SkinSB_SBCalc(LPSB psb, LPSBCALC lpcalc, BOOL fVert);
  102. BOOL SkinSB_GetSizeBoxRect(LPSB psb, LPRECT lprc);
  103. BOOL SkinSB_GetScrollBarRect(LPSB psb, BOOL fVert, LPRECT lprc);
  104. BOOL SkinSB_GetThumbRect(LPSB psb, LPRECT lprc, BOOL fVert);
  105. BOOL SkinSB_GetGrooveRect(LPSB psb, LPRECT lprc, BOOL fVert);
  106. //int SkinSB_GetPosFromPoint(POINT point, BOOL fVert);
  107. // Draw functions
  108. void SkinSB_DrawScrollBar(LPSB psb, HDC hDC, BOOL fVert);
  109. BOOL SkinSB_DrawGroove(LPSB psb, HDC hdc, LPRECT lprc, BOOL fVert);
  110. void SkinSB_DrawThumb(LPSB psb, HDC hdc, BOOL fVert);
  111. BOOL SkinSB_DrawArrow(LPSB psb, HDC hdc, BOOL fVert, int nArrow, UINT uState);
  112. BOOL SkinSB_DrawSizeBox(LPSB psb, HDC hDC);
  113. //BOOL SkinSB_DrawSkinBitmap(HDC hdc, LPRECT lprc, int xSrc, int ySrc, int nWidthSrc, int nHeightSrc,
  114. // BOOL bStretchAll, int leftMargin, int topMargin, int rightMargin, int bottomMargin,
  115. // BOOL bTrans, COLORREF clrTrans);
  116. //void SkinSB_TrackLoop(LPSB psb);
  117. void SkinSB_Track(LPSB psb, BOOL fVert, UINT nHit, POINT pt);
  118. BOOL SkinSB_TrackThumb(LPSB psb, BOOL fVert, POINT pt);
  119. BOOL SkinSB_HotTrack(LPSB psb, int nHitCode, BOOL fVert, BOOL fMouseDown);
  120. UINT SkinSB_HitTest(LPSB psb, BOOL fVert, POINT pt);
  121. BOOL SkinSB_EnableArrows(LPSB psb, int nBar, UINT wArrows);
  122. UINT SkinSB_GetDisableFlags(LPSB psb, BOOL fVert);
  123. UINT SkinSB_GetState(LPSB psb, BOOL fVert, UINT nHit);
  124. // Message functions
  125. LRESULT SkinSB_OnStyleChanged(LPSB psb, int nStyleType, LPSTYLESTRUCT lpStyleStruct);
  126. LRESULT SkinSB_OnNcHitTest(LPSB psb, WPARAM wParam, LPARAM lParam);
  127. LRESULT SkinSB_OnNcPaint(LPSB psb, HRGN hRgn);
  128. LRESULT SkinSB_OnNcCalcSize(LPSB psb, BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  129. LRESULT SkinSB_OnNcMouseMove(LPSB psb, WPARAM wParam, LPARAM lParam);
  130. LRESULT SkinSB_OnNcLButtonDown(LPSB psb, WPARAM wParam, LPARAM lParam);
  131. LRESULT SkinSB_OnNcMouseLeave(LPSB psb, WPARAM wParam, LPARAM lParam);
  132. LRESULT SkinSB_OnMouseMove(LPSB psb, WPARAM wParam, LPARAM lParam);
  133. LRESULT SkinSB_OnLButtonUp(LPSB psb, WPARAM wParam, LPARAM lParam);
  134. LRESULT SkinSB_OnTimer(LPSB psb, WPARAM wParam, LPARAM lParam);
  135. // scroll window procedure
  136. LRESULT CALLBACK SkinSB_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. /*==========================================================================*\
  141. ===滚动条模型描述===
  142. +-------------------------------+---+ <-------+
  143. | | A | (1)
  144. | +---+ <-------+----------+
  145. | | | |
  146. | | | |
  147. | |---| <-------+ |
  148. | | | | |
  149. | (10) | - | (2) |
  150. | | - | | |
  151. | | | | (3)
  152. | |---| <-------+ |
  153. | | | |
  154. | | | |
  155. | +---+ <-------+ |
  156. | | V | (4) |
  157. +---+-----------------------+---+---+ <-------+----------+
  158. | < | [ || ] | > |///| (5)
  159. +---+-----------------------+---+---+ <-------+
  160. ^ ^ ^ ^ ^ ^
  161. | | | | | |
  162. | | | | | |
  163. (8) (7) (6)
  164. 描述:
  165. (1)
  166. (2)
  167. (3)
  168. (4)
  169. \*=========================================================================*/