ReactOS  0.4.15-dev-1377-ga59cecd
shaptest.c File Reference
#include <windows.h>
#include <stdio.h>
#include <assert.h>
Include dependency graph for shaptest.c:

Go to the source code of this file.

Macros

#define ASSERT   assert
 
#define nelem(x)   (sizeof (x) / sizeof *(x))
 

Functions

LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
void PolygonTest (HDC hdc)
 
void shaptest (HDC hdc)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Variables

HFONT tf
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT   assert

Definition at line 16 of file shaptest.c.

◆ nelem

#define nelem (   x)    (sizeof (x) / sizeof *(x))

Definition at line 19 of file shaptest.c.

Function Documentation

◆ MainWndProc()

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

Definition at line 229 of file shaptest.c.

230 {
231  PAINTSTRUCT ps;
232  HDC hDC;
233 
234  switch(msg)
235  {
236 
237  case WM_PAINT:
238  hDC = BeginPaint(hWnd, &ps);
239  shaptest( hDC );
240  EndPaint(hWnd, &ps);
241  break;
242 
243  case WM_DESTROY:
244  PostQuitMessage(0);
245  break;
246 
247  default:
248  return DefWindowProc(hWnd, msg, wParam, lParam);
249  }
250  return 0;
251 }
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WPARAM wParam
Definition: combotst.c:138
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_PAINT
Definition: winuser.h:1602
static HDC hDC
Definition: 3dtext.c:33
void shaptest(HDC hdc)
Definition: shaptest.c:160
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by WinMain().

◆ PolygonTest()

void PolygonTest ( HDC  hdc)

Definition at line 24 of file shaptest.c.

25 {
26  HPEN Pen, OldPen;
27  HBRUSH RedBrush, OldBrush;
28  DWORD Mode;
29  POINT PointsAlternate[] =
30  {
31  { 20, 80 },
32  { 60, 20 },
33  { 90, 80 },
34  { 20, 40 },
35  { 100, 40 }
36  };
37  POINT PointsWinding[] =
38  {
39  { 130, 80 },
40  { 170, 20 },
41  { 200, 80 },
42  { 130, 40 },
43  { 210, 40 }
44  };
45  POINT Tri1[] =
46  {
47  { 3, 3 },
48  { 5, 3 },
49  { 3, 5 }
50  };
51  POINT Tri2[] =
52  {
53  { 7, 3 },
54  { 7, 7 },
55  { 3, 7 },
56  };
57  POINT Square1[] =
58  {
59  { 1, 15 },
60  { 3, 15 },
61  { 3, 17 },
62  { 1, 17 }
63  };
64  POINT Square2[] =
65  {
66  { 5, 15 },
67  { 7, 15 },
68  { 7, 17 },
69  { 5, 17 }
70  };
71  POINT Square3[] =
72  {
73  { 1, 23 },
74  { 3, 23 },
75  { 3, 25 },
76  { 1, 25 }
77  };
78  POINT Square4[] =
79  {
80  { 5, 23 },
81  { 7, 23 },
82  { 7, 25 },
83  { 5, 25 }
84  };
85  POINT Square5[] =
86  {
87  { 1, 31 },
88  { 3, 31 },
89  { 3, 33 },
90  { 1, 33 }
91  };
92  POINT Square6[] =
93  {
94  { 5, 31 },
95  { 7, 31 },
96  { 7, 33 },
97  { 5, 33 }
98  };
99 
100  //create a pen to draw the shape
101  Pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
102  ASSERT(Pen);
103  RedBrush = CreateSolidBrush(RGB(0xff, 0, 0));
104  ASSERT(RedBrush);
105 
106  OldPen = (HPEN)SelectObject(hdc, Pen);
107  OldBrush = (HBRUSH)SelectObject(hdc, RedBrush);
108 
110 
111  RoundRect ( hdc, 32, 8, 48, 24, 8, 8 );
112 
114  Polygon(hdc,PointsAlternate,nelem(PointsAlternate));
115 
117  Polygon(hdc,PointsWinding,nelem(PointsWinding));
118 
119  Rectangle ( hdc, 1, 1, 10, 10 );
120  Polygon(hdc,Tri1,nelem(Tri1));
121  Polygon(hdc,Tri2,nelem(Tri2));
122 
123  Rectangle ( hdc, 1, 11, 4, 14 );
124  Rectangle ( hdc, 5, 11, 8, 14 );
125  Rectangle ( hdc, 9, 11, 12, 14 );
126  Rectangle ( hdc, 13, 11, 16, 14 );
127  Polygon(hdc,Square1,nelem(Square1));
128  Polygon(hdc,Square2,nelem(Square2));
129  Rectangle ( hdc, 1, 19, 4, 22 );
130  Rectangle ( hdc, 5, 19, 8, 22 );
131  Rectangle ( hdc, 9, 19, 12, 22 );
132  Rectangle ( hdc, 13, 19, 16, 22 );
133  Polygon(hdc,Square3,nelem(Square3));
134  Polygon(hdc,Square4,nelem(Square4));
135  Rectangle ( hdc, 1, 27, 4, 30 );
136  Rectangle ( hdc, 5, 27, 8, 30 );
137  Rectangle ( hdc, 9, 27, 12, 30 );
138  Rectangle ( hdc, 13, 27, 16, 30 );
139 
140  // switch to null pen to make surey they display correctly
141  DeleteObject ( SelectObject(hdc, OldPen) );
142  Pen = CreatePen ( PS_NULL, 0, 0 );
143  ASSERT(Pen);
144  OldPen = (HPEN)SelectObject(hdc, Pen);
145 
146  Polygon(hdc,Square5,nelem(Square5));
147  Polygon(hdc,Square6,nelem(Square6));
148  Rectangle ( hdc, 1, 35, 4, 38 );
149  Rectangle ( hdc, 5, 35, 8, 38 );
150  Rectangle ( hdc, 9, 35, 12, 38 );
151  Rectangle ( hdc, 13, 35, 16, 38 );
152 
153  //cleanup
155  DeleteObject ( SelectObject(hdc, OldPen) );
156  DeleteObject ( SelectObject(hdc, OldBrush) );
157 }
#define WINDING
Definition: constants.h:279
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
_In_ ULONG Mode
Definition: hubbusif.h:303
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define RGB(r, g, b)
Definition: precomp.h:62
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PS_SOLID
Definition: wingdi.h:585
#define nelem(x)
Definition: shaptest.c:19
#define ALTERNATE
Definition: constants.h:278
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetPolyFillMode(_In_ HDC, _In_ int)
Definition: dc.c:1145
unsigned long DWORD
Definition: ntddk_ex.h:95
int WINAPI GetPolyFillMode(_In_ HDC)
#define ASSERT
Definition: shaptest.c:16
HDC hdc
Definition: main.c:9
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define PS_NULL
Definition: wingdi.h:590
Definition: gdipluspen.h:22

Referenced by shaptest().

◆ shaptest()

void shaptest ( HDC  hdc)

Definition at line 160 of file shaptest.c.

161 {
162  //Test the Polygon routine.
163  PolygonTest(hdc);
164 }
HDC hdc
Definition: main.c:9
void PolygonTest(HDC hdc)
Definition: shaptest.c:24

Referenced by MainWndProc().

◆ WinMain()

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

Definition at line 168 of file shaptest.c.

172 {
173  WNDCLASS wc;
174  MSG msg;
175  HWND hWnd;
176 
177  wc.lpszClassName = "ShapTestClass";
179  wc.style = CS_VREDRAW | CS_HREDRAW;
180  wc.hInstance = hInstance;
184  wc.lpszMenuName = NULL;
185  wc.cbClsExtra = 0;
186  wc.cbWndExtra = 0;
187  if (RegisterClass(&wc) == 0)
188  {
189  fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
190  (unsigned int)GetLastError());
191  return(1);
192  }
193 
194  hWnd = CreateWindow("ShapTestClass",
195  "Shaptest",
197  0,
198  0,
201  NULL,
202  NULL,
203  hInstance,
204  NULL);
205  if (hWnd == NULL)
206  {
207  fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
208  (unsigned int)GetLastError());
209  return(1);
210  }
211 
215 
216  ShowWindow(hWnd, nCmdShow);
217 
218  while(GetMessage(&msg, NULL, 0, 0))
219  {
222  }
223 
224  DeleteObject(tf);
225 
226  return msg.wParam;
227 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
static HICON
Definition: imagelist.c:84
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define DEFAULT_QUALITY
Definition: wingdi.h:435
#define CreateWindow
Definition: winuser.h:5729
#define FF_DONTCARE
Definition: wingdi.h:447
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
int cbClsExtra
Definition: winuser.h:3140
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3146
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3145
HICON HCURSOR
Definition: windef.h:299
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int cbWndExtra
Definition: winuser.h:3141
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define FIXED_PITCH
Definition: wingdi.h:443
#define TA_BASELINE
Definition: wingdi.h:927
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
HCURSOR hCursor
Definition: winuser.h:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
#define GRAY_BRUSH
Definition: wingdi.h:897
#define CS_VREDRAW
Definition: winuser.h:653
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
#define WS_HSCROLL
Definition: pedump.c:628
LPCSTR lpszClassName
Definition: winuser.h:3147
#define LoadCursor
Definition: winuser.h:5787
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
UINT style
Definition: winuser.h:3138
HINSTANCE hInstance
Definition: winuser.h:3142
#define NULL
Definition: types.h:112
#define WS_VSCROLL
Definition: pedump.c:627
#define GetMessage
Definition: winuser.h:5765
#define FW_NORMAL
Definition: wingdi.h:372
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#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:5811
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: shaptest.c:229
#define LoadIcon
Definition: winuser.h:5788
#define ANSI_CHARSET
Definition: wingdi.h:382
HFONT tf
Definition: shaptest.c:21
HICON hIcon
Definition: winuser.h:3143

Variable Documentation

◆ tf

HFONT tf

Definition at line 21 of file shaptest.c.

Referenced by WinMain().