Guest User

Untitled

a guest
Jan 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.07 KB | None | 0 0
  1. /*------------------------------------------------------------
  2.    HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
  3.                  (c) Charles Petzold, 1998
  4.   ------------------------------------------------------------*/
  5. #include <windows.h>
  6.  
  7. LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
  8.  
  9. int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  10.                     PSTR szCmdLine, int iCmdShow)
  11. {
  12.      static TCHAR szAppName[] = TEXT ("HelloWin") ;
  13.      HWND         hwnd ;
  14.      MSG          msg ;
  15.      WNDCLASS     wndclass ;
  16.      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
  17.      wndclass.lpfnWndProc   = WndProc ;
  18.      wndclass.cbClsExtra    = 0 ;
  19.      wndclass.cbWndExtra    = 0 ;
  20.      wndclass.hInstance     = hInstance ;
  21.      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
  22.      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
  23.      wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
  24.      wndclass.lpszMenuName  = NULL ;
  25.      wndclass.lpszClassName = szAppName ;
  26.      
  27.      if (!RegisterClass (&wndclass))
  28.      {
  29.           MessageBox (NULL, TEXT ("This program requires Windows NT!"),
  30.                       szAppName, MB_ICONERROR) ;
  31.           return 0 ;
  32.      }
  33.      
  34.      hwnd = CreateWindow (szAppName,                  // window class name
  35.                           TEXT ("The Hello Program"), // window caption
  36.                           WS_OVERLAPPEDWINDOW,        // window style
  37.                           CW_USEDEFAULT,              // initial x position
  38.                           CW_USEDEFAULT,              // initial y position
  39.                           CW_USEDEFAULT,              // initial x size
  40.                           CW_USEDEFAULT,              // initial y size
  41.                           NULL,                       // parent window handle
  42.                           NULL,                       // window menu handle
  43.                           hInstance,                  // program instance handle
  44.                           NULL) ;                     // creation parameters
  45.      
  46.      ShowWindow (hwnd, iCmdShow) ;
  47.      UpdateWindow (hwnd) ;
  48.      
  49.      while (GetMessage (&msg, NULL, 0, 0))
  50.      {
  51.           TranslateMessage (&msg) ;
  52.           DispatchMessage (&msg) ;
  53.      }
  54.      return msg.wParam ;
  55. }
  56.  
  57. LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  58. {
  59.      HDC         hdc ;
  60.      PAINTSTRUCT ps ;
  61.      RECT        rect ;
  62.      
  63.      switch (message)
  64.      {
  65.      case WM_CREATE:
  66.           PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
  67.           return 0 ;
  68.      case WM_PAINT:
  69.           hdc = BeginPaint (hwnd, &ps) ;
  70.          
  71.           GetClientRect (hwnd, &rect) ;
  72.          
  73.           DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
  74.                     DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
  75.           EndPaint (hwnd, &ps) ;
  76.           return 0 ;
  77.          
  78.      case WM_DESTROY:
  79.           PostQuitMessage (0) ;
  80.           return 0 ;
  81.      }
  82.  
  83.      return DefWindowProc (hwnd, message, wParam, lParam) ;
  84. }
Add Comment
Please, Sign In to add comment