Annotation of os232sdk/toolkt20/c/samples/semaph/sem_dlg.c, revision 1.1.1.1

1.1       root        1: /*==============================================================*\
                      2:  *  sem_dlg.c - window procedures for the dialog boxes as well  *
                      3:  *              as utility procedures used by them              *
                      4:  *      Created 1990, Microsoft, IBM Corp.                      *
                      5:  *--------------------------------------------------------------*
                      6:  *                                                              *
                      7:  *  This module contains the Dialog Procedures for the user     *
                      8:  *  defined dialogs as well as any support code they need       *
                      9:  *                                                              *
                     10:  *--------------------------------------------------------------*
                     11:  *                                                              *
                     12:  *  This source file contains the following functions:          *
                     13:  *                                                              *
                     14:  *           AboutBoxWndProc(hwnd, msg, mp1, mp2)               *
                     15:  *               TimeDlgProc(hwnd, msg, mp1, mp2)                                               *
                     16: \*==============================================================*/
                     17: 
                     18: /*--------------------------------------------------------------*\
                     19:  *  Include files, macros, defined constants, and externs       *
                     20: \*--------------------------------------------------------------*/
                     21: 
                     22: #define  LINT_ARGS
                     23: #define INCL_PM
                     24: #define INCL_BASE
                     25: 
                     26: #include <os2.h>
                     27: #include <string.h>
                     28: #include <stdlib.h>
                     29: 
                     30: #include "sem_main.h"
                     31: #include "sem_dlg.h"
                     32: #include "sem_xtrn.h"
                     33: #include "sem_pnt.h"
                     34: #include "semaph.h"
                     35: 
                     36: extern CHAR szWindowText[];
                     37: 
                     38: /*--------------------------------------------------------------*\
                     39:  *  Global variables                                            *
                     40: \*--------------------------------------------------------------*/
                     41: 
                     42: 
                     43: /*--------------------------------------------------------------*\
                     44:  *  Entry point declarations                                    *
                     45: \*--------------------------------------------------------------*/
                     46: 
                     47: MRESULT EXPENTRY AboutBoxWndProc(HWND hwnd, USHORT msg,
                     48:                                   MPARAM mp1, MPARAM mp2);
                     49: MRESULT EXPENTRY TimeDlgProc(HWND hwnd, USHORT msg,
                     50:                                   MPARAM mp1, MPARAM mp2);
                     51: 
                     52: /****************************************************************\
                     53:  *  Dialog procedure for the About dialog box                   *
                     54:  *--------------------------------------------------------------*
                     55:  *                                                              *
                     56:  *  Name:   AboutBoxWndProc(hwnd, msg, mp1, mp2)                *
                     57:  *                                                              *
                     58:  *  Purpose: Processes all messages sent to the About Box       *
                     59:  *                                                              *
                     60:  *  Usage:  Called for each message sent to the About Box       *
                     61:  *          dialog box.
                     62:  *                                                              *
                     63:  *  Method: the about box only has a button control so this     *
                     64:  *          routine only processes WM_COMMAND messages.  Any    *
                     65:  *          WM_COMMAND posted must have come from the Ok        *
                     66:  *          button so we dismiss the dialog upon receiving it.  *
                     67:  *                                                              *
                     68:  *  Returns: Dependent upon message sent                        *
                     69:  *                                                              *
                     70: \****************************************************************/
                     71: MRESULT EXPENTRY AboutBoxWndProc(hwnd, msg, mp1, mp2)
                     72: HWND hwnd;      /* handle of window */
                     73: USHORT msg;     /* id of message */
                     74: MPARAM mp1;     /* first message parameter */
                     75: MPARAM mp2;     /* second message parameter */
                     76: {
                     77:     switch(msg)  {
                     78:         case WM_COMMAND:
                     79:             /* no matter what the command, close the dialog */
                     80:             WinDismissDlg(hwnd, TRUE);
                     81:             break;
                     82: 
                     83:         default:
                     84:             return(WinDefDlgProc(hwnd, msg, mp1, mp2));
                     85:             break;
                     86:     }
                     87: 
                     88:     return 0L;
                     89: 
                     90: }   /* AboutBoxWndProc() */
                     91: 
                     92: 
                     93: /****************************************************************\
                     94:  *  Dialog procedure for the Timeout entry dlg box              *
                     95:  *--------------------------------------------------------------*
                     96:  *                                                              *
                     97:  *  Name:   TimeDlg(hwnd, msg, mp1, mp2)                        *
                     98:  *                                                              *
                     99:  *  Purpose: Processes all messages sent to the Timer Box       *
                    100:  *                                                              *
                    101:  *  Usage:  Called for each message sent to the Timer Box       *
                    102:  *          dialog box.                                         * 
                    103:  *                                                              *
                    104:  *  Method: display box on init, and reset global ulTimeout on  *
                    105:  *          successful entry                                    *
                    106:  *                                                              *
                    107:  *                                                              *
                    108:  *                                                              *
                    109:  *  Returns: Dependent upon message sent                        *
                    110:  *                                                              *
                    111: \****************************************************************/
                    112: MRESULT EXPENTRY TimeDlgProc(hwnd, msg, mp1, mp2)
                    113: HWND hwnd;      /* handle of window */
                    114: USHORT msg;     /* id of message */
                    115: MPARAM mp1;     /* first message parameter */
                    116: MPARAM mp2;     /* second message parameter */
                    117: {
                    118:     CHAR    szBuffer [MAXTEXTLEN];
                    119:     ULONG   l_ulTimeout = 0;        /* local copy of timeout for dlg */
                    120:     static  HWND    hwndWork;
                    121: 
                    122:     switch(msg)  {
                    123:             case WM_INITDLG:
                    124:                 /* init the entry field w/current value */
                    125:                 hwndWork = WinWindowFromID ( hwnd, IDD_ENTRY);
                    126:                 WinSetWindowText (hwndWork, itoa (ulTimeout, szBuffer, 10));
                    127:                 WinSendMsg( hwndWork, EM_SETSEL,
                    128:                         MPFROM2SHORT(0, strlen(szBuffer)), (MPARAM)0 );
                    129:                 break;
                    130:             case WM_COMMAND:
                    131:                 /* no matter what the command, close the dialog */
                    132:                 switch(SHORT1FROMMP(mp1))  {
                    133:                     case IDD_OK:
                    134:                         if (WinQueryDlgItemShort(hwnd, IDD_ENTRY,
                    135:                         (PUSHORT) &l_ulTimeout, FALSE) == FALSE) {
                    136:                             WinSetDlgItemText (hwnd, IDD_ENTRY, itoa (ulTimeout, szBuffer, 10));
                    137:                             return 0;
                    138:                         }
                    139:                         else
                    140:                             ulTimeout = l_ulTimeout;
                    141:                         /* fall thru to... */
                    142:                     case IDD_CANCEL:
                    143:                     default:
                    144:                             WinDismissDlg(hwnd, SHORT1FROMMP(mp1));
                    145:                             break;
                    146:                 }
                    147: 
                    148:             default:
                    149:                 return(WinDefDlgProc(hwnd, msg, mp1, mp2));
                    150:                 break;
                    151:     }
                    152: 
                    153:     return 0L;
                    154: 
                    155: }   /* TimeDlgProc() */
                    156: 
                    157: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.