Code:
// test.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
HINSTANCE hInst; // current instance
HFONT hFont;
HWND hWnd; // Main Window Handle
HDC windowdc;
HBRUSH old;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC) WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(wcex.hInstance, NULL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = CreateSolidBrush (15790320);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "AppClass";
wcex.hIconSm = LoadIcon(wcex.hInstance, NULL);
if (!RegisterClassEx(&wcex)) {return 0;};
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindowEx (WS_EX_WINDOWEDGE, "AppClass", "Caro",
WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
565, 103 , 562, 530, NULL, NULL, hInstance, NULL);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
};
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_KEYDOWN:
windowdc = GetDC (hWnd);
old = (HBRUSH) SelectObject (windowdc, (HGDIOBJ) NULL_BRUSH);
Ellipse (windowdc, 0,0, 100, 100);
SelectObject (windowdc, old);
ReleaseDC (hWnd, windowdc);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}