#include <windows.h>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "WindowsApp";
HWND hwnd;
HWND number_1;
HWND number_2;
HWND result;
HWND lab_1;
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName,
"Код клавиши",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
700,
700,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
lab_1= CreateWindow(TEXT("static"),
TEXT("Код клавиши"),
WS_VISIBLE | WS_CHILD ,
0, 0, 150,25,
hwnd, 0, hThisInstance, NULL);
HWND operation_1 = CreateWindow(TEXT("button"),
TEXT("Стереть"),
WS_VISIBLE | WS_CHILD ,
0, 200, 100, 35,
hwnd, (HMENU)1000, hThisInstance, NULL);
ShowWindow (hwnd, nFunsterStil);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
if (wParam ==1000){
SetWindowText(lab_1,"");
SetFocus(hwnd);
}
break;
case WM_KEYDOWN:
if (wParam !=1000){
int key=wParam;
char str[20];
sprintf(str, "%d", key);
SetWindowText(lab_1,str);
}
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
|