Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <Windows.h>
- LRESULT CALLBACK mainwindowproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- if (uMsg == WM_DESTROY)
- {
- PostQuitMessage(0);
- return 0;
- }
- return DefWindowProcA(hwnd, uMsg, wParam, lParam);
- }
- //int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PSTR lpCmdLine, _In_ int nCmdShow) {
- int main(int argc, char *argv[])
- {
- CHAR className[] = "test";
- HMODULE hInstance = GetModuleHandle(NULL);
- WNDCLASSEXA wc = {
- .cbSize = sizeof(WNDCLASSEXA),
- .lpfnWndProc = (WNDPROC)mainwindowproc,
- .hInstance = hInstance,
- .hIcon = LoadIcon(NULL, IDI_APPLICATION),
- .hCursor = LoadCursor(NULL, IDC_ARROW),
- .hbrBackground = (HBRUSH)(COLOR_WINDOW + 1),
- .lpszClassName = className,
- .hIconSm = LoadIcon(NULL, IDI_APPLICATION),
- };
- RegisterClassExA(&wc);
- HWND hwnd = CreateWindowExA(0, className, "testing", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 50, 50, 240, 120, NULL, NULL, hInstance, NULL);
- ShowWindow(hwnd, SW_SHOW);
- MSG msg = { };
- while (GetMessageA(&msg, NULL, 0, 0) > 0)
- {
- if (msg.message == WM_SYSKEYDOWN) {
- printf("triggering WM_SYSKEYDOWN ( VK=%i 'VK_MENU is 18' )\n",msg.wParam);
- continue;
- }
- if (msg.message == WM_KEYDOWN) { printf("triggering KEYDOWN VK=%i\n",msg.wParam); }
- TranslateMessage(&msg);
- DispatchMessageA(&msg);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement