home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 7.ddi / MWHC.007 / Q8 < prev    next >
Encoding:
Text File  |  1991-09-04  |  2.1 KB  |  84 lines

  1. #include "windows.h"
  2.  
  3. long FAR PASCAL WndProc (HWND, WORD, WORD, LONG);
  4. char szText[100];
  5.  
  6. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, 
  7.                     LPSTR lpszCmdParam, int nCmdShow) {
  8.     char szAppName[] = "HelloWin";
  9.     HWND    hwnd;
  10.     MSG        msg;
  11.     WNDCLASS    wndclass;
  12.  
  13.     if (!hPrevInstance) {
  14.         wndclass.style = CS_HREDRAW | CS_VREDRAW;
  15.         wndclass.lpfnWndProc = WndProc;
  16.         wndclass.cbClsExtra = 0;
  17.         wndclass.cbWndExtra = 0;
  18.         wndclass.hInstance = hInstance;
  19.         wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  20.         wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  21.         wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); 
  22.         wndclass.lpszMenuName =  NULL; 
  23.         wndclass.lpszClassName = szAppName;
  24.  
  25.         RegisterClass(&wndclass);
  26.         }
  27.    hwnd = CreateWindow(szAppName,
  28.            "The Hello Program",
  29.         WS_OVERLAPPEDWINDOW,
  30.         CW_USEDEFAULT,
  31.         CW_USEDEFAULT,
  32.         CW_USEDEFAULT,
  33.         CW_USEDEFAULT,
  34.         NULL,
  35.         NULL,
  36.         hInstance,
  37.         NULL
  38.         );
  39.     ShowWindow(hwnd, nCmdShow);
  40.     UpdateWindow(hwnd);
  41.     while (GetMessage(&msg, NULL, 0, 0)) {
  42.         TranslateMessage(&msg);
  43.     DispatchMessage(&msg);
  44.     }
  45.     return msg.wParam;
  46.     }
  47.  
  48. long FAR PASCAL WndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam) {
  49.     HDC     hdc;
  50.     PAINTSTRUCT    ps;
  51.     RECT    rect;
  52.  
  53.     switch (message) {
  54.         case WM_PAINT:
  55.         hdc = BeginPaint(hwnd, &ps);
  56.         GetClientRect(hwnd, &rect);
  57.         DrawText(hdc, "Hello, Windows!", -1, &rect,
  58.             DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  59.         EndPaint(hwnd, &ps);
  60.         return 0;
  61.  
  62.     case WM_DESTROY:
  63.         PostQuitMessage(0);
  64.         return 0;
  65.     }
  66.     return DefWindowProc(hwnd, message, wParam, lParam);
  67.     }
  68.  
  69.  
  70. /****************************************************************************
  71.  
  72.     FUNCTION:  InitInstance(HANDLE, int)
  73.  
  74.     PURPOSE:  Saves instance handle and creates main window
  75.  
  76. ****************************************************************************/
  77.  
  78. BOOL InitInstance(hInstance, nCmdShow)
  79.     HANDLE          hInstance;
  80.     int             nCmdShow;
  81. {
  82.     return TRUE;
  83.     }    
  84.