|
|
1.1 ! root 1: /* ! 2: ============================================================================== ! 3: ! 4: Application: ! 5: ! 6: Microsoft Windows NT (TM) Performance Monitor ! 7: ! 8: File: ! 9: wincrack.h - Windows helper macros. ! 10: ! 11: This file contains macros for more easily dealing with windows ! 12: messages and objects. Think of it as an extension to windows.h. ! 13: ! 14: Written by: ! 15: ! 16: Mike Moskowitz 8 Apr 92. ! 17: ! 18: Copyright 1992, Microsoft Corporation. All Rights Reserved. ! 19: ============================================================================== ! 20: */ ! 21: ! 22: ! 23: ! 24: //==========================================================================// ! 25: // Macros // ! 26: //==========================================================================// ! 27: ! 28: ! 29: #define SetFont(hWnd, hFont) \ ! 30: (SendMessage ((hWnd), WM_SETFONT, (WPARAM) hFont, 0)) ! 31: ! 32: ! 33: //======================================// ! 34: // Object-differentiation routines // ! 35: //======================================// ! 36: ! 37: ! 38: // Windows APIs deal with all GDI objects the same. There's a SelectObject, ! 39: // no SelectBitmap, SelectFont, etc. We use these instead to make the code ! 40: // easier to read. Also, you can redefine one of these to check the ! 41: // validity of a particular GDI object type. ! 42: ! 43: ! 44: #define SelectBitmap(hDC, hBitmap) \ ! 45: (SelectObject (hDC, hBitmap)) ! 46: ! 47: #define SelectFont(hDC, hFont) \ ! 48: (SelectObject (hDC, hFont)) ! 49: ! 50: #define SelectBrush(hDC, hBrush) \ ! 51: (SelectObject (hDC, hBrush)) ! 52: ! 53: #define DeleteBrush(hBrush) \ ! 54: (DeleteObject (hBrush)) ! 55: ! 56: #define SelectPen(hDC, hPen) \ ! 57: (SelectObject (hDC, hPen)) ! 58: ! 59: #define DeletePen(hPen) \ ! 60: (DeleteObject (hPen)) ! 61: ! 62: ! 63: //======================================// ! 64: // // ! 65: //======================================// ! 66: ! 67: ! 68: #define CBData(hWndCB, iIndex) \ ! 69: (SendMessage (hWndCB, CB_GETITEMDATA, iIndex, 0L)) ! 70: ! 71: ! 72: #define CBSetData(hWndCB, iIndex, lData) \ ! 73: (SendMessage (hWndCB, CB_SETITEMDATA, iIndex, (LONG) lData)) ! 74: ! 75: ! 76: #define CBAdd(hWndCB, lpszText) \ ! 77: ((int)(DWORD)SendMessage((hWndCB), CB_ADDSTRING, \ ! 78: 0, (LPARAM)(LPCSTR)(lpszText))) ! 79: ! 80: ! 81: #define CBFind(hWndCB, lpszText) \ ! 82: (SendMessage (hWndCB, CB_FINDSTRING, 0xFFFFFFFF, (LPARAM) lpszText)) ! 83: ! 84: ! 85: #define CBInsert(hWndCB, iIndex, lpszText) \ ! 86: (SendMessage (hWndCB, CB_INSERTSTRING, (WPARAM) iIndex, (LPARAM) lpszText)) ! 87: ! 88: ! 89: #define CBReset(hWndCB) \ ! 90: ((int)(DWORD)SendMessage((hWndCB), CB_RESETCONTENT,\ ! 91: 0, (LPARAM)0)) ! 92: ! 93: ! 94: #define CBSelection(hWndCB) \ ! 95: (SendMessage (hWndCB, CB_GETCURSEL, 0, 0L)) ! 96: ! 97: ! 98: #define CBSetSelection(hWndCB, iIndex) \ ! 99: (SendMessage (hWndCB, CB_SETCURSEL, iIndex, 0L)) ! 100: ! 101: ! 102: #define CBString(hWndCB, iIndex, lpszText) \ ! 103: (SendMessage (hWndCB, CB_GETLBTEXT, iIndex, (LPARAM) lpszText)) ! 104: ! 105: ! 106: #define CBStringLen(hWndCB, iIndex) \ ! 107: (SendMessage (hWndCB, CB_GETLBTEXTLEN, iIndex, 0L)) ! 108: ! 109: ! 110: ! 111: //======================================// ! 112: // Listbox helpers // ! 113: //======================================// ! 114: ! 115: ! 116: #define LBAdd(hWndLB, lpszText) \ ! 117: (SendMessage (hWndLB, LB_ADDSTRING, 0, (LPARAM) lpszText)) ! 118: ! 119: ! 120: #define LBData(hWndLB, iIndex) \ ! 121: (SendMessage (hWndLB, LB_GETITEMDATA, iIndex, 0L)) ! 122: ! 123: ! 124: #define LBDelete(hWndLB, iIndex) \ ! 125: (SendMessage (hWndLB, LB_DELETESTRING, iIndex, 0L)) ! 126: ! 127: ! 128: #define LBFind(hWndLB, lpszText) \ ! 129: (SendMessage (hWndLB, LB_FINDSTRING, (WPARAM) -1, (LPARAM) lpszText)) ! 130: ! 131: ! 132: #define LBFocus(hWndLB) \ ! 133: (SendMessage (hWndLB, LB_GETCARETINDEX, 0, 0)) ! 134: ! 135: ! 136: #define LBInsert(hWndLB, iIndex, lpszText) \ ! 137: (SendMessage (hWndLB, LB_INSERTSTRING, (WPARAM) iIndex, (LPARAM) lpszText)) ! 138: ! 139: ! 140: #define LBNumItems(hWndLB) \ ! 141: ((int) SendMessage (hWndLB, LB_GETCOUNT, 0, 0)) ! 142: ! 143: ! 144: #define LBReset(hWndLB) \ ! 145: ((int)(DWORD)SendMessage((hWndLB), LB_RESETCONTENT,\ ! 146: 0, (LPARAM)0)) ! 147: ! 148: ! 149: #define LBSelected(hwndLB, index) \ ! 150: ((int)(DWORD)SendMessage((hwndLB), LB_GETSEL, \ ! 151: (WPARAM)(int)(index), 0L)) ! 152: ! 153: ! 154: #define LBSelection(hWndLB) \ ! 155: (SendMessage (hWndLB, LB_GETCURSEL, 0, 0L)) ! 156: ! 157: ! 158: #define LBSetData(hWndLB, iIndex, lData) \ ! 159: (SendMessage (hWndLB, LB_SETITEMDATA, iIndex, (LONG) lData)) ! 160: ! 161: ! 162: #define LBSetSelection(hWndLB, iIndex) \ ! 163: (SendMessage (hWndLB, LB_SETCURSEL, iIndex, 0L)) ! 164: ! 165: ! 166: #define LBString(hwndLB, iIndex, lpszText) \ ! 167: ((int)(DWORD)SendMessage((hwndLB), LB_GETTEXT, \ ! 168: (WPARAM)(int)(iIndex), (LPARAM)(LPCSTR)(lpszText))) ! 169: ! 170: ! 171: #define MLBSetSelection(hWndMLB, iIndex, bSet) \ ! 172: (SendMessage (hWndMLB, LB_SETSEL, (WPARAM) bSet, (LPARAM) iIndex)) ! 173: ! 174: #define LBSetVisible(hWndLB, iIndex) \ ! 175: (SendMessage (hWndLB, LB_SETCARETINDEX, (WPARAM) iIndex, 0L)) ! 176: ! 177: ! 178: #define LBSetRedraw(hWndLB, bDrawOnOff) \ ! 179: (SendMessage (hWndLB, WM_SETREDRAW, (WPARAM) bDrawOnOff, 0L)) ! 180: ! 181: ! 182: #define LBSetHorzExtent(hWndLB, wExtent) \ ! 183: (SendMessage (hWndLB, LB_SETHORIZONTALEXTENT, (WPARAM)wExtent, 0L)) ! 184: ! 185: //======================================// ! 186: // Edit helpers // ! 187: //======================================// ! 188: ! 189: ! 190: #define EditModified(hWndEdit) \ ! 191: (SendMessage ((hWndEdit), EM_GETMODIFY, (WPARAM) 0, (LPARAM) 0)) ! 192: ! 193: ! 194: #define EditSetModified(hWndEdit, bModified) \ ! 195: (SendMessage ((hWndEdit), EM_SETMODIFY, (WPARAM) bModified, 0)) ! 196: ! 197: ! 198: #define EditSetLimit(hWndEdit, iLimit) \ ! 199: (SendMessage ((hWndEdit), EM_LIMITTEXT, (WPARAM) iLimit, 0)) ! 200: #define EditSetTextPos(hWnd, idControl, iStartPos, iEndPos) \ ! 201: (SendMessage (GetDlgItem(hWnd, idControl), EM_SETSEL, (WPARAM) iStartPos, (LPARAM) iEndPos)) ! 202: ! 203: #define EditSetTextEndPos(hWnd, idControl) \ ! 204: EditSetTextPos(hWnd, idControl, 0, 32767) ! 205: ! 206: //======================================// ! 207: // Cursor helpers // ! 208: //======================================// ! 209: ! 210: #define SetHourglassCursor() \ ! 211: (SetCursor(LoadCursor(NULL, IDC_WAIT))) ! 212: ! 213: #define SetArrowCursor() \ ! 214: (SetCursor(LoadCursor(NULL, IDC_ARROW))) ! 215: ! 216:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.