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

  1. /*
  2.  *
  3.  *  GetMetaFile
  4.  *  
  5.  *  This program demonstrates the use of the function GetMetaFile.
  6.  *  This function creates a handle for the metafile named by the parameter.
  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.   static char szFileName[] = "gmetafil";
  20.   static char szFuncName[] = "GetMetaFile";
  21.   HDC hDC;
  22.   HANDLE hMF;
  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 ) "GetMenuFunc";
  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, ( HWND ) NULL,
  47.                       ( HANDLE ) hInstance, ( LPSTR ) NULL );
  48.  
  49.   ShowWindow ( hWnd , cmdShow );
  50.   hDC = GetDC ( hWnd );
  51.   
  52.   MessageBox (NULL, (LPSTR)"Getting handle to metafile", (LPSTR) szFuncName,
  53.      MB_OK);
  54.  
  55.   hMF = GetMetaFile ( (LPSTR) "GMETAFIL.MET" );
  56.  
  57.   if ( hMF != NULL )
  58.      MessageBox (NULL, (LPSTR)"Metafile handle gotten", (LPSTR) szFuncName,
  59.         MB_OK);
  60.   else
  61.      MessageBox (NULL, (LPSTR)"Metafile handle not gotten", (LPSTR) szFuncName,
  62.         MB_OK);
  63.  
  64.   PlayMetaFile ( hDC, hMF );
  65.   MessageBox (NULL, (LPSTR)"This is the metafile", (LPSTR) szFuncName, MB_OK);
  66.   ReleaseDC ( hWnd, hDC);
  67.   return 0;
  68. }
  69.