Professional Documents
Culture Documents
#include <windows.h>
#include <math.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass);
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
TranslateMessage(&msg);
DispatchMessage(&msg);
return msg.wParam;
PolyBezier(hdc, a, 4);
double t;
double x, y;
if (t == 0)
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
HDC hdc;
PAINTSTRUCT ps;
switch (iMsg)
case WM_SIZE:
cx = LOWORD(lParam);
cy = HIWORD(lParam);
a[0].x = cx / 4; b[0].x = cx / 4;
a[3].x = 3 * cx / 4; b[3].x = 3 * cx / 4;
return 0;
case WM_MOUSEMOVE:
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(WHITE_PEN));
DrawBezier1(hdc, b);
SelectObject(hdc, GetStockObject(WHITE_PEN));
DrawBezier(hdc, a);
a[1].x = LOWORD(lParam);
a[1].y = HIWORD(lParam);
a[2].x = LOWORD(lParam);
a[2].y = HIWORD(lParam);
SelectObject(hdc, GetStockObject(BLACK_PEN));
DrawBezier1(hdc, b);
DrawBezier(hdc, a);
ReleaseDC(hwnd, hdc);
return 0;
case WM_PAINT:
DrawBezier(hdc, a);
DrawBezier1(hdc, b);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;