home *** CD-ROM | disk | FTP | other *** search
/ Total Destruction / Total_Destruction.iso / addons / Lccwin32.exe / Lccwin32 / lccpub / demo / hellowin / hellowin.c next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  2.9 KB  |  89 lines

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