Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1.  
  2.  
  3. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  4.     LPSTR lpCmdLine, int nCmdShow)
  5. {
  6.     WNDCLASSEX wc;
  7.     HWND hwnd;
  8.     MSG Msg;
  9.  
  10.     //Step 1: Registering the Window Class
  11.     wc.cbSize        = sizeof(WNDCLASSEX);
  12.     wc.style         = 0;
  13.     wc.lpfnWndProc   = WndProc;
  14.     wc.cbClsExtra    = 0;
  15.     wc.cbWndExtra    = 0;
  16.     wc.hInstance     = hInstance;
  17.     wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
  18.     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  19.     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  20.     wc.lpszMenuName  = NULL;
  21.     wc.lpszClassName = g_szClassName;
  22.     wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
  23.  
  24.     if(!RegisterClassEx(&wc))
  25.     {
  26.         MessageBox(NULL, "Window Registration Failed!", "Error!",
  27.             MB_ICONEXCLAMATION | MB_OK);
  28.         return 0;
  29.     }
  30.  
  31.     // Step 2: Creating the Window
  32.     hwnd = CreateWindowEx(
  33.         WS_EX_CLIENTEDGE,
  34.         g_szClassName,
  35.         "The title of my window",
  36.         WS_OVERLAPPEDWINDOW,
  37.         CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
  38.         NULL, NULL, hInstance, NULL);
  39.  
  40.     if(hwnd == NULL)
  41.     {
  42.         MessageBox(NULL, "Window Creation Failed!", "Error!",
  43.             MB_ICONEXCLAMATION | MB_OK);
  44.         return 0;
  45.     }
  46.  
  47.     ShowWindow(hwnd, nCmdShow);
  48.     UpdateWindow(hwnd);
  49.  
  50.     // Step 3: The Message Loop
  51.     while(GetMessage(&Msg, NULL, 0, 0) > 0)
  52.     {
  53.         TranslateMessage(&Msg);
  54.         DispatchMessage(&Msg);
  55.     }
  56.     return Msg.wParam;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement