1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#include <windows.h>
#include "drawE.cpp"
#define WNDCLASSNAME "wndclass"
HDC hdc;
HWND hwnd;
bool quit = false;
// The event handler
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_CLOSE:
{
PostQuitMessage(0);
break;
}
}
return DefWindowProc(hwnd, msg, wparam, lparam);
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd)
{
MSG msg;
WNDCLASSEX ex;
ex.cbSize = sizeof(WNDCLASSEX);
ex.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
ex.lpfnWndProc = WinProc;
ex.cbClsExtra = 0;
ex.cbWndExtra = 0;
ex.hInstance = hinstance;
ex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
ex.hCursor = LoadCursor(NULL, IDI_APPLICATION);
ex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
ex.lpszMenuName = NULL;
ex.lpszClassName = WNDCLASSNAME;
ex.hIconSm = NULL;
RegisterClassEx(&ex);
hwnd = CreateWindowEx(NULL,
WNDCLASSNAME,
"window",
WS_OVERLAPPEDWINDOW,
0, 0,
300, 300,
NULL,
NULL,
hinstance,
NULL);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
HDC hdc = GetDC(hwnd);
while(!quit)
{
if(PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
{
if(msg.message == WM_QUIT)
quit = true;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
drawJ(10, 10, hdc); // This obviously doesn't work
}
ReleaseDC(hwnd, hdc);
return msg.lParam;
}
|