ReactOS  0.4.15-dev-3723-g8d70159
enhmetafile.c File Reference
#include <windows.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for enhmetafile.c:

Go to the source code of this file.

Functions

LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Variables

HENHMETAFILE EnhMetafile
 
SIZE EnhMetafileSize
 

Function Documentation

◆ MainWndProc()

LRESULT WINAPI MainWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 89 of file enhmetafile.c.

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 }
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HENHMETAFILE EnhMetafile
Definition: enhmetafile.c:6
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
WPARAM wParam
Definition: combotst.c:138
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define TRANSPARENT
Definition: wingdi.h:950
LONG cx
Definition: windef.h:334
SIZE EnhMetafileSize
Definition: enhmetafile.c:7
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1596
#define WM_PAINT
Definition: winuser.h:1607
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define msg(x)
Definition: auth_time.c:54
LONG bottom
Definition: windef.h:309
LONG cy
Definition: windef.h:335
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI PlayEnhMetaFile(HDC hdc, HENHMETAFILE hmf, const RECT *lpRect)
Definition: enhmetafile.c:2603

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 11 of file enhmetafile.c.

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 }
#define DispatchMessage
Definition: winuser.h:5745
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5734
HENHMETAFILE EnhMetafile
Definition: enhmetafile.c:6
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
long bottom
Definition: polytest.cpp:53
int cbClsExtra
Definition: winuser.h:3145
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3151
UINT WINAPI GetEnhMetaFileHeader(HENHMETAFILE hmf, UINT bufsize, LPENHMETAHEADER buf)
Definition: enhmetafile.c:417
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3150
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
long right
Definition: polytest.cpp:53
int cbWndExtra
Definition: winuser.h:3146
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,...)
long top
Definition: polytest.cpp:53
HCURSOR hCursor
Definition: winuser.h:3149
#define SM_CYSIZEFRAME
Definition: winuser.h:989
LONG cx
Definition: windef.h:334
long left
Definition: polytest.cpp:53
SIZE EnhMetafileSize
Definition: enhmetafile.c:7
#define SM_CXSIZEFRAME
Definition: winuser.h:987
#define CS_VREDRAW
Definition: winuser.h:653
#define SM_CYCAPTION
Definition: winuser.h:957
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BTNFACE
Definition: winuser.h:922
LPCSTR lpszClassName
Definition: winuser.h:3152
#define LoadCursor
Definition: winuser.h:5792
UINT style
Definition: winuser.h:3143
RECTL rclBounds
Definition: wingdi.h:2322
HINSTANCE hInstance
Definition: winuser.h:3147
#define GetEnhMetaFile
Definition: wingdi.h:4461
#define NULL
Definition: types.h:112
#define GetMessage
Definition: winuser.h:5770
WNDPROC lpfnWndProc
Definition: winuser.h:3144
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
FILE * stderr
#define RegisterClass
Definition: winuser.h:5816
#define LoadIcon
Definition: winuser.h:5793
#define UnregisterClass
Definition: winuser.h:5841
LONG cy
Definition: windef.h:335
BOOL WINAPI DeleteEnhMetaFile(HENHMETAFILE hmf)
Definition: enhmetafile.c:2617
HICON hIcon
Definition: winuser.h:3148

Variable Documentation

◆ EnhMetafile

HENHMETAFILE EnhMetafile

Definition at line 6 of file enhmetafile.c.

Referenced by MainWndProc(), and WinMain().

◆ EnhMetafileSize

SIZE EnhMetafileSize

Definition at line 7 of file enhmetafile.c.

Referenced by MainWndProc(), and WinMain().