home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / os2 / semaph / sem_dlg.c next >
C/C++ Source or Header  |  1999-05-11  |  5KB  |  94 lines

  1. /*static char *SCCSID = "@(#)sem_dlg.c    6.13 92/03/18";*/
  2. /*==============================================================*\
  3.  *  SEM_DLG.C - window procedures for the dialog boxes as well  *
  4.  *              as utility procedures used by them              *
  5.  *      (C) Copyright IBM Corporation 1992.                     *
  6.  *--------------------------------------------------------------*
  7.  *                                                              *
  8.  *  This module contains the Dialog Procedures for the user     *
  9.  *  defined dialogs as well as any support code they need       *
  10.  *                                                              *
  11.  *--------------------------------------------------------------*
  12.  *                                                              *
  13.  *  This source file contains the following functions:          *
  14.  *                                                              *
  15.  *           TimeDlgProc(hwnd, msg, mp1, mp2)                   *
  16. \*==============================================================*/
  17.  
  18. /*--------------------------------------------------------------*\
  19.  *  Include files, macros, defined constants, and externs       *
  20. \*--------------------------------------------------------------*/
  21. #include "semaph.h"
  22.  
  23. /****************************************************************\
  24.  *  Dialog procedure for the Timeout entry dlg box              *
  25.  *--------------------------------------------------------------*
  26.  *                                                              *
  27.  *  Name:   TimeDlg(hwnd, msg, mp1, mp2)                        *
  28.  *                                                              *
  29.  *  Purpose: Processes all messages sent to the Timer Box       *
  30.  *                                                              *
  31.  *  Usage:  Called for each message sent to the Timer Box       *
  32.  *          dialog box.                                         *
  33.  *                                                              *
  34.  *  Method: display box on init, and reset global ulTimeout on  *
  35.  *          successful entry                                    *
  36.  *                                                              *
  37.  *                                                              *
  38.  *                                                              *
  39.  *  Returns: Dependent upon message sent                        *
  40.  *                                                              *
  41. \****************************************************************/
  42. MRESULT EXPENTRY TimeDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  43. {
  44.     CHAR    szBuffer [MAXTEXTLEN];
  45.     SHORT   sTimeout = 0;        /* local copy of timeout for dlg */
  46.     static  HWND    hwndWork;
  47.     MRESULT sRC;
  48.  
  49.     switch(msg)  {
  50.             case WM_INITDLG:
  51.                 /* init the entry field w/current value */
  52.                 hwndWork = WinWindowFromID ( hwnd, IDD_ENTRY);
  53.                 WinSetWindowText (hwndWork, _itoa(ulTimeout, szBuffer, 10));
  54.                 WinSendMsg( hwndWork, EM_SETSEL,
  55.                         MPFROM2SHORT(0, strlen(szBuffer)), (MPARAM)0 );
  56.                 FixSysMenu(hwnd);
  57.                 return (MRESULT)0L;
  58.  
  59.             case WM_COMMAND:
  60.                 /* no matter what the command, close the dialog */
  61.                 switch(SHORT1FROMMP(mp1))  {
  62.                     case DID_OK:
  63.                         if (WinQueryDlgItemShort(hwnd, IDD_ENTRY,
  64.                                  &sTimeout, FALSE) == FALSE) {
  65.                             WinSetDlgItemText (hwnd, IDD_ENTRY,
  66.                                           _itoa(ulTimeout, szBuffer, 10));
  67.                         }
  68.                         else
  69.                             ulTimeout = (ULONG)sTimeout;
  70.  
  71.                         WinDismissDlg(hwnd, TRUE);
  72.                         return (MRESULT)0L;
  73.                                                     /* fall thru to... */
  74.                     case DID_CANCEL:
  75.                         WinDismissDlg(hwnd, FALSE);
  76.                         return (MRESULT)0L;
  77.  
  78.                     default:
  79.                         sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
  80.                         return sRC;
  81.                 }
  82.                 break;
  83.  
  84.             case WM_CLOSE:
  85.                 WinDismissDlg(hwnd, FALSE);
  86.                 return (MRESULT)0L;
  87.  
  88.             default:
  89.                 sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
  90.                 return sRC;
  91.     }
  92.     return (MRESULT)0L;
  93. }                                                      /* TimeDlgProc() */
  94.