/*_##################################### #######################################
_##
### Programming Windows Programming Design Guide-> Chapter 5 example Program 3
_ ## Author: xwlee
_ ## Time: 2007.06.18
### Chang'an University
_ ## Development condition: win2003 SERVER + vc6.0
_##
# Program 5-3
### Besuppliers. c file
### Draw the besell Curve
_ ## The program is only for verification
_##
_##
### Besuppliers. c -- besuppliers splines demo
_ ## (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 ("bezr ");
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 ("bezr splines "),
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;
}
Void drawbezr (HDC, point apt [])
{
Polybezr (HDC, APT, 4 );
Movetoex (HDC, APT [0]. X, APT [0]. Y, null );
Lineto (HDC, APT [1]. X, APT [1]. y );
Movetoex (HDC, APT [2]. X, APT [2]. Y, null );
Lineto (HDC, APT [3]. X, APT [3]. y );
}
Lresult callback wndproc (hwnd, uint message, wparam, lparam)
{
Static point apt [4];
HDC;
Int cxclient, cyclient;
Paintstruct pS;
Switch (Message)
{
Case wm_size:
Cxclient = loword (lparam );
Cyclient = hiword (lparam );
APT [0]. x = cxclient/4;
APT [0]. Y = cyclient/2;
APT [1]. x = cxclient/2;
APT [1]. Y = cyclient/4;
APT [2]. x = cxclient/2;
APT [2]. Y = 3 * cyclient/4;
APT [3]. x = 3 * cxclient/4;
APT [3]. Y = cyclient/2;
Return 0;
Case wm_lbuttondown:
Case wm_rbuttondown:
Case wm_mousemove:
If (wparam & mk_lbutton | wparam & mk_rbutton)
{
HDC = getdc (hwnd );
SelectObject (HDC, getstockobject (white_pen ));
Drawbezr (HDC, APT );
If (wparam & mk_lbutton)
{
APT [1]. x = loword (lparam );
APT [1]. Y = hiword (lparam );
}
If (wparam & mk_rbutton)
{
APT [2]. x = loword (lparam );
APT [2]. Y = hiword (lparam );
}
SelectObject (HDC, getstockobject (black_pen ));
Drawbezr (HDC, APT );
Releasedc (hwnd, HDC );
}
Return 0;
Case wm_paint:
Invalidaterect (hwnd, null, true );
HDC = beginpaint (hwnd, & PS );
Drawbezr (HDC, APT );
Endpaint (hwnd, & PS );
Return 0;
Case wm_destroy:
Postquitmessage (0 );
Return 0;
}
Return defwindowproc (hwnd, message, wparam, lparam );
}