Advertisement
ipwxy

Untitled

Feb 27th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.48 KB | None | 0 0
  1. int WINAPI WinMain(HINSTANCE hInstance,  
  2.                    HINSTANCE hPrevInstance,  
  3.                    LPSTR lpCmdLine,  
  4.                    int nCmdShow)  
  5. {  
  6.     WNDCLASSEX wcex;  
  7.  
  8.     wcex.cbSize = sizeof(WNDCLASSEX);  
  9.     wcex.style          = CS_HREDRAW | CS_VREDRAW;  
  10.     wcex.lpfnWndProc    = WndProc;  
  11.     wcex.cbClsExtra     = 0;  
  12.     wcex.cbWndExtra     = 0;  
  13.     wcex.hInstance      = hInstance;  
  14.     wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));  
  15.     wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);  
  16.     wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);  
  17.     wcex.lpszMenuName   = NULL;  
  18.     wcex.lpszClassName  = szWindowClass;  
  19.     wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));  
  20.  
  21.     if (!RegisterClassEx(&wcex))  
  22.     {  
  23.         MessageBox(NULL,  
  24.             _T("Call to RegisterClassEx failed!"),  
  25.             _T("Win32 Guided Tour"),  
  26.             NULL);  
  27.  
  28.         return 1;  
  29.     }  
  30.  
  31.     hInst = hInstance; // Store instance handle in our global variable  
  32.  
  33.     // The parameters to CreateWindow explained:  
  34.     // szWindowClass: the name of the application  
  35.     // szTitle: the text that appears in the title bar  
  36.     // WS_OVERLAPPEDWINDOW: the type of window to create  
  37.     // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)  
  38.     // 500, 100: initial size (width, length)  
  39.     // NULL: the parent of this window  
  40.     // NULL: this application dows not have a menu bar  
  41.     // hInstance: the first parameter from WinMain  
  42.     // NULL: not used in this application  
  43.     HWND hWnd = CreateWindow(  
  44.         szWindowClass,  
  45.         szTitle,  
  46.         WS_OVERLAPPEDWINDOW,  
  47.         CW_USEDEFAULT, CW_USEDEFAULT,  
  48.         500, 100,  
  49.         NULL,  
  50.         NULL,  
  51.         hInstance,  
  52.         NULL  
  53.     );  
  54.  
  55.     if (!hWnd)  
  56.     {  
  57.         MessageBox(NULL,  
  58.             _T("Call to CreateWindow failed!"),  
  59.             _T("Win32 Guided Tour"),  
  60.             NULL);  
  61.  
  62.         return 1;  
  63.     }  
  64.  
  65.     // The parameters to ShowWindow explained:  
  66.     // hWnd: the value returned from CreateWindow  
  67.     // nCmdShow: the fourth parameter from WinMain  
  68.     ShowWindow(hWnd,  
  69.         nCmdShow);  
  70.     UpdateWindow(hWnd);  
  71.  
  72.     // Main message loop:  
  73.     MSG msg;  
  74.     while (GetMessage(&msg, NULL, 0, 0))  
  75.     {  
  76.         TranslateMessage(&msg);  
  77.         DispatchMessage(&msg);  
  78.     }  
  79.  
  80.     return (int) msg.wParam;  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement