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.

290 lines
11 KiB

  1. //////////////////////////////////////////////////////////////////
  2. // File : ddbtn.h ( DropDownButton)
  3. // Purpose : new control for drop down button
  4. //
  5. //
  6. // Copyright(c) 1991-1997, Microsoft Corp. All rights reserved
  7. //
  8. // History :970905 Started
  9. //////////////////////////////////////////////////////////////////
  10. //----------------------------------------------------------------
  11. //
  12. //Detail description
  13. //
  14. //----------------------------------------------------------------
  15. #if 0
  16. This Drop down Button(DDButton) control has 2 mode,
  17. 1. Separated Button.
  18. 2. No Separated Button.
  19. Normal case is Separated button. like Word or Excel's common interface,
  20. Icon button and Triangle button.
  21. If DDBS_NOSEPARATED is NOT set, you can see below face.
  22. this is 1.case.
  23. Figure 1. normal face.
  24. left right
  25. +-----------+-------+
  26. | | |
  27. | | ##### |
  28. | | ### |
  29. | | # |
  30. | | |
  31. +-----------+-------+
  32. you can set Text or Icon to left button, with DDButton_SetText() or DDButton_SetIcon().
  33. you can set Item list to DDButton with DDButton_InsertItem() or DDButton_AddItem().
  34. If some item are inserted, and you can see drop down menu if you clicked
  35. the "right" button.
  36. Figure 2. drop down menu has shown.
  37. left button right button
  38. +-----------+-------+
  39. | | |
  40. | | ##### |
  41. | | ### |
  42. | | # |
  43. | | |
  44. +-----------+-------+---+
  45. | I t e m 0 |
  46. | I t e m 1 |
  47. |V I t e m 2 |
  48. | I t e m 3 |
  49. | I t e m 4 |
  50. | I t e m 5 |
  51. | I t e m 6 |
  52. +-----------------------+
  53. "V" means current selected Item.
  54. If you Call DDButton_GetCurSel(), you can get current selected item.
  55. in this case, you can get 2 as integer value.
  56. If you selected specified item in the menu, not current selected item,
  57. you can get WM_COMMAND in Parent window procedure with, "DDBN_SELCHANGE".
  58. you can also set current selected item by DDButton_SetCurSel().
  59. If you click "left button", current selected item index is incremented.
  60. in this case, if you click "left button",
  61. you can receive DDBN_CLICKED notify, and AFTER that, you receive
  62. DDBN_SELCHANGE.
  63. current selected index has changed to "3"
  64. and Before menu will be shown, you can receive WM_COMMAND with
  65. DDBN_DROPDOWN, and after menu has hidden, you can receive,
  66. DDBN_CLOSEUP notify.
  67. If DDBS_NOSEPARATED is NOT set, you can see below face.
  68. Figure 3. with DDBS_NOSEPARATED style.
  69. +-------------------+
  70. | |
  71. | ##### |
  72. | ### |
  73. | # |
  74. | |
  75. +-------------------+
  76. This DDButton has this style, you can NOT receive DDBN_CLICKED.
  77. only
  78. DDBN_DROPDOWN, DDBN_CLOSEUP and DDBN_SELCHANGE will be sent.
  79. #endif //if 0
  80. #ifndef _DROP_DOWN_BUTTON_
  81. #define _DROP_DOWN_BUTTON_
  82. //----------------------------------------------------------------
  83. //Drop Down Button Style
  84. //----------------------------------------------------------------
  85. #define DDBS_TEXT 0x0000 // Show Text as Button Face.
  86. #define DDBS_ICON 0x0001 // Show Icon as Button Face.
  87. #define DDBS_THINEDGE 0x0002 // Draw Thin Edge.
  88. #define DDBS_FLAT 0x0004 // Flat style drop down button.
  89. #define DDBS_NOSEPARATED 0x0010 // No separated button.
  90. // when button was pushed, always drop down is shown.
  91. //----------------------------------------------------------------
  92. //Drop down Item's type mask.
  93. //----------------------------------------------------------------
  94. #define DDBF_TEXT 0x0000 //Only Unicode string.
  95. #define DDBF_ICON 0x0001 //not used.
  96. #define DDBF_SEPARATOR 0x0002 //not used.
  97. //----------------------------------------------------------------
  98. //Drop down Item structure
  99. //----------------------------------------------------------------
  100. #pragma pack(1)
  101. typedef struct tagDDBITEM {
  102. INT cbSize; // DDBITEM structure size is needed.
  103. UINT mask; // reserved. not used.
  104. LPWSTR lpwstr; // drop down item string.
  105. HICON hIcon; //reserved. not used.
  106. LPARAM lParam; //reserved. not used.
  107. }DDBITEM, *LPDDBITEM;
  108. #pragma pack()
  109. //----------------------------------------------------------------
  110. //Drop Down Button Message
  111. //----------------------------------------------------------------
  112. #define DDBM_ADDITEM (WM_USER + 100)
  113. #define DDBM_INSERTITEM (WM_USER + 101)
  114. #define DDBM_SETCURSEL (WM_USER + 102)
  115. #define DDBM_GETCURSEL (WM_USER + 103)
  116. #define DDBM_SETICON (WM_USER + 104)
  117. #define DDBM_SETTEXT (WM_USER + 105)
  118. #define DDBM_SETSTYLE (WM_USER + 106)
  119. //----------------------------------------------------------------
  120. //Drop Down Button Notify code.
  121. //It is set to Parent window of Drop Down button as
  122. //WM_COMMAND.
  123. //----------------------------------------------------------------
  124. //----------------------------------------------------------------
  125. // Notify: DDBN_CLICKED
  126. // When it comes?: If DDBS_NOSEPARATED was SET,this notify only come,
  127. // when current selected item was change.
  128. // If DDBS_NOSEPARATED was NOT set, when button was clicked, or menu item
  129. // was changed, this notify come.
  130. //----------------------------------------------------------------
  131. //----------------------------------------------------------------
  132. // Notify: DDBN_SELCHANGED
  133. // When it comes?: If menu item was selected, this notify come.
  134. // if DDBS_NOSEPARATED style is NOT set,
  135. // when right button(Separated right button, not a mouse)
  136. // was clicked, this notify comes, after DDBN_CLICKED notify.
  137. //----------------------------------------------------------------
  138. //----------------------------------------------------------------
  139. // Notify: DDBN_DROPDOWN
  140. // When it comes?: If dropdown menu was shown, this notify come.
  141. //----------------------------------------------------------------
  142. //----------------------------------------------------------------
  143. // Notify: DDBN_CLOSEUP
  144. // When it comes?: If dropdown menu was hidden, this notify come.
  145. //----------------------------------------------------------------
  146. #define DDBN_CLICKED 0
  147. #define DDBN_SELCHANGE 1
  148. #define DDBN_DROPDOWN 2
  149. #define DDBN_CLOSEUP 3
  150. //----------------------------------------------------------------
  151. //Drop Down Button Message Macro.
  152. //----------------------------------------------------------------
  153. //////////////////////////////////////////////////////////////////
  154. // Function : DDButton_AddItem
  155. // Type : INT
  156. // Purpose : add dropdown item.
  157. // Args : HWND hwndCtrl: DDButton window handle
  158. // : LPDDBITEM lpDDBItem:
  159. // Remarks : when it was called,
  160. // : lpDDBItem->lpwstr data is copyed to DDButton's
  161. // : internal data area.
  162. // Return :
  163. //////////////////////////////////////////////////////////////////
  164. #define DDButton_AddItem(hwndCtrl, pddbItem) \
  165. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_ADDITEM, 0, (LPARAM)pddbItem))
  166. //////////////////////////////////////////////////////////////////
  167. // Function : DDButton_InsertItem
  168. // Type : INT
  169. // Purpose : insert dropdown item.
  170. // Args : HWND hwndCtrl: DDButton window handle
  171. // : INT index:
  172. // : LPDDBITEM lpDDBItem:
  173. // Remarks : when it was called,
  174. // : lpDDBItem->lpwstr data is copyed to DDButton's
  175. // : internal data area.
  176. // Return :
  177. //////////////////////////////////////////////////////////////////
  178. #define DDButton_InsertItem(hwndCtrl, index, pddbItem) \
  179. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_INSERTITEM, (WPARAM)(index), (LPARAM)(pddbItem)))
  180. //////////////////////////////////////////////////////////////////
  181. // Function : DDButton_SetCurSel
  182. // Type : INT
  183. // Purpose : Set current item by specified index.
  184. // Args : HWND hwndCtrl: DDButton window handle
  185. // : INT index: Select index.
  186. // Return :
  187. //////////////////////////////////////////////////////////////////
  188. #define DDButton_SetCurSel(hwndCtrl, index) \
  189. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_SETCURSEL, (WPARAM)(index), (LPARAM)0))
  190. //////////////////////////////////////////////////////////////////
  191. // Function : DDButton_GetCurSel
  192. // Type : INT
  193. // Purpose :
  194. // Args : HWND hwndCtrl: DDButton window handle
  195. // Return : current selected item index.
  196. //////////////////////////////////////////////////////////////////
  197. #define DDButton_GetCurSel(hwndCtrl) \
  198. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_GETCURSEL, (WPARAM)0, (LPARAM)0))
  199. //////////////////////////////////////////////////////////////////
  200. // Function : DDButton_SetIcon
  201. // Type : INT
  202. // Purpose : Set button image as icon.
  203. // Args : HWND hwndCtrl: DDButton window handle.
  204. // : HICON hIcon: Icon handle.
  205. // Remarks : DDBS_ICON style must be set.
  206. // Return :
  207. //////////////////////////////////////////////////////////////////
  208. #define DDButton_SetIcon(hwndCtrl, hIcon) \
  209. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_SETICON, (WPARAM)hIcon, (LPARAM)0))
  210. //////////////////////////////////////////////////////////////////
  211. // Function : DDButton_SetText
  212. // Type : INT
  213. // Purpose : Set button image as icon.
  214. // Args : HWND hwndCtrl: DDButton window handle.
  215. // : LPWSTR lpsz: Unicode String pointer.
  216. // Remarks :
  217. // Return :
  218. //////////////////////////////////////////////////////////////////
  219. #define DDButton_SetText(hwndCtrl, lpsz) \
  220. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_SETTEXT, (WPARAM)lpsz, (LPARAM)0))
  221. //////////////////////////////////////////////////////////////////
  222. // Function : DDButton_SetStyle
  223. // Type : INT
  224. // Purpose : Set Drop down button's style.
  225. // Args : HWND hwndCtrl: DDButton window handle.
  226. // : DWORD dwStyle: DDBS_XXXXX combination.
  227. // Remarks :
  228. // Return :
  229. //////////////////////////////////////////////////////////////////
  230. #define DDButton_SetStyle(hwndCtrl, dwStyle) \
  231. ((int)(DWORD)SendMessage((hwndCtrl), DDBM_SETSTYLE, (WPARAM)dwStyle, (LPARAM)0))
  232. //////////////////////////////////////////////////////////////////
  233. // Function : DDButton_CreateWindow
  234. // Type : HWND
  235. // Purpose : Opened API.
  236. // : Create Drop Down Button.
  237. // Args :
  238. // : HINSTANCE hInst
  239. // : HWND hwndParent
  240. // : DWORD dwStyle DDBS_XXXXX combination.
  241. // : INT wID Window ID
  242. // : INT xPos
  243. // : INT yPos
  244. // : INT width
  245. // : INT height
  246. // Return :
  247. // DATE : 970905
  248. //////////////////////////////////////////////////////////////////
  249. extern HWND DDButton_CreateWindow(HINSTANCE hInst,
  250. HWND hwndParent,
  251. DWORD dwStyle,
  252. INT wID,
  253. INT xPos,
  254. INT yPos,
  255. INT width,
  256. INT height);
  257. #ifdef UNDER_CE // In Windows CE, all window classes are process global.
  258. extern BOOL DDButton_UnregisterClass(HINSTANCE hInst);
  259. #endif // UNDER_CE
  260. #endif //_DROP_DOWN_BUTTON_