home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1989 / 03 / schildt.lst < prev    next >
File List  |  1989-02-10  |  3KB  |  144 lines

  1.  
  2. _A PRESENTATION MANAGER APPLICATION TEMPLATE_
  3. by Herbert Schildt
  4.  
  5. [LISTING ONE] 
  6.  
  7.  
  8. /* A Presentation Manager Application skeleton. */
  9.  
  10. #define INCL_PM
  11.  
  12. #include <os2.h>
  13. #include <stddef.h>  /* get definition of NULL */
  14.  
  15. void far * pascal far window_func(void far *, unsigned short,
  16.               void far *, void far *);
  17.  
  18. char class[] = "MyClass";
  19.  
  20. main()
  21. {
  22.   void far *hand_ab;
  23.   void far *hand_mq;
  24.   void far *hand_frame, far *hand_client;
  25.   QMSG q_mess;
  26.   unsigned flags = FCF_SYSMENU |
  27.           FCF_SIZEBORDER | FCF_TITLEBAR |
  28.           FCF_VERTSCROLL| FCF_HORZSCROLL |
  29.           FCF_MINMAX;
  30.  
  31.   hand_ab = WinInitialize(NULL);
  32.  
  33.   hand_mq = WinCreateMsgQueue(hand_ab, 0);
  34.  
  35.   if(!WinRegisterClass(hand_ab,   /* anchor block */
  36.            class,      /* class name */
  37.            window_func,   /* address of window function */
  38.            CS_SIZEREDRAW, /* window style */
  39.            0))          /* no storage reserved */
  40.      exit(1);
  41.  
  42.   hand_frame = WinCreateStdWindow(HWND_DESKTOP,
  43.           WS_VISIBLE,
  44.           (void far *) &flags,
  45.           (char far *) class,
  46.           (char far *) "My Window",
  47.           0L,    /* resource modules */
  48.           NULL,
  49.           0,
  50.           &hand_client); /* client handle */
  51.  
  52.   /* message loop */
  53.   while(WinGetMsg(hand_ab, &q_mess, NULL, 0, 0))
  54.     WinDispatchMsg(hand_ab, &q_mess);
  55.  
  56.   WinDestroyWindow(hand_frame);
  57.  
  58.   WinDestroyMsgQueue(hand_mq);
  59.   WinTerminate(hand_ab);
  60. }
  61.  
  62. /* This is the window function. */
  63. void far * pascal far window_func(void far *handle,
  64.                      unsigned short mess,
  65.                      void far *parm1,
  66.                      void far *parm2)
  67. {
  68.  
  69.   switch(mess) {
  70.       case WM_CREATE:
  71.     /* Perform any necessary initializations here. */
  72.       break;
  73.  
  74.     case WM_PAINT:
  75.     /* Refresh the window each time the WM_PAINT message
  76.        is received.
  77.         */
  78.       break;
  79.  
  80.     case WM_ERASEBACKGROUND:
  81.     /* By returning TRUE, the PM automatically erases
  82.        the old window each time the window is resized
  83.        or moved.   Without this, your program must
  84.        manually handle erasing the window with it changes
  85.        size or location.
  86.     */
  87.       return(TRUE);
  88.  
  89.     case WM_CHAR:
  90.     /* Process keystrokes here. */
  91.       break;
  92.  
  93.     case WM_HSCROLL:
  94.     /* Process horizontal scroll request.  */
  95.       break;
  96.  
  97.     case WM_VSCROLL:
  98.     /* Process vertical scroll request. */
  99.       break;
  100.  
  101.     case WM_MOUSEMOVE:
  102.     /*  Process a mouse motion message. */
  103.       break;
  104.  
  105.     case WM_BUTTON1DOWN:
  106.     /* 1st mouse button is pressed. */
  107.       break;
  108.  
  109.     case WM_BUTTON2DOWN:
  110.     /* 2nd mouse button is pressed. */
  111.       break;
  112.  
  113.     case WM_BUTTON3DOWN:
  114.     /* 3rd mouse button is pressed. */
  115.       break;
  116.  
  117.     /* If required by your application, you may also need to
  118.        process these mouse messages:
  119.  
  120.        WM_BUTTON1UP
  121.        WM_BUTTON1DBLCLK   
  122.        WM_BUTTON2UP
  123.        WM_BUTTON2DBLCLK
  124.        WM_BUTTON3UP
  125.        WM_BUTTON3DBLCLK
  126.     */
  127.   }
  128.   /* All messages not handled by the window_func,
  129.      must be passed along to the PM for default
  130.      processing.
  131.   */
  132.   return WinDefWindowProc(handle, mess, parm1, parm2);
  133. }
  134.  
  135.  
  136. [LISTING TWO]
  137.  
  138. NAME skeleton
  139. HEAPSIZE 4096
  140. STACKSIZE 4096
  141. EXPORTS window_func
  142.  
  143.  
  144.