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

  1. /*
  2.  *  SetMapperFlags
  3.  *  smapflag.c
  4.  *  
  5.  *  This program demonstrates the use of the function SetMapperFlags.
  6.  *  This function alters the algorithm that the font mapper uses when it
  7.  *  maps logical fonts to physical fonts.  When the first bit in the first
  8.  *  parameter is set to one, the mapper will only select fonts whose aspect
  9.  *  ratios match those of the specified device.  If no fonts exit with a
  10.  *  matching aspect ratio, GDI chooses an aspect ratio and select fonts
  11.  *  with aspect ratios that match the one by GDI.
  12.  *
  13.  */
  14.  
  15. #include "windows.h"
  16.  
  17. static HANDLE hWnd;
  18.  
  19. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  20. HANDLE hInstance, hPrevInstance;
  21. LPSTR  lpszCmdLine;
  22. int    cmdShow;
  23. {
  24.   HDC hDC;
  25.   PAINTSTRUCT ps;
  26.   DWORD ptAspectRatio;
  27.   DWORD ptMapperFlags;
  28.   char szbuff[160];
  29.   
  30.   if ( !hPrevInstance )
  31.      {
  32.      WNDCLASS rClass;
  33.  
  34.      rClass.lpszClassName = ( LPSTR ) "smapflag";
  35.      rClass.hInstance     = hInstance;
  36.      rClass.lpfnWndProc   = DefWindowProc;
  37.      rClass.hCursor       = LoadCursor ( NULL , IDC_ARROW );
  38.      rClass.hIcon         = LoadIcon ( hInstance, IDI_APPLICATION );
  39.      rClass.lpszMenuName  = ( LPSTR ) NULL;
  40.      rClass.hbrBackground = GetStockObject ( WHITE_BRUSH );
  41.      rClass.style         = CS_HREDRAW | CS_VREDRAW;
  42.      rClass.cbClsExtra    = 0;
  43.      rClass.cbWndExtra    = 0;
  44.    
  45.      RegisterClass ( ( LPWNDCLASS ) &rClass );
  46.      }
  47.  
  48.   hWnd = CreateWindow ( ( LPSTR ) "smapflag", ( LPSTR ) "SetMapperFlags",
  49.                       WS_OVERLAPPEDWINDOW,
  50.                       CW_USEDEFAULT, CW_USEDEFAULT,
  51.                       CW_USEDEFAULT, CW_USEDEFAULT,
  52.                       ( HWND ) NULL, ( HMENU ) NULL,
  53.                       ( HANDLE ) hInstance, ( LPSTR ) NULL );
  54.  
  55.   ShowWindow ( hWnd , cmdShow );
  56.   BeginPaint ( hWnd, ( LPPAINTSTRUCT ) &ps );
  57.   hDC = ps.hdc;
  58.  
  59.   MessageBox (NULL, (LPSTR)"Setting font-mapper flag",
  60.      (LPSTR)"SetMapperFlags", MB_OK);
  61.  
  62.   ptMapperFlags = SetMapperFlags( hDC, (long) 1 );
  63.  
  64.   ptAspectRatio = GetAspectRatioFilter ( hDC );
  65.  
  66.   sprintf ( szbuff, "%s%d%s%d\n%s%d%s%d\0", "Old aspect ratio is: x= ",
  67.            HIWORD(ptMapperFlags), " y= ", LOWORD(ptMapperFlags),
  68.            "New aspect ratio is: x= ", HIWORD(ptAspectRatio), " y= ",
  69.            LOWORD(ptAspectRatio));
  70.  
  71.   MessageBox (NULL, (LPSTR) szbuff, (LPSTR)"SetMapperFlags", MB_OK);
  72.  
  73.   return 0;
  74. }
  75.