Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #define bt1_id 1
- #define bt2_id 2
- #define bt3_id 3
- LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
- {
- if (message == WM_DESTROY)
- PostQuitMessage(0);
- else if (message == WM_COMMAND)
- {
- if (LOWORD(wparam) == bt1_id)
- MessageBox(0, L" Нажали 1 кнопку", L"Сообщение", MB_OK);
- else if (LOWORD(wparam) == bt2_id)
- MessageBox(0, L" Нажали 2 кнопку", L"Сообщение", MB_OK);
- else if (LOWORD(wparam) == bt3_id)
- MessageBox(0, L" Нажали 3 кнопку", L"Сообщение", MB_OK);
- }
- else return DefWindowProcA(hwnd, message, wparam, lparam);
- }
- int main()
- {
- WNDCLASSA wcl;
- memset(&wcl, 0, sizeof(WNDCLASSA));
- wcl.lpszClassName = "my_Window";
- wcl.lpfnWndProc = WndProc;
- RegisterClassA(&wcl);
- HWND hwnd;
- hwnd = CreateWindow(L"my_Window", L"Окошечко", WS_OVERLAPPEDWINDOW, 10, 10, 640, 480, NULL, NULL, NULL, NULL);
- MSG msg;
- ShowWindow(hwnd, SW_SHOWNORMAL);
- HWND bt1 = CreateWindow(L"button", L"Кнопка1", WS_VISIBLE | WS_CHILD, 50, 10, 75, 50, hwnd, (HMENU)bt1_id, NULL, NULL);
- HWND bt2 = CreateWindow(L"button", L"Кнопка2", WS_VISIBLE | WS_CHILD, 150, 10, 75, 50, hwnd, (HMENU)bt2_id, NULL, NULL);
- HWND bt3 = CreateWindow(L"button", L"Кнопка3", WS_VISIBLE | WS_CHILD, 250, 10, 75, 50, hwnd, (HMENU)bt3_id, NULL, NULL);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement