Leaked source code of windows server 2003
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.

133 lines
5.4 KiB

  1. #ifndef _DDBTN__H_
  2. #define _DDBTN__H_
  3. #include <windowsx.h>
  4. #include "dbg.h"
  5. #include "ddbtn.h"
  6. #include "ccom.h"
  7. #include "cddbitem.h"
  8. #ifdef UNDER_CE // macro
  9. #undef DrawIcon
  10. #endif // UNDER_CE
  11. //----------------------------------------------------------------
  12. //Button ID
  13. //----------------------------------------------------------------
  14. #define BID_BUTTON 0x0001
  15. #define BID_DROPDOWN 0x0002
  16. #define BID_ALL (BID_BUTTON | BID_DROPDOWN)
  17. #define BID_UNDEF 0x1000
  18. //----------------------------------------------------------------
  19. //Local Command ID.
  20. //----------------------------------------------------------------
  21. #define CMD_DROPDOWN 0x0100
  22. //----------------------------------------------------------------
  23. //Pushed poped, flat image style definition.
  24. //----------------------------------------------------------------
  25. typedef enum tagIMAGESTYLE {
  26. IS_FLAT = 0,
  27. IS_POPED,
  28. IS_PUSHED,
  29. }IMAGESTYLE;
  30. class CDDButton : public CCommon
  31. {
  32. public:
  33. CDDButton(HINSTANCE hInst, HWND hwndParent, DWORD dwStyle, DWORD wID);
  34. ~CDDButton();
  35. #ifndef UNDER_CE
  36. BOOL RegisterWinClass(LPSTR lpstrClassName);
  37. #else // UNDER_CE
  38. BOOL RegisterWinClass(LPTSTR lpstrClassName);
  39. #endif // UNDER_CE
  40. INT MsgCreate (HWND hwnd, WPARAM wParam, LPARAM lParam);
  41. INT MsgPaint (HWND hwnd, WPARAM wParam, LPARAM lParam);
  42. INT MsgDestroy (HWND hwnd, WPARAM wParam, LPARAM lParam);
  43. INT MsgTimer (HWND hwnd, WPARAM wParam, LPARAM lParam);
  44. INT MsgMouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam);
  45. INT MsgButtonDown (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  46. INT MsgButtonUp (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  47. INT MsgEnable (HWND hwnd, WPARAM wParam, LPARAM lParam);
  48. INT MsgCaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam);
  49. INT MsgUserCommand (HWND hwnd, WPARAM wParam, LPARAM lParam);
  50. INT MsgCommand (HWND hwnd, WPARAM wParam, LPARAM lParam);
  51. INT MsgSetFont (HWND hwnd, WPARAM wParam, LPARAM lParam);
  52. INT MsgExitMenuLoop (HWND hwnd, WPARAM wParam, LPARAM lParam);
  53. INT MsgMeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam);
  54. INT MsgDrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam);
  55. INT MsgDDB_AddItem (HWND hwnd, WPARAM wParam, LPARAM lParam);
  56. INT MsgDDB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam);
  57. INT MsgDDB_SetCurSel (HWND hwnd, WPARAM wParam, LPARAM lParam);
  58. INT MsgDDB_GetCurSel (HWND hwnd, WPARAM wParam, LPARAM lParam);
  59. INT MsgDDB_SetIcon (HWND hwnd, WPARAM wParam, LPARAM lParam);
  60. INT MsgDDB_SetText (HWND hwnd, WPARAM wParam, LPARAM lParam);
  61. INT MsgDDB_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam);
  62. private:
  63. //----------------------------------------------------------------
  64. // Private method
  65. //----------------------------------------------------------------
  66. INT NotifyToParent (INT notify);
  67. INT GetButtonFromPos(INT xPos, INT yPos);
  68. INT SplitRect (LPRECT lpRc, LPRECT lpButton, LPRECT lpDrop);
  69. INT DrawButton (HDC hDC, LPRECT lpRc);
  70. INT DrawThickEdge (HDC hDC, LPRECT lpRc, IMAGESTYLE imageStyle);
  71. INT DrawThinEdge (HDC hDC, LPRECT lpRc, IMAGESTYLE imageStyle);
  72. INT DrawTriangle (HDC hDC, LPRECT lpRc, IMAGESTYLE imageStyle);
  73. INT DrawIcon (HDC hDC, LPRECT lpRc, IMAGESTYLE imageStyle);
  74. INT DrawBitmap (HDC hDC, LPRECT lpRc, IMAGESTYLE imageStyle);
  75. INT DrawText (HDC hDC, LPRECT lpRc, IMAGESTYLE imageStyle);
  76. INT GetDDBItemCount (VOID);
  77. LPCDDBItem GetDDBItemByIndex(INT index);
  78. LPCDDBItem InsertDDBItem(LPCDDBItem lpCDDBItem, INT index);
  79. INT DropDownItemList(VOID);
  80. INT IncrementIndex (VOID);
  81. INT MenuMeasureItem (HWND hwndOwner, LPMEASUREITEMSTRUCT lpmis);
  82. INT MenuDrawItem (HWND hwndOwner, LPDRAWITEMSTRUCT lpdis);
  83. //----------------------------------------------------------------
  84. //member variable
  85. //----------------------------------------------------------------
  86. HINSTANCE m_hInst;
  87. HWND m_hwndParent;
  88. HWND m_hwndFrame;
  89. DWORD m_dwStyle; //combination of DDBS_XXXX
  90. DWORD m_wID; //Window ID;
  91. BOOL m_fEnable; //Enabled or Disabled.
  92. HFONT m_hFont; //Font handle;
  93. HICON m_hIcon; //Icon handle;
  94. INT m_cxIcon; //Icon width;
  95. INT m_cyIcon; //Icon height;
  96. LPWSTR m_lpwstrText; //Button face text;
  97. BOOL m_fExitMenuLoop;
  98. INT m_bidDown;
  99. BOOL m_fButton;
  100. BOOL m_fDrop;
  101. INT m_curDDBItemIndex; //current selected item index.
  102. LPCDDBItem m_lpCDDBItem; //CDDBItem Linked list head.
  103. INT m_cxDropDown; //
  104. #ifndef UNDER_CE // not support WNDCLASSEX
  105. WNDCLASSEX m_tmpWC; //to reduce stack;
  106. #else // UNDER_CE
  107. WNDCLASS m_tmpWC; //to reduce stack;
  108. #endif // UNDER_CE
  109. RECT m_tmpBtnRc; //to reduce stack;
  110. RECT m_tmpDropRc; //to reduce stack;
  111. RECT m_tmpRect; //to reduce stack;
  112. RECT m_tmpRect2; //to reduce stack;
  113. POINT m_tmpPoint; //to reduce stack;
  114. PAINTSTRUCT m_tmpPs; //to reduce stack;
  115. ICONINFO m_tmpIconInfo; //to reduce stack;
  116. BITMAP m_tmpBitmap; //to reduce stack;
  117. TPMPARAMS m_tmpTpmParams; //to reduce stack;
  118. SIZE m_tmpSize;
  119. MENUITEMINFO m_miInfo;
  120. BOOL m_f16bitOnNT;
  121. #ifndef UNDER_CE // not support NONCLIENTMETRICS
  122. NONCLIENTMETRICS m_ncm;
  123. #endif // UNDER_CE
  124. #ifdef UNDER_CE // Windows CE does not support GetCursorPos
  125. POINT m_ptEventPoint; //ButtonDown/Up Event Point
  126. #endif // UNDER_CE
  127. };
  128. #endif //_DDBTN__H_