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.

214 lines
6.4 KiB

  1. /*
  2. ==============================================================================
  3. Application:
  4. Microsoft Windows NT (TM) Performance Monitor
  5. File:
  6. wincrack.h - Windows helper macros.
  7. This file contains macros for more easily dealing with windows
  8. messages and objects. Think of it as an extension to windows.h.
  9. Written by:
  10. Mike Moskowitz 8 Apr 92.
  11. Copyright 1992, Microsoft Corporation. All Rights Reserved.
  12. ==============================================================================
  13. */
  14. //==========================================================================//
  15. // Macros //
  16. //==========================================================================//
  17. #define SetFont(hWnd, hFont) \
  18. (SendMessage ((hWnd), WM_SETFONT, (WPARAM) hFont, 0))
  19. //======================================//
  20. // Object-differentiation routines //
  21. //======================================//
  22. // Windows APIs deal with all GDI objects the same. There's a SelectObject,
  23. // no SelectBitmap, SelectFont, etc. We use these instead to make the code
  24. // easier to read. Also, you can redefine one of these to check the
  25. // validity of a particular GDI object type.
  26. #define SelectBitmap(hDC, hBitmap) \
  27. (SelectObject (hDC, hBitmap))
  28. #define SelectFont(hDC, hFont) \
  29. (SelectObject (hDC, hFont))
  30. #define SelectBrush(hDC, hBrush) \
  31. (SelectObject (hDC, hBrush))
  32. #define DeleteBrush(hBrush) \
  33. (DeleteObject (hBrush))
  34. #define SelectPen(hDC, hPen) \
  35. (SelectObject (hDC, hPen))
  36. #define DeletePen(hPen) \
  37. (DeleteObject (hPen))
  38. //======================================//
  39. // //
  40. //======================================//
  41. #define CBData(hWndCB, iIndex) \
  42. (SendMessage (hWndCB, CB_GETITEMDATA, iIndex, 0L))
  43. #define CBSetData(hWndCB, iIndex, lData) \
  44. (SendMessage (hWndCB, CB_SETITEMDATA, iIndex, (LPARAM) lData))
  45. #define CBAdd(hWndCB, lpszText) \
  46. ((int)(DWORD)SendMessage((hWndCB), CB_ADDSTRING, \
  47. 0, (LPARAM)(LPCSTR)(lpszText)))
  48. #define CBFind(hWndCB, lpszText) \
  49. (SendMessage (hWndCB, CB_FINDSTRING, 0xFFFFFFFF, (LPARAM) lpszText))
  50. #define CBInsert(hWndCB, iIndex, lpszText) \
  51. (SendMessage (hWndCB, CB_INSERTSTRING, (WPARAM) iIndex, (LPARAM) lpszText))
  52. #define CBReset(hWndCB) \
  53. ((int)(DWORD)SendMessage((hWndCB), CB_RESETCONTENT,\
  54. 0, (LPARAM)0))
  55. #define CBSelection(hWndCB) \
  56. (SendMessage (hWndCB, CB_GETCURSEL, 0, 0L))
  57. #define CBSetSelection(hWndCB, iIndex) \
  58. (SendMessage (hWndCB, CB_SETCURSEL, iIndex, 0L))
  59. #define CBString(hWndCB, iIndex, lpszText) \
  60. (SendMessage (hWndCB, CB_GETLBTEXT, iIndex, (LPARAM) lpszText))
  61. #define CBStringLen(hWndCB, iIndex) \
  62. (SendMessage (hWndCB, CB_GETLBTEXTLEN, iIndex, 0L))
  63. //======================================//
  64. // Listbox helpers //
  65. //======================================//
  66. #define LBAdd(hWndLB, lpszText) \
  67. (SendMessage (hWndLB, LB_ADDSTRING, 0, (LPARAM) lpszText))
  68. #define LBData(hWndLB, iIndex) \
  69. (SendMessage (hWndLB, LB_GETITEMDATA, iIndex, 0L))
  70. #define LBDelete(hWndLB, iIndex) \
  71. (SendMessage (hWndLB, LB_DELETESTRING, iIndex, 0L))
  72. #define LBFind(hWndLB, lpszText) \
  73. (SendMessage (hWndLB, LB_FINDSTRING, (WPARAM) -1, (LPARAM) lpszText))
  74. #define LBFocus(hWndLB) \
  75. (SendMessage (hWndLB, LB_GETCARETINDEX, 0, 0))
  76. #define LBInsert(hWndLB, iIndex, lpszText) \
  77. (SendMessage (hWndLB, LB_INSERTSTRING, (WPARAM) iIndex, (LPARAM) lpszText))
  78. #define LBNumItems(hWndLB) \
  79. ((int) SendMessage (hWndLB, LB_GETCOUNT, 0, 0))
  80. #define LBReset(hWndLB) \
  81. ((int)(DWORD)SendMessage((hWndLB), LB_RESETCONTENT,\
  82. 0, (LPARAM)0))
  83. #define LBSelected(hwndLB, index) \
  84. ((int)(DWORD)SendMessage((hwndLB), LB_GETSEL, \
  85. (WPARAM)(int)(index), 0L))
  86. #define LBSelection(hWndLB) \
  87. (SendMessage (hWndLB, LB_GETCURSEL, 0, 0L))
  88. #define LBSetData(hWndLB, iIndex, lData) \
  89. (SendMessage (hWndLB, LB_SETITEMDATA, iIndex, (LPARAM) lData))
  90. #define LBSetSelection(hWndLB, iIndex) \
  91. (SendMessage (hWndLB, LB_SETCURSEL, iIndex, 0L))
  92. #define LBString(hwndLB, iIndex, lpszText) \
  93. ((int)(DWORD)SendMessage((hwndLB), LB_GETTEXT, \
  94. (WPARAM)(int)(iIndex), (LPARAM)(LPCSTR)(lpszText)))
  95. #define MLBSetSelection(hWndMLB, iIndex, bSet) \
  96. (SendMessage (hWndMLB, LB_SETSEL, (WPARAM) bSet, (LPARAM) iIndex))
  97. #define LBSetVisible(hWndLB, iIndex) \
  98. (SendMessage (hWndLB, LB_SETCARETINDEX, (WPARAM) iIndex, 0L))
  99. #define LBSetRedraw(hWndLB, bDrawOnOff) \
  100. (SendMessage (hWndLB, WM_SETREDRAW, (WPARAM) bDrawOnOff, 0L))
  101. #define LBSetHorzExtent(hWndLB, wExtent) \
  102. (SendMessage (hWndLB, LB_SETHORIZONTALEXTENT, (WPARAM)wExtent, 0L))
  103. //======================================//
  104. // Edit helpers //
  105. //======================================//
  106. #define EditModified(hWndEdit) \
  107. (SendMessage ((hWndEdit), EM_GETMODIFY, (WPARAM) 0, (LPARAM) 0))
  108. #define EditSetModified(hWndEdit, bModified) \
  109. (SendMessage ((hWndEdit), EM_SETMODIFY, (WPARAM) bModified, 0))
  110. #define EditSetLimit(hWndEdit, iLimit) \
  111. (SendMessage ((hWndEdit), EM_LIMITTEXT, (WPARAM) iLimit, 0))
  112. #define EditSetTextPos(hWnd, idControl, iStartPos, iEndPos) \
  113. (SendMessage (GetDlgItem(hWnd, idControl), EM_SETSEL, (WPARAM) iStartPos, (LPARAM) iEndPos))
  114. #define EditSetTextEndPos(hWnd, idControl) \
  115. EditSetTextPos(hWnd, idControl, 0, 32767)
  116. //======================================//
  117. // Cursor helpers //
  118. //======================================//
  119. #define SetHourglassCursor() \
  120. (SetCursor(LoadCursor(NULL, IDC_WAIT)))
  121. #define SetArrowCursor() \
  122. (SetCursor(LoadCursor(NULL, IDC_ARROW)))