2 * COPYRIGHT: See COPYING in the top level directory
3 * AUTHOR: See gditest-- (initial changes by Mark Tempel)
6 * This is a windowed application that should draw two polygons. One
7 * is drawn with ALTERNATE fill, the other is drawn with WINDING fill.
8 * This is used to test out the Polygon() implementation.
16 LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
18 void __stdcall PolygonTest(HDC Desktop)
24 POINT lpPointsAlternate[5];
25 POINT lpPointsWinding[5];
28 //create a pen to draw the shape
29 BluePen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0xff));
30 RedBrush = CreateSolidBrush(RGB(0xff, 0, 0));
32 //initialize a set of points for alternate.
33 lpPointsAlternate[0].x = 20;
34 lpPointsAlternate[0].y = 80; //{20,80};
35 lpPointsAlternate[1].x = 60;
36 lpPointsAlternate[1].y = 20; //{60,20};
37 lpPointsAlternate[2].x = 90;
38 lpPointsAlternate[2].y = 80; //{90,80};
39 lpPointsAlternate[3].x = 20;
40 lpPointsAlternate[3].y = 40; //{20,40};
41 lpPointsAlternate[4].x = 100;
42 lpPointsAlternate[4].y = 40; //{100,40};
44 //initialize a set of points for winding.
45 lpPointsWinding[0].x = 130;
46 lpPointsWinding[0].y = 80; //{130,80};
47 lpPointsWinding[1].x = 170;
48 lpPointsWinding[1].y = 20; //{170,20};
49 lpPointsWinding[2].x = 200;
50 lpPointsWinding[2].y = 80; //{200,80};
51 lpPointsWinding[3].x = 130;
52 lpPointsWinding[3].y = 40; //{130,40};
53 lpPointsWinding[4].x = 210;
54 lpPointsWinding[4].y = 40; //{210,40};
56 OldPen = (HPEN)SelectObject(Desktop, BluePen);
57 OldBrush = (HBRUSH)SelectObject(Desktop, RedBrush);
59 Mode = GetPolyFillMode(Desktop);
61 SetPolyFillMode(Desktop, ALTERNATE);
62 Polygon(Desktop,lpPointsAlternate,5);
64 SetPolyFillMode(Desktop, WINDING);
65 Polygon(Desktop,lpPointsWinding,5);
68 SetPolyFillMode(Desktop, Mode);
69 SelectObject(Desktop, OldPen);
70 SelectObject(Desktop, OldBrush);
71 DeleteObject(BluePen);
72 DeleteObject(RedBrush);
77 void shaptest( HDC DevCtx ){
78 HDC Desktop, MyDC, DC24;
79 HPEN RedPen, GreenPen, BluePen, WhitePen;
80 HBITMAP MyBitmap, DIB24;
82 BITMAPINFOHEADER BitInf;
84 HRGN hRgn1, hRgn2, hRgn3;
85 HBRUSH BlueBrush, DefBrush;
90 BlueBrush = CreateSolidBrush( RGB(0, 0, 0xff) );
91 DefBrush = SelectObject( DevCtx, BlueBrush );
93 SelectObject( DevCtx, DefBrush );
94 DeleteObject( BlueBrush );
96 // Create a blue pen and select it into the DC
97 BluePen = CreatePen(PS_SOLID, 8, RGB(0, 0, 0xff));
98 SelectObject(DevCtx, BluePen);
100 //Test the Polygon routine.
106 WinMain(HINSTANCE hInstance,
107 HINSTANCE hPrevInstance,
115 wc.lpszClassName = "ShapTestClass";
116 wc.lpfnWndProc = MainWndProc;
117 wc.style = CS_VREDRAW | CS_HREDRAW;
118 wc.hInstance = hInstance;
119 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
120 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
121 wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
122 wc.lpszMenuName = NULL;
125 if (RegisterClass(&wc) == 0)
127 fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
132 hWnd = CreateWindow("ShapTestClass",
134 WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
145 fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
150 tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
151 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
152 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
154 ShowWindow(hWnd, nCmdShow);
156 while(GetMessage(&msg, NULL, 0, 0))
158 TranslateMessage(&msg);
159 DispatchMessage(&msg);
167 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
172 char spr[100], sir[100];
178 hDC = BeginPaint(hWnd, &ps);
188 return DefWindowProc(hWnd, msg, wParam, lParam);