home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / memsz200.zip / SETTIMER.CC < prev    next >
Text File  |  1993-06-04  |  7KB  |  215 lines

  1. /**************************************************************** SETTIMER.CC
  2.  *                                        *
  3.  *            Dialog: Set Timer Interval                *
  4.  *                                        *
  5.  ****************************************************************************/
  6.  
  7. #define INCL_BASE
  8. #define INCL_PM
  9. #define INCL_WINSTDSPIN
  10. #include <os2.h>
  11.  
  12. #include "support.h"
  13. #include "settimer.h"
  14.  
  15.  
  16. /****************************************************************************
  17.  *                                        *
  18.  *               Definitions & Declarations                *
  19.  *                                        *
  20.  ****************************************************************************/
  21.  
  22.   // Function Prototypes
  23.  
  24. static METHODFUNCTION InitDlg ;
  25. static METHODFUNCTION Command ;
  26. static METHODFUNCTION OK ;
  27. static METHODFUNCTION Cancel ;
  28.  
  29.  
  30.   // Global Data
  31.  
  32. static SHORT id ;
  33. static PUSHORT TimerInterval ;
  34.  
  35.  
  36. /****************************************************************************
  37.  *                                        *
  38.  *    "SetTimer" Dialog Processor                        *
  39.  *                                        *
  40.  ****************************************************************************/
  41.  
  42. extern MRESULT EXPENTRY SetTimerProcessor
  43. (
  44.   HWND hwnd,
  45.   USHORT msg,
  46.   MPARAM mp1,
  47.   MPARAM mp2
  48. )
  49. {
  50.  /***************************************************************************
  51.   *                Declarations                    *
  52.   ***************************************************************************/
  53.  
  54.   static METHOD Methods [] =
  55.   {
  56.     { WM_INITDLG, InitDlg },
  57.     { WM_COMMAND, Command }
  58.   } ;
  59.  
  60.  /***************************************************************************
  61.   * Dispatch the message according to the method table and return the        *
  62.   *   result.  Any messages not defined above get handled by the system     *
  63.   *   default dialog processor.                         *
  64.   ***************************************************************************/
  65.  
  66.   return ( DispatchMessage ( hwnd, msg, mp1, mp2, Methods, sizeof(Methods)/sizeof(Methods[0]), WinDefDlgProc ) ) ;
  67. }
  68.  
  69. /****************************************************************************
  70.  *                                        *
  71.  *    Initialize Dialog                            *
  72.  *                                        *
  73.  ****************************************************************************/
  74.  
  75. static MRESULT APIENTRY InitDlg
  76.   HWND hwnd, 
  77.   USHORT msg,
  78.   MPARAM mp1, 
  79.   MPARAM mp2
  80. )
  81. {
  82.  /***************************************************************************
  83.   * Local Declarations                                *
  84.   ***************************************************************************/
  85.  
  86.   SETTIMER_PARMS *Parms = (SETTIMER_PARMS*) ( PVOIDFROMMP ( mp2 ) ) ;
  87.  
  88.  /***************************************************************************
  89.   * Save parameter data.                            *
  90.   ***************************************************************************/
  91.  
  92.   id = Parms->id ;
  93.   TimerInterval = Parms->TimerInterval ;
  94.  
  95.  /***************************************************************************
  96.   * Set the dialog help instance.                        *
  97.   ***************************************************************************/
  98.  
  99.   WinSetWindowUShort ( hwnd, QWS_ID, id ) ;
  100.  
  101.   if ( Parms->hwndHelp )
  102.   {
  103.     WinAssociateHelpInstance ( Parms->hwndHelp, hwnd ) ;
  104.   }
  105.  
  106.  /***************************************************************************
  107.   * Set the limits and initial value of the spin-button control.        *
  108.   ***************************************************************************/
  109.  
  110.   WinSendDlgItemMsg ( hwnd, id,
  111.     SPBM_SETLIMITS, (MPARAM)300L, (MPARAM)10L ) ;
  112.  
  113.   WinSendDlgItemMsg ( hwnd, id,
  114.     SPBM_SETCURRENTVALUE, (MPARAM)(*TimerInterval/100), NULL ) ;
  115.  
  116.  /***************************************************************************
  117.   * Return OK.                                    *
  118.   ***************************************************************************/
  119.  
  120.   return ( MRFROMSHORT ( FALSE ) ) ;
  121.  
  122.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  123. }
  124.  
  125. /****************************************************************************
  126.  *                                        *
  127.  *    Process command messages.                        *
  128.  *                                        *
  129.  ****************************************************************************/
  130.  
  131. static MRESULT APIENTRY Command
  132.   HWND hwnd, 
  133.   USHORT msg, 
  134.   MPARAM mp1, 
  135.   MPARAM mp2
  136. )
  137. {
  138.  /***************************************************************************
  139.   * Local Declarations                                *
  140.   ***************************************************************************/
  141.  
  142.   static METHOD Methods [] =
  143.   {
  144.     { DID_OK,      OK     },
  145.     { DID_CANCEL, Cancel },
  146.   } ;
  147.  
  148.  /***************************************************************************
  149.   * Dispatch the message without a default message processor.            *
  150.   ***************************************************************************/
  151.  
  152.   return ( DispatchMessage ( hwnd, SHORT1FROMMP(mp1), mp1, mp2, Methods, sizeof(Methods)/sizeof(Methods[0]), NULL ) ) ;
  153.  
  154.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  155. }
  156.  
  157. /****************************************************************************
  158.  *                                        *
  159.  *    Process acceptance of new timer value.                    *
  160.  *                                        *
  161.  ****************************************************************************/
  162.  
  163. static MRESULT APIENTRY OK
  164.   HWND hwnd, 
  165.   USHORT msg, 
  166.   MPARAM mp1, 
  167.   MPARAM mp2
  168. )
  169. {
  170.  /***************************************************************************
  171.   * Save the results.                                *
  172.   ***************************************************************************/
  173.  
  174.   WinSendDlgItemMsg ( hwnd, id, SPBM_QUERYVALUE, TimerInterval, MPFROM2SHORT(NULL,SPBQ_UPDATEIFVALID) ) ;
  175.   *TimerInterval *= 100 ;
  176.  
  177.  /***************************************************************************
  178.   * Dismiss the dialog with a TRUE status.                    *
  179.   ***************************************************************************/
  180.  
  181.   WinDismissDlg ( hwnd, TRUE ) ;
  182.  
  183.   return ( 0 ) ;
  184.  
  185.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  186. }
  187.  
  188. /****************************************************************************
  189.  *                                        *
  190.  *    Process cancellation.                            *
  191.  *                                        *
  192.  ****************************************************************************/
  193.  
  194. static MRESULT APIENTRY Cancel
  195.   HWND hwnd, 
  196.   USHORT msg, 
  197.   MPARAM mp1, 
  198.   MPARAM mp2
  199. )
  200. {
  201.  /***************************************************************************
  202.   * Dismiss the dialog with a TRUE status.                    *
  203.   ***************************************************************************/
  204.  
  205.   WinDismissDlg ( hwnd, FALSE ) ;
  206.  
  207.   return ( 0 ) ;
  208.  
  209.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  210. }
  211.