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

  1. /*
  2.  *  GetDCOrg
  3.  *  
  4.  *  This program demonstrates the use of the function GetDCOrg.
  5.  *  This function obtians the final translation origin for the device
  6.  *  context.  
  7.  *
  8.  *  Microsoft Product Support Services
  9.  *  Windows Version 2.0 function demonstration application
  10.  *
  11.  */
  12.  
  13. #include <windows.h>
  14.  
  15. static HANDLE hWnd;
  16.  
  17. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  18. HANDLE hInstance, hPrevInstance;
  19. LPSTR  lpszCmdLine;
  20. int    cmdShow;
  21. {
  22.   HDC hDC;
  23.   LONG ptOrigin;
  24.   char szbuff[80];
  25.   
  26.   if ( !hPrevInstance )
  27.      {
  28.      WNDCLASS rClass;
  29.  
  30.      rClass.lpszClassName = ( LPSTR ) "getdcorg";
  31.      rClass.hInstance     = hInstance;
  32.      rClass.lpfnWndProc   = DefWindowProc;
  33.      rClass.hCursor       = LoadCursor ( NULL , IDC_ARROW );
  34.      rClass.hIcon         = LoadIcon ( hInstance, IDI_APPLICATION );
  35.      rClass.lpszMenuName  = ( LPSTR ) NULL;
  36.      rClass.hbrBackground = GetStockObject ( WHITE_BRUSH );
  37.      rClass.style         = CS_HREDRAW | CS_VREDRAW;
  38.      rClass.cbClsExtra    = 0;
  39.      rClass.cbWndExtra    = 0;
  40.    
  41.      RegisterClass ( ( LPWNDCLASS ) &rClass );
  42.      }
  43.  
  44.   hWnd = CreateWindow ( ( LPSTR ) "getdcorg", ( LPSTR ) "GetDCOrg",
  45.                       WS_OVERLAPPEDWINDOW,
  46.                       CW_USEDEFAULT, CW_USEDEFAULT,
  47.                       CW_USEDEFAULT, CW_USEDEFAULT,
  48.                       ( HWND ) NULL, ( HMENU ) NULL,
  49.                       ( HANDLE ) hInstance, ( LPSTR ) NULL );
  50.  
  51.   ShowWindow ( hWnd , cmdShow );
  52.   hDC = GetDC ( hWnd );
  53.  
  54.   MessageBox (NULL, (LPSTR)"Getting origin", (LPSTR)"GetDCOrg", MB_OK);
  55.  
  56.   ptOrigin = GetDCOrg ( hDC );
  57.  
  58.   sprintf ( szbuff, "The origin of this window is at (%d,%d)",
  59.      LOWORD(ptOrigin), HIWORD(ptOrigin) );
  60.   MessageBox (NULL, (LPSTR) szbuff, (LPSTR)"GetDCOrg", MB_OK);
  61.  
  62.   ReleaseDC ( hWnd, hDC );
  63.  
  64.   return 0;
  65. }
  66.