Advertisement
lofojak

5sPP2Task1

Oct 9th, 2024
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4.  
  5. LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
  6. {
  7.     if (message == WM_DESTROY)
  8.     {
  9.         MessageBox(0, L"Вы закрыли окно", L"Сообщение", MB_OK);
  10.         PostQuitMessage(0);
  11.     }
  12.     else if (message == WM_LBUTTONDOWN)
  13.         MessageBox(0, L"Вы нажали левую кнопку мыши", L"Сообщение", MB_OK);
  14.     else return DefWindowProcA(hwnd, message, wparam, lparam);
  15. }
  16.  
  17. int main()
  18. {
  19.     WNDCLASSA wcl;
  20.     memset(&wcl, 0, sizeof(WNDCLASSA));
  21.     wcl.lpszClassName = "my_Window";
  22.     wcl.lpfnWndProc = WndProc;
  23.     RegisterClassA(&wcl);
  24.     HWND hwnd;
  25.     hwnd = CreateWindow(L"my_Window", L"Окошечко", WS_OVERLAPPEDWINDOW, 10, 10, 640, 480, NULL, NULL, NULL, NULL);
  26.  
  27.     MSG msg;
  28.     ShowWindow(hwnd, SW_SHOWNORMAL);
  29.  
  30.     while (GetMessage(&msg, NULL, 0, 0))
  31.     {
  32.         TranslateMessage(&msg);
  33.         DispatchMessage(&msg);
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement