Advertisement
amgineyoc

Untitled

Aug 30th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  4. {
  5.     switch (msg)
  6.     {
  7.     case WM_CREATE:
  8.         break;
  9.     case WM_CLOSE:
  10.         DestroyWindow(hWnd);
  11.         break;
  12.     case WM_DESTROY:
  13.         PostQuitMessage(0);
  14.         break;
  15.     }
  16.  
  17.     return DefWindowProc(hWnd, msg, wParam, lParam);
  18. }
  19.  
  20. INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
  21. {
  22.     WNDCLASSEX wcex;
  23.     wcex.cbClsExtra = 0;
  24.     wcex.cbSize = sizeof(wcex);
  25.     wcex.cbWndExtra = 0;
  26.     wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
  27.     wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  28.     wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  29.     wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  30.     wcex.hInstance = hInstance;
  31.     wcex.lpfnWndProc = WndProc;
  32.     wcex.lpszClassName = "MyForm";
  33.     wcex.lpszMenuName = NULL;
  34.     wcex.style = 0;
  35.  
  36.     if (!RegisterClassEx(&wcex))
  37.     {
  38.         MessageBox(NULL, "RegisterClassEx() failed !", "ERROR", MB_ICONINFORMATION | MB_OK);
  39.         return 1;
  40.     }
  41.  
  42.     HWND hForm = CreateWindowEx(WS_EX_WINDOWEDGE, wcex.lpszClassName, "IMG", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 600, 500, NULL, NULL, hInstance, NULL);
  43.  
  44.     if (!hForm)
  45.     {
  46.         MessageBox(NULL, "CreateWindowEx() failed !", "ERROR", MB_ICONINFORMATION | MB_OK);
  47.         return 1;
  48.     }
  49.  
  50.     ShowWindow(hForm, nCmdShow);
  51.     UpdateWindow(hForm);
  52.  
  53.     MSG msg{ 0 };
  54.  
  55.     while (GetMessage(&msg, hForm, NULL, NULL) > NULL)
  56.     {
  57.         TranslateMessage(&msg);
  58.         DispatchMessage(&msg);
  59.     }
  60.  
  61.     return msg.wParam;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement