SHARE
TWEET

Untitled

a guest Dec 9th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4.  
  5. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  6.     PSTR szCmdLine, int iCmdShow)
  7. {
  8.     static TCHAR szAppName[] = TEXT("HelloWin");
  9.     HWND         hwnd;
  10.     MSG          msg;
  11.     WNDCLASS     wndclass;
  12.  
  13.     wndclass.style = CS_HREDRAW | CS_VREDRAW;
  14.     wndclass.lpfnWndProc = WndProc;
  15.     wndclass.cbClsExtra = 0;
  16.     wndclass.cbWndExtra = 0;
  17.     wndclass.hInstance = hInstance;
  18.     wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  19.     wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  20.     wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  21.     wndclass.lpszMenuName = NULL;
  22.     wndclass.lpszClassName = szAppName;
  23.  
  24.     if (!RegisterClass(&wndclass))
  25.     {
  26.         MessageBox(NULL, TEXT("This program requires Windows NT!"),
  27.             szAppName, MB_ICONERROR);
  28.         return 0;
  29.     }
  30.  
  31.     hwnd = CreateWindow(szAppName, TEXT("Graficzne Weze"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  32.  
  33.     ShowWindow(hwnd, iCmdShow);
  34.     UpdateWindow(hwnd);
  35.  
  36.     while (GetMessage(&msg, NULL, 0, 0))
  37.     {
  38.         TranslateMessage(&msg);
  39.         DispatchMessage(&msg);
  40.     }
  41.     return msg.wParam;
  42. }
  43.  
  44. LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  45. {
  46.     HDC         hdc;
  47.     PAINTSTRUCT ps;
  48.     RECT        rect;
  49.  
  50.     switch (message)
  51.     {
  52.  
  53.         case WM_PAINT:
  54.             hdc = BeginPaint(hwnd, &ps);
  55.  
  56.             GetClientRect(hwnd, &rect);
  57.  
  58.             DrawText(hdc, TEXT("Hello, Windows 98!"), -1, &rect,
  59.                 DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  60.  
  61.             EndPaint(hwnd, &ps);
  62.             return 0;
  63.  
  64.         case WM_DESTROY:
  65.             PostQuitMessage(0);
  66.             return 0;
  67.     }
  68.     return DefWindowProc(hwnd, message, wParam, lParam);
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top