ReactOS 0.4.15-dev-8116-gf69e256
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;
6HENHMETAFILE EnhMetafile;
9
10int 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";
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,
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;
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:
117 break;
118
119 default:
121 }
122 return 0;
123}
static HDC hDC
Definition: 3dtext.c:33
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define CALLBACK
Definition: compat.h:35
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: enhmetafile.c:11
HENHMETAFILE EnhMetafile
Definition: enhmetafile.c:6
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: enhmetafile.c:89
SIZE EnhMetafileSize
Definition: enhmetafile.c:7
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define DefWindowProc
Definition: ros2win.h:31
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
RECTL rclBounds
Definition: wingdi.h:2322
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
#define GetEnhMetaFile
Definition: wingdi.h:4461
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)
#define WM_PAINT
Definition: winuser.h:1620
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define UnregisterClass
Definition: winuser.h:5861
#define IDI_APPLICATION
Definition: winuser.h:704
#define CreateWindow
Definition: winuser.h:5754
#define GetMessage
Definition: winuser.h:5790
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
#define SM_CXSIZEFRAME
Definition: winuser.h:993
#define RegisterClass
Definition: winuser.h:5836
#define WM_DESTROY
Definition: winuser.h:1609
#define DispatchMessage
Definition: winuser.h:5765
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define SM_CYCAPTION
Definition: winuser.h:963
#define SM_CYSIZEFRAME
Definition: winuser.h:995
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BTNFACE
Definition: winuser.h:928
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193