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

  1. /*
  2.  *
  3.  *  GetMapMode
  4.  *  
  5.  *  This program demonstrates the use of the function GetMapMode.
  6.  *  This function retrieves the cuurent mapping mode.
  7.  *
  8.  */
  9.  
  10. #include <windows.h>
  11.  
  12. static HANDLE hWnd;
  13.  
  14. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  15. HANDLE hInstance, hPrevInstance;
  16. LPSTR  lpszCmdLine;
  17. int    cmdShow;
  18. {
  19.   HDC hDC;
  20.   static char szFileName[] = "getmapm";
  21.   static char szFuncName[] = "GetMapMode";
  22.   short nMapMode;
  23.   
  24.   if ( !hPrevInstance )
  25.      {
  26.      WNDCLASS rClass;
  27.  
  28.      rClass.lpszClassName = ( LPSTR ) szFileName;
  29.      rClass.hInstance     = hInstance;
  30.      rClass.lpfnWndProc   = DefWindowProc;
  31.      rClass.hCursor       = LoadCursor ( NULL , IDC_ARROW );
  32.      rClass.hIcon         = LoadIcon ( hInstance, IDI_APPLICATION );
  33.      rClass.lpszMenuName  = ( LPSTR ) NULL;
  34.      rClass.hbrBackground = GetStockObject ( WHITE_BRUSH );
  35.      rClass.style         = CS_HREDRAW | CS_VREDRAW;
  36.      rClass.cbClsExtra    = 0;
  37.      rClass.cbWndExtra    = 0;
  38.    
  39.      RegisterClass ( ( LPWNDCLASS ) &rClass );
  40.      }
  41.  
  42.   hWnd = CreateWindow ( ( LPSTR ) szFileName, ( LPSTR ) szFuncName,
  43.                       WS_OVERLAPPEDWINDOW,
  44.                       CW_USEDEFAULT, CW_USEDEFAULT,
  45.                       CW_USEDEFAULT, CW_USEDEFAULT,
  46.                       ( HWND ) NULL, ( HMENU ) NULL,
  47.                       ( HANDLE ) hInstance, ( LPSTR ) NULL );
  48.  
  49.   ShowWindow ( hWnd , cmdShow );
  50.   hDC = GetDC ( hWnd );
  51.   SetMapMode ( hDC, MM_TEXT);
  52.  
  53.   MessageBox (NULL, (LPSTR)"Getting mapping mode", (LPSTR)szFuncName, MB_OK);
  54.  
  55.   nMapMode = GetMapMode ( hDC );
  56.  
  57.   if ( nMapMode == MM_ANISOTROPIC )
  58.      MessageBox (NULL, (LPSTR)"Mapping mode is anisotropic" ,
  59.         (LPSTR)szFuncName, MB_OK);
  60.   else
  61.      if ( nMapMode == MM_HIENGLISH )
  62.         MessageBox (NULL, (LPSTR)"Mapping mode is high english" ,
  63.            (LPSTR)szFuncName, MB_OK);
  64.      else
  65.         if ( nMapMode == MM_HIMETRIC )
  66.            MessageBox (NULL, (LPSTR)"Mapping mode is high metric" ,
  67.               (LPSTR)szFuncName, MB_OK);
  68.         else
  69.            if ( nMapMode == MM_ISOTROPIC )
  70.               MessageBox (NULL, (LPSTR)"Mapping mode is isotropic" ,
  71.                  (LPSTR)szFuncName, MB_OK);
  72.            else
  73.               if ( nMapMode == MM_LOMETRIC )
  74.                  MessageBox (NULL, (LPSTR)"Mapping mode is low metric" ,
  75.                     (LPSTR)szFuncName, MB_OK);
  76.               else
  77.                  if ( nMapMode == MM_LOENGLISH )
  78.                     MessageBox (NULL, (LPSTR)"Mapping mode is low english" ,
  79.                        (LPSTR)szFuncName, MB_OK);
  80.                  else
  81.                     if ( nMapMode == MM_TEXT )
  82.                        MessageBox (NULL, (LPSTR)"Mapping mode is text" ,
  83.                           (LPSTR)szFuncName, MB_OK);
  84.                     else
  85.                        if ( nMapMode == MM_TWIPS )
  86.                           MessageBox (NULL, (LPSTR)"Mapping mode is twips" ,
  87.                              (LPSTR)szFuncName, MB_OK);
  88.                        else
  89.                           MessageBox (NULL, (LPSTR)"Error no mapping mode" ,
  90.                              (LPSTR)szFuncName, MB_OK|MB_ICONEXCLAMATION);
  91.  
  92.   ReleaseDC ( hWnd, hDC );
  93.  
  94.   return 0;
  95. }
  96.