#include #include #include #include #define ID_BTN 1 static TCHAR szWindowClass[] = _T("DesktopApp"); static TCHAR szTitle[] = _T("Калькулятор"); HINSTANCE hInst; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow ) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(wcex.hInstance, IDI_APPLICATION); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = CreateSolidBrush(RGB(63, 80, 95)); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION); if (!RegisterClassEx(&wcex)) { MessageBox(NULL, _T("Call to RegisterClassEx failed!"), _T("Windows Desktop"), NULL); return 1; } hInst = hInstance; HWND hWnd = CreateWindowEx( WS_EX_OVERLAPPEDWINDOW, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 340, 500, NULL, NULL, hInstance, NULL ); if (!hWnd) { MessageBox(NULL, _T("Call to CreateWindow failed!"), _T("Windows Desktop"), NULL); return 1; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; TCHAR greeting[] = _T("Hello, Windows desktop!"); switch (message) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); //TextOut(hdc, 5, 5, greeting, _tcslen(greeting)); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; case WM_CREATE: HWND hButton; hButton = CreateWindowEx( WS_EX_TRANSPARENT, TEXT("Button"), TEXT("Press me"), WS_CHILD, 150, 150, 80, 40, hWnd, (HMENU)ID_BTN, NULL, NULL ); ShowWindow(hButton, SW_SHOW); UpdateWindow(hButton); HWND hEdit; hEdit = CreateWindowEx( WS_EX_TRANSPARENT, TEXT("Edit"), TEXT(""), WS_CHILD | ES_LEFT | WS_BORDER, 20, 20, 278, 90, hWnd, NULL, NULL, NULL ); ShowWindow(hEdit, SW_SHOW); UpdateWindow(hEdit); break; case WM_CTLCOLORSTATIC: { HDC hdcStatic = (HDC)wParam; SetBkMode(hdcStatic, TRANSPARENT); return (INT_PTR)(HBRUSH)GetStockObject(NULL_BRUSH); break; } default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }