Annotation of mstools/samples/sdktools/perfmon/utils.h, revision 1.1.1.1

1.1       root        1: //==========================================================================//
                      2: //                                  Constants                               //
                      3: //==========================================================================//
                      4: 
                      5: 
                      6: #define ThreeDPad          2
                      7: #define NOCHANGE           -1
                      8: 
                      9: #define MENUCLOSING        (0xFFFF0000)
                     10: 
                     11: #define WM_DLGSETFOCUS     (WM_USER + 0x201)
                     12: #define WM_DLGKILLFOCUS    (WM_USER + 0x202)
                     13: 
                     14: 
                     15: 
                     16: //==========================================================================//
                     17: //                                   Macros                                 //
                     18: //==========================================================================//
                     19: 
                     20: 
                     21: #define PinInclusive(x, lo, hi)                       \
                     22:    (max (lo, min (x, hi)))
                     23: 
                     24: 
                     25: #define PinExclusive(x, lo, hi)                       \
                     26:    (max ((lo) + 1, min (x, (hi) - 1)))
                     27: 
                     28: 
                     29: #define BoolEqual(a, b)                               \
                     30:    ((a == 0) == (b == 0))
                     31: 
                     32: 
                     33: //=============================//
                     34: // Window Instance Accessors   //
                     35: //=============================//
                     36: 
                     37: #define WindowParent(hWnd)                            \
                     38:    ((HWND) GetWindowLong (hWnd, GWL_HWNDPARENT))
                     39: 
                     40: #define WindowID(hWnd)                                \
                     41:    GetWindowLong (hWnd, GWL_ID)
                     42: 
                     43: #define WindowInstance(hWnd)                          \
                     44:    GetWindowWord (hWnd, GWW_HINSTANCE)
                     45: 
                     46: #define WindowStyle(hWnd)                             \
                     47:    GetWindowLong (hWnd, GWL_STYLE)
                     48: 
                     49: #define WindowSetStyle(hWnd, lStyle)                  \
                     50:    SetWindowLong (hWnd, GWL_STYLE, lStyle)
                     51: 
                     52: #define WindowExStyle(hWnd)                           \
                     53:    GetWindowLong (hWnd, GWL_EXSTYLE)
                     54: 
                     55: #define WindowSetID(hWnd, wID)                        \
                     56:    SetWindowLong (hWnd, GWL_ID, wID)
                     57: 
                     58: 
                     59: // All modeless dialogs need to be dispatched separately in the WinMain
                     60: // message loop, but only if the dialog exists.
                     61: 
                     62: 
                     63: #define ModelessDispatch(hDlg, lpMsg)                 \
                     64:    (hDlg ? IsDialogMessage (hDlg, lpMsg) : FALSE)
                     65: 
                     66: 
                     67: #define strclr(szString)                              \
                     68:    (szString [0] = TEXT('\0'))
                     69: 
                     70: 
                     71: #define strempty(lpszString)                          \
                     72:    (!(lpszString) || !(lpszString[0]))
                     73: 
                     74: #define pstrsame(lpsz1, lpsz2)                        \
                     75:    ((!lpsz1 && !lpsz2) || (lpsz1 && lpsz2 && strsame (lpsz1, lpsz2)))
                     76: 
                     77: #define pstrsamei(lpsz1, lpsz2)                        \
                     78:    ((!lpsz1 && !lpsz2) || (lpsz1 && lpsz2 && strsamei (lpsz1, lpsz2)))
                     79: 
                     80: #define StringLoad(wID, szText)                       \
                     81:    (LoadString (hInstance, wID,                       \
                     82:     szText, sizeof (szText) - sizeof(TCHAR)))
                     83: 
                     84: 
                     85: #define WindowInvalidate(hWnd)                        \
                     86:    (InvalidateRect (hWnd, NULL, TRUE))
                     87: 
                     88: 
                     89: #define WindowShow(hWnd, bShow)                       \
                     90:    (ShowWindow (hWnd, (bShow) ? SW_SHOW : SW_HIDE))
                     91: 
                     92: 
                     93: #define MenuCheck(hMenu, wID, bCheck)                 \
                     94:    (CheckMenuItem (hMenu, wID, (bCheck) ?             \
                     95:      (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED)))
                     96: 
                     97: #define DeleteFont(hFont)                             \
                     98:    (DeleteObject (hFont))
                     99: 
                    100: #define DeleteBitmap(hBitmap)                         \
                    101:    (DeleteObject (hBitmap))
                    102: 
                    103: #define DialogControl(hDlg, wControlID)               \
                    104:    GetDlgItem (hDlg, wControlID)
                    105: 
                    106: 
                    107: #define DialogSetInt(hDlg, wControlID, iValue)        \
                    108:    (SetDlgItemInt (hDlg, wControlID, iValue, TRUE))
                    109: 
                    110: 
                    111: #define DialogText(hDlg, wControlID, szText)          \
                    112:    (GetDlgItemText (hDlg, wControlID, szText, sizeof (szText) / sizeof(TCHAR) - 1))
                    113: 
                    114: #define DialogInt(hDlg, wControlID)                   \
                    115:    (GetDlgItemInt (hDlg, wControlID, NULL, TRUE))
                    116: 
                    117: #define strsame(szText1, szText2)                     \
                    118:    (!lstrcmp (szText1, szText2))
                    119: 
                    120: #define strsamei(szText1, szText2)                     \
                    121:    (!lstrcmpi (szText1, szText2))
                    122: 
                    123: #define strnsame(szText1, szText2, iLen)              \
                    124:    (!lstrncmp (szText1, szText2, iLen))
                    125: 
                    126: 
                    127: #define CreateScreenDC()                              \
                    128:    CreateDC (TEXT("DISPLAY"), NULL, NULL, NULL)
                    129: 
                    130: 
                    131: 
                    132: #define RectContract(lpRect, xAmt, yAmt)              \
                    133:    {                                                  \
                    134:    (lpRect)->left += (xAmt) ;                         \
                    135:    (lpRect)->top += (yAmt) ;                          \
                    136:    (lpRect)->right -= (xAmt) ;                        \
                    137:    (lpRect)->bottom -= (yAmt) ;                       \
                    138:    }
                    139: 
                    140: #define IsBW(hDC)                                     \
                    141:    (DeviceNumColors (hDC) <= 2)
                    142: 
                    143: #ifdef KEEP_PRINT
                    144: #define IsPrinterDC(hDC)                              \
                    145:    (GetDeviceCaps (hDC, TECHNOLOGY) != DT_RASDISPLAY)
                    146: #else
                    147: #define IsPrinterDC(hDC)                              \
                    148:    (FALSE)
                    149: #endif
                    150: 
                    151: #define VertInchPixels(hDC, iNumerator, iDenominator) \
                    152:    ((iNumerator * GetDeviceCaps (hDC, LOGPIXELSY)) / iDenominator)
                    153: 
                    154: 
                    155: #define HorzInchPixels(hDC, iNumerator, iDenominator) \
                    156:    ((iNumerator * GetDeviceCaps (hDC, LOGPIXELSX)) / iDenominator)
                    157: 
                    158: 
                    159: #define VertPointPixels(hDC, iPoints)                 \
                    160:    ((iPoints * GetDeviceCaps (hDC, LOGPIXELSY)) / 72)
                    161: 
                    162: 
                    163: 
                    164: #define SimulateButtonPush(hDlg, wControlID)          \
                    165:    (PostMessage (hDlg, WM_COMMAND,                    \
                    166:                  (WPARAM) MAKELONG (wControlID, BN_CLICKED),  \
                    167:                  (LPARAM) DialogControl (hDlg, wControlID)))
                    168: 
                    169: 
                    170: // convert an unicode string to ASCII string
                    171: #define ConvertUnicodeStr(pNonUnicodeStr, pUnicodeStr)   \
                    172:    wcstombs(pNonUnicodeStr, pUnicodeStr, lstrlen(pUnicodeStr) + 1)
                    173: 
                    174: #define CallWinHelp(ContextID)   \
                    175:    WinHelp(hWndMain, pszHelpFile, HELP_CONTEXT, ContextID) ;
                    176: 
                    177: //==========================================================================//
                    178: //                             Exported Functions                           //
                    179: //==========================================================================//
                    180: 
                    181: void Fill (HDC hDC,
                    182:            DWORD rgbColor,
                    183:            LPRECT lpRect) ;
                    184: 
                    185: void ScreenRectToClient (HWND hWnd,
                    186:                          LPRECT lpRect) ;
                    187: 
                    188: int TextWidth (HDC hDC, LPTSTR lpszText) ;
                    189: 
                    190: 
                    191: void ThreeDConcave (HDC hDC,
                    192:                     int x1, int y1, 
                    193:                     int x2, int y2,
                    194:                     BOOL bFace) ;
                    195: 
                    196: 
                    197: void ThreeDConvex (HDC hDC,
                    198:                    int x1, int y1, 
                    199:                    int x2, int y2) ;
                    200: 
                    201: 
                    202: void ThreeDConcave1 (HDC hDC,
                    203:                      int x1, int y1, 
                    204:                      int x2, int y2) ;
                    205: 
                    206: 
                    207: void ThreeDConvex1 (HDC hDC,
                    208:                    int x1, int y1, 
                    209:                    int x2, int y2) ;
                    210: 
                    211: 
                    212: int _cdecl mike (TCHAR *szFormat, ...) ;
                    213: 
                    214: int _cdecl DlgErrorBox (HWND hDlg, UINT id, ...) ;
                    215: 
                    216: int _cdecl mike1 (TCHAR *szFormat, ...) ;
                    217: int _cdecl mike2 (TCHAR *szFormat, ...) ;
                    218: 
                    219: int FontHeight (HDC hDC, 
                    220:                  BOOL bIncludeLeading) ;
                    221: 
                    222: 
                    223: int TextAvgWidth (HDC hDC,
                    224:                   int iNumChars) ;
                    225: 
                    226: 
                    227: 
                    228: void WindowCenter (HWND hWnd) ;
                    229: 
                    230: 
                    231: 
                    232: BOOL DialogMove (HDLG hDlg,
                    233:                  WORD wControlID,
                    234:                  int xPos, 
                    235:                  int yPos,
                    236:                  int xWidth,
                    237:                  int yHeight) ;
                    238: 
                    239: 
                    240: int DialogWidth (HDLG hDlg, 
                    241:                  WORD wControlID) ;
                    242: 
                    243: 
                    244: int DialogXPos (HDLG hDlg,
                    245:                 WORD wControlID) ;
                    246: 
                    247: int DialogYPos (HDLG hDlg,
                    248:                 WORD wControlID) ;
                    249: 
                    250: 
                    251: void DialogShow (HDLG hDlg,
                    252:                  WORD wID,
                    253:                  BOOL bShow) ;
                    254: 
                    255: 
                    256: BOOL _cdecl DialogSetText (HDLG hDlg,
                    257:                            WORD wControlID,
                    258:                            WORD wStringID,
                    259:                            ...) ;
                    260: 
                    261: BOOL _cdecl DialogSetString (HDLG hDlg,
                    262:                              WORD wControlID,
                    263:                              LPTSTR lpszFormat,
                    264:                              ...) ;
                    265: 
                    266: 
                    267: LPTSTR LongToCommaString (LONG lNumber,
                    268:                          LPTSTR lpszText) ;
                    269: 
                    270: 
                    271: BOOL MenuSetPopup (HWND hWnd,
                    272:                    int iPosition,
                    273:                    WORD  wControlID,
                    274:                    LPTSTR lpszResourceID) ;
                    275: 
                    276: void DialogEnable (HDLG hDlg,
                    277:                    WORD wID,
                    278:                    BOOL bEnable) ;
                    279: 
                    280: 
                    281: LPTSTR FileCombine (LPTSTR lpszFileSpec,
                    282:                    LPTSTR lpszFileDirectory,
                    283:                    LPTSTR lpszFileName) ;
                    284: 
                    285: LPTSTR ExtractFileName (LPTSTR pFileSpec) ;
                    286: 
                    287: int CBAddInt (HWND hWndCB,
                    288:               int iValue) ;
                    289: 
                    290: FLOAT DialogFloat (HDLG hDlg, 
                    291:                    WORD wControlID,
                    292:                    BOOL *pbOK) ;
                    293: 
                    294: 
                    295: LPTSTR StringAllocate (LPTSTR lpszText1) ;
                    296: 
                    297: 
                    298: int DivRound (int iNumerator, int iDenominator) ;
                    299: 
                    300: 
                    301: 
                    302: BOOL MenuEnableItem (HMENU hMenu,
                    303:                      WORD wID,
                    304:                      BOOL bEnable) ;
                    305: 
                    306: 
                    307: 
                    308: void DrawBitmap (HDC hDC,
                    309:                  HBITMAP hBitmap,
                    310:                  int xPos,
                    311:                  int yPos,
                    312:                  LONG  lROPCode) ;
                    313: 
                    314: 
                    315: int BitmapWidth (HBITMAP hBitmap) ;
                    316: 
                    317: 
                    318: 
                    319: int BitmapHeight (HBITMAP hBitmap) ;
                    320: 
                    321: 
                    322: void WindowResize (HWND hWnd,
                    323:                    int xWidth,
                    324:                    int yHeight) ;
                    325: 
                    326: 
                    327: int WindowWidth (HWND hWnd) ;
                    328: 
                    329: 
                    330: int WindowHeight (HWND hWnd) ;
                    331: 
                    332: 
                    333: 
                    334: void WindowSetTopmost (HWND hWnd, BOOL bTopmost) ;
                    335: 
                    336: 
                    337: void WindowEnableTitle (HWND hWnd, BOOL bTitle) ;
                    338: 
                    339: 
                    340: void Line (HDC hDC,
                    341:            HPEN hPen,
                    342:            int x1, int y1,
                    343:            int x2, int y2) ;
                    344: 
                    345: 
                    346: 
                    347: #define HLine(hDC, hPen, x1, x2, y)          \
                    348:    Line (hDC, hPen, x1, y, x2, y) ;
                    349: 
                    350: 
                    351: #define VLine(hDC, hPen, x, y1, y2)          \
                    352:    Line (hDC, hPen, x, y1, x, y2) ;
                    353: 
                    354: 
                    355: int DialogHeight (HDLG hDlg, 
                    356:                   WORD wControlID) ;
                    357: 
                    358: 
                    359: 
                    360: void DialogSetFloat (HDLG hDlg,
                    361:                      WORD wControlID,
                    362:                      FLOAT eValue) ;
                    363: 
                    364: void DialogSetInterval (HDLG hDlg,
                    365:                         WORD wControlID,
                    366:                         int  IntervalMSec ) ;
                    367: 
                    368: int MessageBoxResource (HWND hWndParent,
                    369:                         WORD wTextID,
                    370:                         WORD wTitleID,
                    371:                         UINT uiStyle) ;
                    372: 
                    373: 
                    374: 
                    375: BOOL DlgFocus (HDLG hDlg, WORD wControlID) ;
                    376: 
                    377: 
                    378: BOOL DeviceNumColors (HDC hDC) ;
                    379: 
                    380: 
                    381: 
                    382: void WindowPlacementToString (PWINDOWPLACEMENT pWP, 
                    383:                               LPTSTR lpszText) ;
                    384: 
                    385: void StringToWindowPlacement (LPTSTR lpszText,
                    386:                               PWINDOWPLACEMENT pWP) ;
                    387: 
                    388: DWORD MenuIDToHelpID (DWORD MenuID) ;
                    389: 
                    390: 
                    391: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.