home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 02 / jpi / min.c < prev    next >
Text File  |  1990-12-20  |  3KB  |  89 lines

  1. /*-------------------------------------------------------------*\
  2.  |   MIN.C   A Minimum Windows Program that displays a window. |
  3.  |           The window can be moved, sized, minimized and     |
  4.  |           maximized.  The WM_QUIT message is correctly      |
  5.  |           handled so that the program terminates properly.  |
  6. \*-------------------------------------------------------------*/
  7. #pragma warn(wall => on)
  8. #pragma warn(wpnu => off)
  9.  
  10. #include <Windows.H>
  11.  
  12.  
  13. /*-------------------------------------------------------------*\
  14.  |                    Function Prototypes.                     |
  15. \*-------------------------------------------------------------*/
  16. #pragma save
  17. #pragma call( windows => on )
  18. long FAR  PASCAL MinWndProc (HWND, WORD, WORD, LONG);
  19. #pragma restore
  20.  
  21. /*-------------------------------------------------------------*\
  22.  |                 Main Function:  WinMain.                    |
  23. \*-------------------------------------------------------------*/
  24. int PASCAL WinMain (HANDLE hInstance,
  25.                     HANDLE hPrevInstance,
  26.                     LPSTR  lpszCmdLine,
  27.                     int    cmdShow)
  28.     {
  29.     HWND     hwnd;
  30.     MSG      msg;
  31.     WNDCLASS wndclass;
  32.  
  33.     if (!hPrevInstance)
  34.         {
  35.         wndclass.lpszClassName = (LPSTR)"MIN:MAIN";
  36.         wndclass.hInstance     = hInstance;
  37.         wndclass.lpfnWndProc   = MinWndProc;
  38.         wndclass.hCursor       = LoadCursor (hInstance, (LPSTR)"hand");
  39.         wndclass.hIcon         = LoadIcon (hInstance,(LPSTR)"snapshot");
  40.         wndclass.lpszMenuName  = NULL;
  41.         wndclass.hbrBackground = COLOR_WINDOW+1;
  42.         wndclass.style         = NULL;
  43.         wndclass.cbClsExtra    = 0;
  44.         wndclass.cbWndExtra    = 0;
  45.  
  46.         RegisterClass( (LPWNDCLASS)&wndclass);
  47.         }
  48.  
  49.     hwnd = CreateWindow((LPSTR)"MIN:MAIN",    /* Class name.   */
  50.                         (LPSTR)"Minimum",     /* Title.        */
  51.                         WS_OVERLAPPEDWINDOW,  /* Style bits.   */
  52.                         CW_USEDEFAULT,        /* x - default.  */
  53.                         0,                    /* y - default.  */
  54.                         CW_USEDEFAULT,        /* cx - default. */
  55.                         0,                    /* cy - default. */
  56.                         NULL,                 /* No parent.    */
  57.                         NULL,                 /* Class menu.   */
  58.                         hInstance,            /* Creator.      */
  59.                         NULL);                /* Params.       */
  60.     ShowWindow (hwnd, cmdShow);
  61.  
  62.     while (GetMessage((LPMSG)&msg, 0, 0, 0))
  63.         {
  64.         TranslateMessage((LPMSG)&msg); /*  Keyboard input.     */
  65.         DispatchMessage((LPMSG)&msg);
  66.         }
  67.     return 0;
  68.     }
  69.  
  70. /*-------------------------------------------------------------*\
  71.  |              Window Procedure:  MinWndProc.                 |
  72. \*-------------------------------------------------------------*/
  73. long FAR PASCAL MinWndProc (HWND hwnd,   WORD wMsg,
  74.                             WORD wParam, LONG lParam)
  75.     {
  76.     switch (wMsg)
  77.         {
  78.         case WM_DESTROY:
  79.             PostQuitMessage(0);
  80.             break;
  81.  
  82.         default:
  83.             return(DefWindowProc(hwnd,wMsg,wParam,lParam));
  84.             break;
  85.         }
  86.     return 0L;
  87.     }
  88. 
  89.