home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / owf.zip / template / stdc / stdc.c < prev    next >
C/C++ Source or Header  |  1997-04-09  |  4KB  |  115 lines

  1. #define INCL_PM
  2. #include "os2.h"
  3.  
  4. #include "resource.h"
  5.  
  6.  
  7. MRESULT EXPENTRY stdcWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  8. {
  9.   switch( msg )
  10.   {
  11.     case WM_CREATE:
  12.       /*
  13.        * Window initialization is performed here in WM_CREATE processing
  14.        * WinLoadString loads strings from the resource file.
  15.        */
  16.     case WM_COMMAND:
  17.       /*
  18.        * When the user chooses option 1, 2, or 3 from the Options pull-
  19.        * down, the text string is set to 1, 2, or 3, and
  20.        * WinInvalidateRegion sends a WM_PAINT message.
  21.        * When Exit is chosen, the application posts itself a WM_CLOSE
  22.        * message.
  23.        */
  24.       {
  25.       USHORT command;                   /* WM_COMMAND command value     */
  26.       command = SHORT1FROMMP(mp1);      /* Extract the command value    */
  27.       switch (command)
  28.       {
  29.       }
  30.  
  31.       break;
  32.       }
  33.     case WM_ERASEBACKGROUND:
  34.       /*
  35.        * Return TRUE to request PM to paint the window background
  36.        * in SYSCLR_WINDOW.
  37.        */
  38.       return (MRESULT)( TRUE );
  39.     case WM_PAINT:
  40.       /*
  41.        * Window contents are drawn here in WM_PAINT processing.
  42.        */
  43.       {
  44.       HPS    hps;                       /* Presentation Space handle    */
  45.       RECTL  rc;                        /* Rectangle coordinates        */
  46.       POINTL pt;                        /* String screen coordinates    */
  47.                                         /* Create a presentation space  */
  48.       hps = WinBeginPaint( hwnd, 0L, &rc );
  49.       WinFillRect( hps, &rc, SYSCLR_WINDOW);
  50.       WinEndPaint( hps );                      /* Drawing is complete   */
  51.       break;
  52.       }
  53.     case WM_CLOSE:
  54.       /*
  55.        * This is the place to put your termination routines
  56.        */
  57.       WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );/* Cause termination*/
  58.       break;
  59.     default:
  60.       /*
  61.        * Everything else comes here.  This call MUST exist
  62.        * in your window procedure.
  63.        */
  64.  
  65.       return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  66.   }
  67.   return (MRESULT) FALSE;
  68.  
  69.  
  70. void main ( void)
  71. {
  72.     HMQ  hmq;                             /* Message queue */
  73.     HWND hwndClient = NULLHANDLE;         /* Client area window handle    */
  74.     HWND hwndFrame = NULLHANDLE;          /* Frame window handle          */
  75.     QMSG qmsg;                            /* Message from message queue   */
  76.     HAB hab;
  77.     ULONG flCreate;                       /* creation control flags */
  78.  
  79.     /* create anchor block */
  80.     hab = WinInitialize(0);
  81.  
  82.     /* Create a message queue */
  83.     hmq = WinCreateMsgQueue( hab, 0 );  
  84.  
  85.     /* register the window class */
  86.     WinRegisterClass( hab, (PSZ)"stdcWindow", 
  87.      (PFNWP) stdcWindowProc, CS_SIZEREDRAW,
  88.      0);
  89.  
  90.     /* style for the frame */
  91.     flCreate = FCF_SIZEBORDER | FCF_SYSMENU /MENU | FCF_MENU MENU/ | FCF_TITLEBAR | FCF_MINMAX | FCF_TASKLIST & ~FCF_SHELLPOSITION;
  92.  
  93.     /* create a window */
  94.     hwndFrame = WinCreateStdWindow(
  95.                HWND_DESKTOP, 0, &flCreate,
  96.                "stdcWindow", "", 0, 
  97.                (HMODULE) 0,
  98.                WIN_MAIN, &hwndClient);
  99.  
  100.   WinSetWindowText(hwndFrame, "stdc Window");
  101.  
  102.   WinSetWindowPos( hwndFrame,
  103.                    HWND_TOP, 100, 100, 200, 200,
  104.                    SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_SHOW );
  105.  
  106.   while( WinGetMsg( hab, &qmsg, 0L, 0, 0 ) )
  107.     WinDispatchMsg( hab, &qmsg );
  108.  
  109.   /*clean*/
  110.   WinDestroyWindow(hwndFrame);
  111.   WinDestroyMsgQueue( hmq );
  112.   WinTerminate( hab );
  113. }
  114.