/*_##################################### #######################################
_##
### Programming Windows Programming Design Guide-> Chapter 5 example program 4
_ ## Author: xwlee
_ ## Time: 2007.06.19
### Chang'an University
_ ## Development condition: win2003 SERVER + vc6.0
_##
_ ## Program 5-4 altwind
_ ## Altwind. c file
### Images in the internal area
_ ## The program is only for verification
_##
_##
_ ## Altwind. c -- alternate and winding fill Modes
_ ## (C) Charles Petzold, 1998
_##
_####################################### ###################################*/
# Include <windows. h>
Lresult callback wndproc (hwnd, uint, wparam, lparam );
Int winapi winmain (hinstance, hinstance hprevinstance,
Pstr szcmdline, int icmdshow)
{
Static tchar szappname [] = text ("altwind ");
Hwnd;
MSG;
Wndclass;
Wndclass. Style = cs_hredraw | cs_vredraw;
Wndclass. lpfnwndproc = wndproc;
Wndclass. cbclsextra = 0;
Wndclass. cbwndextra = 0;
Wndclass. hinstance = hinstance;
Wndclass. hicon = loadicon (null, idi_application );
Wndclass. hcursor = loadcursor (null, idc_arrow );
Wndclass. hbrbackground = (hbrush) getstockobject (white_brush );
Wndclass. lpszmenuname = NULL;
Wndclass. lpszclassname = szappname;
If (! Registerclass (& wndclass ))
{
MessageBox (null, text ("program requires Windows NT! "),
Szappname, mb_iconerror );
Return 0;
}
Hwnd = createwindow (szappname, text ("alternate and winding fill Modes "),
Ws_overlappedwindow,
Cw_usedefault, cw_usedefault,
Cw_usedefault, cw_usedefault,
Null, null, hinstance, null );
Showwindow (hwnd, icmdshow );
Updatewindow (hwnd );
While (getmessage (& MSG, null, 0, 0 ))
{
Translatemessage (& MSG );
Dispatchmessage (& MSG );
}
Return msg. wparam;
}
Lresult callback wndproc (hwnd, uint message, wparam, lparam)
{
Static point aptfigure [10] = {10, 70, 50, 70, 50, 10, 90, 10, 90, 50,
30,50, 30,90, 70,90, 70,30, 10,30 };
Static int cxclient, cyclient;
HDC;
Int I;
Paintstruct pS;
Point apt [10];
Switch (Message)
{
Case wm_size:
Cxclient = loword (lparam );
Cyclient = hiword (lparam );
Return 0;
Case wm_paint:
HDC = beginpaint (hwnd, & PS );
SelectObject (HDC, getstockobject (gray_brush ));
For (I = 0; I <10; I ++)
{
APT [I]. x = cxclient * aptfigure [I]. X/200;
APT [I]. Y = cyclient * aptfigure [I]. Y/100;
}
Setpolyfillmode (HDC, alternate );
Polygon (HDC, APT, 10 );
For (I = 0; I <10; I ++)
{
APT [I]. x + = cxclient/2;
}
Setpolyfillmode (HDC, winding );
Polygon (HDC, APT, 10 );
Endpaint (hwnd, & PS );
Return 0;
Case wm_destroy:
Postquitmessage (0 );
Return 0;
}
Return defwindowproc (hwnd, message, wparam, lparam );
}