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
|
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc; // Handle to a device context, for drawing
PAINTSTRUCT ps; // Extra information useful when painting
RECT Window;
RECT ClickMeBox;
RECT ExitBox;
BOOL PaintInitialiser;
switch (message) /* handle the messages */
{
//-------------------------------------------
case WM_CREATE:
// Once only initialisation
GetClientRect(hwnd,&Window);
PaintInitialiser = TRUE;
return 0;
//-------------------------------------------
case WM_PAINT:
hdc = BeginPaint( hwnd, &ps );
if (PaintInitialiser = TRUE)
{
ExitBox.right = Window.right;
ExitBox.top = Window.top;
ExitBox.left = ExitBox.right - 50;
ExitBox.bottom = ExitBox.top + 50;
ClickMeBox.left = (Window.right/2) - 75;
ClickMeBox.right = (Window.right/2) + 75;
ClickMeBox.top = (Window.bottom/2) - 75;
ClickMeBox.bottom = (Window.bottom/2) + 75;
Rectangle(hdc, ExitBox.left, ExitBox.top, ExitBox.right, ExitBox.bottom);
Rectangle(hdc, ClickMeBox.left, ClickMeBox.top, ClickMeBox.right, ClickMeBox.bottom);
}
// Do painting here
EndPaint( hwnd, &ps );
return 0;
//-------------------------------------------
case WM_DESTROY:
// Once only cleanup.
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
return 0;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
|