Advertisement
Rapptz

WinAPI bullshit

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