SHOW:
|
|
- or go back to the newest paste.
1 | - | #include <iostream> |
1 | + | #include <stdio.h> |
2 | #include <Windows.h> | |
3 | - | |
3 | + | |
4 | LRESULT CALLBACK mainwindowproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | |
5 | { | |
6 | if (uMsg == WM_DESTROY) | |
7 | { | |
8 | PostQuitMessage(0); | |
9 | return 0; | |
10 | } | |
11 | - | return DefWindowProc(hwnd, uMsg, wParam, lParam); |
11 | + | return DefWindowProcA(hwnd, uMsg, wParam, lParam); |
12 | } | |
13 | - | |
13 | + | |
14 | //int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PSTR lpCmdLine, _In_ int nCmdShow) { | |
15 | int main(int argc, char *argv[]) | |
16 | { | |
17 | - | WNDCLASSEXA wc; |
17 | + | |
18 | CHAR className[] = "test"; | |
19 | ||
20 | - | wc.cbSize = sizeof(WNDCLASSEXA); wc.style = 0; wc.lpfnWndProc = (WNDPROC)mainwindowproc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
20 | + | |
21 | - | wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = className; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); |
21 | + | |
22 | WNDCLASSEXA wc = { | |
23 | - | HWND hwnd = CreateWindowExA(WS_EX_COMPOSITED, className, "testing", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 50, 50, 240, 120, NULL, NULL, hInstance, NULL); |
23 | + | .cbSize = sizeof(WNDCLASSEXA), |
24 | - | ShowWindow(hwnd, SW_MAXIMIZE); |
24 | + | .lpfnWndProc = (WNDPROC)mainwindowproc, |
25 | .hInstance = hInstance, | |
26 | - | while (GetMessage(&msg, NULL, 0, 0) > 0) |
26 | + | .hIcon = LoadIcon(NULL, IDI_APPLICATION), |
27 | .hCursor = LoadCursor(NULL, IDC_ARROW), | |
28 | - | if (msg.message == WM_SYSKEYDOWN) |
28 | + | .hbrBackground = (HBRUSH)(COLOR_WINDOW + 1), |
29 | - | { |
29 | + | .lpszClassName = className, |
30 | - | int t = 5; |
30 | + | .hIconSm = LoadIcon(NULL, IDI_APPLICATION), |
31 | - | std::cout << "triggering WM_SYSKEYDOWN" << std::endl; |
31 | + | }; |
32 | RegisterClassExA(&wc); | |
33 | ||
34 | - | DispatchMessage(&msg); |
34 | + | HWND hwnd = CreateWindowExA(0, className, "testing", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 50, 50, 240, 120, NULL, NULL, hInstance, NULL); |
35 | ||
36 | ShowWindow(hwnd, SW_SHOW); | |
37 | MSG msg = { }; | |
38 | while (GetMessageA(&msg, NULL, 0, 0) > 0) | |
39 | { | |
40 | if (msg.message == WM_SYSKEYDOWN) { | |
41 | printf("triggering WM_SYSKEYDOWN ( VK=%i 'VK_MENU is 18' )\n",msg.wParam); | |
42 | continue; | |
43 | } | |
44 | if (msg.message == WM_KEYDOWN) { printf("triggering KEYDOWN VK=%i\n",msg.wParam); } | |
45 | TranslateMessage(&msg); | |
46 | DispatchMessageA(&msg); | |
47 | } | |
48 | return 1; | |
49 | } |