home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / device / getdcaps.c next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.9 KB  |  68 lines

  1. /*
  2.  *
  3.  *  GetDeviceCaps
  4.  *  
  5.  *  This program demonstrates the use of the function GetDeviceCaps.
  6.  *  This function retrieves device-specific information about a given 
  7.  *  display device.  The last parameter specifies the type os information
  8.  *  desired.
  9.  *
  10.  *  Windows Version 2.0 function demonstration application
  11.  *
  12.  */
  13.  
  14. #include <windows.h>
  15.  
  16. static HANDLE hWnd;
  17.  
  18. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  19. HANDLE hInstance, hPrevInstance;
  20. LPSTR  lpszCmdLine;
  21. int    cmdShow;
  22. {
  23.   HDC hDC;
  24.   short nValue;
  25.   char szbuff[80];
  26.   
  27.   if ( !hPrevInstance )
  28.      {
  29.      WNDCLASS rClass;
  30.  
  31.      rClass.lpszClassName = ( LPSTR ) "getdcaps";
  32.      rClass.hInstance     = hInstance;
  33.      rClass.lpfnWndProc   = DefWindowProc;
  34.      rClass.hCursor       = LoadCursor ( NULL , IDC_ARROW );
  35.      rClass.hIcon         = LoadIcon ( hInstance, IDI_APPLICATION );
  36.      rClass.lpszMenuName  = ( LPSTR ) NULL;
  37.      rClass.hbrBackground = GetStockObject ( WHITE_BRUSH );
  38.      rClass.style         = CS_HREDRAW | CS_VREDRAW;
  39.      rClass.cbClsExtra    = 0;
  40.      rClass.cbWndExtra    = 0;
  41.    
  42.      RegisterClass ( ( LPWNDCLASS ) &rClass );
  43.      }
  44.  
  45.   hWnd = CreateWindow ( ( LPSTR ) "getdcaps", ( LPSTR ) "GetDeviceCaps",
  46.                       WS_OVERLAPPEDWINDOW,
  47.                       CW_USEDEFAULT, CW_USEDEFAULT,
  48.                       CW_USEDEFAULT, CW_USEDEFAULT,
  49.                       ( HWND ) NULL, ( HMENU ) NULL,
  50.                       ( HANDLE ) hInstance, ( LPSTR ) NULL );
  51.  
  52.   ShowWindow ( hWnd , cmdShow );
  53.   hDC = GetDC ( hWnd );
  54.  
  55.   MessageBox (NULL, (LPSTR)"Getting driver version number", 
  56.              (LPSTR)"GetDeviceCaps", MB_OK);
  57.  
  58.   nValue = GetDeviceCaps ( hDC, DRIVERVERSION );
  59.  
  60.   sprintf ( szbuff, "%s%d\0", "Driver version number is ",
  61.      nValue );
  62.   MessageBox (NULL, (LPSTR) szbuff, (LPSTR)"GetDeviceCaps", MB_OK);
  63.  
  64.   ReleaseDC ( hWnd, hDC );
  65.  
  66.   return 0;
  67. }
  68.