/*_##################################### #######################################
_##
### Programming Windows Programming Design Guide-> Chapter 5 example Program 2
_ ## Author: xwlee
_ ## Time: 2007.06.18
### Chang'an University
_ ## Development condition: win2003 SERVER + vc6.0
_##
_ ## Program 5-2 linedemo
_ ## Linedemo. c file
### Draw a rectangle, an elliptic, a rounded rectangle, and two line segments, but not in this order.
_ ## The program indicates that the function defining the closed area actually fills in these areas, because the line behind the elliptical is hidden.
_##
_##
_ ## Linedemo. c -- line-drawing demonstration program
_ ## (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 ("linedemo ");
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 ("line demonstration "),
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 int cxclient, cyclient;
HDC;
Paintstruct pS;
Switch (Message)
{
Case wm_size:
Cxclient = loword (lparam );
Cyclient = hiword (lparam );
Return 0;
Case wm_paint:
HDC = beginpaint (hwnd, & PS );
Rectangle (HDC, cxclient/8, cyclient/8,
7 * cxclient/8, 7 * cyclient/8 );
Movetoex (HDC, 0, 0, null );
Lineto (HDC, cxclient, cyclient );
Movetoex (HDC, 0, cyclient, null );
Lineto (HDC, cxclient, 0 );
Ellipse (HDC, cxclient/8, cyclient/8,
7 * cxclient/8, 7 * cyclient/8); // elliptical
Roundrect (HDC, cxclient/4, cyclient/4,
3 * cxclient/4, 3 * cyclient/4,
Cxclient/6, cyclient/6 );
Endpaint (hwnd, & PS );
Return 0;
Case wm_destroy:
Postquitmessage (0 );
Return 0;
}
Return defwindowproc (hwnd, message, wparam, lparam );
}