File:  [OS/2 SDKs] / os232sdk / toolkt20 / c / samples / semaph / sem_dlg.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:30 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1990, HEAD
Microsoft OS/2 SDK 2.0 05-30-1990

/*==============================================================*\
 *  sem_dlg.c - window procedures for the dialog boxes as well  *
 *              as utility procedures used by them              *
 *      Created 1990, Microsoft, IBM Corp.                      *
 *--------------------------------------------------------------*
 *                                                              *
 *  This module contains the Dialog Procedures for the user     *
 *  defined dialogs as well as any support code they need       *
 *                                                              *
 *--------------------------------------------------------------*
 *                                                              *
 *  This source file contains the following functions:          *
 *                                                              *
 *           AboutBoxWndProc(hwnd, msg, mp1, mp2)               *
 *               TimeDlgProc(hwnd, msg, mp1, mp2)                                               *
\*==============================================================*/

/*--------------------------------------------------------------*\
 *  Include files, macros, defined constants, and externs       *
\*--------------------------------------------------------------*/

#define  LINT_ARGS
#define INCL_PM
#define INCL_BASE

#include <os2.h>
#include <string.h>
#include <stdlib.h>

#include "sem_main.h"
#include "sem_dlg.h"
#include "sem_xtrn.h"
#include "sem_pnt.h"
#include "semaph.h"

extern CHAR szWindowText[];

/*--------------------------------------------------------------*\
 *  Global variables                                            *
\*--------------------------------------------------------------*/


/*--------------------------------------------------------------*\
 *  Entry point declarations                                    *
\*--------------------------------------------------------------*/

MRESULT EXPENTRY AboutBoxWndProc(HWND hwnd, USHORT msg,
                                  MPARAM mp1, MPARAM mp2);
MRESULT EXPENTRY TimeDlgProc(HWND hwnd, USHORT msg,
                                  MPARAM mp1, MPARAM mp2);

/****************************************************************\
 *  Dialog procedure for the About dialog box                   *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:   AboutBoxWndProc(hwnd, msg, mp1, mp2)                *
 *                                                              *
 *  Purpose: Processes all messages sent to the About Box       *
 *                                                              *
 *  Usage:  Called for each message sent to the About Box       *
 *          dialog box.
 *                                                              *
 *  Method: the about box only has a button control so this     *
 *          routine only processes WM_COMMAND messages.  Any    *
 *          WM_COMMAND posted must have come from the Ok        *
 *          button so we dismiss the dialog upon receiving it.  *
 *                                                              *
 *  Returns: Dependent upon message sent                        *
 *                                                              *
\****************************************************************/
MRESULT EXPENTRY AboutBoxWndProc(hwnd, msg, mp1, mp2)
HWND hwnd;      /* handle of window */
USHORT msg;     /* id of message */
MPARAM mp1;     /* first message parameter */
MPARAM mp2;     /* second message parameter */
{
    switch(msg)  {
        case WM_COMMAND:
            /* no matter what the command, close the dialog */
            WinDismissDlg(hwnd, TRUE);
            break;

        default:
            return(WinDefDlgProc(hwnd, msg, mp1, mp2));
            break;
    }

    return 0L;

}   /* AboutBoxWndProc() */


/****************************************************************\
 *  Dialog procedure for the Timeout entry dlg box              *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:   TimeDlg(hwnd, msg, mp1, mp2)                        *
 *                                                              *
 *  Purpose: Processes all messages sent to the Timer Box       *
 *                                                              *
 *  Usage:  Called for each message sent to the Timer Box       *
 *          dialog box.                                         * 
 *                                                              *
 *  Method: display box on init, and reset global ulTimeout on  *
 *          successful entry                                    *
 *                                                              *
 *                                                              *
 *                                                              *
 *  Returns: Dependent upon message sent                        *
 *                                                              *
\****************************************************************/
MRESULT EXPENTRY TimeDlgProc(hwnd, msg, mp1, mp2)
HWND hwnd;      /* handle of window */
USHORT msg;     /* id of message */
MPARAM mp1;     /* first message parameter */
MPARAM mp2;     /* second message parameter */
{
    CHAR    szBuffer [MAXTEXTLEN];
    ULONG   l_ulTimeout = 0;        /* local copy of timeout for dlg */
    static  HWND    hwndWork;

    switch(msg)  {
            case WM_INITDLG:
                /* init the entry field w/current value */
                hwndWork = WinWindowFromID ( hwnd, IDD_ENTRY);
                WinSetWindowText (hwndWork, itoa (ulTimeout, szBuffer, 10));
                WinSendMsg( hwndWork, EM_SETSEL,
                        MPFROM2SHORT(0, strlen(szBuffer)), (MPARAM)0 );
                break;
            case WM_COMMAND:
                /* no matter what the command, close the dialog */
                switch(SHORT1FROMMP(mp1))  {
                    case IDD_OK:
                        if (WinQueryDlgItemShort(hwnd, IDD_ENTRY,
                        (PUSHORT) &l_ulTimeout, FALSE) == FALSE) {
                            WinSetDlgItemText (hwnd, IDD_ENTRY, itoa (ulTimeout, szBuffer, 10));
                            return 0;
                        }
                        else
                            ulTimeout = l_ulTimeout;
                        /* fall thru to... */
                    case IDD_CANCEL:
                    default:
                            WinDismissDlg(hwnd, SHORT1FROMMP(mp1));
                            break;
                }

            default:
                return(WinDefDlgProc(hwnd, msg, mp1, mp2));
                break;
    }

    return 0L;

}   /* TimeDlgProc() */



unix.superglobalmegacorp.com

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