home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
TIMEXSRC.ZIP
/
UA_MWIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-29
|
6KB
|
222 lines
/* ua_mwin.c -- Main window control
February 1990 Mark E. Mallett, Personal Workstation Magazine
This module contains the code controlling the main window, and, in
effect, the timexua program.
Included are the following routines:
main_winproc Main window procedure
*/
#define INCL_WIN
#include <stdio.h>
#include <malloc.h>
#include <os2.h>
#include "timex.h"
#include "ua_timex.h"
#include "ua_pm.h"
#include "ua_baif.h"
/* Local definitions */
/* External data referenced */
extern EVENT *CureventP; /* Current event being modified */
extern HWND CurwinH; /* Currently active window */
extern HWND EvlistH; /* Event list window handle */
extern HWND MainwinH; /* Main window handle */
/* External routines used */
extern MRESULT EXPENTRY event_winproc();
extern void get_events( void );
/* Local data publicly available */
/* Local routines and forward declarations */
static void mw_delete( void ); /* Perform a DELETE action */
static void mw_modify( void ); /* Perform a MODIFY action */
/* Private data */
/*
*//* main_winproc( winH, msgcode, mp1, mp2 )
Window procedure for the main window
Accepts :
winH Window handler
msgcode Message code
mp1 First message parameter
mp2 Second window parameter
Returns :
*/
MRESULT EXPENTRY
main_winproc(
HWND winH, /* Window handle */
USHORT msgcode, /* Message code */
MPARAM mp1, /* First parm */
MPARAM mp2 /* Second parm */
) {
int eecode; /* Event editing result code */
HWND eewin; /* Event editing window handle */
HWND oldcwH; /* Previous curwin handle */
/* Dispatch on the message code */
switch( msgcode ) {
case WM_INITDLG:
EvlistH = WinWindowFromID( winH, MEL_EVLIST );
break;
case WM_COMMAND: /* Command from a button */
switch ( COMMANDMSG( &msgcode )->cmd ) {
case MEL_CREATE: /* Create an event */
/* Present fill-in form in create mode */
eewin = WinLoadDlg( HWND_DESKTOP, winH, event_winproc,
NULL, WID_EVENTEDIT, NULL );
oldcwH = CurwinH;
CurwinH = eewin;
eecode = WinProcessDlg( eewin );
WinDestroyWindow( eewin );
CurwinH = oldcwH;
return( 0 );
case MEL_MODIFY: /* Modify an event */
mw_modify(); /* Perform the modify function */
return( 0 );
case MEL_DELETE: /* Delete the selected event */
mw_delete(); /* Perform the delete function */
return( 0 );
case MEL_NEWLIST: /* Obtain new list of events */
get_events();
return( 0 );
}
break;
case WM_ERASEBACKGROUND:
return( 1 );
}
/* Not handled here... give to parent handler */
return( WinDefWindowProc( winH, msgcode, mp1, mp2 ) );
}
/*
*//* mw_delete()
Control the delete event
Accepts :
Returns :
*/
static void
mw_delete( void ) {
int listX; /* Event list item number */
char evname[100]; /* Name of the event */
/* Get the currently selected event */
listX = (int)WinSendMsg( EvlistH, LM_QUERYSELECTION,
MPFROMSHORT( LIT_FIRST ), 0L );
if ( listX == LIT_NONE ) {
/* No item selected; ignore. */
warning( EC_OK, "No event selected." );
}
else {
/* Obtain the event */
WinSendMsg( EvlistH, LM_QUERYITEMTEXT,
MPFROM2SHORT( listX, 99 ),
MPFROMP( &evname[0] ) );
/* Attempt to delete it */
if ( ba_del( &evname[0] ) )
/* Success -- get new list of events */
get_events();
}
}
/*
*//* mw_modify()
Control the modify event
Accepts :
Returns :
*/
static void
mw_modify( void ) {
int listX; /* Event list item number */
int eecode; /* Event editing result code */
HWND eewin; /* Event editing window handle */
HWND oldcwH; /* Previous curwinH */
char evname[100]; /* Name of the event */
/* Get the currently selected event */
listX = (int)WinSendMsg( EvlistH, LM_QUERYSELECTION,
MPFROMSHORT( LIT_FIRST ), 0L );
if ( listX == LIT_NONE ) {
/* No item selected; ignore. */
warning( EC_OK, "No event selected." );
}
else {
/* Obtain the event */
WinSendMsg( EvlistH, LM_QUERYITEMTEXT,
MPFROM2SHORT( listX, 99 ),
MPFROMP( &evname[0] ) );
CureventP = ba_get( &evname[0] );
if ( CureventP == NULL ) {
warning( EC_OK, "Can't get event \"%s\"", &evname[0] );
}
else {
/* Get and process the event-edit dialog */
eewin = WinLoadDlg( HWND_DESKTOP, MainwinH, event_winproc,
NULL, WID_EVENTEDIT, NULL );
oldcwH = CurwinH;
CurwinH = eewin;
eecode = WinProcessDlg( eewin );
WinDestroyWindow( eewin );
CurwinH = oldcwH;
/* Get rid of current event that we made */
free( CureventP );
CureventP = NULL;
}
}
}