SHARE
TWEET

Untitled

a guest Jan 16th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static HHOOK hMsgBoxHook;
  2.  
  3. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  4. {
  5.  
  6.     switch(msg)
  7.     {
  8.         case WM_CLOSE:
  9.             DestroyWindow(hwnd);
  10.         break;
  11.         case WM_DESTROY:
  12.             PostQuitMessage(0);
  13.         break;
  14.         default:
  15.             return DefWindowProc(hwnd, msg, wParam, lParam);
  16.     }
  17.     return 0;
  18. }
  19.  
  20.  
  21. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  22.     LPSTR lpCmdLine, int nCmdShow)
  23. {
  24.     WNDCLASSEX wc;
  25.     HWND hwnd;
  26.     MSG Msg;
  27.  
  28.     //Step 1: Registering the Window Class
  29.     wc.cbSize        = sizeof(WNDCLASSEX);
  30.     wc.style         = 0;
  31.     wc.lpfnWndProc   = WndProc;
  32.     wc.cbClsExtra    = 0;
  33.     wc.cbWndExtra    = 0;
  34.     wc.hInstance     = hInstance;
  35.     wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
  36.     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  37.     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  38.     wc.lpszMenuName  = NULL;
  39.     wc.lpszClassName =  L"Csam";
  40.     wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
  41.  
  42.     if(!RegisterClassEx(&wc))
  43.     {
  44.         MessageBox(NULL, L"Window Registration Failed!", L"Error!",
  45.             MB_ICONEXCLAMATION | MB_OK);
  46.         return 0;
  47.     }
  48.  
  49.     // Step 2: Creating the Window
  50.     hwnd = CreateWindowEx(
  51.         WS_EX_CLIENTEDGE,
  52.         L"myWindowClass",
  53.         L"The title of my window",
  54.         WS_OVERLAPPEDWINDOW,
  55.         CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
  56.         NULL, NULL, hInstance, NULL);
  57.  
  58.     if(hwnd == NULL)
  59.     {
  60.         MessageBox(NULL, L"Window Creation Failed!", L"Error!",
  61.             MB_ICONEXCLAMATION | MB_OK);
  62.         return 0;
  63.     }
  64.  
  65.     ShowWindow(hwnd, nCmdShow);
  66.     UpdateWindow(hwnd);
  67.  
  68.     // Step 3: The Message Loop
  69.     while(GetMessage(&Msg, NULL, 0, 0) > 0)
  70.     {
  71.         TranslateMessage(&Msg);
  72.         DispatchMessage(&Msg);
  73.     }
  74.     return Msg.wParam;
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top