home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
GPF.ZIP
/
SAMPLE.SRC
/
SOURCES.ZIP
/
SAMPLE.SQC
< prev
next >
Wrap
Text File
|
1991-04-02
|
180KB
|
4,469 lines
/******** Sample C Program Source Code File (.Sqc) ********/
/* */
/* PROGRAM NAME: Sample Application (Sample) */
/* ------------- */
/* Generated by GPF (Gui Programming Facility) */
/* */
/* DATABASE NAME: SAMPLE */
/* ------------- */
/* */
/* DATE AND TIME: Tue Apr 02 17:42:44 1991 */
/* */
/* Presentation Manager */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright Jean Bernard CLERIN */
/* */
/* REVISION LEVEL: 1.1 */
/* --------------- */
/* */
/* WHAT YOU NEED TO COMPILE THIS PROGRAM: */
/* -------------------------------------- */
/* */
/* REQUIRED FILES: */
/* --------------- */
/* */
/* Sample.C - Source code */
/* Sample.Cmd - Command file to build this program */
/* Sample.Mak - Make file for this program */
/* Sample.Def - Module definition file */
/* Sample.Ext - External definition file */
/* Sample.Ids - Pm header file */
/* Sample.L - Linker automatic response file */
/* Sample.Rc - Resource file */
/* */
/* OS2.H - Presentation Manager include file */
/* STDLIB.H - Miscellaneous function declarations */
/* STDIO.H - Declarations for standard I/O routines */
/* STRING.H - String function declarations */
/* MEMORY.H - Declarations for buffer (memory) manipulation */
/* MALLOC.H - Definitions for memory allocation functions */
/* PROCESS.H - Definitions for process control functions */
/* */
/* REQUIRED LIBRARIES: */
/* ------------------- */
/* */
/* OS2.LIB - Presentation Manager/OS2 library */
/* LLIBCMT.LIB - Protect mode/standard combined large model C */
/* library multi-threaded. */
/* */
/* REQUIRED PROGRAMS: */
/* ------------------ */
/* */
/* IBM C Compiler */
/* IBM Linker */
/* Resource Compiler */
/* */
/**********************************************************************/
/**********************************************************************/
/* */
/* Include relevant sections of the PM header file. */
/* */
/**********************************************************************/
/*====================================================================*/
/* */
/* #define: To include: */
/* */
/* + INCL_WINWINDOWMGR General window management */
/* + INCL_WINMESSAGEMGR Message management */
/* + INCL_WININPUT Mouse and keyboard input */
/* + INCL_WINDIALOGS Dialog boxes */
/* + INCL_WINSTATICS Static controls */
/* + INCL_WINBUTTONS Button controls */
/* + INCL_WINENTRYFIELDS Entry Fields */
/* INCL_WINMLE Multiple Line Entry Fields */
/* + INCL_WINLISTBOXES List box controls */
/* + INCL_WINMENUS Menu controls */
/* + INCL_WINSCROLLBARS Scroll bar controls */
/* + INCL_WINFRAMEMGR Frame manager */
/* INCL_WINFRAMECTLS Frame controls (title bars & size border)*/
/* INCL_WINRECTANGLES Rectangle routines */
/* INCL_WINSYS System values (and colors) */
/* INCL_WINTIMER Timer routines */
/* + INCL_WINACCELERATORS Keyboard accelerators */
/* INCL_WINTRACKRECT WinTrackRect() function */
/* INCL_WINCLIPBOARD Clipboard manager */
/* + INCL_WINCURSORS Text cursors */
/* + INCL_WINPOINTERS Mouse pointers */
/* INCL_WINHOOKS Hook manager */
/* + INCL_WINSWITCHLIST Shell Switch List API */
/* INCL_WINPROGRAMLIST Shell Program List API */
/* INCL_WINSHELLDATA Shell Data (?) */
/* INCL_WINCOUNTRY Country support */
/* INCL_WINHEAP Heap Manager */
/* INCL_WINATOM Atom Manager */
/* INCL_WINCATCHTHROW WinCatch/WinThrow support */
/* INCL_WINERRORS Error code definitions */
/* INCL_NLS DBCS window manager definition */
/* + INCL_WINHELP Help Manager definitions */
/* INCL_WINSEI Set Error Info API */
/* INCL_WINLOAD Load/Delete Library/Procedure */
/* INCL_WINTYPES Definitions for Datatypes */
/* */
/* ===================================================================*/
/* */
/* INCL_GPI Include all of the GPI */
/* INCL_GPICONTROL Basic PS control */
/* INCL_GPICORRELATION Picking, Boundary and Correlation */
/* INCL_GPISEGMENTS Segment Control and Drawing */
/* INCL_GPISEGEDITING Segment Editing via Elements */
/* INCL_GPITRANSFORMS Transform and Transform Conversion */
/* INCL_GPIPATHS Paths and Clipping with Paths */
/* INCL_GPILOGCOLORTABLE Logical Color Tables */
/* INCL_GPIPRIMITIVES Drawing Primitives and Primitive Attributes*/
/* INCL_GPILCIDS Phyical and Logical Fonts with Lcids */
/* INCL_GPIBITMAPS Bitmaps and Pel Operations */
/* INCL_GPIREGIONS Regions and Clipping with Regions */
/* INCL_GPIMETAFILES Metafiles */
/* INCL_GPIDEFAULTS Default Primitive Attributes */
/* INCL_GPIERRORS defined if INCL_ERRORS defined */
/* */
/**********************************************************************/
#define INCL_DOS /* Need DOS support */
#define INCL_DOSERRORS
#define INCL_WINWINDOWMGR /* General window management */
#define INCL_WINMESSAGEMGR /* Message management */
#define INCL_WININPUT /* Mouse and keyboard input */
#define INCL_WINDIALOGS /* Dialog boxes */
#define INCL_WINSTATICS /* Static controls */
#define INCL_WINBUTTONS /* Button controls */
#define INCL_WINENTRYFIELDS /* Entry Fields */
#define INCL_WINMLE /* Multiple Line Entry Fields */
#define INCL_WINLISTBOXES /* List box controls */
#define INCL_WINMENUS /* Menu controls */
#define INCL_WINSCROLLBARS /* Scroll bar controls */
#define INCL_WINFRAMEMGR /* Frame manager */
#define INCL_WINRECTANGLES /* Rectangle routines */
#define INCL_WINSYS /* System values (and colors) */
#define INCL_WINACCELERATORS /* Keyboard accelerators */
#define INCL_WINCLIPBOARD /* Clipboard manager */
#define INCL_WINCURSORS /* Text cursors */
#define INCL_WINPOINTERS /* Mouse pointers */
#define INCL_WINSWITCHLIST /* Shell Switch List API */
#define INCL_WINPROGRAMLIST /* Shell Program List API */
#define INCL_WINSHELLDATA /* Shell Data (?) */
#define INCL_WINERRORS /* Error code definitions */
#define INCL_WINHELP /* Help Manager definitions */
#define INCL_WINHEAP /* Heap Manager */
#define INCL_WINTIMER /* Timer routines */
#define INCL_GPIPRIMITIVES /* Drawing Primitives and Attributes*/
#define INCL_GPILCIDS /* Phyical and Logical Fonts Lcids */
#include <os2.h> /* Presentation Manager include file */
/**********************************************************************/
/* */
/* Include C library routine header files */
/* */
/**********************************************************************/
#include <stdlib.h> /* Miscellaneous function declarations */
#include <stdio.h> /* Declarations for standard I/O routines */
#include <string.h> /* String function declarations */
#include <memory.h> /* Declarations for memory manipulation */
#include <malloc.h> /* Definitions for memory allocation */
#include <process.h> /* Definitions for process control functions */
/**********************************************************************/
/* */
/* Include Sql library routine header files */
/* */
/**********************************************************************/
#include <sqlenv.h>
#include <sql.h>
#include <sqlca.h>
/**********************************************************************/
/* */
/* Define GPFPARMS (Gpf Parameters) */
/* */
/**********************************************************************/
#include "GpfParms.h" /* Definitions for GpfParms */
/**********************************************************************/
/* */
/* Miscellaneous constants */
/* */
/**********************************************************************/
#define EXTRAWORDS (4 * sizeof(PVOID)) /* Extra window words */
#define GPF_PMC_LEVEL 1 /* GpfPmc.lib Level */
#define COMMAND 0 /* Process commands received from the user */
#define EXTERN
#define STACKSIZE (1024*8)
/**********************************************************************/
/* */
/* Miscellaneous constants Ids */
/* */
/**********************************************************************/
#include "Sample.Ids"
/**********************************************************************/
/* */
/* Function prototypes for private C functions */
/* */
/**********************************************************************/
#include "Sample.Ext"
/**********************************************************************/
/* */
/* STATIC Function prototypes for private C functions */
/* */
/**********************************************************************/
static VOID ActionMenuExit( PGPFPARMS pGpfParms );
static VOID ActionListDep( PGPFPARMS pGpfParms );
static VOID ActionOrgList( PGPFPARMS pGpfParms );
static VOID ActionMsgInfo( PGPFPARMS pGpfParms );
static VOID ActionMsg1( PGPFPARMS pGpfParms );
static VOID ActionMsg2( PGPFPARMS pGpfParms );
static VOID ActionMsg3( PGPFPARMS pGpfParms );
static VOID ActionMsg4( PGPFPARMS pGpfParms );
static VOID ActionMsg5( PGPFPARMS pGpfParms );
static VOID ActionPullDownMark( PGPFPARMS pGpfParms );
static VOID ActionPullDownUnMark( PGPFPARMS pGpfParms );
static VOID ActionPullDownSwap( PGPFPARMS pGpfParms );
static VOID ActionForHelp( PGPFPARMS pGpfParms );
static VOID ActionExHelp( PGPFPARMS pGpfParms );
static VOID ActionKeysHelp( PGPFPARMS pGpfParms );
static VOID ActionIndxHelp( PGPFPARMS pGpfParms );
static VOID ActionContHelp( PGPFPARMS pGpfParms );
static VOID ActionAbout( PGPFPARMS pGpfParms );
static VOID ActionExecExit( PGPFPARMS pGpfParms );
static VOID ActionAbout3( PGPFPARMS pGpfParms );
static VOID ActionAboutMenuBitMap( PGPFPARMS pGpfParms );
static VOID WmInitWndMainWindow( PGPFPARMS pGpfParms );
static VOID WmActiveMainWindow( PGPFPARMS pGpfParms );
static VOID WmDeActiveMainWindow( PGPFPARMS pGpfParms );
static VOID WmCreateMainWindow( PGPFPARMS pGpfParms );
static VOID WmDestroyMainWindow( PGPFPARMS pGpfParms );
static VOID WmPaintMainWindow( PGPFPARMS pGpfParms );
static VOID WmShowMainWindow( PGPFPARMS pGpfParms );
static VOID WmHideMainWindow( PGPFPARMS pGpfParms );
static VOID CommandMainWindow( PGPFPARMS pGpfParms );
static VOID ActionListBox( PGPFPARMS pGpfParms );
static VOID ActionItalic( PGPFPARMS pGpfParms );
static VOID ActionBold( PGPFPARMS pGpfParms );
static VOID ActionUserButton( PGPFPARMS pGpfParms );
static VOID ActionButtonStaff( PGPFPARMS pGpfParms );
static VOID ActionShowStaf( PGPFPARMS pGpfParms );
static VOID ActionCancel( PGPFPARMS pGpfParms );
static VOID ActionButtonHelp( PGPFPARMS pGpfParms );
static VOID WmInitWndListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmActiveListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmDeActiveListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmCreateListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmDestroyListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmPaintListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmShowListStaffWindow( PGPFPARMS pGpfParms );
static VOID WmHideListStaffWindow( PGPFPARMS pGpfParms );
static VOID CommandListStaffWindow( PGPFPARMS pGpfParms );
static VOID InitializeApplication( VOID );
static VOID EndApplication( VOID );
/*---------------------- Sql thread commands -------------------------*/
#define SQLEXEC (WM_USER+1) /* Execute SQL */
#define SQLEND (WM_USER+2) /* Execute SQL END (Return Code) */
#define SQLCLOSE (WM_USER+3) /* Close SQL Terminate thread */
#define FOREVER 1
HAB habSqlThread; /* Sqlthread anchor block handle */
HMQ hmqSqlThread; /* SqlThread queue handle */
SEL SelSqlThreadStack;
ULONG StartSqlSem = (ULONG)NULL; /* Semaphore to signal that */
HSEM hsemStartSqlThread = &StartSqlSem; /* second thread has started*/
ULONG KillSqlSem = (ULONG)NULL; /* Semaphore to signal that */
HSEM hsemKillSqlThread = &KillSqlSem; /* second thread has ended. */
/*********************************************************************/
/* */
/* SQL constants */
/* */
/*********************************************************************/
struct sqlca sqlca;
EXEC SQL INCLUDE SQLCA;
EXEC SQL INCLUDE SQLDA;
EXEC SQL BEGIN DECLARE SECTION;
/*
Table : ORG
Creator : USERID
*/
char ORG_DEPTNAME [15];
short ORG_DEPTNAME_N;
short ORG_DEPTNUMB;
char ORG_DIVISION [11];
short ORG_DIVISION_N;
char ORG_LOCATION [14];
short ORG_LOCATION_N;
short ORG_MANAGER;
short ORG_MANAGER_N;
/*
Table : STAFF
Creator : USERID
*/
double STAFF_COMM;
short STAFF_COMM_N;
short STAFF_DEPT;
short STAFF_DEPT_N;
short STAFF_ID;
char STAFF_JOB [6];
short STAFF_JOB_N;
char STAFF_NAME [10];
short STAFF_NAME_N;
double STAFF_SALARY;
short STAFF_SALARY_N;
short STAFF_YEARS;
short STAFF_YEARS_N;
EXEC SQL END DECLARE SECTION;
UCHAR DataBaseName[9] = {0}; /* DataBase Name */
/****************** Start of main procedure ***************************/
/**********************************************************************/
/* */
/* FUNCTION: main */
/* */
/* This is a typical PM main function. */
/* It initializes PM, creates a message queue, loads some strings , */
/* registers some window classes, creates a main window, gets and */
/* dispatches messages to its window procedure until the time to */
/* quit, and then tidies up before terminating. */
/* */
/* It sets the values of the following globals:- */
/* */
/* habMainTask, hwndFrameMainWindow, hwndMainWindow */
/* */
/**********************************************************************/
VOID cdecl main( SHORT argc, PUCHAR *argv)
{
QMSG qmsg; /* Message structure */
PID Pid; /* Process Id */
TID Tid; /* Thread Id */
HELPINIT hinit; /* Help init */
HPOINTER hptrIcon; /* Handle of the Icon */
Argc = argc;
Argv = argv;
EndOfAppl = FALSE; /* Switch Accept End Application */
AcceptMsgInfo = TRUE; /* Switch Accept MsgInfo */
hmodSample = (HMODULE)NULL; /* hMod Inline */
hwndHelp = (HWND)0; /* Help Hwnd */
szTaskList = "Sample";
/********************************************************************/
/* Initialize PM and Create application msg queue */
/********************************************************************/
/* Initialize PM */
habMainTask = WinInitialize( 0 );
/* Create application msg queue */
hmqMainTask = WinCreateMsgQueue(habMainTask,1024);
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE));
/********************************************************************/
/* Query System preferences set by the user from the Control Panel */
/********************************************************************/
LogoTimer = WinQueryProfileInt(habMainTask,
"PM_ControlPanel","LogoDisplayTime",-1);
WinQueryProfileString(habMainTask,"PM_National","sDecimal",
".",sDecimal,sizeof(sDecimal));
/********************************************************************/
/* Initialize Application */
/********************************************************************/
InitializeApplication();
/********************************************************************/
/* Initialize the help manager initialization structure, create an */
/* instance of the help manager, and associate that instance with */
/* the frame. */
/********************************************************************/
/* size of initialization structure */
hinit.cb = sizeof(hinit);
/* store HM return code from init. */
hinit.ulReturnCode = (ULONG)NULL;
/* no tutorial program */
hinit.pszTutorialName = (PSZ)NULL;
/* indicates help table is defined */
/* in the RC file. */
hinit.phtHelpTable = (PHELPTABLE)(0xFFFF0000 |
ID_SAMPLE);
/* help table in Exe or a DLL */
hinit.hmodHelpTableModule = hmodSample;
hinit.hmodAccelActionBarModule = (HMODULE)NULL;
hinit.idAccelTable = (USHORT)NULL;
/* action bar is not tailored */
hinit.idActionBar = (USHORT)NULL;
/* help window title */
hinit.pszHelpWindowTitle = szTaskList;
/* help panels ID is not displayed */
hinit.usShowPanelId = CMIC_HIDE_PANEL_ID;
/* library with help panels */
hinit.pszHelpLibraryName = "Sample.Hlp";
/********************************************************************/
/* Control Gpf Library Level */
/********************************************************************/
if (GpfPmcLevel() != GPF_PMC_LEVEL)
{
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Gpf Verion Error",
(PSZ) "Invalid Pmc Level",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
DosExit( EXIT_PROCESS, 0 );
}
/********************************************************************/
/* Create Instance of IPF, pass Anchor Block handle and address of */
/* of IPF initialization structure, and check that creation was */
/* successful. */
/********************************************************************/
hwndHelp = WinCreateHelpInstance(habMainTask, &hinit);
if (!hwndHelp)
{
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Not Available",
(PSZ) "Help Creation Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
}
else
{
if (hinit.ulReturnCode)
{
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Terminated Due to Error",
(PSZ) "Help Creation Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hwndHelp);
hwndHelp = (HWND)NULL;
}
}
/********************************************************************/
/* Create Async Sql Thread And Open DataBase "SAMPLE" */
/********************************************************************/
GpfCreateSqlThread(); /* Create Async Sql Thread And Open DataBase */
/********************************************************************/
/* Create Async WindowThreads */
/********************************************************************/
CreateAboutTask();
/********************************************************************/
/* Create the window "MainWindow". */
/********************************************************************/
CreateMainWindow(NULL);
/********************************************************************/
/* Make sure the window was created. */
/********************************************************************/
if ((!hwndFrameMainWindow) || (!hwndMainWindow))
DosExit( EXIT_PROCESS, 0 );
hptrIcon = (HPOINTER) WinSendMsg( hwndFrameMainWindow,
WM_QUERYICON,NULL,NULL);
/********************************************************************/
/* Set the window title (Task List) */
/********************************************************************/
WinQueryWindowProcess(hwndFrameMainWindow,&Pid,&Tid);
Swctl.hwnd = hwndFrameMainWindow;
Swctl.hwndIcon = hptrIcon;
Swctl.hprog = NULL;
Swctl.idProcess = Pid;
Swctl.idSession = (USHORT)NULL;
Swctl.uchVisibility = SWL_VISIBLE;
Swctl.fbJump = SWL_JUMPABLE;
strncpy(Swctl.szSwtitle,szTaskList,sizeof(Swctl.szSwtitle)-1);
hSwitch = WinAddSwitchEntry(&Swctl);
/********************************************************************/
/* Show the window "MainWindow". */
/********************************************************************/
ShowMainWindow(NULL); /* Show Main Window */
/********************************************************************/
/* SetFocus the window "MainWindow". */
/********************************************************************/
WinSetFocus( HWND_DESKTOP,hwndFrameMainWindow);
/********************************************************************/
/* The font resources are loaded. It may not be necessary to do */
/* this as fonts can be loaded automatically when the system is */
/* started. However, this is a user option that can be turned off */
/* via the Control Panel. */
/********************************************************************/
GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\COURIER.FON");
GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\HELV.FON");
GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\TIMES.FON");
GpiLoadFonts(habMainTask, "C:\\OS2\\DLL\\SYSMONO.FON");
/********************************************************************/
/* A heap for allocating temporary storage is created. */
/********************************************************************/
hHeap = WinCreateHeap(0,0,0,0,0,0);
/********************************************************************/
/* Show the Logo window "AboutWindow". */
/********************************************************************/
if (LogoTimer)
ShowAboutWindow(NULL); /* Show Logo Window */
else
LogoTimer = -1; /* Set Indefinite LogoTimer */
/********************************************************************/
/* Main message-processing loop - get and dispatch messages until */
/* WM_QUIT received and Accepted (EndOfAppl = TRUE) */
/********************************************************************/
while(!EndOfAppl)
{
if (! WinGetMsg( habMainTask, &qmsg, (HWND)NULL, 0, 0 ) )
EndApplication();
else
WinDispatchMsg( habMainTask, &qmsg );
}
/********************************************************************/
/* Tidy up and terminate */
/********************************************************************/
GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\COURIER.FON");
GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\HELV.FON");
GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\TIMES.FON");
GpiUnloadFonts(habMainTask, "C:\\OS2\\DLL\\SYSMONO.FON");
WinDestroyWindow( hwndFrameMainWindow );
if (hwndHelp != (HWND)NULL)
WinDestroyHelpInstance(hwndHelp);
WinDestroyHeap( hHeap );
WinDestroyMsgQueue( hmqMainTask );
WinTerminate( habMainTask );
/********************************************************************/
/* Close DataBase "SAMPLE" */
/********************************************************************/
if (DataBaseName[0])
GpfKillSqlThread(); /* Close DataBase */
/********************************************************************/
/* Dos Exit */
/********************************************************************/
DosExit( EXIT_PROCESS, 0 );
}
/**********************************************************************/
/* End of main procedure */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* WinProc: GpfDefWindowProc */
/* */
/* Controls the "DefaultWindowProc" Area. */
/* */
/* */
/**********************************************************************/
MRESULT EXPENTRY GpfDefWindowProc(
HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
LONG Color; /* Work BackGround Color */
HWND hwndActive; /* Query Active Window */
PGPFPARMS pGpfParms; /* Far Pointer */
SEL Selector; /* Seloctor */
USHORT uShort; /* Work uShort */
/*******************************************************************/
/* Initialize Gpf Parameters */
/*******************************************************************/
pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
if (!pGpfParms)
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
switch(msg)
{
/**************************************************************/
/* Things to do when the Window is first initalized */
/**************************************************************/
case WM_INITDLG:
/**************************************************************/
/* Save CreateUserParms */
/**************************************************************/
pGpfParms->pCrtParms = (PVOID)mp2;
/**************************************************************/
/* Associate Help Instance */
/**************************************************************/
WinAssociateHelpInstance(hwndHelp,GpfGetHwndFrame(hwnd));
/**************************************************************/
/* Set Default BackGroundColor */
/**************************************************************/
pGpfParms->BgColor = SYSCLR_WINDOW;
/**************************************************************/
/* Query Presentation Parameters BackGroundColor */
/**************************************************************/
if (WinQueryPresParam(hwnd,PP_BACKGROUNDCOLOR,
(ULONG)NULL,(PULONG)NULL,
4L,&Color,(USHORT)NULL))
pGpfParms->BgColor = Color;
/**************************************************************/
/* Query Presentation Parameters BackGroundColor Index */
/**************************************************************/
if (WinQueryPresParam(hwnd,(ULONG)NULL,
PP_BACKGROUNDCOLORINDEX,(PULONG)NULL,
4L,&Color,QPF_ID1COLORINDEX))
pGpfParms->BgColor = Color;
/**************************************************************/
/* Set Default ForeGroundColor */
/**************************************************************/
pGpfParms->FgColor = SYSCLR_WINDOWTEXT;
/**************************************************************/
/* Query Presentation Parameters ForeGroundColor */
/**************************************************************/
if (WinQueryPresParam(hwnd,PP_FOREGROUNDCOLOR,
(ULONG)NULL,(PULONG)NULL,
4L,&Color,(USHORT)NULL))
pGpfParms->FgColor = Color;
/**************************************************************/
/* Query Presentation Parameters ForeGroundColor Index */
/**************************************************************/
if (WinQueryPresParam(hwnd,(ULONG)NULL,
PP_FOREGROUNDCOLORINDEX,(PULONG)NULL,
4L,&Color,QPF_ID1COLORINDEX))
pGpfParms->FgColor = Color;
/**************************************************************/
/* Return pGpfParms Mresult */
/**************************************************************/
return (pGpfParms->mresult);
/**************************************************************/
/* The application has asked for the window to be destroyed. */
/**************************************************************/
case WM_DESTROY:
WinSetWindowULong(hwnd,QWL_USER,(ULONG)NULL);
GpfDestroyTemplate(hwnd); /* Reset Help Instance */
/* Extract selector from far pointer */
Selector = SELECTOROF(pGpfParms);
DosFreeSeg(Selector); /* Freemain (GpfParms) */
break;
/**************************************************************/
/* Let frame control erase background for us */
/**************************************************************/
case WM_ERASEBACKGROUND:
/* The client window is cleared to SYSCLR_WINDOW. */
return (MRESULT)(FALSE); /* No background windows. */
/***************************************************************/
/* The window needs painting. */
/***************************************************************/
case WM_PAINT:
uShort = pGpfParms->ShortMsgId; /* Save MsgId */
pGpfParms->ShortMsgId = -1; /* Reset MsgId */
GpfSendMsgInfo(pGpfParms,uShort);
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
break;
/**************************************************************/
/* Resize & Reposition all the BASE windows. */
/* WM_SIZE message was generated when window was created. */
/**************************************************************/
case WM_SIZE:
if (pGpfParms->Options & GPF_OP_ADJUSTSIZE)
GpfAdjustControlSize(hwnd,mp1,mp2); /* Adjust Size */
return ((MRESULT) FALSE);
/**************************************************************/
/* Receive Char ( Set Tabulation ) */
/**************************************************************/
case WM_CHAR:
pGpfParms->mresult = GpfSetTabulation( hwnd, msg, mp1, mp2 );
uShort = WinQueryWindowUShort(WinQueryFocus(HWND_DESKTOP,FALSE),
QWS_ID);
GpfSendMsgInfo(pGpfParms,uShort);
return (pGpfParms->mresult);
break;
case WM_MOUSEMOVE:
/**************************************************************/
/* Process MouseMove for Information Msg */
/**************************************************************/
uShort = WinQueryWindowUShort(GpfGetHwndFrame(hwnd),QWS_ID);
GpfSendMsgInfo(pGpfParms,uShort);
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* Process ControlPointer & MenuSelected for Information Msg */
/**************************************************************/
case WM_CONTROLPOINTER:
case WM_MENUSELECT:
GpfSendMsgInfo(pGpfParms,SHORT1FROMMP(mp1));
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* Process MenuEnd for Information Msg */
/**************************************************************/
case WM_MENUEND:
pGpfParms->ShortMsgId = -1; /* Reset MsgId */
GpfSendMsgInfo(pGpfParms,0);
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* Things to do when the Window is Moved */
/**************************************************************/
case WM_MOVE:
WinPostMsg( hwnd, WM_PAINT, NULL, NULL);
break;
/**************************************************************/
/* Message from system to close the client window. */
/**************************************************************/
case WM_CLOSE:
if (pGpfParms->Options & GPF_OP_MAINWINDOW)
{
WinPostMsg(hwnd,WM_QUIT,0L,0L); /* Cause termination */
return ((MRESULT) FALSE);
}
/**************************************************************/
/* Simulate CANCEL - Send Did CANCEL to Window. */
/**************************************************************/
WinPostMsg( hwnd, /* Send Message */
WM_COMMAND, /* simulate CANCEL */
MPFROM2SHORT( DID_CANCEL , 0 ),
MPFROM2SHORT( CMDSRC_OTHER , 0 )
);
break;
/***************************************************************/
/* The List Box needs to know how big to make an Item. */
/***************************************************************/
case WM_MEASUREITEM:
return (MRESULT)GpfMeasureItem( hwnd, mp1, mp2 );
break;
/**************************************************************/
/* The List Box wants us to Draw an Item */
/**************************************************************/
case WM_DRAWITEM:
return (MRESULT)GpfDrawItem( hwnd, mp1, mp2 );
break;
case HM_HELPSUBITEM_NOT_FOUND:
/**************************************************************/
/* Help manager couldn't find a help panel for an item. */
/* Returning FALSE will display the extended help for that */
/* window. */
/**************************************************************/
return (MRESULT)(FALSE);
break;
case HM_QUERY_KEYS_HELP:
/**************************************************************/
/* Return Keys help panel ID for the help manager */
/**************************************************************/
/**************************************************************/
/* QUERY_KEYS_HELP */
/* */
/* If the user requests KEYS HELP from the help pull-down, */
/* IPF sends the HM_QUERY_KEYS_HELP message to the application*/
/* which should return the panel id of the keys_help panel, */
/* or a 0 to tell IPF to do nothing. */
/**************************************************************/
return (MRESULT)(ID_SAMPLE);
break;
case HM_ERROR:
/*************************************************************/
/* If an error occurs using IPF, an HM_ERROR msg will be */
/* sent to the application. */
/*************************************************************/
hwndActive = WinQueryActiveWindow( HWND_DESKTOP, FALSE );
if (hwndHelp && ((ULONG) mp1 == HMERR_NO_MEMORY))
{
WinMessageBox( HWND_DESKTOP, hwndActive,
(PSZ) "Help Terminated Due to Error",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hwndHelp);
hwndHelp = (HWND)NULL;
}
break;
/***************************************************************/
/* Other messages are handled by the default window procedure. */
/***************************************************************/
default:
/* Pass all other messages to the default window procedure */
return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
return ((MRESULT) FALSE);
}
/**********************************************************************/
/* End of window procedure - WinProc: GpfDefWindowProc */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfGetHwnfFrame */
/* */
/* Get Hwnd Frame From Hwnd */
/* */
/**********************************************************************/
HWND GpfGetHwndFrame( HWND hwnd )
{
if (WinQueryWindowUShort(hwnd,QWS_ID) == FID_CLIENT)
return (WinQueryWindow( hwnd, QW_PARENT, FALSE));
else
return (hwnd);
}
/**********************************************************************/
/* End of GpfGetHwndFrame Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfSetTextTitleBar */
/* */
/* Set Text Title Bar */
/* */
/**********************************************************************/
VOID GpfSetTextTitleBar(HWND hwnd,PUCHAR Text)
{
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/*******************************************************************/
/* Set Text */
/*******************************************************************/
WinSetWindowText(hwndFrame, Text);
}
/**********************************************************************/
/* End of GpfSetCentreWindow Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfSetCentreWindow */
/* */
/* Positions Window in the center of the screen */
/* */
/**********************************************************************/
VOID GpfSetCentreWindow( HWND hwnd )
{
SHORT ix, iy;
SHORT iwidth, idepth;
SWP swp;
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/*******************************************************************/
/* Query width and depth of screen device */
/*******************************************************************/
iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
/*******************************************************************/
/* Query width and depth of Window */
/*******************************************************************/
WinQueryWindowPos( hwndFrame, (PSWP)&swp );
/*******************************************************************/
/* Center Window within the screen */
/*******************************************************************/
ix = ( iwidth - swp.cx ) / 2;
iy = ( idepth - swp.cy ) / 2;
WinSetWindowPos( hwndFrame, HWND_TOP, ix, iy, 0, 0, SWP_MOVE );
}
/**********************************************************************/
/* End of GpfSetCentreWindow Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfSetTopWindow */
/* */
/* Positions the Window in the Top of the screen */
/* */
/**********************************************************************/
VOID GpfSetTopWindow( HWND hwnd )
{
SHORT iy;
SHORT iwidth, idepth;
SWP swp;
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/*******************************************************************/
/* Query width and depth of screen device */
/*******************************************************************/
iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
/*******************************************************************/
/* Query Window Position */
/*******************************************************************/
WinQueryWindowPos( hwndFrame, (PSWP)&swp );
/*******************************************************************/
/* Top Window within the screen */
/*******************************************************************/
iy = ( idepth - swp.cy );
WinSetWindowPos( hwnd, HWND_TOP, 0, iy, 0, 0, SWP_MOVE );
}
/**********************************************************************/
/* End of GpfSetTopWindow Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfSetMaxWindow */
/* */
/* Positions the Window in the Max of the screen */
/* */
/**********************************************************************/
VOID GpfSetMaxWindow( HWND hwnd )
{
SHORT iwidth, idepth;
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/*******************************************************************/
/* Query width and depth of screen device */
/*******************************************************************/
iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
/*******************************************************************/
/* Top Window within the screen */
/*******************************************************************/
WinSetWindowPos( hwndFrame, HWND_TOP, 0 , 0 ,
iwidth, idepth, SWP_MOVE|SWP_SIZE );
}
/**********************************************************************/
/* End of GpfSetMaxWindow Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: GpfUpdateSysMenu */
/* */
/* Edit items in the system menu to leave "Move", "Close", and */
/* "Switch to Task Manager". */
/* */
/**********************************************************************/
VOID GpfUpdateSysMenu( HWND hwnd )
{
HWND hwndSubMenu; /* sys menu pull-down handle */
MENUITEM miTemp; /* menu item template */
SHORT sItemId; /* system menu item ID */
SHORT sItemIndex; /* system menu item index */
HWND hwndFrame;
MRESULT mresult;
/* Query Hwnd Frame */
hwndFrame = GpfGetHwndFrame(hwnd);
/********************************************************************/
/* Get the handle of the system menu pull-down. */
/********************************************************************/
hwndSubMenu = WinWindowFromID( hwndFrame, FID_SYSMENU );
WinSendMsg( hwndSubMenu,
MM_QUERYITEM,
MPFROM2SHORT( SC_SYSMENU, FALSE ),
MPFROMP( (PSZ)&miTemp ));
hwndSubMenu = miTemp.hwndSubMenu;
/********************************************************************/
/* Remove all items from the system menu pull-down that are no */
/* longer wanted. */
/********************************************************************/
mresult = WinSendMsg( hwndSubMenu,
MM_QUERYITEMCOUNT,
MPFROMSHORT(0),
MPFROMSHORT(0));
sItemIndex = SHORT1FROMMR(mresult);
for ( sItemId = 0; sItemIndex != -1;sItemIndex--)
{
mresult = WinSendMsg( hwndSubMenu,
MM_ITEMIDFROMPOSITION,
MPFROMSHORT( sItemIndex ),
MPFROMSHORT(0) );
sItemId = SHORT1FROMMR(mresult);
if ( sItemId != MIT_ERROR &&
sItemId != SC_MOVE &&
sItemId != SC_CLOSE &&
sItemId != SC_TASKMANAGER )
{
WinSendMsg( hwndSubMenu,
MM_DELETEITEM,
MPFROM2SHORT( sItemId, FALSE ),
MPFROMSHORT(0) );
}
}
}
/**********************************************************************/
/* End of GpfUpdateSysMenu Private Function */
/**********************************************************************/
/**********************************************************************/
/************** Start of GpfSysMenuGray Private Function **************/
/**********************************************************************/
/* GpfSysMenuGray: */
/* This function enables and disables choices (menu items) as required*/
/**********************************************************************/
VOID GpfSysMenuGray(HWND hwnd, USHORT item, BOOL option )
{
WinSendMsg( WinWindowFromID( hwnd, FID_SYSMENU )
, MM_SETITEMATTR
, MPFROM2SHORT( item, TRUE)
, MPFROM2SHORT( MIA_DISABLED,
option ? MIA_DISABLED : ~MIA_DISABLED )
);
return;
}
/**********************************************************************/
/*************** End of GpfSysMenuGray Private Function ***************/
/**********************************************************************/
/**********************************************************************/
/***************** Start of GpfMenuGray Private Function **************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfMenuGray */
/* */
/* This function enables and disables choices (menu items) as required*/
/* */
/**********************************************************************/
VOID GpfMenuGray(HWND hwnd, USHORT Item, BOOL Option )
{
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/********************************************************************/
/* Enables or Disables choices (menu items) as required */
/********************************************************************/
WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU )
, MM_SETITEMATTR
, MPFROM2SHORT( Item, TRUE)
, MPFROM2SHORT( MIA_DISABLED,
Option ? MIA_DISABLED : ~MIA_DISABLED )
);
}
/**********************************************************************/
/* End of GpfMenuGray Private Function */
/**********************************************************************/
/**********************************************************************/
/***************** Start of GpfMenuTick Private Function **************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfMenuTick */
/* */
/* This function updates the check marks against choices as required. */
/* */
/**********************************************************************/
VOID GpfMenuTick(HWND hwnd , USHORT Item, BOOL Option )
{
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/*******************************************************************/
/* Updates the check marks against choices as required. */
/*******************************************************************/
WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU )
, MM_SETITEMATTR
, MPFROM2SHORT( Item, TRUE)
, MPFROM2SHORT( MIA_CHECKED,
Option ? MIA_CHECKED : ~MIA_CHECKED )
);
}
/**********************************************************************/
/* End of GpfMenuTick Private Function */
/**********************************************************************/
/**********************************************************************/
/************** Start of GpfMenuSwapTick Private Function *************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfMenuSwapTick */
/* */
/* This function updates-Swap the check marks. */
/* */
/**********************************************************************/
VOID GpfMenuSwapTick(HWND hwnd , USHORT Item )
{
HWND hwndFrame;
/*******************************************************************/
/* Query Hwnd Frame */
/*******************************************************************/
hwndFrame = GpfGetHwndFrame(hwnd);
/*******************************************************************/
/* Updates the check marks. */
/*******************************************************************/
if (WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU ),
MM_QUERYITEMATTR,
MPFROM2SHORT( Item, TRUE ),
MPFROM2SHORT(MIA_CHECKED, 0)))
{
WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU),
MM_SETITEMATTR,
MPFROM2SHORT( Item, TRUE),
MPFROM2SHORT(MIA_CHECKED, 0));
}
else
{
WinSendMsg( WinWindowFromID( hwndFrame, FID_MENU),
MM_SETITEMATTR,
MPFROM2SHORT( Item, TRUE),
MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED));
}
}
/**********************************************************************/
/* End of GpfMenuTick Private Function */
/**********************************************************************/
/**********************************************************************/
/************* Start of GpfStringIsNumeric Private Function ***********/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfStringIsNumeric */
/* */
/**********************************************************************/
BOOL GpfStringIsNumeric( UCHAR String[] )
{
SHORT Index;
SHORT Length;
Length = strlen(String);
if (!Length)
return FALSE;
for (Index = 0; Index < Length; Index++)
{
if (String[Index] < '0' || String[Index] > '9')
return FALSE;
}
return TRUE;
}
/**********************************************************************/
/* End of GpfStringIsNumeric Private Function */
/**********************************************************************/
/**********************************************************************/
/***************** Start of GpfSendMsg Private Function ***************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfSendMsg */
/* */
/* Display, and operate the message box window */
/**********************************************************************/
SHORT GpfSendMsg( SHORT Id )
{
UCHAR String[256];
HWND SysModalWindow;
HWND hwndActive; /* Query Active Window (ApplModal) */
USHORT Reply = 0;
SHORT Alarm = -1;
SHORT Style = 0;
PUCHAR Token1 = 0;
PUCHAR Token2 = 0;
UCHAR szTitle[128];
/*********************************************************************/
/* Save Window (System Modal) */
/*********************************************************************/
SysModalWindow = WinQuerySysModalWindow(HWND_DESKTOP,FALSE);
/*********************************************************************/
/* Load Msg strings */
/*********************************************************************/
WinLoadString(habMainTask, hmodSample,
Id, sizeof(String),(PSZ)String );
Token1 = strchr(String,':');
if (Token1)
{
*Token1 = 0;
Alarm = atoi(String);
Token2 = strchr(++Token1,' ');
if (Token2)
{
*(Token2++) = 0;
Style = atoi(Token1);
/***************************************************/
/* Set Alarm */
/***************************************************/
if (Alarm != -1)
WinAlarm(HWND_DESKTOP,Alarm);
/***************************************************/
/* Query HwndOwner and Title */
/***************************************************/
hwndActive = WinQueryActiveWindow( HWND_DESKTOP, FALSE );
WinQueryWindowText(hwndFrameMainWindow,
sizeof(szTitle),szTitle);
/***************************************************/
/* Now, display the message, save the button press */
/* for a return code. */
/* Pop up a Message box. */
/***************************************************/
Reply = WinMessageBox(HWND_DESKTOP,hwndActive,
Token2,szTitle,Id,Style);
/***************************************************/
/* Restore Window (System Modal) */
/***************************************************/
WinSetSysModalWindow(HWND_DESKTOP,SysModalWindow);
/***************************************************/
/* Reset Information Message */
/***************************************************/
hwndActive = WinWindowFromID( hwndActive, FID_CLIENT );
WinPostMsg( hwndActive, WM_MOUSEMOVE, 0L, 0L );
}
}
return(Reply);
}
/**********************************************************************/
/* End of GpfSendMsg Private Function */
/**********************************************************************/
/**********************************************************************/
/*************** Start of GpfSendMsgInfo Private Function *************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION : GpfSendMsgInfo */
/* */
/* Display, and operate the message */
/**********************************************************************/
VOID GpfSendMsgInfo(PGPFPARMS pGpfParms,SHORT ShortMsgId)
{
if (!(pGpfParms->Options & GPF_OP_MSGINFO))
return;
if (pGpfParms->ShortMsgId == ShortMsgId)
return;
if (!(AcceptMsgInfo | pGpfParms->ShortMsgId))
return;
if (!(AcceptMsgInfo)) /* Accept Msg Info ... */
pGpfParms->ShortMsgId = 0; /* No... Reset MsgId */
else
pGpfParms->ShortMsgId = ShortMsgId; /* Save Msg Id */
GpfDisplayMsgInformation(pGpfParms->hwnd,pGpfParms->ShortMsgId,
pGpfParms->BgColor,pGpfParms->hmod);
}
/**********************************************************************/
/* End of GpfSendMsgInfo Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* GpfCreateSqlThread: */
/* Allocate a stack for the Sql thread, and set it running. */
/**********************************************************************/
VOID GpfCreateSqlThread( VOID )
{
/********************************************************************/
/* Allocate Stack */
/********************************************************************/
DosAllocSeg( STACKSIZE, &SelSqlThreadStack, 0 );
/********************************************************************/
/* Begin Thread */
/********************************************************************/
DosSemSet( hsemStartSqlThread );
_beginthread ( GpfSqlThread,
MAKEP( SelSqlThreadStack, 0),
STACKSIZE ,NULL);
DosSemWait( hsemStartSqlThread, (ULONG)-1);
}
/**********************************************************************/
/* GpfKillSqlThread: */
/* Close down the Sql thread. Wait on the semaphore to indicate that */
/* the Sql thread has ended, before freeing its stack. */
/**********************************************************************/
VOID GpfKillSqlThread( VOID )
{
DosSemSet( hsemKillSqlThread );
if(WinPostQueueMsg( hmqSqlThread,
SQLCLOSE,
MPFROMLONG(NULL),
MPFROMLONG(NULL)))
while( DosSemWait( hsemKillSqlThread, (ULONG)-1));
DosFreeSeg( SelSqlThreadStack );
}
/**********************************************************************/
/* GpfSqlThread: */
/* Execute Sql Command. */
/**********************************************************************/
VOID cdecl GpfSqlThread ( PVOID Arg )
{
QMSG qmsgSqlThread; /* qMsg Sql Thread */
LONG ReturnCode; /* Sql Return Code */
/* Union - ANSI standard for C - Compiler Option -W3 and -W4 */
/* Delete - Warning Msg - Cast of Data Pointer to Function Pointer */
union { PVOID PointerData; PFNSQL PointerProc; } U;
Arg = Arg; /* Delete - Warning Msg - Compiler Option -W3 and -W4 */
habSqlThread = WinInitialize( (USHORT)NULL );
hmqSqlThread = WinCreateMsgQueue( habSqlThread, (SHORT)NULL );
DosSemClear( hsemStartSqlThread );
/********************************************************************/
/* Open DataBase "SAMPLE" */
/********************************************************************/
strcpy(DataBaseName,"SAMPLE"); /* Set DataBase Name */
sqlestar(); /* Start Database Manager */
sqleisig(&sqlca); /* install signal handler */
sqlestrd(DataBaseName,'S',&sqlca); /* Start Using DataBase */
if (sqlca.sqlcode == SQLE_RC_NOLOGON) /* User not logged on */
{ /* -1093 User not logged on */
GpfDisplaySqlError(&sqlca);
DosExit( EXIT_PROCESS, 0 );
}
if (sqlca.sqlcode == SQLE_RC_DB_RESTART) /* DataBase needs Restart */
{ /* -1015 DataBase needs Restart */
sqlerest(DataBaseName,&sqlca); /* Restart DataBase */
sqlestrd(DataBaseName,'S',&sqlca); /* Start Database Again */
}
if (sqlca.sqlcode)
{
GpfDisplaySqlError(&sqlca);
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Couldn't Open DataBase - SAMPLE",
(PSZ) "Open DataBase Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinPostQueueMsg( hmqMainTask,
WM_QUIT, NULL, NULL ); /* Cause termination */
DosExit( EXIT_PROCESS, 0 );
}
if ( hmqSqlThread != (HMQ)NULL )
{
/*****************************************************************/
/* Main message processing loop. */
/* Terminates on receipt of a SQLCLOSE message from the main */
/* thread. */
/*****************************************************************/
do
{
WinGetMsg( habSqlThread, &qmsgSqlThread, (HWND)NULL, 0, 0 );
if ( qmsgSqlThread.msg == SQLEXEC )
{
/*********************************************************/
/* Execute Sql Command */
/*********************************************************/
U.PointerData = PVOIDFROMMP(qmsgSqlThread.mp1);
ReturnCode = (*U.PointerProc)();
if (qmsgSqlThread.mp2)
{
/*****************************************************/
/* Post SQLEND and Sql Code */
/*****************************************************/
WinPostMsg( HWNDFROMMP(qmsgSqlThread.mp2),
SQLEND,
MPFROMLONG(ReturnCode),
NULL);
}
}
}
while (qmsgSqlThread.msg != SQLCLOSE);
}
/********************************************************************/
/* Close DataBase "SAMPLE" */
/********************************************************************/
if (DataBaseName[0])
sqlestpd(&sqlca); /* Close DataBase */
/********************************************************************/
/* Close Thread */
/********************************************************************/
WinDestroyMsgQueue( hmqSqlThread ); /* Destroy Msg Queue */
WinTerminate( habSqlThread ); /* Terminate */
DosEnterCritSec();
DosSemClear( hsemKillSqlThread );
DosExit( EXIT_THREAD, 0 );
}
/**********************************************************************/
/* GpfExecuteSql: */
/* Execute Sql. */
/**********************************************************************/
VOID GpfExecuteSql( PFNSQL Proc ,HWND hwnd )
{
WinPostQueueMsg( hmqSqlThread, SQLEXEC,
MPFROMP(Proc),
MPFROMHWND(hwnd));
}
/**********************************************************************/
/* GpfSqlWait: */
/* Wait SQLEND Message. */
/**********************************************************************/
LONG GpfSqlWait ( HWND hwnd )
{
QMSG qmsg; /* Message structure */
HAB hab; /* Anchor block handle */
HPOINTER hptrWait;
hptrWait = WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE);
hab = WinQueryAnchorBlock(hwnd);
/********************************************************************/
/* Wind message-processing loop - get and dispatch messages until */
/* SQLEND received */
/********************************************************************/
do
{
WinGetMsg( hab, &qmsg, (HWND)NULL, 0, 0 );
if (qmsg.msg != SQLEND) /* If Not End Sql */
{
switch (qmsg.msg) /* Dispatch Or Delete Message */
{
/*****************************************************/
/* Set Wait Pointer */
/*****************************************************/
case WM_MOUSEMOVE: /* Set Wait Pointer */
WinSetPointer(HWND_DESKTOP,hptrWait);
break; /* Delete Msg */
/*****************************************************/
/* Set Focus To Window */
/*****************************************************/
case WM_BUTTON1UP: /* Set */
case WM_BUTTON2UP: /* Focus */
case WM_BUTTON3UP: /* to Window */
WinSetFocus( HWND_DESKTOP,hwnd );
break; /* Delete Msg */
/*****************************************************/
/* Set Focus To Window And Alarm Warning */
/*****************************************************/
case WM_BUTTON1DOWN: /* Set */
case WM_BUTTON2DOWN: /* Focus */
case WM_BUTTON3DOWN: /* to Window */
case WM_BUTTON1DBLCLK: /* And */
case WM_BUTTON2DBLCLK: /* Alarm */
case WM_BUTTON3DBLCLK: /* Warning */
case WM_CHAR:
WinSetFocus( HWND_DESKTOP,hwnd );
WinAlarm(HWND_DESKTOP,WA_WARNING);
break; /* Delete Msg */
/*****************************************************/
/* Dispatch Pass all other messages */
/*****************************************************/
default: /* Dispatch Pass all other messages */
WinDispatchMsg( hab, &qmsg );
break;
}
}
}
while (qmsg.msg != SQLEND); /* While Not End Sql Message */
return(LONGFROMMP(qmsg.mp1)); /* Return SqlCa.SqlCode */
}
/**********************************************************************/
/* */
/* name: GpfDisplaySqlError */
/* */
/* purpose: */
/* Display SQL error message */
/* */
/* returns: */
/* SqlCa.SqlCode */
/* */
/**********************************************************************/
LONG GpfDisplaySqlError(struct sqlca *SqlCa)
{
char mbuff[256];
LONG SqlCode;
HWND SysModalWindow;
SqlCode = SqlCa->sqlcode;
if (SqlCode >= 0)
return(SqlCode);
/********************************************************************/
/* Save Window (System Modal) */
/********************************************************************/
SysModalWindow = WinQuerySysModalWindow(HWND_DESKTOP,FALSE);
/********************************************************************/
/* Query error message */
/********************************************************************/
sqlaintp(mbuff,255,254,SqlCa);
/********************************************************************/
/* Print error message */
/********************************************************************/
WinAlarm(HWND_DESKTOP,WA_WARNING); /* Set Beep ( Warning ) */
WinMessageBox( HWND_DESKTOP,
HWND_DESKTOP,
mbuff, /* Display Message Sql Error */
"Sql Error",
0,
MB_ENTER | MB_WARNING | MB_SYSTEMMODAL);
/********************************************************************/
/* Restore Window (System Modal) */
/********************************************************************/
WinSetSysModalWindow(HWND_DESKTOP,SysModalWindow);
SqlCa->sqlcode = SqlCode; /* Restore SqlCode */
return(SqlCode);
}
/**********************************************************************/
/* End GpfDisplaySqlError */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: Initialize Application */
/* */
/**********************************************************************/
static VOID InitializeApplication( VOID )
{
}
/**********************************************************************/
/* End of Private Function: Initialize Application */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: End Application */
/* */
/**********************************************************************/
static VOID EndApplication( VOID )
{
EndOfAppl = TRUE;
/**************************************************************/
/* User Function ActionEndApplication */
/**************************************************************/
/**************************************************************/
/* Send Message "Msg006". */
/**************************************************************/
if (GpfSendMsg(ID_MSG006) == MBID_YES)
EndOfAppl = TRUE;
else
EndOfAppl = FALSE;
}
/**********************************************************************/
/* End of Private Function: End Application */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: ShowMainWindow */
/* */
/* Show Window "MainWindow". */
/* */
/**********************************************************************/
BOOL ShowMainWindow( PVOID pCrtParms )
{
SWP Swp;
/* Make sure the window was not created. */
if (!hwndFrameMainWindow)
CreateMainWindow(pCrtParms);
WinSetWindowPos( hwndFrameMainWindow,
NULL,0,0,0,0,SWP_RESTORE);
WinQueryWindowPos( hwndFrameMainWindow, &Swp );
WinSetWindowPos( hwndFrameMainWindow,
HWND_TOP,
Swp.x,Swp.y,Swp.cx,Swp.cy,
SWP_ZORDER | SWP_SIZE | SWP_MOVE |
SWP_ACTIVATE | SWP_SHOW
);
return(FALSE);
}
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: DismissMainWindow */
/* */
/* Dismiss Window Hide - Window "MainWindow". */
/* */
/**********************************************************************/
VOID DismissMainWindow( BOOL Rcode )
{
Rcode = Rcode; /* Null , For Delete Unreferenced Formal Parameter */
/* Hide Window */
WinShowWindow(hwndFrameMainWindow, FALSE);
}
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: CreateMainWindow */
/* */
/* Create the window "MainWindow" And Controls. */
/* */
/**********************************************************************/
VOID CreateMainWindow( PVOID pCrtParms)
{
/********************************************************************/
/* Register the window class "MainWindow". */
/********************************************************************/
WinRegisterClass( /* Register window class */
habMainTask, /* Anchor block handle */
"MainWindow", /* Window class name */
fnwpMainWindow, /* Address window procedure */
CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style */
CS_MOVENOTIFY | /* Class style */
CS_SIZEREDRAW | CS_SYNCPAINT, /* Class style */
EXTRAWORDS /* Extra window words */
);
/********************************************************************/
/* Create the window "MainWindow". */
/********************************************************************/
hwndFrameMainWindow = /* Save Hwnd */
GpfCreateTemplate( ID_MAINWINDOW, /* Ressource Id */
hmodSample, /* Ressource Md */
HWND_DESKTOP, /* Hwnd Parent */
HWND_DESKTOP, /* Hwnd Owner */
pCrtParms); /* User Parms */
}
/**********************************************************************/
/* End of Private Function - CreateMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* WinProc: fnwpMainWindow */
/* */
/* Controls the "MainWindow" Area. */
/* */
/* */
/**********************************************************************/
MRESULT EXPENTRY fnwpMainWindow(
HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
HPS hps; /* Presentation space handle */
RECTL rcl; /* Window rectangle */
PGPFPARMS pGpfParms; /* Far Pointer */
SEL Selector; /* Seloctor */
/*******************************************************************/
/* Initialize Gpf Parameters */
/*******************************************************************/
pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
if (pGpfParms)
{
pGpfParms->hwnd = hwnd; /* window handle */
pGpfParms->msg = msg; /* message number */
pGpfParms->mp1 = mp1; /* 1st (packed) parms */
pGpfParms->mp2 = mp2; /* 2nd (packed) parms */
pGpfParms->mresult = (MRESULT) FALSE; /* Mresult */
pGpfParms->Command = 0; /* Command From mp1 (SHORT 1) */
pGpfParms->Notify = 0; /* Notify From mp1 (SHORT 2) */
}
switch(msg)
{
/**************************************************************/
/* Things to do when the Window is first initalized */
/**************************************************************/
case WM_INITDLG:
/**************************************************************/
/* Initialize Window 'MainWindow' */
/**************************************************************/
GpfDefWindowProc( hwnd, msg, mp1, mp2 );
WmInitWndMainWindow(pGpfParms); /* Init Dialog */
/**************************************************************/
/* Return pGpfParms Mresult */
/**************************************************************/
return (pGpfParms->mresult);
/**************************************************************/
/* Things to do when the Window is Activated/Deactivated */
/**************************************************************/
case WM_ACTIVATE:
if (SHORT1FROMMP(mp1))
WmActiveMainWindow(pGpfParms); /* Activate Window */
else
WmDeActiveMainWindow(pGpfParms); /* DeActivate Window */
return (pGpfParms->mresult);
/**************************************************************/
/* Things to do when the Window is "Show/Hide" */
/**************************************************************/
case WM_SHOW:
if (SHORT1FROMMP(mp1))
WmShowMainWindow(pGpfParms); /* Show Window */
else
WmHideMainWindow(pGpfParms); /* Hide Window */
return (pGpfParms->mresult);
/**************************************************************/
/* The application has asked for the window to be created. */
/**************************************************************/
case WM_CREATE:
DosAllocSeg(sizeof(GPFPARMS),&Selector,0); /* Getmain */
pGpfParms = MAKEP(Selector, 0); /* Set Pointer*/
WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
memset(pGpfParms,0,sizeof(GPFPARMS)); /* Clear Area */
pGpfParms->Options |= GPF_OP_MAINWINDOW; /* Set MainWindow */
hwndMainWindow = hwnd; /* Save Hwnd */
hwndFrameMainWindow = GpfGetHwndFrame(hwnd);
pGpfParms->hwnd = hwnd; /* window handle */
pGpfParms->msg = msg; /* message number */
pGpfParms->mp1 = mp1; /* 1st (packed) parms */
pGpfParms->mp2 = mp2; /* 2nd (packed) parms */
pGpfParms->hmod = hmodSample;
pGpfParms->hab = habMainTask; /* Anchor block handle */
WmCreateMainWindow(pGpfParms); /* Create Window */
break;
/**************************************************************/
/* The application has asked for the window to be destroyed. */
/**************************************************************/
case WM_DESTROY:
WmDestroyMainWindow(pGpfParms); /* Destroy Window */
hwndFrameMainWindow = (HWND)NULL; /* Reset HwndFrm */
hwndMainWindow = (HWND)NULL; /* Reset Hwnd */
/* Destroy Template , Help Instance and GpfParms */
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* The window needs painting. */
/**************************************************************/
case WM_PAINT:
/**************************************************************/
/* Obtain a cache PS */
/**************************************************************/
hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect */
pGpfParms->hps = hps; /* Pass Hps ( Paint ) */
WmPaintMainWindow(pGpfParms); /* Paint Window */
WinEndPaint( hps ); /* Release cache PS */
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* Process ScrollBar received from the user */
/**************************************************************/
case WM_VSCROLL:
case WM_HSCROLL:
/* Set Command From mp1 */
pGpfParms->Command = SHORT1FROMMP( mp1 );
/* Set Notify From mp2 */
pGpfParms->Notify = SHORT2FROMMP( mp2 );
CommandMainWindow( pGpfParms ); /* Process the command */
return (pGpfParms->mresult);
/**************************************************************/
/* Process Controls received from the user */
/**************************************************************/
case WM_CONTROL:
/* Set Command From mp1 */
pGpfParms->Command = SHORT1FROMMP( mp1 );
/* Set Notify From mp1 */
pGpfParms->Notify = SHORT2FROMMP( mp1 );
CommandMainWindow( pGpfParms ); /* Process the command */
return (pGpfParms->mresult);
/**************************************************************/
/* Process commands received from the user */
/**************************************************************/
case WM_SYSCOMMAND:
case WM_HELP:
case WM_COMMAND:
/* Set Command From mp1 */
pGpfParms->Command = SHORT1FROMMP( mp1 );
pGpfParms->Notify = COMMAND; /* Set Notify From mp1 */
CommandMainWindow( pGpfParms ); /* Process the command */
if (pGpfParms->mresult)
return (pGpfParms->mresult);
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* All other messages are passed to the default procedure. */
/**************************************************************/
default:
/* Pass all other messages to the default window procedure */
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
}
return ((MRESULT) FALSE);
}
/**********************************************************************/
/* End of window procedure - WinProc: fnwpMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: CommandMainWindow */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID CommandMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) TRUE; /* Set Return Code */
/* Switch according to Control chosen */
switch( pGpfParms->Command )
{
/******************************************************************/
/* Name "MenuExit". */
/* Text "~Exit\tF3". */
/******************************************************************/
case ID_MENUEXIT:
ActionMenuExit(pGpfParms);
return;
/******************************************************************/
/* Name "ListDep". */
/* Text "~List...". */
/******************************************************************/
case ID_LISTDEP:
ActionListDep(pGpfParms);
return;
/******************************************************************/
/* Name "OrgList". */
/* Text "~List...". */
/******************************************************************/
case ID_ORGLIST:
ActionOrgList(pGpfParms);
return;
/******************************************************************/
/* Name "MsgInfo". */
/* Text "~MsgInfo". */
/******************************************************************/
case ID_MSGINFO:
ActionMsgInfo(pGpfParms);
return;
/******************************************************************/
/* Name "Msg1". */
/* Text "Msg1 ~Information Icon". */
/******************************************************************/
case ID_MSG1:
ActionMsg1(pGpfParms);
return;
/******************************************************************/
/* Name "Msg2". */
/* Text "Msg2 ~Question Icon". */
/******************************************************************/
case ID_MSG2:
ActionMsg2(pGpfParms);
return;
/******************************************************************/
/* Name "Msg3". */
/* Text "Msg3 ~Warning Icon". */
/******************************************************************/
case ID_MSG3:
ActionMsg3(pGpfParms);
return;
/******************************************************************/
/* Name "Msg4". */
/* Text "Msg4 ~Error Icon". */
/******************************************************************/
case ID_MSG4:
ActionMsg4(pGpfParms);
return;
/******************************************************************/
/* Name "Msg5". */
/* Text "Msg5 ~No Icon". */
/******************************************************************/
case ID_MSG5:
ActionMsg5(pGpfParms);
return;
/******************************************************************/
/* Name "PullDownMark". */
/* Text "~Mark". */
/******************************************************************/
case ID_PULLDOWNMARK:
ActionPullDownMark(pGpfParms);
return;
/******************************************************************/
/* Name "PullDownUnMark". */
/* Text "~UnMark". */
/******************************************************************/
case ID_PULLDOWNUNMARK:
ActionPullDownUnMark(pGpfParms);
return;
/******************************************************************/
/* Name "PullDownSwap". */
/* Text "~Swap". */
/******************************************************************/
case ID_PULLDOWNSWAP:
ActionPullDownSwap(pGpfParms);
return;
/******************************************************************/
/* Name "ForHelp". */
/* Text "~Help For Help...". */
/******************************************************************/
case ID_FORHELP:
ActionForHelp(pGpfParms);
return;
/******************************************************************/
/* Name "ExHelp". */
/* Text "~Extended Help...". */
/******************************************************************/
case ID_EXHELP:
ActionExHelp(pGpfParms);
return;
/******************************************************************/
/* Name "KeysHelp". */
/* Text "~Keys Help...". */
/******************************************************************/
case ID_KEYSHELP:
ActionKeysHelp(pGpfParms);
return;
/******************************************************************/
/* Name "IndxHelp". */
/* Text "Help ~Index...". */
/******************************************************************/
case ID_INDXHELP:
ActionIndxHelp(pGpfParms);
return;
/******************************************************************/
/* Name "ContHelp". */
/* Text "Help ~Contents...". */
/******************************************************************/
case ID_CONTHELP:
ActionContHelp(pGpfParms);
return;
/******************************************************************/
/* Name "About". */
/* Text "~About". */
/******************************************************************/
case ID_ABOUT:
ActionAbout(pGpfParms);
return;
/******************************************************************/
/* Name "ExecExit". */
/* Text "~Exit...". */
/******************************************************************/
case ID_EXECEXIT:
ActionExecExit(pGpfParms);
return;
/******************************************************************/
/* Name "About3". */
/* Text "~About". */
/******************************************************************/
case ID_ABOUT3:
ActionAbout3(pGpfParms);
return;
/******************************************************************/
/* Name "AboutMenuBitMap". */
/* Text " ". */
/******************************************************************/
case ID_ABOUTMENUBITMAP:
ActionAboutMenuBitMap(pGpfParms);
return;
}
/* Take no action for any other selections */
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: CommandMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMenuExit */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMenuExit( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Exit selected */
/**************************************************************/
WinPostMsg( hwndMainWindow, WM_QUIT, 0L, 0L );
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionListDep */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionListDep( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Show Window "ListStaffWindow". */
/**************************************************************/
ShowListStaffWindow(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionOrgList */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionOrgList( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Show Window "ListOrgWindow". */
/**************************************************************/
ShowListOrgWindow(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMsgInfo */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMsgInfo( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* SwapMark Menu/Item "MsgInfo". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuSwapTick(hwndFrameMainWindow,ID_MSGINFO);
/**************************************************************/
/* Alternate MsgInfo. */
/**************************************************************/
if (AcceptMsgInfo)
AcceptMsgInfo = FALSE;
else
AcceptMsgInfo = TRUE;
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMsg1 */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMsg1( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Send Message "Msg001". */
/**************************************************************/
GpfSendMsg(ID_MSG001);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMsg2 */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMsg2( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Send Message "Msg002". */
/**************************************************************/
GpfSendMsg(ID_MSG002);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMsg3 */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMsg3( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Send Message "Msg003". */
/**************************************************************/
GpfSendMsg(ID_MSG003);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMsg4 */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMsg4( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Send Message "Msg004". */
/**************************************************************/
GpfSendMsg(ID_MSG004);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionMsg5 */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionMsg5( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Send Message "Msg005". */
/**************************************************************/
GpfSendMsg(ID_MSG005);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionPullDownMark */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionPullDownMark( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Mark Menu/Item "PullDownSwap". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuTick(hwndFrameMainWindow,ID_PULLDOWNSWAP,TRUE);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionPullDownUnMark */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionPullDownUnMark( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* UnMark Menu/Item "PullDownSwap". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuTick(hwndFrameMainWindow,ID_PULLDOWNSWAP,FALSE);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionPullDownSwap */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionPullDownSwap( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* SwapMark Menu/Item "PullDownSwap". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuSwapTick(hwndFrameMainWindow,ID_PULLDOWNSWAP);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionForHelp */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionForHelp( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Help For Help. */
/**************************************************************/
if (hwndHelp)
WinSendMsg( hwndHelp, HM_DISPLAY_HELP,0L,0L);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionExHelp */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionExHelp( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Help Extended. */
/**************************************************************/
if (hwndHelp)
WinSendMsg( hwndHelp, HM_DISPLAY_HELP,
MPFROMSHORT( ID_SAMPLE ),
0L );
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionKeysHelp */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionKeysHelp( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Help Keys. */
/**************************************************************/
if (hwndHelp)
WinSendMsg( hwndHelp, HM_KEYS_HELP,0l,0l);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionIndxHelp */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionIndxHelp( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Help Index. */
/**************************************************************/
if (hwndHelp)
WinSendMsg( hwndHelp, HM_HELP_INDEX,0l,0l);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionContHelp */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionContHelp( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Help Contents. */
/**************************************************************/
if (hwndHelp)
WinSendMsg( hwndHelp, HM_HELP_CONTENTS,0l,0l);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionAbout */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionAbout( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Disable Control "UserButton". */
/* Window "ListStaffWindow". */
/**************************************************************/
WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
ID_USERBUTTON),
FALSE);
/**************************************************************/
/* Disable Menu/Item "About". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,TRUE);
/**************************************************************/
/* Disable Menu/Item "About1". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
/**************************************************************/
/* Show Window "AboutWindow". */
/**************************************************************/
ShowAboutWindow(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionExecExit */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionExecExit( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Exit selected */
/**************************************************************/
WinPostMsg( hwndMainWindow, WM_QUIT, 0L, 0L );
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionAbout3 */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionAbout3( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Disable Control "UserButton". */
/* Window "ListStaffWindow". */
/**************************************************************/
WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
ID_USERBUTTON),
FALSE);
/**************************************************************/
/* Disable Menu/Item "About". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,TRUE);
/**************************************************************/
/* Disable Menu/Item "About1". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
/**************************************************************/
/* Show Window "AboutWindow". */
/**************************************************************/
ShowAboutWindow(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionAboutMenuBitMap */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "MainWindow". */
/* */
/**********************************************************************/
static VOID ActionAboutMenuBitMap( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case COMMAND:
/**************************************************************/
/* Disable Control "UserButton". */
/* Window "ListStaffWindow". */
/**************************************************************/
WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
ID_USERBUTTON),
FALSE);
/**************************************************************/
/* Disable Menu/Item "About". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT,TRUE);
/**************************************************************/
/* Disable Menu/Item "About1". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
/**************************************************************/
/* Show Window "AboutWindow". */
/**************************************************************/
ShowAboutWindow(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: MoveMainWindowToData */
/* */
/* Move "MainWindow" To Assosiate Data. */
/* */
/**********************************************************************/
BOOL MoveMainWindowToData ( VOID )
{
UCHAR String[32];
PUCHAR Token;
String[0] = 0; /* Null, Delete Unreferenced Local variable */
Token = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
return (TRUE);
}
/**********************************************************************/
/* End of Private Function: MoveMainWindowToData */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: MoveDataToMainWindow */
/* */
/* Move Data To Window "MainWindow". */
/* */
/**********************************************************************/
BOOL MoveDataToMainWindow ( VOID )
{
UCHAR String[32];
PUCHAR Token;
String[0] = 0; /* Null, Delete Unreferenced Local variable */
Token = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
return (TRUE);
}
/**********************************************************************/
/* End of Private Function: MoveDataToMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmInitWndMainWindow */
/* */
/* Wm Init Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmInitWndMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
/**************************************************************/
/* Center Window "MainWindow". */
/* Positions Window in the center of the screen */
/**************************************************************/
GpfSetCentreWindow(hwndFrameMainWindow);
}
/**********************************************************************/
/* End of Private Function: WmInitWndMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmActiveMainWindow */
/* */
/* Wm Activate Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmActiveMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmActiveMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmDeActiveMainWindow */
/* */
/* DeActivate Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmDeActiveMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmDeActiveMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmCreateMainWindow */
/* */
/* Wm Create Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmCreateMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmCreateMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmDestroyMainWindow */
/* */
/* Wm Destroy Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmDestroyMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmDestroyMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmPaintMainWindow */
/* */
/* Wm Paint Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmPaintMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmPaintMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmShowMainWindow */
/* */
/* Wm Show Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmShowMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmShowMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmHideMainWindow */
/* */
/* Wm Hide Window "MainWindow". */
/* */
/**********************************************************************/
static VOID WmHideMainWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmHideMainWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: ShowListStaffWindow */
/* */
/* Show Window "ListStaffWindow". */
/* */
/**********************************************************************/
BOOL ShowListStaffWindow( PVOID pCrtParms )
{
SWP Swp;
/* Make sure the window was not created. */
if (!hwndFrameListStaffWindow)
CreateListStaffWindow(pCrtParms);
WinSetWindowPos( hwndFrameListStaffWindow,
NULL,0,0,0,0,SWP_RESTORE);
WinQueryWindowPos( hwndFrameListStaffWindow, &Swp );
WinSetWindowPos( hwndFrameListStaffWindow,
HWND_TOP,
Swp.x,Swp.y,Swp.cx,Swp.cy,
SWP_ZORDER | SWP_SIZE | SWP_MOVE |
SWP_ACTIVATE | SWP_SHOW
);
return(FALSE);
}
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: DismissListStaffWindow */
/* */
/* Dismiss Window Hide - Window "ListStaffWindow". */
/* */
/**********************************************************************/
VOID DismissListStaffWindow( BOOL Rcode )
{
Rcode = Rcode; /* Null , For Delete Unreferenced Formal Parameter */
/* Hide Window */
WinShowWindow(hwndFrameListStaffWindow, FALSE);
}
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: CreateListStaffWindow */
/* */
/* Create the window "ListStaffWindow" And Controls. */
/* */
/**********************************************************************/
VOID CreateListStaffWindow( PVOID pCrtParms)
{
/********************************************************************/
/* Register the window class "ListStaffWindow". */
/********************************************************************/
WinRegisterClass( /* Register window class */
habMainTask, /* Anchor block handle */
"ListStaffWindow", /* Window class name */
fnwpListStaffWindow, /* Address window procedure */
CS_CLIPSIBLINGS | CS_SAVEBITS | /* Class style */
CS_MOVENOTIFY | /* Class style */
CS_SIZEREDRAW | CS_SYNCPAINT, /* Class style */
EXTRAWORDS /* Extra window words */
);
/********************************************************************/
/* Create the window "ListStaffWindow". */
/********************************************************************/
hwndFrameListStaffWindow = /* Save Hwnd */
GpfCreateTemplate( ID_LISTSTAFFWINDOW, /* Ressource Id */
hmodSample, /* Ressource Md */
hwndMainWindow, /* Hwnd Parent */
hwndMainWindow, /* Hwnd Owner */
pCrtParms); /* User Parms */
}
/**********************************************************************/
/* End of Private Function - CreateListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* WinProc: fnwpListStaffWindow */
/* */
/* Controls the "ListStaffWindow" Area. */
/* */
/* */
/**********************************************************************/
MRESULT EXPENTRY fnwpListStaffWindow(
HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
HPS hps; /* Presentation space handle */
RECTL rcl; /* Window rectangle */
PGPFPARMS pGpfParms; /* Far Pointer */
SEL Selector; /* Seloctor */
/*******************************************************************/
/* Initialize Gpf Parameters */
/*******************************************************************/
pGpfParms = (PGPFPARMS) WinQueryWindowULong(hwnd,QWL_USER);
if (pGpfParms)
{
pGpfParms->hwnd = hwnd; /* window handle */
pGpfParms->msg = msg; /* message number */
pGpfParms->mp1 = mp1; /* 1st (packed) parms */
pGpfParms->mp2 = mp2; /* 2nd (packed) parms */
pGpfParms->mresult = (MRESULT) FALSE; /* Mresult */
pGpfParms->Command = 0; /* Command From mp1 (SHORT 1) */
pGpfParms->Notify = 0; /* Notify From mp1 (SHORT 2) */
}
switch(msg)
{
/**************************************************************/
/* Things to do when the Window is first initalized */
/**************************************************************/
case WM_INITDLG:
/**************************************************************/
/* Initialize Window 'ListStaffWindow' */
/**************************************************************/
GpfDefWindowProc( hwnd, msg, mp1, mp2 );
WmInitWndListStaffWindow(pGpfParms); /* Init Dialog */
/**************************************************************/
/* Return pGpfParms Mresult */
/**************************************************************/
return (pGpfParms->mresult);
/**************************************************************/
/* Things to do when the Window is Activated/Deactivated */
/**************************************************************/
case WM_ACTIVATE:
if (SHORT1FROMMP(mp1))
WmActiveListStaffWindow(pGpfParms); /* Activate Window */
else
WmDeActiveListStaffWindow(pGpfParms); /* DeActivate Window */
return (pGpfParms->mresult);
/**************************************************************/
/* Things to do when the Window is "Show/Hide" */
/**************************************************************/
case WM_SHOW:
if (SHORT1FROMMP(mp1))
WmShowListStaffWindow(pGpfParms); /* Show Window */
else
WmHideListStaffWindow(pGpfParms); /* Hide Window */
return (pGpfParms->mresult);
/**************************************************************/
/* The application has asked for the window to be created. */
/**************************************************************/
case WM_CREATE:
DosAllocSeg(sizeof(GPFPARMS),&Selector,0); /* Getmain */
pGpfParms = MAKEP(Selector, 0); /* Set Pointer*/
WinSetWindowULong(hwnd,QWL_USER,(ULONG)pGpfParms);
memset(pGpfParms,0,sizeof(GPFPARMS)); /* Clear Area */
pGpfParms->Options |= GPF_OP_MSGINFO; /* Set Msg Info */
pGpfParms->Options |= GPF_OP_ADJUSTSIZE; /* Set AdjustSize */
hwndListStaffWindow = hwnd; /* Save Hwnd */
hwndFrameListStaffWindow = GpfGetHwndFrame(hwnd);
pGpfParms->hwnd = hwnd; /* window handle */
pGpfParms->msg = msg; /* message number */
pGpfParms->mp1 = mp1; /* 1st (packed) parms */
pGpfParms->mp2 = mp2; /* 2nd (packed) parms */
pGpfParms->hmod = hmodSample;
pGpfParms->hab = habMainTask; /* Anchor block handle */
WmCreateListStaffWindow(pGpfParms); /* Create Window */
break;
/**************************************************************/
/* The application has asked for the window to be destroyed. */
/**************************************************************/
case WM_DESTROY:
WmDestroyListStaffWindow(pGpfParms); /* Destroy Window */
hwndFrameListStaffWindow = (HWND)NULL; /* Reset HwndFrm */
hwndListStaffWindow = (HWND)NULL; /* Reset Hwnd */
/* Destroy Template , Help Instance and GpfParms */
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* The window needs painting. */
/**************************************************************/
case WM_PAINT:
/**************************************************************/
/* Obtain a cache PS */
/**************************************************************/
hps = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)&rcl );
WinFillRect(hps,&rcl,pGpfParms->BgColor); /* Fill Rect */
pGpfParms->hps = hps; /* Pass Hps ( Paint ) */
WmPaintListStaffWindow(pGpfParms); /* Paint Window */
WinEndPaint( hps ); /* Release cache PS */
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* Process ScrollBar received from the user */
/**************************************************************/
case WM_VSCROLL:
case WM_HSCROLL:
/* Set Command From mp1 */
pGpfParms->Command = SHORT1FROMMP( mp1 );
/* Set Notify From mp2 */
pGpfParms->Notify = SHORT2FROMMP( mp2 );
CommandListStaffWindow( pGpfParms ); /* Process the command */
return (pGpfParms->mresult);
/**************************************************************/
/* Process Controls received from the user */
/**************************************************************/
case WM_CONTROL:
/* Set Command From mp1 */
pGpfParms->Command = SHORT1FROMMP( mp1 );
/* Set Notify From mp1 */
pGpfParms->Notify = SHORT2FROMMP( mp1 );
CommandListStaffWindow( pGpfParms ); /* Process the command */
return (pGpfParms->mresult);
/**************************************************************/
/* Process commands received from the user */
/**************************************************************/
case WM_SYSCOMMAND:
case WM_HELP:
case WM_COMMAND:
/* Set Command From mp1 */
pGpfParms->Command = SHORT1FROMMP( mp1 );
pGpfParms->Notify = COMMAND; /* Set Notify From mp1 */
CommandListStaffWindow( pGpfParms ); /* Process the command */
if (pGpfParms->mresult)
return (pGpfParms->mresult);
/* If DID_CANCEL Dismiss Window */
if (pGpfParms->Command == DID_CANCEL)
DismissListStaffWindow(FALSE);
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
/**************************************************************/
/* All other messages are passed to the default procedure. */
/**************************************************************/
default:
/* Pass all other messages to the default window procedure */
return GpfDefWindowProc( hwnd, msg, mp1, mp2 );
}
return ((MRESULT) FALSE);
}
/**********************************************************************/
/* End of window procedure - WinProc: fnwpListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: CommandListStaffWindow */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID CommandListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) TRUE; /* Set Return Code */
/* Switch according to Control chosen */
switch( pGpfParms->Command )
{
/******************************************************************/
/* Name "ListBox". */
/* Text "Text". */
/******************************************************************/
case ID_LISTBOX:
ActionListBox(pGpfParms);
return;
/******************************************************************/
/* Name "Italic". */
/* Text "~Italic". */
/******************************************************************/
case ID_ITALIC:
ActionItalic(pGpfParms);
return;
/******************************************************************/
/* Name "Bold". */
/* Text "~Bold". */
/******************************************************************/
case ID_BOLD:
ActionBold(pGpfParms);
return;
/******************************************************************/
/* Name "UserButton". */
/* Text "About". */
/******************************************************************/
case ID_USERBUTTON:
ActionUserButton(pGpfParms);
return;
/******************************************************************/
/* Name "ButtonStaff". */
/* Text " ". */
/******************************************************************/
case ID_BUTTONSTAFF:
ActionButtonStaff(pGpfParms);
return;
/******************************************************************/
/* Name "ShowStaf". */
/* Alias "DID_OK". */
/* Text "~Show Staff". */
/******************************************************************/
case ID_SHOWSTAF:
case DID_OK:
ActionShowStaf(pGpfParms);
return;
/******************************************************************/
/* Name "Cancel". */
/* Alias "DID_CANCEL". */
/* Text "Cancel". */
/******************************************************************/
case ID_CANCEL:
case DID_CANCEL:
ActionCancel(pGpfParms);
return;
/******************************************************************/
/* Name "ButtonHelp". */
/* Text "~Help". */
/******************************************************************/
case ID_BUTTONHELP:
ActionButtonHelp(pGpfParms);
return;
}
/* Take no action for any other selections */
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: CommandListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionItalic */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionItalic( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_CLICKED:
case BN_DBLCLICKED:
case COMMAND:
/************************************************************/
/* User Function ChangeFont */
/************************************************************/
{
FONTMETRICS Metrics; /* Font metrics data structure */
LONG NoOfFonts = 1;
FATTRS SelectedFont;
HPS hps;
MRESULT mresult;
/************************************************************/
/* Query "System Font" */
/************************************************************/
hps = WinGetPS(pGpfParms->hwnd);
GpiQueryFonts(hps,
QF_PUBLIC,
NULL,
&NoOfFonts,
(LONG)sizeof(FONTMETRICS),
&Metrics);
SelectedFont.usRecordLength = sizeof(FATTRS);
SelectedFont.fsSelection = Metrics.fsSelection;
SelectedFont.lMatch = Metrics.lMatch;
strcpy(SelectedFont.szFacename, Metrics.szFacename);
SelectedFont.idRegistry = Metrics.idRegistry;
SelectedFont.usCodePage = Metrics.usCodePage;
SelectedFont.lMaxBaselineExt = Metrics.lMaxBaselineExt;
SelectedFont.lAveCharWidth = Metrics.lAveCharWidth;
SelectedFont.fsType = 0;
SelectedFont.fsFontUse = FATTR_FONTUSE_NOMIX;
mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
ID_BOLD,BM_QUERYCHECK,NULL,NULL);
if (!SHORT1FROMMR(mresult))
SelectedFont.fsSelection &= ~FATTR_SEL_BOLD;
else
SelectedFont.fsSelection |= FATTR_SEL_BOLD;
mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
ID_ITALIC,BM_QUERYCHECK,NULL,NULL);
if (!SHORT1FROMMR(mresult))
SelectedFont.fsSelection &= ~FATTR_SEL_ITALIC;
else
SelectedFont.fsSelection |= FATTR_SEL_ITALIC;
WinReleasePS(hps);
WinSendDlgItemMsg(pGpfParms->hwnd,
ID_MLE,
MLM_SETFONT,
MPFROMP( &SelectedFont ),
MPFROMSHORT( NULL ) );
}
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionBold */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionBold( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_CLICKED:
case BN_DBLCLICKED:
case COMMAND:
/************************************************************/
/* User Function ChangeFont */
/************************************************************/
{
FONTMETRICS Metrics; /* Font metrics data structure */
LONG NoOfFonts = 1;
FATTRS SelectedFont;
HPS hps;
MRESULT mresult;
/************************************************************/
/* Query "System Font" */
/************************************************************/
hps = WinGetPS(pGpfParms->hwnd);
GpiQueryFonts(hps,
QF_PUBLIC,
NULL,
&NoOfFonts,
(LONG)sizeof(FONTMETRICS),
&Metrics);
SelectedFont.usRecordLength = sizeof(FATTRS);
SelectedFont.fsSelection = Metrics.fsSelection;
SelectedFont.lMatch = Metrics.lMatch;
strcpy(SelectedFont.szFacename, Metrics.szFacename);
SelectedFont.idRegistry = Metrics.idRegistry;
SelectedFont.usCodePage = Metrics.usCodePage;
SelectedFont.lMaxBaselineExt = Metrics.lMaxBaselineExt;
SelectedFont.lAveCharWidth = Metrics.lAveCharWidth;
SelectedFont.fsType = 0;
SelectedFont.fsFontUse = FATTR_FONTUSE_NOMIX;
mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
ID_BOLD,BM_QUERYCHECK,NULL,NULL);
if (!SHORT1FROMMR(mresult))
SelectedFont.fsSelection &= ~FATTR_SEL_BOLD;
else
SelectedFont.fsSelection |= FATTR_SEL_BOLD;
mresult = WinSendDlgItemMsg(pGpfParms->hwnd,
ID_ITALIC,BM_QUERYCHECK,NULL,NULL);
if (!SHORT1FROMMR(mresult))
SelectedFont.fsSelection &= ~FATTR_SEL_ITALIC;
else
SelectedFont.fsSelection |= FATTR_SEL_ITALIC;
WinReleasePS(hps);
WinSendDlgItemMsg(pGpfParms->hwnd,
ID_MLE,
MLM_SETFONT,
MPFROMP( &SelectedFont ),
MPFROMSHORT( NULL ) );
}
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionUserButton */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionUserButton( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_PAINT:
{
/*************************************************************/
/* Paint UserButton. */
/*************************************************************/
PUSERBUTTON UsrBtn; /* UserButton Pointer */
SWP Swp; /* Size Cx Cy Button */
UCHAR String[64]; /* Work Button Text */
POINTL PointL; /* Start BitMap */
RECTL rcl; /* Rect Button */
HBITMAP Hbm; /* Work Hbitmap */
USHORT BitMapId; /* Work BitMap Id */
USHORT fsCmd; /* DrawText Option */
UsrBtn = (PUSERBUTTON) PVOIDFROMMP(pGpfParms->mp2);
WinQueryWindowPos( UsrBtn->hwnd, &Swp );
WinQueryWindowRect(UsrBtn->hwnd,&rcl);
if ((UsrBtn->fsState) & BDS_HILITED)
BitMapId = ID_SAMPLE2_BMP;
else
BitMapId = ID_SAMPLE1_BMP;
Hbm = GpiLoadBitmap(UsrBtn->hps,
hmodSample,
BitMapId,
MAKELONG(Swp.cx,0),
MAKELONG(Swp.cy,0));
PointL.x = (LONG)NULL;
PointL.y = (LONG)NULL;
WinDrawBitmap(UsrBtn->hps,Hbm,(PRECTL)NULL,&PointL,
(LONG)NULL,(LONG)NULL,DBM_IMAGEATTRS);
GpiDeleteBitmap(Hbm);
if ((UsrBtn->fsState) & BDS_DEFAULT)
WinDrawBorder( UsrBtn->hps,&rcl,1,1,
CLR_BLACK,CLR_BLACK,DB_STANDARD );
WinQueryWindowText(UsrBtn->hwnd,sizeof(String),String);
if (strlen(String)) /* String TEXT Found .... */
{ /* Yes Draw the String */
fsCmd = DT_CENTER | DT_VCENTER;
if ((UsrBtn->fsState) & BDS_DISABLED)
fsCmd = fsCmd | DT_HALFTONE;
WinDrawText(UsrBtn->hps,strlen(String),String,
&rcl,SYSCLR_WINDOWTEXT,SYSCLR_WINDOW,
fsCmd);
}
}
return;
case COMMAND:
/**************************************************************/
/* Disable Control "UserButton". */
/* Window "ListStaffWindow". */
/**************************************************************/
WinEnableWindow(WinWindowFromID( hwndListStaffWindow,
ID_USERBUTTON),
FALSE);
/**************************************************************/
/* Disable Menu/Item "About1". */
/* Window "MainWindow". */
/**************************************************************/
GpfMenuGray(hwndFrameMainWindow,ID_ABOUT1,TRUE);
/**************************************************************/
/* Show Window "AboutWindow". */
/**************************************************************/
ShowAboutWindow(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionButtonStaff */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionButtonStaff( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_PAINT:
{
/*************************************************************/
/* Paint UserButton. */
/*************************************************************/
PUSERBUTTON UsrBtn; /* UserButton Pointer */
SWP Swp; /* Size Cx Cy Button */
UCHAR String[64]; /* Work Button Text */
POINTL PointL; /* Start BitMap */
RECTL rcl; /* Rect Button */
HBITMAP Hbm; /* Work Hbitmap */
USHORT BitMapId; /* Work BitMap Id */
USHORT fsCmd; /* DrawText Option */
UsrBtn = (PUSERBUTTON) PVOIDFROMMP(pGpfParms->mp2);
WinQueryWindowPos( UsrBtn->hwnd, &Swp );
WinQueryWindowRect(UsrBtn->hwnd,&rcl);
if ((UsrBtn->fsState) & BDS_HILITED)
BitMapId = ID_SAMPLE5_BMP;
else
BitMapId = ID_SAMPLE4_BMP;
Hbm = GpiLoadBitmap(UsrBtn->hps,
hmodSample,
BitMapId,
MAKELONG(Swp.cx,0),
MAKELONG(Swp.cy,0));
PointL.x = (LONG)NULL;
PointL.y = (LONG)NULL;
WinDrawBitmap(UsrBtn->hps,Hbm,(PRECTL)NULL,&PointL,
(LONG)NULL,(LONG)NULL,DBM_IMAGEATTRS);
GpiDeleteBitmap(Hbm);
if ((UsrBtn->fsState) & BDS_DEFAULT)
WinDrawBorder( UsrBtn->hps,&rcl,1,1,
CLR_BLACK,CLR_BLACK,DB_STANDARD );
WinQueryWindowText(UsrBtn->hwnd,sizeof(String),String);
if (strlen(String)) /* String TEXT Found .... */
{ /* Yes Draw the String */
fsCmd = DT_CENTER | DT_VCENTER;
if ((UsrBtn->fsState) & BDS_DISABLED)
fsCmd = fsCmd | DT_HALFTONE;
WinDrawText(UsrBtn->hps,strlen(String),String,
&rcl,SYSCLR_WINDOWTEXT,SYSCLR_WINDOW,
fsCmd);
}
}
return;
case COMMAND:
/**************************************************************/
/* Show Window "DialogStaff". */
/**************************************************************/
ShowDialogStaff(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionShowStaf */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionShowStaf( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_CLICKED:
case BN_DBLCLICKED:
case COMMAND:
/**************************************************************/
/* Reset Default Button Window "ListStaffWindow". */
/**************************************************************/
GpfResetDefaultButton(hwndListStaffWindow);
/**************************************************************/
/* Get Selection "ListBox". */
/* Window "ListStaffWindow". */
/**************************************************************/
GetSelBoxListBox();
/**************************************************************/
/* Show Window "DialogStaff". */
/**************************************************************/
ShowDialogStaff(NULL);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionCancel */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionCancel( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_CLICKED:
case BN_DBLCLICKED:
case COMMAND:
/**************************************************************/
/* Dismiss Window Hide Window "ListStaffWindow". */
/**************************************************************/
DismissListStaffWindow(FALSE);
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionButtonHelp */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionButtonHelp( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case BN_CLICKED:
case BN_DBLCLICKED:
case COMMAND:
/**************************************************************/
/* Help Extended for Window "ListStaffWindow". */
/**************************************************************/
if (hwndHelp)
WinSendMsg( hwndHelp, HM_DISPLAY_HELP,
MPFROMSHORT( ID_LISTSTAFFWINDOW ),
0L );
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* STATIC PRIVATE FUNCTION: ActionListBox */
/* */
/* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
/* received by the window procedure. */
/* Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID ActionListBox( PGPFPARMS pGpfParms )
{
/* Switch according to Control chosen */
switch( pGpfParms->Notify )
{
case LN_ENTER: /* Catch double click on */
/**************************************************************/
/* Reset Default Button Window "ListStaffWindow". */
/**************************************************************/
GpfResetDefaultButton(hwndListStaffWindow);
/**************************************************************/
/* Simulate OK - Send Did OK to Window */
/* "ListStaffWindow". */
/*************************************************************/
WinSendMsg( hwndListStaffWindow,
WM_COMMAND, /* simulate OK */
MPFROM2SHORT( DID_OK , 0 ),
MPFROM2SHORT( CMDSRC_OTHER , 0 )
);
return;
case LN_SELECT: /* Catch click on */
/**************************************************************/
/* Get Selection "ListBox". */
/* Window "ListStaffWindow". */
/**************************************************************/
GetSelBoxListBox();
/**************************************************************/
/* Move Data To Window "ListStaffWindow". */
/**************************************************************/
MoveDataToListStaffWindow();
return;
case LN_KILLFOCUS: /* Kill Focus */
return;
case LN_SETFOCUS: /* Set Focus */
return;
case LN_SCROLL: /* Scroll */
return;
}
/* Take no action for any other selections */
}
/**********************************************************************/
/* End of Private Function */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: MoveListStaffWindowToData */
/* */
/* Move "ListStaffWindow" To Assosiate Data. */
/* */
/**********************************************************************/
BOOL MoveListStaffWindowToData ( VOID )
{
UCHAR String[32];
PUCHAR Token;
String[0] = 0; /* Null, Delete Unreferenced Local variable */
Token = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
/**********************************************************************/
/* Move "ID_CLICKNAME" To "STAFF_NAME". (VARCHAR) */
/**********************************************************************/
WinQueryWindowText( WinWindowFromID( hwndListStaffWindow,
ID_CLICKNAME),
sizeof(STAFF_NAME),
STAFF_NAME);
if (!STAFF_NAME[0]) /* If Null Data */
STAFF_NAME_N = -1; /* Set Sql Null Indicator */
/**********************************************************************/
/* Move "ID_MLE" To "STAFF_NAME". (VARCHAR) */
/**********************************************************************/
WinQueryWindowText( WinWindowFromID( hwndListStaffWindow,
ID_MLE),
sizeof(STAFF_NAME),
STAFF_NAME);
if (!STAFF_NAME[0]) /* If Null Data */
STAFF_NAME_N = -1; /* Set Sql Null Indicator */
return (TRUE);
}
/**********************************************************************/
/* End of Private Function: MoveListStaffWindowToData */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: MoveDataToListStaffWindow */
/* */
/* Move Data To Window "ListStaffWindow". */
/* */
/**********************************************************************/
BOOL MoveDataToListStaffWindow ( VOID )
{
UCHAR String[32];
PUCHAR Token;
String[0] = 0; /* Null, Delete Unreferenced Local variable */
Token = (PUCHAR)NULL; /* Null, Delete Unreferenced Local variable */
/**********************************************************************/
/* Move "STAFF_NAME" To "ID_CLICKNAME". (VARCHAR) */
/**********************************************************************/
WinSendDlgItemMsg(hwndListStaffWindow,
ID_CLICKNAME,
EM_SETTEXTLIMIT,
MPFROMSHORT( sizeof(STAFF_NAME) -1 ),
MPFROMSHORT( NULL ) );
if (STAFF_NAME_N < 0) /* If Null Indicator */
STAFF_NAME[0] = 0; /* Set Null Data */
WinSetWindowText( WinWindowFromID( hwndListStaffWindow,
ID_CLICKNAME),
STAFF_NAME);
/**********************************************************************/
/* Move "STAFF_NAME" To "ID_MLE". (VARCHAR) */
/**********************************************************************/
WinSendDlgItemMsg(hwndListStaffWindow,
ID_MLE,
EM_SETTEXTLIMIT,
MPFROMSHORT( sizeof(STAFF_NAME) -1 ),
MPFROMSHORT( NULL ) );
if (STAFF_NAME_N < 0) /* If Null Indicator */
STAFF_NAME[0] = 0; /* Set Null Data */
WinSetWindowText( WinWindowFromID( hwndListStaffWindow,
ID_MLE),
STAFF_NAME);
return (TRUE);
}
/**********************************************************************/
/* End of Private Function: MoveDataToListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmInitWndListStaffWindow */
/* */
/* Wm Init Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmInitWndListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
/**************************************************************/
/* Load ListBox / ComboBox "ListBox". */
/* Window "ListStaffWindow". */
/**************************************************************/
/* Send Msg for Execute LoadBoxListBox(); */
GpfExecuteSql(LoadBoxListBox,hwndListStaffWindow);
/* Wait Async Execute LoadBoxListBox(); */
GpfSqlWait(hwndListStaffWindow);
/**************************************************************/
/* Get Selection "ListBox". */
/* Window "ListStaffWindow". */
/**************************************************************/
GetSelBoxListBox();
/**************************************************************/
/* Move Data To Window "ListStaffWindow". */
/**************************************************************/
MoveDataToListStaffWindow();
}
/**********************************************************************/
/* End of Private Function: WmInitWndListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmActiveListStaffWindow */
/* */
/* Wm Activate Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmActiveListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmActiveListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmDeActiveListStaffWindow */
/* */
/* DeActivate Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmDeActiveListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmDeActiveListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmCreateListStaffWindow */
/* */
/* Wm Create Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmCreateListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmCreateListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmDestroyListStaffWindow */
/* */
/* Wm Destroy Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmDestroyListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmDestroyListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmPaintListStaffWindow */
/* */
/* Wm Paint Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmPaintListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmPaintListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmShowListStaffWindow */
/* */
/* Wm Show Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmShowListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmShowListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: WmHideListStaffWindow */
/* */
/* Wm Hide Window "ListStaffWindow". */
/* */
/**********************************************************************/
static VOID WmHideListStaffWindow ( PGPFPARMS pGpfParms )
{
pGpfParms->mresult = (MRESULT) FALSE; /* Set Return Code */
}
/**********************************************************************/
/* End of Private Function: WmHideListStaffWindow */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: LoadBoxListBox */
/* */
/* Load Box To ID_LISTBOX */
/* */
/**********************************************************************/
LONG LoadBoxListBox( VOID )
{
UCHAR String[256];
PUCHAR Token = NULL;
SHORT i;
/***************************************************/
/* clear out both list boxes in preperation for a */
/* refresh given the new environment */
/***************************************************/
WinSendDlgItemMsg(hwndListStaffWindow,
ID_LISTBOX,
LM_DELETEALL,
MPFROMSHORT( NULL ),
MPFROMSHORT( NULL ) );
/********************************/
/* Declare Sql Cursor */
/********************************/
EXEC SQL DECLARE CURSOR_10055 CURSOR FOR SELECT
ID,
NAME,
DEPT,
JOB,
SALARY,
COMM
FROM STAFF ;
/********************************/
/* Open Sql Cursor */
/********************************/
/* Position cursor at first record */
EXEC SQL OPEN CURSOR_10055;
GpfDisplaySqlError(&sqlca);
while (!sqlca.sqlcode)
{
STAFF_ID = 0;
STAFF_NAME[0] = 0;
STAFF_DEPT = 0;
STAFF_JOB[0] = 0;
STAFF_SALARY = 0.0;
STAFF_COMM = 0.0;
/******************************************************/
/* Fetch next row inorder to properly position cursor */
/******************************************************/
EXEC SQL FETCH CURSOR_10055 INTO
:STAFF_ID,
:STAFF_NAME :STAFF_NAME_N,
:STAFF_DEPT :STAFF_DEPT_N,
:STAFF_JOB :STAFF_JOB_N,
:STAFF_SALARY :STAFF_SALARY_N,
:STAFF_COMM :STAFF_COMM_N;
GpfDisplaySqlError(&sqlca);
if (!sqlca.sqlcode)
{
/********************************/
/* Add Item to ListBox/ComboBox */
/********************************/
i = 0;
i += sprintf(&String[i]," %6d\xFF",STAFF_ID);
i += sprintf(&String[i],"%-9s\xFF",STAFF_NAME);
i += sprintf(&String[i]," %6d\xFF",STAFF_DEPT);
i += sprintf(&String[i],"%-5s\xFF",STAFF_JOB);
i += sprintf(&String[i]," %7.2f\xFF",STAFF_SALARY);
Token = strrchr(String,'.'); /* Search US Decimal */
if (Token) /* If Found */
*(Token) = sDecimal[0]; /* Change to National Decimal */
i += sprintf(&String[i]," %7.2f\xFF",STAFF_COMM);
Token = strrchr(String,'.'); /* Search US Decimal */
if (Token) /* If Found */
*(Token) = sDecimal[0]; /* Change to National Decimal */
WinSendDlgItemMsg ( hwndListStaffWindow,
ID_LISTBOX,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP( String ));
}
}
/********************************/
/* Close Sql Cursor */
/********************************/
EXEC SQL CLOSE CURSOR_10055;
GpfDisplaySqlError(&sqlca);
/********************************/
/* Commit and Drop Lock */
/********************************/
EXEC SQL COMMIT WORK; /* Drop Table any table locks */
GpfDisplaySqlError(&sqlca);
/***************************************************/
/* Make the first list item initially-selected. */
/***************************************************/
WinSendDlgItemMsg(hwndListStaffWindow,
ID_LISTBOX,
LM_SELECTITEM,
MPFROMSHORT(0), /* First item index value */
MPFROMSHORT( TRUE ) );
return (LONG)NULL;
}
/**********************************************************************/
/* End of Private Function - LoadBoxListBox */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* */
/* PRIVATE FUNCTION: GetSelBoxListBox */
/* */
/* GetSelection Box To ID_LISTBOX */
/* */
/**********************************************************************/
BOOL GetSelBoxListBox( VOID )
{
UCHAR String[256];
SHORT Position;
PUCHAR Token = (PUCHAR)NULL;
PUCHAR Token1 = (PUCHAR)NULL;
PUCHAR EndToken = (PUCHAR)NULL;
MRESULT mresult;
/*********************************************************************/
/* Get the first selection item. */
/*********************************************************************/
mresult = WinSendDlgItemMsg(
hwndListStaffWindow,
ID_LISTBOX,
LM_QUERYSELECTION,
MPFROM2SHORT( LIT_END, 0 ),
MPFROMSHORT( NULL ) );
Position = SHORT1FROMMR(mresult);
/*********************************************************************/
/* When nothing was selected by the user. */
/*********************************************************************/
if ((Position == LIT_NONE) || (Position == LIT_ERROR))
return FALSE;
/*********************************************************************/
/* When something was selected by the user. */
/*********************************************************************/
WinSendDlgItemMsg(hwndListStaffWindow,
ID_LISTBOX,
LM_QUERYITEMTEXT,
MPFROM2SHORT(Position,sizeof(String)-1),
MPFROMP( String ) );
Token = String;
/**********************************************************************/
/* Move selected Item by the user. */
/**********************************************************************/
EndToken = strchr(Token,'\xFF');
if(!EndToken)
return FALSE;
*EndToken = 0; /* Set Null Separator */
STAFF_ID = atoi(Token);
Token = (EndToken+1); /* Token = EndToken + Separator */
/**********************************************************************/
/* Move selected Item by the user. */
/**********************************************************************/
EndToken = strchr(Token,'\xFF');
if(!EndToken)
return FALSE;
*EndToken = 0; /* Set Null Separator */
strcpy(STAFF_NAME,Token);
if (!strlen(Token))
STAFF_NAME_N = -1;
Token = (EndToken+1); /* Token = EndToken + Separator */
/**********************************************************************/
/* Move selected Item by the user. */
/**********************************************************************/
EndToken = strchr(Token,'\xFF');
if(!EndToken)
return FALSE;
*EndToken = 0; /* Set Null Separator */
STAFF_DEPT = atoi(Token);
if (!strlen(Token))
STAFF_DEPT_N = -1;
Token = (EndToken+1); /* Token = EndToken + Separator */
/**********************************************************************/
/* Move selected Item by the user. */
/**********************************************************************/
EndToken = strchr(Token,'\xFF');
if(!EndToken)
return FALSE;
*EndToken = 0; /* Set Null Separator */
strcpy(STAFF_JOB,Token);
if (!strlen(Token))
STAFF_JOB_N = -1;
Token = (EndToken+1); /* Token = EndToken + Separator */
/**********************************************************************/
/* Move selected Item by the user. */
/**********************************************************************/
EndToken = strchr(Token,'\xFF');
if(!EndToken)
return FALSE;
*EndToken = 0; /* Set Null Separator */
Token1 = strrchr(Token,sDecimal[0]); /* Search National Decimal */
if (Token1) /* If Found */
*(Token1) = '.'; /* Change To US Decimal */
STAFF_SALARY = atof(Token);
if (!strlen(Token))
STAFF_SALARY_N = -1;
Token = (EndToken+1); /* Token = EndToken + Separator */
/**********************************************************************/
/* Move selected Item by the user. */
/**********************************************************************/
EndToken = strchr(Token,'\xFF');
if(!EndToken)
return FALSE;
*EndToken = 0; /* Set Null Separator */
Token1 = strrchr(Token,sDecimal[0]); /* Search National Decimal */
if (Token1) /* If Found */
*(Token1) = '.'; /* Change To US Decimal */
STAFF_COMM = atof(Token);
if (!strlen(Token))
STAFF_COMM_N = -1;
Token = (EndToken+1); /* Token = EndToken + Separator */
return TRUE;
}
/**********************************************************************/
/* End of Private Function - GetSelBoxListBox */
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/* CreateAboutTask: */
/* Allocate a stack for the Window thread, and set it running. */
/**********************************************************************/
VOID CreateAboutTask( VOID )
{
SEL SelAboutTaskStack;
DosAllocSeg( STACKSIZE, &SelAboutTaskStack, 0 );
_beginthread ( AboutTaskEntryPoint,
MAKEP( SelAboutTaskStack, 0),
STACKSIZE ,NULL);
}
/**********************************************************************/
/* AboutTaskEntryPoint: */
/* Thread "AboutTask" */
/**********************************************************************/
VOID cdecl AboutTaskEntryPoint ( PVOID Arg )
{
QMSG qmsgAboutTask;
Arg = Arg;
habAboutTask = WinInitialize( (USHORT)NULL );
hmqAboutTask = WinCreateMsgQueue( habAboutTask, (SHORT)1024 );
/********************************************************************/
/* Main message-processing loop - get and dispatch messages until */
/* WM_QUIT received */
/********************************************************************/
while( WinGetMsg( habAboutTask, &qmsgAboutTask, (HWND)NULL, 0, 0 ) )
WinDispatchMsg( habAboutTask, &qmsgAboutTask );
/********************************************************************/
/* Close Thread */
/********************************************************************/
WinDestroyMsgQueue( hmqAboutTask );
WinTerminate( habAboutTask );
DosExit( EXIT_THREAD, 0 );
}