mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 03:15:30 +00:00
Create beziercurve.c
This commit is contained in:
parent
1796c36486
commit
17026b8e0e
58
graphics/beziercurve.c
Normal file
58
graphics/beziercurve.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include <windows.h>
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
PWSTR lpCmdLine, int nCmdShow) {
|
||||
|
||||
MSG msg;
|
||||
WNDCLASSW wc = {0};
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpszClassName = L"BezierCurve";
|
||||
wc.hInstance = hInstance;
|
||||
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
|
||||
RegisterClassW(&wc);
|
||||
CreateWindowW(wc.lpszClassName, L"Beziér curve",
|
||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
100, 100, 500, 200, NULL, NULL, hInstance, NULL);
|
||||
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam) {
|
||||
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
POINT points[4] = { 20, 40, 320, 200, 330, 110, 450, 40 };
|
||||
|
||||
switch(msg) {
|
||||
|
||||
case WM_PAINT:
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
PolyBezier(hdc, points, 4);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProcW(hwnd, msg, wParam, lParam);
|
||||
}
|
Loading…
Reference in New Issue
Block a user