Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.6 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: flexscrollbar.h
  3. //
  4. // Desc: Implements CFlexScrollBar (derived from CFlexWnd), a scroll bar
  5. // control similar to a Windows scroll bar.
  6. //
  7. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  8. //-----------------------------------------------------------------------------
  9. #ifndef __FLEXSCROLLBAR_H__
  10. #define __FLEXSCROLLBAR_H__
  11. #include "flexwnd.h"
  12. #define FSBF_HORZ 0
  13. #define FSBF_VERT 1
  14. struct FLEXSCROLLBARCREATESTRUCT {
  15. DWORD dwSize;
  16. DWORD dwFlags;
  17. int min, max, page, pos;
  18. HWND hWndParent;
  19. HWND hWndNotify;
  20. RECT rect;
  21. BOOL bVisible;
  22. };
  23. class CFlexScrollBar : public CFlexWnd
  24. {
  25. public:
  26. CFlexScrollBar();
  27. ~CFlexScrollBar();
  28. BOOL Create(FLEXSCROLLBARCREATESTRUCT *);
  29. void SetColors(COLORREF bk, COLORREF fill, COLORREF line);
  30. void SetValues(int, int, int, int);
  31. void SetValues(int min, int max, int page) {SetRange(min, max, page);}
  32. void SetValues(int min, int max) {SetRange(min, max);}
  33. void SetRange(int min, int max, int page) {SetValues(min, max, page, GetPos());}
  34. void SetRange(int min, int max) {SetRange(min, max, GetPage());}
  35. void SetMin(int v) {SetValues(v, GetMax(), GetPage(), GetPos());}
  36. void SetMax(int v) {SetValues(GetMin(), v, GetPage(), GetPos());}
  37. void SetPage(int v) {SetValues(GetMin(), GetMax(), v, GetPos());}
  38. void SetPos(int v) {SetValues(GetMin(), GetMax(), GetPage(), v);}
  39. int GetMin() {return m_nMin;}
  40. int GetMax() {return m_nMax;}
  41. int GetPage() {return m_nPage;}
  42. int GetPos() {return m_nPos;}
  43. int GetThumbPos() {return m_bDragging ? m_nThumbPos : -1;}
  44. void AdjustPos(int adj, BOOL bForceCalc = FALSE);
  45. protected:
  46. virtual void OnPaint(HDC hDC);
  47. virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  48. private:
  49. int m_nMin, m_nMax, m_nPage, m_nPos;
  50. BOOL m_bVert;
  51. HWND m_hWndNotify;
  52. COLORREF m_rgbBk, m_rgbFill, m_rgbLine;
  53. // ui rects... calced by Calc
  54. RECT m_rectLineUp;
  55. RECT m_rectPageUp;
  56. RECT m_rectTrack;
  57. RECT m_rectThumb;
  58. RECT m_rectPageDown;
  59. RECT m_rectLineDown;
  60. BOOL Calc();
  61. BOOL FailCalc(BOOL);
  62. BOOL m_bValid; // true only when we have been created and hav valid values
  63. // and calc has been called and returned successfully.
  64. void InternalPaint(HDC hDC);
  65. POINT m_point, m_startpoint;
  66. int m_nThumbPos, m_nPreDragPos;
  67. int m_code;
  68. int m_startcode;
  69. BOOL m_bCapture;
  70. BOOL m_bDragging;
  71. int HitTest(POINT point);
  72. void Notify(int code);
  73. int GetLineAdjust();
  74. int GetPageAdjust();
  75. };
  76. CFlexScrollBar *CreateFlexScrollBar(FLEXSCROLLBARCREATESTRUCT *pcs);
  77. #endif //__FLEXSCROLLBAR_H__