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.

304 lines
16 KiB

  1. #ifndef _WIN_API_H_
  2. #define _WIN_API_H_
  3. #include <windows.h>
  4. #include <commctrl.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //----------------------------------------------------------------
  9. //Common
  10. //----------------------------------------------------------------
  11. #ifndef UNDER_CE
  12. extern BOOL WINAPI WinSetWindowTextA_CP(UINT codePage, HWND hWnd, LPCSTR lpString);
  13. extern int WINAPI WinGetWindowTextA_CP(UINT codePage, HWND hWnd, LPSTR lpString, int nMaxCount);
  14. extern int WINAPI WinGetWindowTextLengthA_CP(UINT codePage, HWND hWnd);
  15. extern BOOL WINAPI WinSetWindowTextW_CP(UINT codePage, HWND hWnd, LPCWSTR lpString);
  16. extern int WINAPI WinGetWindowTextW_CP(UINT codePage, HWND hWnd, LPWSTR lpString, int nMaxCount);
  17. extern int WINAPI WinGetWindowTextLengthW_CP(UINT codePage, HWND hWnd);
  18. #endif
  19. #if defined(UNICODE) || defined(_UNICODE) || !defined(AWBOTH)
  20. #define WinSendMessage SendMessage
  21. #define WinPostMessage PostMessage
  22. #define WinPeekMessage PeekMessage
  23. #define WinDispatchMessage DispatchMessage
  24. #define WinTranslateMessage TranslateMessage
  25. #define WinSetWindowLong SetWindowLong
  26. #define WinGetWindowLong GetWindowLong
  27. #define WinCallWindowProc CallWindowProc
  28. #define WinDefWindowProc DefWindowProc
  29. #define WinIsDialogMessage IsDialogMessage
  30. #define WinDefWindowProc DefWindowProc
  31. #define WinTranslateAccelerator TranslateAccelerator
  32. #define WinMessageBoxA MessageBoxA
  33. #define WinMessageBoxW MessageBoxW
  34. #define WinSetWindowTextA SetWindowTextA
  35. #define WinSetWindowTextW SetWindowTextW
  36. #define WinGetWindowTextA GetWindowTextA
  37. #define WinGetWindowTextW GetWindowTextW
  38. #define WinGetWindowTextLengthA GetWindowTextLengthA
  39. #define WinGetWindowTextLengthW GetWindowTextLengthW
  40. #ifdef UNDER_CE
  41. #define WinSetWindowTextW_CP(_cp, _h, _s) WinSetWindowTextW((_h), (_s))
  42. #define WinGetWindowTextW_CP(_cp, _h, _s, _n) WinGetWindowTextW((_h), (_s), (_n))
  43. #define WinGetWindowTextLengthW_CP(_cp, _h) WinGetWindowTextLengthW(_h)
  44. #endif
  45. #ifdef _WIN64
  46. #define WinSetUserData(_h, _l) SetWindowLongPtr(_h, GWLP_USERDATA, (LONG_PTR)_l)
  47. #define WinGetUserData(_h) GetWindowLongPtr(_h, GWLP_USERDATA)
  48. #define WinSetUserDlgData(_h, _ud) SetWindowLongPtr(_h, DWLP_USER, (LONG_PTR)_ud)
  49. #define WinGetUserDlgData(_h) GetWindowLongPtr(_h, DWLP_USER)
  50. #define WinSetMsgResult(_h, _ud) SetWindowLongPtr(_h, DWLP_MSGRESULT, (LONG_PTR)_ud)
  51. #define WinGetMsgResult(_h) GetWindowLongPtr(_h, DWLP_MSGRESULT)
  52. #define WinSetWndProc(_h, _proc) (WNDPROC)SetWindowLongPtr(_h, GWLP_WNDPROC, (WNDPROC)_proc)
  53. #define WinGetWndProc(_h) (WNDPROC)GetWindowLongPtr(_h, GWLP_WNDPROC)
  54. #define WinGetInstanceHandle(_h) (HINSTANCE)GetWindowLongPtr(_h, GWLP_HINSTANCE)
  55. #else //!_WIN64
  56. #define WinSetUserData(_h, _l) SetWindowLong(_h, GWL_USERDATA, (LONG)_l)
  57. #define WinGetUserData(_h) GetWindowLong(_h, GWL_USERDATA)
  58. #define WinSetUserDlgData(_h, _ud) SetWindowLong(_h, DWL_USER, (LONG)_ud)
  59. #define WinGetUserDlgData(_h) GetWindowLong(_h, DWL_USER)
  60. #define WinSetMsgResult(_h, _ud) SetWindowLong(_h, DWL_MSGRESULT, (LONG)_ud)
  61. #define WinGetMsgResult(_h) GetWindowLong(_h, DWL_MSGRESULT)
  62. #define WinSetWndProc(_h, _proc) SetWindowLong(_h, GWL_WNDPROC, (LONG)_proc)
  63. #define WinGetWndProc(_h) GetWindowLong(_h, GWL_WNDPROC)
  64. #define WinGetInstanceHandle(_h) (HINSTANCE)GetWindowLong(_h, GWL_HINSTANCE)
  65. #define WinSetUserPtr(_h, _lp) WinSetUserData(_h, _lp)
  66. #define WinGetUserPtr(_h) WinGetUserData(_h)
  67. #define WinSetStyle(_h, _s) (DWORD)SetWindowLong(_h, GWL_STYLE, _s)
  68. #define WinGetStyle(_h) (DWORD)GetWindowLong(_h, GWL_STYLE)
  69. #define WinSetExStyle(_h, _s) (DWORD)SetWindowLong(_h, GWL_EXSTYLE, (LONG)_s)
  70. #define WinGetExStyle(_h) (DWORD)GetWindowLong(_h, GWL_EXSTYLE)
  71. #endif
  72. #else //if defined(UNICODE) || defined(_UNICODE) || !defined(AWBOTH)---
  73. extern LRESULT WINAPI WinSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  74. extern BOOL WINAPI WinPostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  75. extern BOOL WINAPI WinPeekMessage(LPMSG lpMsg,
  76. HWND hWnd,
  77. UINT wMsgFilterMin,
  78. UINT wMsgFilterMax,
  79. UINT wRemoveMsg);
  80. #define WinTranslateMessage TranslateMessage
  81. extern LRESULT WINAPI WinDispatchMessage(CONST MSG *lpMsg);
  82. extern LONG WINAPI WinSetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
  83. extern LONG WINAPI WinGetWindowLong(HWND hWnd, int nIndex);
  84. extern LRESULT WINAPI WinCallWindowProc(WNDPROC lpPrevWndFunc,
  85. HWND hWnd,
  86. UINT Msg,
  87. WPARAM wParam,
  88. LPARAM lParam);
  89. extern LRESULT WINAPI WinDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  90. extern BOOL WINAPI WinIsDialogMessage(HWND hDlg, LPMSG lpMsg);
  91. extern int WINAPI WinTranslateAccelerator(HWND hWnd, HACCEL hAccTable, LPMSG lpMsg);
  92. extern int WINAPI WinMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
  93. extern int WINAPI WinMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
  94. #define WinSetWindowTextA(_h, _lp) WinSetWindowTextA_CP(CP_ACP, _h, _lp)
  95. #define WinGetWindowTextA(_h, _lp, _c) WinGetWindowTextA_CP(CP_ACP, _h, _lp, _c)
  96. #define WinSetWindowTextW(_h, _lp) WinSetWindowTextW_CP(CP_ACP, _h, _lp)
  97. #define WinGetWindowTextW(_h, _lp, _c) WinGetWindowTextW_CP(CP_ACP, _h, _lp, _c)
  98. #ifdef _WIN64
  99. extern LONG_PTR WINAPI WinSetUserData(HWND hwnd, LONG_PTR lUserData);
  100. extern LONG_PTR WINAPI WinGetUserData(HWND hwnd);
  101. extern LONG_PTR WINAPI WinSetUserDlgData(HWND hwnd, LONG_PTR lUserData);
  102. extern LONG_PTR WINAPI WinGetUserDlgData(HWND hwnd);
  103. extern LONG_PTR WINAPI WinSetMsgResult(HWND hwnd, LONG_PTR lUserData);
  104. extern LONG_PTR WINAPI WinGetMsgResult(HWND hwnd);
  105. #else
  106. extern LONG WINAPI WinSetUserData(HWND hwnd, LONG lUserData);
  107. extern LONG WINAPI WinGetUserData(HWND hwnd);
  108. extern LONG WINAPI WinSetUserDlgData(HWND hwnd, LONG lUserData);
  109. extern LONG WINAPI WinGetUserDlgData(HWND hwnd);
  110. extern LONG WINAPI WinSetMsgResult(HWND hwnd, LONG lUserData);
  111. extern LONG WINAPI WinGetMsgResult(HWND hwnd);
  112. #endif
  113. extern LPVOID WINAPI WinSetUserPtr(HWND hwnd, LPVOID lpVoid);
  114. extern LPVOID WINAPI WinGetUserPtr(HWND hwnd);
  115. extern WNDPROC WINAPI WinSetWndProc(HWND hwnd, WNDPROC lpfnWndProc);
  116. extern WNDPROC WINAPI WinGetWndProc(HWND hwnd);
  117. extern DWORD WINAPI WinSetStyle(HWND hwnd, DWORD dwStyle);
  118. extern DWORD WINAPI WinGetStyle(HWND hwnd);
  119. extern DWORD WINAPI WinSetExStyle(HWND hwnd, DWORD dwStyle);
  120. extern DWORD WINAPI WinGetExStyle(HWND hwnd);
  121. extern HINSTANCE WINAPI WinGetInstanceHandle(HWND hwnd);
  122. #endif //End of --if defined(UNICODE) || defined(_UNICODE) || !defined(AWBOTH)---
  123. //----------------------------------------------------------------
  124. // ComboBox common api
  125. //----------------------------------------------------------------
  126. #ifndef UNDER_CE
  127. INT CB_AddStringA (HWND hwndCtl, LPCSTR lpsz);
  128. INT CB_FindStringA (HWND hwndCtl, INT indexStart, LPCSTR lpszFind);
  129. INT CB_InsertStringA (HWND hwndCtl, INT index, LPCSTR lpsz);
  130. INT CB_GetLBTextLenA (HWND hwndCtl, INT index);
  131. INT CB_GetLBTextA (HWND hwndCtl, INT index, LPSTR lpszBuffer);
  132. INT CB_FindStringExactA (HWND hwndCtl, INT indexStart, LPCSTR lpszFind);
  133. INT CB_SelectStringA (HWND hwndCtl, INT indexStart, LPCSTR lpszSelect);
  134. #endif
  135. INT CB_AddStringW (HWND hwndCtl, LPCWSTR lpsz);
  136. INT CB_InsertStringW (HWND hwndCtl, INT index, LPCWSTR lpsz);
  137. INT CB_GetLBTextLenW (HWND hwndCtl, INT index);
  138. INT CB_GetLBTextW (HWND hwndCtl, INT index, LPWSTR lpszBuffer);
  139. INT CB_FindStringW (HWND hwndCtl, INT indexStart, LPCWSTR lpszFind);
  140. INT CB_FindStringExactW (HWND hwndCtl, INT indexStart, LPCWSTR lpszFind);
  141. INT CB_SelectStringW (HWND hwndCtl, INT indexStart, LPCWSTR lpszSelect);
  142. //----------------------------------------------------------------
  143. // ComboBox macro
  144. //----------------------------------------------------------------
  145. #define WinComboBox_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
  146. #define WinComboBox_GetText(hwndCtl, lpch, cchMax) GetWindowText((hwndCtl), (lpch), (cchMax))
  147. #define WinComboBox_GetTextA(hwndCtl, lpch, cchMax) WinGetWindowTextA((hwndCtl), (lpch), (cchMax))
  148. #define WinComboBox_GetTextW(hwndCtl, lpch, cchMax) WinGetWindowTextW((hwndCtl), (lpch), (cchMax))
  149. #define WinComboBox_GetTextLength(hwndCtl) GetWindowTextLength(hwndCtl)
  150. #define WinComboBox_GetTextLengthA(hwndCtl) WinGetWindowTextLengthA(hwndCtl)
  151. #define WinComboBox_GetTextLengthW(hwndCtl) WinGetWindowTextLengthW(hwndCtl)
  152. #define WinComboBox_SetText(hwndCtl, lpsz) SetWindowText((hwndCtl), (lpsz))
  153. #define WinComboBox_SetTextA(hwndCtl, lpsz) WinSetWindowTextA((hwndCtl), (lpsz))
  154. #define WinComboBox_SetTextW(hwndCtl, lpsz) WinSetWindowTextW((hwndCtl), (lpsz))
  155. #define WinComboBox_LimitText(hwndCtl, cchLimit) ((int)(DWORD)WinSendMessage((hwndCtl), \
  156. CB_LIMITTEXT, \
  157. (WPARAM)(int)(cchLimit), \
  158. 0L))
  159. #define WinComboBox_GetEditSel(hwndCtl) ((DWORD)WinSendMessage((hwndCtl), \
  160. CB_GETEDITSEL, \
  161. 0L, 0L))
  162. #define WinComboBox_SetEditSel(hwndCtl, ichStart, ichEnd) ((int)(DWORD)WinSendMessage((hwndCtl), \
  163. CB_SETEDITSEL, \
  164. 0L, \
  165. MAKELPARAM((ichStart), \
  166. (ichEnd))))
  167. #define WinComboBox_GetCount(hwndCtl) ((int)(DWORD)WinSendMessage((hwndCtl), \
  168. CB_GETCOUNT, \
  169. 0L, 0L))
  170. #define WinComboBox_ResetContent(hwndCtl) ((int)(DWORD)WinSendMessage((hwndCtl), \
  171. CB_RESETCONTENT, \
  172. 0L, 0L))
  173. #define WinComboBox_AddString(hwndCtl, lpsz) ((int)(DWORD)WinSendMessage((hwndCtl), \
  174. CB_ADDSTRING, \
  175. 0L, \
  176. (LPARAM)(LPCTSTR)(lpsz)))
  177. #define WinComboBox_AddStringA(hwndCtl, lpsz) CB_AddStringA((hwndCtl), lpsz)
  178. #define WinComboBox_AddStringW(hwndCtl, lpsz) CB_AddStringW((hwndCtl), lpsz)
  179. #define WinComboBox_InsertString(hwndCtl, index, lpsz) ((int)(DWORD)WinSendMessage((hwndCtl), \
  180. CB_INSERTSTRING, \
  181. (WPARAM)(int)(index), \
  182. (LPARAM)(LPCTSTR)(lpsz)))
  183. #define WinComboBox_InsertStringA(hwndCtl, index, lpsz) CB_InsertStringA((hwndCtl), index, lpsz)
  184. #define WinComboBox_InsertStringW(hwndCtl, index, lpsz) CB_InsertStringW((hwndCtl), index, lpsz)
  185. #define WinComboBox_AddItemData(hwndCtl, data) ((int)(DWORD)WinSendMessage((hwndCtl), \
  186. CB_ADDSTRING, \
  187. 0L, \
  188. (LPARAM)(data)))
  189. #define WinComboBox_InsertItemData(hwndCtl, index, data) ((int)(DWORD)WinSendMessage((hwndCtl), \
  190. CB_INSERTSTRING, \
  191. (WPARAM)(int)(index), \
  192. (LPARAM)(data)))
  193. #define WinComboBox_DeleteString(hwndCtl, index) ((int)(DWORD)WinSendMessage((hwndCtl), \
  194. CB_DELETESTRING, \
  195. (WPARAM)(int)(index), \
  196. 0L))
  197. #define WinComboBox_GetLBTextLen(hwndCtl, index) ((int)(DWORD)WinSendMessage((hwndCtl), \
  198. CB_GETLBTEXTLEN, \
  199. (WPARAM)(int)(index), \
  200. 0L))
  201. //#define WinComboBox_GetLBTextLenA(hwndCtl, index) CB_GetLBTextLenA((hwndCtl), (index))
  202. //#define WinComboBox_GetLBTextLenW(hwndCtl, index) CB_GetLBTextLenW((hwndCtl), (index))
  203. #define WinComboBox_GetLBText(hwndCtl, index, lpszBuffer) ((int)(DWORD)WinSendMessage((hwndCtl), \
  204. CB_GETLBTEXT, \
  205. (WPARAM)(int)(index), \
  206. (LPARAM)(LPCTSTR)(lpszBuffer)))
  207. #define WinComboBox_GetLBTextA(hwndCtl, index, lpszBuffer) CB_GetLBTextA((hwndCtl), (index), lpszBuffer)
  208. #define WinComboBox_GetLBTextW(hwndCtl, index, lpszBuffer) CB_GetLBTextW((hwndCtl), (index), lpszBuffer)
  209. #define WinComboBox_GetItemData(hwndCtl, index) ((LRESULT)(DWORD)WinSendMessage((hwndCtl), \
  210. CB_GETITEMDATA, \
  211. (WPARAM)(int)(index), \
  212. 0L))
  213. #define WinComboBox_SetItemData(hwndCtl, index, data) ((int)(DWORD)WinSendMessage((hwndCtl), \
  214. CB_SETITEMDATA, \
  215. (WPARAM)(int)(index), \
  216. (LPARAM)(data)))
  217. #define WinComboBox_FindString(hwndCtl, indexStart, lpszFind) ((int)(DWORD)WinSendMessage((hwndCtl), \
  218. CB_FINDSTRING, \
  219. (WPARAM)(int)(indexStart), \
  220. (LPARAM)(LPCTSTR)(lpszFind)))
  221. #define WinComboBox_FindStringA(hwndCtl,indexStart,lpszFind) CB_FindStringA((hwndCtl), indexStart,lpszFind)
  222. #define WinComboBox_FindStringW(hwndCtl,indexStart,lpszFind) CB_FindStringW((hwndCtl), indexStart,lpszFind)
  223. #define WinComboBox_FindItemData(hwndCtl, indexStart, data) ((int)(DWORD)WinSendMessage((hwndCtl), \
  224. CB_FINDSTRING, \
  225. (WPARAM)(int)(indexStart), \
  226. (LPARAM)(data)))
  227. #define WinComboBox_GetCurSel(hwndCtl) ((int)(DWORD)WinSendMessage((hwndCtl), \
  228. CB_GETCURSEL, \
  229. 0L, 0L))
  230. #define WinComboBox_SetCurSel(hwndCtl, index) ((int)(DWORD)WinSendMessage((hwndCtl), \
  231. CB_SETCURSEL, \
  232. (WPARAM)(int)(index), \
  233. 0L))
  234. #define WinComboBox_SelectString(hwndCtl, indexStart, lpszSelect) ((int)WinSendMessage((hwndCtl), \
  235. CB_SELECTSTRING, \
  236. (WPARAM)(indexStart), \
  237. (LPARAM)(lpszSelect)))
  238. #define WinComboBox_SelectStringA(hwndCtl, indexStart, lpszSelect) CB_SelectStringA((hwndCtl), \
  239. (indexStart), \
  240. (lpszSelect))
  241. #define WinComboBox_SelectStringW(hwndCtl, indexStart, lpszSelect) CB_SelectStringW((hwndCtl), \
  242. (indexStart), \
  243. (lpszSelect))
  244. #define WinComboBox_SelectItemData(hwndCtl, indexStart, data) ((int)WinSendMessage((hwndCtl), \
  245. CB_SELECTSTRING, \
  246. (WPARAM)(indexStart), \
  247. (LPARAM)(data)))
  248. #define WinComboBox_Dir(hwndCtl, attrs, lpszFileSpec) ((int)(DWORD)WinSendMessage((hwndCtl), \
  249. CB_DIR, \
  250. (WPARAM)(UINT)(attrs), \
  251. (LPARAM)(LPCTSTR)(lpszFileSpec)))
  252. #define WinComboBox_ShowDropdown(hwndCtl, fShow) ((BOOL)(DWORD)WinSendMessage((hwndCtl), \
  253. CB_SHOWDROPDOWN, \
  254. (WPARAM)(BOOL)(fShow), \
  255. 0L))
  256. #define WinComboBox_FindStringExact(hwndCtl, indexStart, lpszFind) ((int)(DWORD)WinSendMessage((hwndCtl), CB_FINDSTRINGEXACT, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
  257. #define WinComboBox_FindStringExactA(hwndCtl,indexStart,lpszFind) CB_FindStringExactA((hwndCtl), indexStart,lpszFind)
  258. #define WinComboBox_FindStringExactW(hwndCtl,indexStart,lpszFind) CB_FindStringExactW((hwndCtl), indexStart,lpszFind)
  259. #define WinComboBox_GetDroppedState(hwndCtl) ((BOOL)(DWORD)WinSendMessage((hwndCtl), \
  260. CB_GETDROPPEDSTATE, \
  261. 0L, 0L))
  262. #define WinComboBox_GetDroppedControlRect(hwndCtl, lprc) ((void)WinSendMessage((hwndCtl), \
  263. CB_GETDROPPEDCONTROLRECT, \
  264. 0L, (LPARAM)(RECT *)(lprc)))
  265. #define WinComboBox_GetItemHeight(hwndCtl) ((int)(DWORD)WinSendMessage((hwndCtl), \
  266. CB_GETITEMHEIGHT, \
  267. 0L, 0L))
  268. #define WinComboBox_SetItemHeight(hwndCtl, index, cyItem) ((int)(DWORD)WinSendMessage((hwndCtl), \
  269. CB_SETITEMHEIGHT, \
  270. (WPARAM)(int)(index), \
  271. (LPARAM)(int)cyItem))
  272. #define WinComboBox_GetExtendedUI(hwndCtl) ((UINT)(DWORD)WinSendMessage((hwndCtl), \
  273. CB_GETEXTENDEDUI, \
  274. 0L, 0L))
  275. #define WinComboBox_SetExtendedUI(hwndCtl, flags) ((int)(DWORD)WinSendMessage((hwndCtl), \
  276. CB_SETEXTENDEDUI, \
  277. (WPARAM)(UINT)(flags), \
  278. 0L))
  279. #ifdef __cplusplus
  280. };
  281. #endif
  282. #endif //_WIN_API_H_