ReactOS  0.4.14-dev-342-gdc047f9
enhmetafile.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <string.h>
4 
5 //HFONT tf;
6 HENHMETAFILE EnhMetafile;
9 
10 int WINAPI
12  HINSTANCE hPrevInstance,
13  LPSTR lpszCmdLine,
14  int nCmdShow)
15 {
16  WNDCLASS wc;
17  MSG msg;
18  HWND hWnd;
19  ENHMETAHEADER emh;
20 
21  EnhMetafile = GetEnhMetaFile("test.emf");
22  if(!EnhMetafile)
23  {
24  fprintf(stderr, "GetEnhMetaFile failed (last error 0x%lX)\n",
25  GetLastError());
26  return(1);
27  }
31 
32  wc.lpszClassName = "EnhMetaFileClass";
35  wc.hInstance = hInstance;
38  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
39  wc.lpszMenuName = NULL;
40  wc.cbClsExtra = 0;
41  wc.cbWndExtra = 0;
42  if (RegisterClass(&wc) == 0)
43  {
45  fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
46  GetLastError());
47  return(1);
48  }
49 
50  hWnd = CreateWindow("EnhMetaFileClass",
51  "Enhanced Metafile test",
53  0,
54  0,
57  NULL,
58  NULL,
59  hInstance,
60  NULL);
61  if (hWnd == NULL)
62  {
64  fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
65  GetLastError());
66  return(1);
67  }
68 
69  //tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
70  // ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
71  // DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
72 
73  ShowWindow(hWnd, nCmdShow);
74 
75  while(GetMessage(&msg, NULL, 0, 0))
76  {
79  }
80 
82 
83  //DeleteObject(tf);
84  UnregisterClass("EnhMetaFileClass", hInstance);
85 
86  return msg.wParam;
87 }
88 
90 {
91  switch(msg)
92  {
93 
94  case WM_PAINT:
95  {
96  PAINTSTRUCT ps;
97  RECT rc;
98  HDC hDC;
99  int bk;
100 
101  GetClientRect(hWnd, &rc);
102  hDC = BeginPaint(hWnd, &ps);
103  rc.left = (rc.right / 2) - (EnhMetafileSize.cx / 2);
104  rc.top = (rc.bottom / 2) - (EnhMetafileSize.cy / 2);
105  rc.right = rc.left + EnhMetafileSize.cx;
106  rc.bottom = rc.top + EnhMetafileSize.cy;
107  bk = SetBkMode(hDC, TRANSPARENT);
108  Rectangle(hDC, rc.left - 1, rc.top - 1, rc.right + 1, rc.bottom + 1);
109  SetBkMode(hDC, bk);
111  EndPaint(hWnd, &ps);
112  break;
113  }
114 
115  case WM_DESTROY:
116  PostQuitMessage(0);
117  break;
118 
119  default:
120  return DefWindowProc(hWnd, msg, wParam, lParam);
121  }
122  return 0;
123 }
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5655
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HENHMETAFILE EnhMetafile
Definition: enhmetafile.c:6
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:292
long bottom
Definition: polytest.cpp:53
int cbClsExtra
Definition: winuser.h:3139
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3145
UINT WINAPI GetEnhMetaFileHeader(HENHMETAFILE hmf, UINT bufsize, LPENHMETAHEADER buf)
Definition: enhmetafile.c:388
#define IDI_APPLICATION
Definition: winuser.h:699
UINT_PTR WPARAM
Definition: windef.h:207
HBRUSH hbrBackground
Definition: winuser.h:3144
LONG left
Definition: windef.h:291
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
char * LPSTR
Definition: xmlstorage.h:182
LONG right
Definition: windef.h:293
WPARAM wParam
Definition: combotst.c:138
long right
Definition: polytest.cpp:53
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
int cbWndExtra
Definition: winuser.h:3140
HINSTANCE hInstance
Definition: charmap.c:20
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: enhmetafile.c:89
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
long top
Definition: polytest.cpp:53
HCURSOR hCursor
Definition: winuser.h:3143
#define TRANSPARENT
Definition: wingdi.h:949
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYSIZEFRAME
Definition: winuser.h:985
LONG cx
Definition: windef.h:319
LONG_PTR LPARAM
Definition: windef.h:208
long left
Definition: polytest.cpp:53
SIZE EnhMetafileSize
Definition: enhmetafile.c:7
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define SM_CXSIZEFRAME
Definition: winuser.h:983
#define CS_VREDRAW
Definition: winuser.h:653
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: enhmetafile.c:11
#define SM_CYCAPTION
Definition: winuser.h:953
#define WINAPI
Definition: msvc.h:8
int WINAPI GetSystemMetrics(_In_ int)
#define WM_PAINT
Definition: winuser.h:1602
#define COLOR_BTNFACE
Definition: winuser.h:918
LPCSTR lpszClassName
Definition: winuser.h:3146
#define LoadCursor
Definition: winuser.h:5713
UINT style
Definition: winuser.h:3137
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
RECTL rclBounds
Definition: wingdi.h:2317
HINSTANCE hInstance
Definition: winuser.h:3141
#define GetEnhMetaFile
Definition: wingdi.h:4456
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5691
WNDPROC lpfnWndProc
Definition: winuser.h:3138
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
FILE * stderr
LONG bottom
Definition: windef.h:294
#define RegisterClass
Definition: winuser.h:5737
#define LoadIcon
Definition: winuser.h:5714
LONG_PTR LRESULT
Definition: windef.h:209
#define UnregisterClass
Definition: winuser.h:5762
LONG cy
Definition: windef.h:320
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI DeleteEnhMetaFile(HENHMETAFILE hmf)
Definition: enhmetafile.c:2548
HICON hIcon
Definition: winuser.h:3142
BOOL WINAPI PlayEnhMetaFile(HDC hdc, HENHMETAFILE hmf, const RECT *lpRect)
Definition: enhmetafile.c:2533