UTILS.C
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:42k
源码类别:
Windows编程
开发平台:
Visual C++
- /*
- ==============================================================================
- Application:
- Microsoft Windows NT (TM) Performance Monitor
- File:
- utils.c -- miscellaneous utility routines.
- This file contains miscellaneous utiltity routines, mostly
- low-level windows helpers. These routines are not specific
- to the perfmon utillity.
- Copyright 1992-1997, Microsoft Corporation. All Rights Reserved.
- Microsoft Confidential.
- ==============================================================================
- */
- //==========================================================================//
- // Includes //
- //==========================================================================//
- #include <stdarg.h> // For ANSI variable args. Dont use UNIX <varargs.h>
- #include <stdlib.h> // For itoa
- #include <stdio.h> // for vsprintf.
- #include <string.h> // for strtok
- #include <wchar.h> // for swscanf
- #include "perfmon.h"
- #include "pmemory.h" // for MemoryXXX (mallloc-type) routines
- #include "utils.h"
- #include "pmhelpid.h" // IDs for WinHelp
- #include "perfmops.h" // for ConvertDecimalPoint() & ReconvertDecimalPoint()
- #include "sizes.h"
- //==========================================================================//
- // Constants //
- //==========================================================================//
- #define DOS_FILES 0x0000 // Ordinary files
- #define DOS_READONLY 0x0001 // Read-only files
- #define DOS_HIDDEN 0x0002 // Hidden files
- #define DOS_SYSTEM 0x0004 // System files
- #define DOS_SUBDIRECTORIES 0x0010 // Subdirectories
- #define DOS_ARCHIVES 0x0020 // Archives
- #define DOS_LIB_DIR 0x2000 // LB_DIR flag
- #define DOS_DRIVES 0x4000 // Drives
- #define DOS_EXCLUSIVE 0x8000 // Exclusive bit
- #define DOS_DRIVES_DIRECTORIES 0xC010 // Find drives and directories only
- #define WILD_ONE '?'
- #define WILD_ANY '*'
- //==========================================================================//
- // Local Functions //
- //==========================================================================//
- void ClientRectToScreen (HWND hWnd,
- LPRECT lpRect)
- /*
- Effect: Remaps lpRect from client coordinates to screen
- coordinates. Analogous to ClientToScreen for rectangles.
- Note: To convert a rectangle from the client coordinates of
- Wnd1 to the client coordinates of Wnd2, call:
- ClientRectToScreen (hWnd1, &rect) ;
- ScreenRectToClient (hWnd2, &rect) ;
- See Also: ClientToScreen (windows), ScreenRectToClient.
- Internals: Since a rectangle is really only two points, let
- windows do the work with ClientToScreen.
- */
- { /* ClientRectToScreen */
- POINT pt1, pt2 ;
- pt1.x = lpRect->left ;
- pt1.y = lpRect->top ;
- pt2.x = lpRect->right ;
- pt2.y = lpRect->bottom ;
- ClientToScreen (hWnd, &pt1) ;
- ClientToScreen (hWnd, &pt2) ;
- lpRect->left = pt1.x ;
- lpRect->top = pt1.y ;
- lpRect->right = pt2.x ;
- lpRect->bottom = pt2.y ;
- } // ClientRectToScreen
- void ScreenRectToClient (HWND hWnd, LPRECT lpRect)
- /*
- Effect: Remaps lpRect from screen coordinates to client
- coordinates. Analogous to ScreenToClient for rectangles.
- Note: To convert a rectangle from the client coordinates of
- Wnd1 to the client coordinates of Wnd2, call:
- ClientRectToScreen (hWnd1, &rect) ;
- ScreenRectToClient (hWnd2, &rect) ;
- See Also: ScreenToClient (windows), ClientRectToScreen.
- Internals: Since a rectangle is really only two points, let
- windows do the work with ScreenToClient.
- */
- { // ScreenRectToClient
- POINT pt1, pt2 ;
- pt1.x = lpRect->left ;
- pt1.y = lpRect->top ;
- pt2.x = lpRect->right ;
- pt2.y = lpRect->bottom ;
- ScreenToClient (hWnd, &pt1) ;
- ScreenToClient (hWnd, &pt2) ;
- lpRect->left = pt1.x ;
- lpRect->top = pt1.y ;
- lpRect->right = pt2.x ;
- lpRect->bottom = pt2.y ;
- } // ScreenRectToClient
- //==========================================================================//
- // Exported Functions //
- //==========================================================================//
- void Line (HDC hDC,
- HPEN hPen,
- int x1, int y1,
- int x2, int y2)
- { // Line
- HPEN hPenPrevious ;
- if (hPen)
- hPenPrevious = SelectPen (hDC, hPen) ;
- MoveToEx (hDC, x1, y1, NULL) ;
- LineTo (hDC, x2, y2) ;
- if (hPen)
- SelectObject (hDC, hPenPrevious) ;
- } // Line
- #if 0
- void HLine (HDC hDC,
- HPEN hPen,
- int x1,
- int x2,
- int y)
- { // HLine
- Line (hDC, hPen, x1, y, x2, y) ;
- }
- void VLine (HDC hDC,
- HPEN hPen,
- int x,
- int y1,
- int y2)
- { // VLine
- Line (hDC, hPen, x, y1, x, y2) ;
- } // VLine
- #endif
- #ifdef KEEP_UTIL
- void Fill (HDC hDC,
- DWORD rgbColor,
- LPRECT lpRect)
- { // Fill
- HBRUSH hBrush ;
- hBrush = CreateSolidBrush (rgbColor) ;
- FillRect (hDC, lpRect, hBrush) ;
- DeleteBrush (hBrush) ;
- } // Fill
- void ThreeDConvex (HDC hDC,
- int x1, int y1,
- int x2, int y2)
- { // ThreeDConvex
- HBRUSH hBrushPrevious ;
- POINT aPoints [8] ;
- DWORD aCounts [2] ;
- HPEN hPenPrevious ;
- //谀哪哪哪哪哪哪哪哪哪哪哪哪哪目
- //