Guest User

Untitled

a guest
Oct 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <WindowsX.h>
  3.  
  4. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  5. {
  6.     switch(msg)
  7.     {
  8.         case WM_CLOSE:
  9.             DestroyWindow(hwnd);
  10.         break;
  11.  
  12.         case WM_DESTROY:
  13.             PostQuitMessage(0);
  14.         break;
  15.  
  16.         default:
  17.             return DefWindowProc(hwnd, msg, wParam, lParam);
  18.     }
  19.  
  20.     return 0;
  21. }
  22.  
  23. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  24. {
  25.     WNDCLASSEX wcex;
  26.     HWND hwnd;
  27.     MSG Msg;
  28.  
  29.     wcex.cbSize = sizeof(WNDCLASSEX);
  30.     wcex.style = 0;
  31.     wcex.lpfnWndProc = WndProc;
  32.     wcex.cbClsExtra = 0;
  33.     wcex.cbWndExtra = 0;
  34.     wcex.hInstance = hInstance;
  35.     wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  36.     wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  37.     wcex.hbrBackground = (HBRUSH) (COLOR_BACKGROUND - 1);
  38.     wcex.lpszMenuName = NULL;
  39.     wcex.lpszClassName = L"This is the title";
  40.     wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  41.  
  42.     if(!RegisterClassEx(&wcex))
  43.     {
  44.         MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
  45.         return 0;
  46.     }
  47.  
  48.     hwnd = CreateWindowEx(NULL, L"This is the title", L"This is the title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400, NULL, NULL, hInstance, NULL);
  49.  
  50.     if(hwnd == NULL)
  51.     {
  52.         MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
  53.         return 0;
  54.     }
  55.  
  56.     ShowWindow(hwnd, nCmdShow);
  57.     UpdateWindow(hwnd);
  58.  
  59.     while(GetMessage (&Msg, NULL, 0, 0) > 0)
  60.     {
  61.         TranslateMessage(&Msg);
  62.         DispatchMessage(&Msg);
  63.     }
  64.  
  65.     return Msg.wParam;
  66. }
Add Comment
Please, Sign In to add comment