Advertisement
Mysoft

Untitled

Aug 3rd, 2022 (edited)
1,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <Windows.h>
  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 DefWindowProcA(hwnd, uMsg, wParam, lParam);
  12. }
  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.    
  18.     CHAR className[] = "test";
  19.    
  20.     HMODULE hInstance = GetModuleHandle(NULL);
  21.    
  22.     WNDCLASSEXA wc = {
  23.         .cbSize = sizeof(WNDCLASSEXA),
  24.         .lpfnWndProc = (WNDPROC)mainwindowproc,
  25.         .hInstance = hInstance,
  26.         .hIcon = LoadIcon(NULL, IDI_APPLICATION),
  27.         .hCursor = LoadCursor(NULL, IDC_ARROW),
  28.         .hbrBackground = (HBRUSH)(COLOR_WINDOW + 1),
  29.         .lpszClassName = className,
  30.         .hIconSm = LoadIcon(NULL, IDI_APPLICATION),
  31.     };
  32.     RegisterClassExA(&wc);
  33.    
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement