mirror of https://github.com/flysand7/ciabatta.git
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
|
|
#include <assert.h>
|
|
#include <windows.h>
|
|
|
|
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE p, LPSTR pCmdLine, int nCmdShow) {
|
|
const char CLASS_NAME[] = "Sample Window Class";
|
|
assert(0);
|
|
WNDCLASS wc = {
|
|
.lpfnWndProc = WindowProc,
|
|
.hInstance = hInstance,
|
|
.lpszClassName = CLASS_NAME,
|
|
};
|
|
RegisterClass(&wc);
|
|
HWND hwnd = CreateWindowEx(
|
|
0,
|
|
CLASS_NAME,
|
|
"Learn to Program Windows",
|
|
WS_OVERLAPPEDWINDOW,
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
NULL,
|
|
NULL,
|
|
hInstance,
|
|
NULL
|
|
);
|
|
if (hwnd == NULL) {
|
|
return 0;
|
|
}
|
|
ShowWindow(hwnd, nCmdShow);
|
|
MSG msg;
|
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessage(&msg);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|
switch (uMsg)
|
|
{
|
|
case WM_DESTROY:
|
|
PostQuitMessage(0);
|
|
return 0;
|
|
case WM_PAINT:
|
|
{
|
|
PAINTSTRUCT ps;
|
|
HDC hdc = BeginPaint(hwnd, &ps);
|
|
|
|
// All painting occurs here, between BeginPaint and EndPaint.
|
|
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
|
|
EndPaint(hwnd, &ps);
|
|
}
|
|
return 0;
|
|
}
|
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
|
} |