home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Product
/
Product.zip
/
DBDEMO.ZIP
/
DEMOFLS.ZIP
/
DBDEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-09
|
91KB
|
2,150 lines
/************************************************************************/
/* DATABASE PERFORMANCE CONCEPTS AND TECHNIQUE DEMONSTRATION PROGRAM */
/* PM DRIVER MODULE */
/************************************************************************/
/************************************************************************/
/* Source File : DBDEMO.C */
/* Use defined Include Files: DBDEMO.H, DBDLGDEM.h DBCOMM.H */
/************************************************************************/
/************************************************************************/
/* PM Functions: */
/* main(argc, argv) */
/* - main procedure call for PM driver program */
/* - initializes message queue and main window */
/* - calls startdb() */
/* WndProc(hWnd, message, mp1, mp2) */
/* OPENMsgProc(hWndDlg, message, mp1, mp2) */
/* PARMMsgProc(hWndDlg, message, mp1, mp2) */
/* CLOSEMsgProc(hWndDlg, message, mp1, mp2) */
/* SHOWTIMEMsgProc(hWndDlg, message, mp1, mp2) */
/* EDITBOXMsgProc(hWndDlg, message, mp1, mp2) */
/* DDOCMENUsgProc(hWndDlg, message, mp1, mp2) */
/* DOCRDSMsgProc(hWndDlg, message, mp1, mp2) */
/* DOCPARMSMsgProc(hWndDlg, message, mp1, mp2) */
/* */
/* SetDlgText(Filename) */
/* - sets the text from file Filename to the dialog window */
/* PMErrChk(hAB, hWnd, usermsg) */
/* */
/* Database Functions: */
/* SQLthread(hWndDlg) */
/* - starts a separate thread for database demo programs */
/* StartDB() */
/* - issues START USING DATABASE command */
/* StopDB() */
/* - issues STOP USING DATABASE command */
/************************************************************************/
#define EXTERN
/************************************************************************/
/* HEADER FILES - USER DEFINED */
/************************************************************************/
#include "DBDEMO.h"
#include "dbcomm.h"
#include "dbdemodb.h" /* user defined variables (non window) */
#include "dlgdbdem.h"
SHORT cdecl main(argc, argv)
int argc;
char *argv[];
{
QMSG qmsg; /* MSG structure to store your messages */
PID pid; /* Process identifier for adding name to switch list */
TID tid; /* Thread identifier */
static CHAR szTitle[26];
/* The WinInitialize routine initializes the Presentation Manager */
/* facilities for use by this application and returns a handle to the */
/* anchor block assigned to the application by PM. */
StartDB(&sqlca);
if((hAB = WinInitialize(0)) == 0)
return(FALSE);
/* The WinCreateMsgQueue call creates a message queue for this application*/
if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
return(FALSE);
/* The following function registers the classes of all application windows*/
if(!cwRegisterClass())
return(FALSE);
/* If the application's Initialization Panel is not already shown, display*/
/* it on the desktop window before any other application window is shown. */
if(!WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, (PFNWP)INITMsgProc, 0,
IDLG_INIT, (PBYTE)HWND_DESKTOP))
DosExit(0, 1);
/**************************************************************************/
/* IPF Initialization Structure */
/**************************************************************************/
hiDBDEMOHelp.cb = sizeof(HELPINIT); /* size of init structure */
hiDBDEMOHelp.ulReturnCode = 0;
hiDBDEMOHelp.pszTutorialName = 0; /* no tutorial */
hiDBDEMOHelp.phtHelpTable = (PVOID)(0xffff0000 | ID_DBDEMO);
hiDBDEMOHelp.hmodAccelActionBarModule = 0;
hiDBDEMOHelp.idAccelTable = 0;
hiDBDEMOHelp.idActionBar = 0;
hiDBDEMOHelp.pszHelpWindowTitle = "DBDEMO";
hiDBDEMOHelp.hmodHelpTableModule = 0;
hiDBDEMOHelp.usShowPanelId = 0;
hiDBDEMOHelp.pszHelpLibraryName = "DBDEMO.HLP";
/**************************************************************************/
/* Create Instance of IPF */
/**************************************************************************/
hWndDBDEMOHelp = WinCreateHelpInstance(hAB, &hiDBDEMOHelp);
if(!hWndDBDEMOHelp || hiDBDEMOHelp.ulReturnCode)
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ)"No help is available.",
(PSZ) szAppName,
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hWndDBDEMOHelp);
}
/* The CreateWindow function creates a frame window for this application's*/
/* top window, and set the window's size and location as appropriate. */
WinLoadString(hAB, 0, IDS_TITLE, 26, szTitle);
hWndFrame = cwCreateWindow((HWND)HWND_DESKTOP,
FCF_TITLEBAR |
FCF_SYSMENU |
FCF_MINBUTTON |
FCF_MAXBUTTON |
FCF_SIZEBORDER |
FCF_MENU |
FCF_SHELLPOSITION,
szAppName,
szTitle,
ID_DBDEMO,
0, 0,
0, 0,
&hWndClient,
0L, SWP_MAXIMIZE | SWP_SHOW);
if(hWndFrame == 0)
return(FALSE);
/**************************************************************************/
/* Associate Instance of IPF */
/**************************************************************************/
if(hWndDBDEMOHelp)
WinAssociateHelpInstance(hWndDBDEMOHelp, hWndFrame);
/* The following inline routine fills out the application's switch control*/
/* structure with the appropriate information to add the application's */
/* name to the OS/2 Task Manager List, a list of the jobs currently */
/* running on the computer. */
WinQueryWindowProcess(hWndFrame, &pid, &tid);
Swctl.hwnd = hWndFrame; /* Frame window handle */
Swctl.idProcess = pid; /* Process identifier */
Swctl.uchVisibility = SWL_VISIBLE; /* visibility */
Swctl.fbJump = SWL_JUMPABLE; /* Jump indicator */
strcpy(Swctl.szSwtitle, szTitle); /* Frame window title */
hSwitch = WinAddSwitchEntry(&Swctl);
/* The following is the message loop for the application. */
while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
WinDispatchMsg(hAB,(PQMSG)&qmsg);
/* Perform clean up before exiting application. */
/**************************************************************************/
/* Destroy Instance of IPF */
/**************************************************************************/
if(hWndDBDEMOHelp)
WinDestroyHelpInstance(hWndDBDEMOHelp);
/* The following routine destroys the application's frame window (which */
/* also destroys its child windows), destroys its message queue, and */
/* disassociates the application from the Presentation Manager system. */
WinDestroyWindow(hWndFrame); /* Destroy the frame window */
WinDestroyMsgQueue(hMQ); /* Destroy this application's message queue */
WinTerminate(hAB); /* Terminate this application's use of the */
/* Presentation Manager resources */
} /* end of main */
/***************************************************************************/
/* */
/* Main Window Procedure */
/* */
/* This procedure provides service routines for the general PM events */
/* (messages) that PM sends to the window, as well as the user */
/* initiated events (messages) that are generated when the user selects */
/* the action bar and pulldown menu controls or the corresponding */
/* keyboard accelerators. */
/* */
/***************************************************************************/
MRESULT EXPENTRY WndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{ /* Beginning of message processor */
HPS hPS; /* Handle for the Presentation Space */
RECTL rClient; /* Handle to rectangle formed by client area */
USHORT rc; /* common return code value */
switch(message)
{
case WM_COMMAND:
/* The PM messages for action bar and pulldown menu items are */
/* processed in this routine. */
switch(SHORT1FROMMP(mp1))
{
case IDM_D_STARTUSING:
StartDB(&sqlca);
break;
case IDM_D_STOPUSING:
StopDB(&sqlca);
break;
case IDM_H_HELPFORHELP:
if(hWndDBDEMOHelp)
WinSendMsg(hWndDBDEMOHelp, HM_DISPLAY_HELP, 0L, 0L);
break;
case DOCM_DDOCS: /* Control text: "Demo Docs" */
hWndDDOCMENU = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)DDOCMENUMsgProc,
0, IDLG_DDOCMENU, (PBYTE)hWnd);
break;
case DOCM_PTECH: /* Control text: "Perf Techniques" */
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_ptech1);
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_ptech2, eboxh_ptech3);
rc = SetDlgText("dbptech.txt");
if(rc)
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWnd);
break;
case DOCM_PARMS: /* Control text: "Parameter Tuning" */
hWndDOCPARMS = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)DOCPARMSMsgProc,
0, IDLG_DOCPARMS, (PBYTE)hWnd);
break;
case DOCM_RDS: /* Control text: "RDS Docs" */
hWndDOCRDS = WinLoadDlg(HWND_DESKTOP, hWnd, (PFNWP)DOCRDSMsgProc,
0, IDLG_DOCRDS, (PBYTE)hWnd);
break;
case DEMOM_ARI: /* Control text: "A R I" */
demo_num = DEMO_ARI ;
strcpy(temp_timeh_heading1, timeh_ari1 );
strcpy(temp_timeh_heading2, timeh_ari2 );
strcpy(temp_timeh_heading3, timeh_ari3 );
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWnd);
break;
case DEMOM_RBLOCK: /* Control text: "Record Blocking" */
demo_num = DEMO_RBLOCK ;
strcpy(temp_timeh_heading1, timeh_rblock1 );
strcpy(temp_timeh_heading2, timeh_rblock2 );
strcpy(temp_timeh_heading3, timeh_rblock3 );
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWnd);
break;
case DEMOM_STATDYN: /* Control text: "Static vs Dynamic" */
demo_num = DEMO_STATDYN ;
strcpy(temp_timeh_heading1, timeh_statdyn1 );
strcpy(temp_timeh_heading2, timeh_statdyn2 );
strcpy(temp_timeh_heading3, timeh_statdyn3 );
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWnd);
break;
case DEMOM_INDICES: /* Control text: "I N D I C E S" */
demo_num = DEMO_INDICES ;
strcpy(temp_timeh_heading1, timeh_indices1 );
strcpy(temp_timeh_heading2, timeh_indices2 );
strcpy(temp_timeh_heading3, timeh_indices3 );
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWnd, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWnd);
break;
case MMENU_EXIT: /* Control text: "EXIT" */
WinSendMsg(hWnd, WM_CLOSE, MPFROMSHORT(WM_CLOSE), 0L);
break;
case MMENU_HELP: /* Control text: "HELP" */
break;
default:
break; /* End of default case for switch(mp1) */
}
break; /* End of WM_COMMAND */
case WM_CONTROL:
break; /* End of WM_COMMAND */
case HM_QUERY_KEYS_HELP:
/* If the user requests Keys Help from the help pulldown, */
/* IPF sends the HM_QUERY_KEYS_HELP message to the application, */
/* which should return the panel id of the Keys Help panel */
return((MRESULT)999);
break;
case HM_ERROR:
/* If an IPF error occurs, an HM_ERROR message will be sent to */
/* the application. */
if(hWndDBDEMOHelp && ((ULONG)mp1) == HMERR_NO_MEMORY)
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Terminated Due to Error",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hWndDBDEMOHelp);
}
else
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Error Occurred",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
}
break;
case WM_CREATE:
{
PVOID pControlData;
PCREATESTRUCT pCreateStruct;
pControlData = (PVOID)PVOIDFROMMP(mp1);
pCreateStruct = (PCREATESTRUCT)PVOIDFROMMP(mp2);
}
cwCreateClientControls(hWnd);
cwSetInitDlgStatus(hWnd);
break; /* End of WM_CREATE */
case WM_MOUSEMOVE:
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break;
case WM_SIZE: /* code for sizing client area */
break; /* End of WM_SIZE */
case WM_PAINT: /* code for the window's client area */
/* Obtain a handle to a cache presentation space */
hPS = WinBeginPaint(hWnd, 0, 0);
/* Determine the size of the client area */
WinQueryWindowRect(hWnd, &rClient);
/* Fill the background with the default background color */
WinFillRect(hPS, &rClient, CLR_BACKGROUND);
/* return presentation space to state before WinBeginPaint */
WinEndPaint(hPS);
break; /* End of WM_PAINT */
case WM_INITMENU:
/* Occurs when a menu is being initilaized. */
/* A window message sent when a menu is about to become active, */
/* allowing the application to modify the menu before it is */
/* displayed. */
/* */
/* Parameters: */
/* MenuID - low word of mp1 */
/* Specifies the menu item identifier. */
/* */
/* hMenu - low and high word of mp2 */
/* Identifies the menu. */
/* */
/* Return Value: 0 if this message is processed. */
MenuID = SHORT1FROMMP(mp1);
hMenu = (HWND)mp2;
break; /* End of case WM_INITMENU */
case WM_CLOSE: /* close the window */
if(hWnd != hWndClient)
break;
cwFreeDlgMemory(hWnd);
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of WM_CLOSE */
default:
/* For any message for which you don't specifically provide a */
/* service routine, you should return the message to PM using */
/* the WinDefWindowProc function. */
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of default */
}
return(0L);
} /* End of WndProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
//* /** INSERT COD HERE TO EXIT FROM THE PROGRAM, DESTROY WINDOW ETC. */
/***************************************************************************/
MRESULT EXPENTRY INITMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static INT iLogoTime;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
iLogoTime = WinQueryProfileInt(hAB, "PM_ControlPanel",
"LogoDisplayTime", -1);
if(iLogoTime == 0)
{
WinDismissDlg(hWndDlg, TRUE);
break;
}
if(iLogoTime == -1)
break;
WinStartTimer(hAB, hWndDlg, ID_LOGO_TIMER, iLogoTime);
break; /* End of WM_INITDLG */
case WM_TIMER:
WinStopTimer(hAB, hWndDlg, ID_LOGO_TIMER);
WinDismissDlg(hWndDlg, TRUE);
break;
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "ENTER" */
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "ESC" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of INITMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/***************************************************************************/
MRESULT EXPENTRY DDOCMENUMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
USHORT rc;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DDOCM_ARI: /* Button text: "A R I Docs" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_ari1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_ari2, eboxh_ari3);
// strcpy( temp_ebox_heading3, eboxh_ari3 );
rc = SetDlgText("ari.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DDOCM_STATDYN: /* Button text: "Static vs Dynamic" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_statdyn1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_statdyn2, eboxh_statdyn3);
// strcpy( temp_ebox_heading3, eboxh_statdyn3 );
rc = SetDlgText("stat_dyn.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DDOCM_RBLOCK: /* Button text: "Record Blocking " */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_rblock1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_rblock2, eboxh_rblock3);
// strcpy( temp_ebox_heading3, eboxh_rblock3 );
rc = SetDlgText("rblock.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DDOCM_INDICES: /* Button text: "INDICES" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_indices1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_indices2, eboxh_indices3);
// strcpy( temp_ebox_heading3, eboxh_indices3 );
rc = SetDlgText("indices.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DID_CANCEL: /* Button text: "CANCEL" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDestroyWindow(hWndDlg);
hWndDDOCMENU = 0;
break;
case DDOCM_HELP: /* Button text: "HELP" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of DDOCMENUMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/***************************************************************************/
MRESULT EXPENTRY SHOWTIMEMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static CHAR szWorkBuf[50];
static HWND hWndParent;
SHOWTIMEStruct FAR *Showtime;
switch(message)
{
case WM_INITDLG:
Showtime = (SHOWTIMEStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SHOWTIME);
hWndParent = (HWND)mp2;
Showtime->num_of_iterations = DEFAULT_NUM_OF_ITERATIONS ;
num_runs = (Showtime->num_of_iterations);
/* Initialize entry field control: num_of_iterations */
itoa(Showtime->num_of_iterations, szWorkBuf, 10);
WinSetDlgItemText(hWndDlg, STIME_ITERFIELD, szWorkBuf);
/* Initialize entry field control: stime_time1 */
WinSendDlgItemMsg(hWndDlg, STIME_TIME1, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
if(Showtime->stime_time1[0])
WinSetDlgItemText(hWndDlg, STIME_TIME1, Showtime->stime_time1);
/* Initialize entry field control: stime_time2 */
WinSendDlgItemMsg(hWndDlg, STIME_TIME2, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
if(Showtime->stime_time2[0])
WinSetDlgItemText(hWndDlg, STIME_TIME2, Showtime->stime_time2);
/* Initialize entry field control: stime_htxt1 */
WinSendDlgItemMsg(hWndDlg, STIME_HTXT1, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
strcpy(&(Showtime->stime_htxt1[0]), temp_timeh_heading1 );
if(Showtime->stime_htxt1[0])
WinSetDlgItemText(hWndDlg, STIME_HTXT1, Showtime->stime_htxt1);
WinSetDlgItemText(hWndDlg, STIME_HTXT1, temp_timeh_heading1 );
/* Initialize entry field control: stime_htxt2 */
WinSendDlgItemMsg(hWndDlg, STIME_HTXT2, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
strcpy(&(Showtime->stime_htxt2[0]), temp_timeh_heading2 );
if(Showtime->stime_htxt2[0])
WinSetDlgItemText(hWndDlg, STIME_HTXT2, Showtime->stime_htxt2);
WinSetDlgItemText(hWndDlg, STIME_HTXT2, temp_timeh_heading2 );
/* Initialize entry field control: stime_htxt3 */
WinSendDlgItemMsg(hWndDlg, STIME_HTXT3, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
strcpy(&(Showtime->stime_htxt3[0]), temp_timeh_heading3 );
if(Showtime->stime_htxt3[0])
WinSetDlgItemText(hWndDlg, STIME_HTXT3, Showtime->stime_htxt3);
/* Initialize entry field control: stime_dname1 */
WinSendDlgItemMsg(hWndDlg, STIME_DNAME1, EM_SETTEXTLIMIT, MPFROMSHORT(15), 0L);
if(Showtime->stime_dname1[0])
WinSetDlgItemText(hWndDlg, STIME_DNAME1, Showtime->stime_dname1);
/* Initialize entry field control: stime_dname2 */
WinSendDlgItemMsg(hWndDlg, STIME_DNAME2, EM_SETTEXTLIMIT, MPFROMSHORT(15), 0L);
if(Showtime->stime_dname2[0])
WinSetDlgItemText(hWndDlg, STIME_DNAME2, Showtime->stime_dname2);
WinSetDlgItemText(hWndDlg, STIME_HTXT3, temp_timeh_heading3 );
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case STIME_ITERFIELD: /* Entry field variable: "num_of_iterations" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
{
/* Validate the field */
static char buffer[80];
WinQueryDlgItemText(hWndDlg, STIME_ITERFIELD,
sizeof(buffer), buffer);
if(buffer[0]==0x00)
break;
if(sfValidate && !cwNumericValidate(buffer))
WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
//mycode b
num_runs = atoi(buffer);
//mycode e
}
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_TIME1: /* Entry field variable: "stime_time1" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_TIME2: /* Entry field variable: "stime_time2" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_HTXT1: /* Entry field variable: "stime_htxt1" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_HTXT2: /* Entry field variable: "stime_htxt2" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_HTXT3: /* Entry field variable: "stime_htxt3" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_DNAME1: /* Entry field variable: "stime_dname1" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case STIME_DNAME2: /* Entry field variable: "stime_dname2" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case STIME_START: /* Button text: "START" */
// #include "uthnew.INC"
{
// Clear DBOX
szWorkBuf[0] = '\0';
fSuccess = WinSetDlgItemText(hWndDlg, STIME_TIME1, szWorkBuf);
fSuccess = WinSetDlgItemText(hWndDlg, STIME_TIME2, szWorkBuf);
fSuccess = WinSetDlgItemText(hWndDlg, STIME_DNAME1, szWorkBuf);
fSuccess = WinSetDlgItemText(hWndDlg, STIME_DNAME2, szWorkBuf);
strcpy(szWorkBuf,"PROCESSING...PLEASE WAIT!!");
fSuccess = WinSetDlgItemText(hWndDlg,STIME_TIME1,szWorkBuf);
}
WAITING = TRUE;
// Call SQC program
if( NULL == (stack = malloc (STACKSIZE)))
{
WinAlarm(HWND_DESKTOP, WA_ERROR);
return(0);
}
if(-1 == (tidSQL = _beginthread(SQLthread, stack,
STACKSIZE, hWndDlg)))
{
WinAlarm(HWND_DESKTOP, WA_ERROR);
return(0);
}
break;
case DID_OK: /* Button text: "OK" */
Showtime = (SHOWTIMEStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SHOWTIME);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_ITERFIELD, 50, szWorkBuf);
Showtime->num_of_iterations = atoi(szWorkBuf);
num_runs = (Showtime->num_of_iterations);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_TIME1,
sizeof(Showtime->stime_time1),
Showtime->stime_time1);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_TIME2,
sizeof(Showtime->stime_time2),
Showtime->stime_time2);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_HTXT1,
sizeof(Showtime->stime_htxt1),
Showtime->stime_htxt1);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_HTXT2,
sizeof(Showtime->stime_htxt2),
Showtime->stime_htxt2);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_HTXT3,
sizeof(Showtime->stime_htxt3),
Showtime->stime_htxt3);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_DNAME1,
sizeof(Showtime->stime_dname1),
Showtime->stime_dname1);
/* Query the string value in the entry field control and */
/* move the string value to the dialog structure variable */
WinQueryDlgItemText(hWndDlg, STIME_DNAME2,
sizeof(Showtime->stime_dname2),
Showtime->stime_dname2);
//mycode b
Showtime->num_of_iterations = DEFAULT_NUM_OF_ITERATIONS ;
num_runs = DEFAULT_NUM_OF_ITERATIONS;
szWorkBuf[0] = '\0';
Showtime->stime_time1[0] = '\0';
Showtime->stime_time2[0] = '\0';
Showtime->stime_htxt1[0] = '\0';
Showtime->stime_htxt2[0] = '\0';
Showtime->stime_htxt3[0] = '\0';
Showtime->stime_dname1[0] = '\0';
Showtime->stime_dname2[0] = '\0';
//mycode e
WinDestroyWindow(hWndDlg);
hWndSHOWTIME = 0;
break;
case STIME_HELP: /* Button text: "HELP" */
break;
// This message is received when the database program ends
// The times are displayed
case DISPLAY_TIME: /* message to display time */
WAITING = FALSE;
WinAlarm(HWND_DESKTOP, WA_NOTE);
szWorkBuf[0] = '\0';
// Display timing data
// --- demo time #1
sprintf(szWorkBuf, "%14.14s", Timetext[0].demoname);
fSuccess = WinSetDlgItemText(hWndDlg,STIME_DNAME1,szWorkBuf);
sprintf(szWorkBuf," %5.2f secs", Timetext[0].demotime);
fSuccess = WinSetDlgItemText(hWndDlg,STIME_TIME1,szWorkBuf);
// --- demo time #2
sprintf(szWorkBuf, "%14.14s", Timetext[1].demoname);
fSuccess = WinSetDlgItemText(hWndDlg,STIME_DNAME2,szWorkBuf);
sprintf(szWorkBuf," %5.2f secs", Timetext[1].demotime);
fSuccess = WinSetDlgItemText(hWndDlg,STIME_TIME2,szWorkBuf);
break;
// unsuccessful completion of demo
case DEMO_DIED: // Process Msg DEMO_DIED
sprintf (szWorkBuf, "Demo failed , error code = %ld", error_sql);
WinMessageBox ( HWND_DESKTOP,
hWndClient,
szWorkBuf,
"User Message",
0,
MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
WinDismissDlg(hWndDlg, TRUE);
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinDismissDlg(hWndDlg, FALSE);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of SHOWTIMEMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/***************************************************************************/
MRESULT EXPENTRY EDITBOXMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
EDITBOXStruct FAR *Editbox;
//mycode b
const char *pszFont = "8.Courier";
//mycode e
switch(message)
{
case WM_INITDLG:
Editbox = (EDITBOXStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_EDITBOX);
hWndParent = (HWND)mp2;
/* Initialize entry field control: ebox_heading1 */
WinSendDlgItemMsg(hWndDlg, EBOX_H, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
// copy the appropriate headings to the display structure
strcpy(Editbox->ebox_heading1 , temp_ebox_heading1);
// strcpy(Editbox->ebox_heading2 , temp_ebox_heading2);
// strcpy(Editbox->ebox_heading3 , temp_ebox_heading3);
if(Editbox->ebox_heading1[0])
WinSetDlgItemText(hWndDlg, EBOX_H, Editbox->ebox_heading1);
//mycode b
/* set up the txt for main display window */
WinSetPresParam(hWndDlg, PP_FONTNAMESIZE, strlen(pszFont) +1, pszFont);
if(!WinSetDlgItemText(hWndDlg, EBOX_HTEXT1, temp_ebox_heading2))
PMErrChk(hAB, HWND_DESKTOP, "WinSetDlgItemText() failed!");
if(!WinSetDlgItemText(hWndDlg, EBOX_MLE, pszDisplayTxt))
PMErrChk(hAB, HWND_DESKTOP, "WinSetDlgItemText() failed!");
if(pszDisplayTxt != NULL)
free(pszDisplayTxt);
//mycode e
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case EBOX_MLE: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case EBOX_H: /* Entry field variable: "ebox_heading1" */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case EBOX_HTEXT1: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case EBOX_PMENU: /* Button text: "Previous menu" */
WinDestroyWindow(hWndDlg);
hWndEDITBOX = 0;
break;
case EBOX_MMENU: /* Button text: "Top level menu" */
WinDestroyWindow(hWndDlg);
// send message corresponding calling menu to quit (dismiss
// WinSendDlgItemMsg(HWND_DESKTOP, IDLG_DDOCMENU , WM_COMMAND , MPFROMSHORT(DID_CANCEL), 0L);
{
HWND hWndOwner;
hWndOwner = WinQueryWindow(hWndDlg, QW_OWNER, 0);
WinSendMsg( hWndOwner, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
}
// end mycode
hWndEDITBOX = 0;
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinDismissDlg(hWndDlg, FALSE);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of EDITBOXMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/***************************************************************************/
MRESULT EXPENTRY MMENUMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DOCM_DDOCS: /* Button text: "Demo Docs" */
hWndDDOCMENU = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)DDOCMENUMsgProc,
0, IDLG_DDOCMENU, (PBYTE)hWndParent);
break;
case DOCM_PTECH: /* Button text: "Perf Techniques" */
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DOCM_PARMS: /* Button text: "Parameter Tuning" */
hWndDOCPARMS = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)DOCPARMSMsgProc,
0, IDLG_DOCPARMS, (PBYTE)hWndParent);
break;
case DOCM_RDS: /* Button text: "RDS Docs" */
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWndParent);
break;
case DEMOM_ARI: /* Button text: "A R I" */
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWndParent);
break;
case DEMOM_RBLOCK: /* Button text: "Record Blocking" */
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWndParent);
break;
case DEMOM_STATDYN: /* Button text: "Static vs Dynamic" */
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWndParent);
break;
case DEMOM_INDICES: /* Button text: "I N D I C E S" */
hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)SHOWTIMEMsgProc,
0, IDLG_SHOWTIME, (PBYTE)hWndParent);
break;
case MMENU_EXIT: /* Button text: "EXIT" */
break;
case MMENU_HELP: /* Button text: "HELP" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinDismissDlg(hWndDlg, FALSE);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of MMENUMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/***************************************************************************/
MRESULT EXPENTRY DOCRDSMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
USHORT rc;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DRDS_REQ: /* Button text: "REQUESTER" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_rdsreq1);
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_rdsreq2, eboxh_rdsreq3);
// strcpy( temp_ebox_heading3, eboxh_rdsreq3);
rc = SetDlgText("rdsreq.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DID_CANCEL: /* Button text: "CANCEL" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDestroyWindow(hWndDlg);
hWndDOCRDS = 0;
break;
case DRDS_HELP: /* Button text: "HELP" */
break;
case DRDS_SRV: /* Button text: "SERVER" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_rdssrv1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_rdssrv2, eboxh_rdssrv3);
// strcpy( temp_ebox_heading3, eboxh_rdssrv3 );
rc = SetDlgText("rdssrv.txt");
if(rc)
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
//mycode e
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of DOCRDSMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/***************************************************************************/
/* Generates the menu for selecting DBM parameter files */
/************************************************************************/
MRESULT EXPENTRY DOCPARMSMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
USHORT rc;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DPARMS_DBMAN: /* Button text: "Database Manager" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_dbmparms1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbmparms2, eboxh_dbmparms3);
// strcpy( temp_ebox_heading3, eboxh_dbmparms3 );
rc = SetDlgText("dbmparms.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DPARMS_LOG: /* Button text: "Database Log" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_dbparmsl1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbparmsl2, eboxh_dbparmsl3);
// strcpy( temp_ebox_heading3, eboxh_dbparmsl3 );
rc = SetDlgText("dbparmsl.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DPARMS_GENDB: /* Button text: "General Database " */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_dbparmsg1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbparmsg2, eboxh_dbparmsg3);
// strcpy( temp_ebox_heading3, eboxh_dbparmsg3 );
rc = SetDlgText("dbparmsg.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DPARMS_HEAP: /* Button text: "Database Heap" */
//mycode b
/* set up the text string pszDisplayTxt with the */
/* corresponding file for later display in edit box */
strcpy( temp_ebox_heading1, eboxh_dbparmsh1 );
sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbparmsh2, eboxh_dbparmsh3);
// strcpy( temp_ebox_heading3, eboxh_dbparmsh3 );
rc = SetDlgText("dbparmsh.txt");
if(rc)
//mycode e
hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
hWndDlg, (PFNWP)EDITBOXMsgProc,
0, IDLG_EDITBOX, (PBYTE)hWndParent);
break;
case DID_CANCEL: /* Button text: "CANCEL" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDestroyWindow(hWndDlg);
hWndDOCPARMS = 0;
break;
case DPARMS_HELP: /* Button text: "HELP" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of DOCPARMSMsgProc */
/***************************************************************************/
/* */
/* cwRegisterClass Function */
/* */
/* The following function registers all the classes of all the windows */
/* associated with this application. The function returns TRUE if it is */
/* successful, otherwise it returns FALSE. */
/* */
/***************************************************************************/
INT cwRegisterClass()
{
CLASSINFO ci;
INT rc;
strcpy(szAppName, "DBDEMO");
rc = WinRegisterClass(hAB, /* Anchor block handle */
(PCH)szAppName, /* Name of class being registered */
(PFNWP)WndProc, /* Window procedure for class */
CS_SIZEREDRAW ,
2*sizeof(char FAR *));
if (rc == FALSE)
return(FALSE);
WinQueryClassInfo(hAB, WC_ENTRYFIELD, (PCLASSINFO)&ci);
pfnEditWndProc = ci.pfnWindowProc;
rc = WinRegisterClass(hAB, "UDNumeric", UDNumericWndProc, CS_SIZEREDRAW,
ci.cbWindowData + sizeof(PVOID));
if (rc == FALSE)
return(FALSE);
return(TRUE);
} /* End of cwRegisterClass */
/***************************************************************************/
/* */
/* cwCreateWindow Function */
/* */
/* The following function is used to create a window (the main window, */
/* a child window, an icon window, etc.) and set it's initial size and */
/* position. It returns the handle to the frame window. */
/* */
/***************************************************************************/
HWND cwCreateWindow(
HWND hWndParent, /* Handle to the parent of the window to be created */
ULONG ctldata, /* Frame control flags for the window */
PCH appname, /* Class name of the window */
PCH title, /* Title of the window */
USHORT ResID, /* Resource id value */
INT x, /* Initial horizontal and vertical location */
INT y,
INT cx, /* Initial width and height of the window */
INT cy,
PHWND hWndClient, /* Handle to the client area of the window */
ULONG lfStyle, /* Frame window style */
USHORT uSizeStyle) /* User defined size and location flags */
{
USHORT rc; /* accepts return codes from function calls */
HWND hWndFrame; /* local handle to created window frame */
USHORT SizeStyle; /* local window positioning options */
CHAR MsgBuffer[80]; /* buffer for error messages */
HPS hPS; /* handle to a presentation space */
int xmod, ymod; /* modifiers for sizing */
#define DLGXMOD 4 /* Dialog units X modulo */
#define DLGYMOD 8 /* Dialog units Y modulo */
FONTMETRICS fm; /* structure for determing modifiers */
/* Create the frame window */
hWndFrame = WinCreateStdWindow(hWndParent, /* parent of window */
lfStyle, /* frame window style */
&ctldata, /* frame flags */
appname, /* class name */
title, /* window title */
0L, /* client window style */
0, /* module for resources */
ResID, /* resource id */
(HWND FAR *)hWndClient); /* client handle*/
/* if hWndFrame is NULL, an error occured when opening the window, */
/* notify the user and exit this function */
if(hWndFrame == 0)
{
WinLoadString(hAB, 0, IDS_ERR_WINDOW_CREATE, 80, MsgBuffer);
WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
/* set up size options */
SizeStyle = SWP_ACTIVATE | SWP_ZORDER | uSizeStyle;
/* if the height, width, intial x or initial y values are non-zero, */
/* then we will need to set up the modifiers for size and location */
if((cx > 0) || (cy > 0) ||
(x > 0) || (y > 0))
{
hPS = WinGetPS(HWND_DESKTOP);
GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
xmod = (INT)fm.lAveCharWidth;
ymod = (INT)fm.lMaxBaselineExt;
WinReleasePS(hPS);
}
/* if either the width or the height are non-zero, then the size of the */
/* created window will be changed, set SizeStyle accordingly */
if((cx > 0) || (cy > 0))
SizeStyle |= SWP_SIZE;
/* set the size and position of the window and activate it */
rc = WinSetWindowPos(hWndFrame, HWND_TOP, 0, 0,
(USHORT)(cx * xmod)/DLGXMOD,
(USHORT)(cy * ymod)/DLGYMOD, SizeStyle);
/* if the either the intial x or y position of the window is non-zero, */
/* set the window to its new position */
if((x > 0) || (y > 0))
rc = WinSetWindowPos(hWndFrame, HWND_TOP,
(USHORT)(x * xmod)/DLGXMOD,
(USHORT)(y * ymod)/DLGYMOD, 0, 0, SWP_MOVE);
/* if rc is not set to TRUE then WinSetWindowPos failed, notify the user*/
/* and exit this function */
if(!rc)
{
WinLoadString(hAB, 0, IDS_ERR_WINDOW_POS, 80, MsgBuffer);
WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
/* return the handle to the frame window */
return(hWndFrame);
} /* End of cwCreateWindow */
int cwCreateClientControls(hWnd)
HWND hWnd;
{
long cyscroll;
int xmod, ymod;
#define DLGXMOD 4 /* Dialog units X modulo */
#define DLGYMOD 8 /* Dialog units Y modulo */
HPS hPS;
FONTMETRICS fm;
hPS = WinGetPS(HWND_DESKTOP);
GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
xmod = (INT)fm.lAveCharWidth;
ymod = (INT)fm.lMaxBaselineExt;
cyscroll = 0;
WinReleasePS(hPS);
WinCreateWindow( hWnd,
WC_STATIC,
"RUN DEMO",
SS_GROUPBOX | WS_GROUP | WS_VISIBLE,
(USHORT)(236*xmod)/DLGXMOD, (USHORT)((44*ymod)/DLGYMOD+cyscroll),
(USHORT)(156*xmod)/DLGXMOD, (USHORT)(167*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
257,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"Demo Docs",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(32*xmod)/DLGXMOD, (USHORT)((180*ymod)/DLGYMOD+cyscroll),
(USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DOCM_DDOCS,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"Perf Techniques",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(32*xmod)/DLGXMOD, (USHORT)((144*ymod)/DLGYMOD+cyscroll),
(USHORT)(98*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DOCM_PTECH,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"Parameter Tuning",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(32*xmod)/DLGXMOD, (USHORT)((103*ymod)/DLGYMOD+cyscroll),
(USHORT)(98*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DOCM_PARMS,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"RDS Docs",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(32*xmod)/DLGXMOD, (USHORT)((62*ymod)/DLGYMOD+cyscroll),
(USHORT)(98*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DOCM_RDS,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"A R I",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(268*xmod)/DLGXMOD, (USHORT)((179*ymod)/DLGYMOD+cyscroll),
(USHORT)(98*xmod)/DLGXMOD, (USHORT)(12*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DEMOM_ARI,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"Record Blocking",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(268*xmod)/DLGXMOD, (USHORT)((143*ymod)/DLGYMOD+cyscroll),
(USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DEMOM_RBLOCK,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"Static vs Dynamic",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(267*xmod)/DLGXMOD, (USHORT)((102*ymod)/DLGYMOD+cyscroll),
(USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DEMOM_STATDYN,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"I N D I C E S",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(267*xmod)/DLGXMOD, (USHORT)((61*ymod)/DLGYMOD+cyscroll),
(USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
DEMOM_INDICES,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"EXIT",
BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
(USHORT)(178*xmod)/DLGXMOD, (USHORT)((111*ymod)/DLGYMOD+cyscroll),
(USHORT)(34*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
MMENU_EXIT,
0,
0 );
WinCreateWindow( hWnd,
WC_BUTTON,
"HELP",
BS_PUSHBUTTON | BS_HELP | WS_TABSTOP | WS_VISIBLE,
(USHORT)(175*xmod)/DLGXMOD, (USHORT)((71*ymod)/DLGYMOD+cyscroll),
(USHORT)(38*xmod)/DLGXMOD, (USHORT)(12*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
MMENU_HELP,
0,
0 );
WinCreateWindow( hWnd,
WC_STATIC,
"DISPLAY DOCUMENTS",
SS_GROUPBOX | WS_GROUP | WS_VISIBLE,
(USHORT)(10*xmod)/DLGXMOD, (USHORT)((43*ymod)/DLGYMOD+cyscroll),
(USHORT)(148*xmod)/DLGXMOD, (USHORT)(167*ymod)/DLGYMOD,
hWnd,
HWND_TOP,
INIT_DLG,
0,
0 );
}
/***************************************************************************/
/* cwNumericValidate Function */
/* */
/* Returns TRUE if the string is acceptable, otherwise returns FALSE */
/* */
/***************************************************************************/
INT cwNumericValidate(string)
CHAR *string;
{
INT count;
for(count = 0; count <= (INT)strlen(string)-1; count++)
if(isdigit((int)string[count]) ||
(string[count] == '-' && count == 0))
continue;
else
return(FALSE);
return(TRUE);
}
/***************************************************************************/
/* UDNumericWndProc */
/* */
/* Is used on subclassing edit fields for numeric validation */
/* */
/***************************************************************************/
MRESULT EXPENTRY UDNumericWndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static CHAR key;
ULONG location;
switch(message)
{
case WM_CHAR:
if(SHORT2FROMMP(mp2) == VK_SPACE)
return((MRESULT)TRUE);
if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)
break;
if(SHORT1FROMMP(mp1) & KC_CHAR)
{
key = (CHAR)SHORT1FROMMP(mp2);
if(isdigit((int)key))
return(pfnEditWndProc(hWnd, message, mp1, mp2));
else if(key == '-')
{
location = (ULONG)WinSendMsg(hWnd, EM_QUERYSEL, 0L, 0L);
if(SHORT1FROMMP(location) != 0)
{
WinAlarm(HWND_DESKTOP, WA_ERROR);
return((MRESULT)TRUE);
}
else
return(pfnEditWndProc(hWnd, message, mp1, mp2));
}
else
{
WinAlarm(HWND_DESKTOP, WA_ERROR);
return((MRESULT)TRUE);
}
}
break;
case WM_TRANSLATEACCEL:
return((MRESULT)FALSE);
break;
}
return(pfnEditWndProc(hWnd, message, mp1, mp2));
} /* End of UDNumericWndProc */
/***************************************************************************/
/* cwCenter Function */
/* */
/* Centers a dialog box on the client area of the caller */
/* */
/***************************************************************************/
INT cwCenter(hWnd, hWndParent)
HWND hWnd; /* handle of the window to be centered */
HWND hWndParent; /* handle of the window to center on */
{
ULONG SrcX, SrcY; /* Center of parent */
INT ix, iy; /* Destination points */
SWP DlgSwp, ParentSwp; /* Set window position structures */
ULONG ScreenWidth, ScreenHeight; /* Dimensions of the DESKTOP */
POINTL pt; /* Point */
/* Determine the width and height of the DESKTOP so the dialog box */
/* will not be positioned to a point off of the screen. */
ScreenWidth = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
ScreenHeight = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
/* Query width and depth of dialog box */
WinQueryWindowPos(hWnd, (PSWP)&DlgSwp);
/* Query width and depth of caller */
WinQueryWindowPos(hWndParent, (PSWP)&ParentSwp);
/* Map the point parent points to the Desktop */
pt.x = ParentSwp.x;
pt.y = ParentSwp.y;
/* Convert the point from having our window as the origin to having */
/* the DESKTOP as the origin */
WinMapWindowPoints(hWndParent, HWND_DESKTOP, &pt, 1);
SrcX = pt.x + (ParentSwp.cx / 2);
SrcY = pt.y + (ParentSwp.cy / 2);
/* Determine the point to move the dialog box to */
ix = (INT)(SrcX - (DlgSwp.cx / 2));
iy = (INT)(SrcY - (DlgSwp.cy / 2));
/* if either point is less than zero, then set that point to zero */
/* so the dialog box will not be positoned off of the window */
ix = (ix < 0) ? 0 : ix;
iy = (iy < 0) ? 0 : iy;
/* if either point plus the height or width of the dialog box is */
/* greater than the height or width of the screen adjust point */
if(((ULONG)ix + DlgSwp.cx) > ScreenWidth)
ix = (INT)(ScreenWidth - DlgSwp.cx);
if(((ULONG)iy + DlgSwp.cy) > ScreenHeight)
iy = (INT)(ScreenHeight - DlgSwp.cy);
/* move the dialog box */
return(WinSetWindowPos(hWnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE));
}
/* This function initializes the states of all dialog box radio buttons */
/* and check boxes that have had their initial status set to true */
INT cwSetInitDlgStatus(hWnd)
HWND hWnd;
{
SHOWTIMEStruct FAR *Showtime;
EDITBOXStruct FAR *Editbox;
OFFSETOF(Showtime) = 0;
DosAllocSeg(sizeof(SHOWTIMEStruct), (PSEL)&SELECTOROF(Showtime), 0);
lmemset(Showtime, 0x00, sizeof(SHOWTIMEStruct));
WinSetWindowULong(hWnd, OFFSET_SHOWTIME, (ULONG)Showtime);
OFFSETOF(Editbox) = 0;
DosAllocSeg(sizeof(EDITBOXStruct), (PSEL)&SELECTOROF(Editbox), 0);
lmemset(Editbox, 0x00, sizeof(EDITBOXStruct));
WinSetWindowULong(hWnd, OFFSET_EDITBOX, (ULONG)Editbox);
}
INT cwFreeDlgMemory(hWnd)
HWND hWnd;
{
SHOWTIMEStruct FAR *Showtime;
EDITBOXStruct FAR *Editbox;
Showtime = (SHOWTIMEStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_SHOWTIME);
DosFreeSeg(SELECTOROF(Showtime));
Editbox = (EDITBOXStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_EDITBOX);
DosFreeSeg(SELECTOROF(Editbox));
}
void lmemset(memptr, value, size)
void FAR *memptr;
char value;
int size;
{
char FAR *chrptr = memptr;
while (size--)
*chrptr++ = value;
}
/* LONGSTRCPY - is a functional equivalent to the C library routine */
/* strcpy, with the exception that it takes far pointers to */
/* to character strings as it's parameters. */
PSZ longstrcpy(target, source)
PSZ target;
PSZ source;
{
PSZ z = target;
while(*target++ = *source++);
return(z);
}
INT SetDlgText(Filename)
unsigned char *Filename;
//unsigned char Filename[FILENAME_LENGTH];
{
INT rc;
FILE *fileh;
long length;
USHORT num_char = 0, num_read = 0;
rc = TRUE;
if ((fileh = fopen(Filename,"r+")) == NULL)
{
num_char = sprintf(szMessage,"RC for FILE_OPEN = %ld.\n",fileh);
WinMessageBox ( HWND_DESKTOP,
hWndClient,
szMessage,
"FILE ERRORS",
0,
MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
rc = FALSE;
}
if(rc)
{
if ((length = filelength(fileno(fileh))) == -1L)
{
num_char = sprintf(szMessage,"RC for FILE_LENGTH = %ld.\n",length);
WinMessageBox ( HWND_DESKTOP,
hWndClient,
szMessage,
"FILE ERRORS",
0,
MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
rc = FALSE;
}
if(rc)
if ((pszDisplayTxt = (char *)malloc(length+1)) == NULL)
{
num_char = sprintf(szMessage,"MALLOC.\n");
WinMessageBox ( HWND_DESKTOP,
hWndClient,
szMessage,
"FILE ERRORS",
0,
MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
rc = FALSE;
}
if(rc)
if ((num_read = fread((void *)pszDisplayTxt,sizeof(char),length,fileh)) != length)
{
// Next lines commented out because the number of bytes
// read is always different than filelength due to CR/LF.
/***
num_char = sprintf(szMessage,
"FILE_READ ERROR. Bytes read = %d. File size = %ld.\n",
num_read,length);
WinMessageBox ( HWND_DESKTOP,
hWndClient,
szMessage,
"FILE ERRORS",
0,
MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
rc = FALSE;
**/
}
pszDisplayTxt[num_read] = '\0';
pszDisplayTxt[length] = '\0';
fclose(fileh);
}
// if(pszDisplayTxt != NULL)
// free(pszDisplayTxt);
return(rc);
} /* End of SetDlgText */
/***************************************************************************/
/* FUNCTION PMErrChk */
/* puts up a message box in case of errors */
/***************************************************************************/
BOOL PMErrChk(hAB, hWnd, usermsg)
HAB hAB;
HWND hWnd;
PSZ usermsg;
{
PERRINFO perriBlk;
PSZ pszErrMsg;
PUSHORT pusTemp;
if((perriBlk = WinGetErrorInfo(hAB)) == NULL)
return(FALSE);
SELECTOROF(pszErrMsg) = SELECTOROF(perriBlk);
SELECTOROF(pusTemp) = SELECTOROF(perriBlk);
OFFSETOF(pusTemp) = perriBlk->offaoffszMsg;
OFFSETOF(pszErrMsg) = *pusTemp;
if(ERRORIDSEV(perriBlk->idError) != SEVERITY_WARNING)
WinMessageBox(HWND_DESKTOP, hWnd,
pszErrMsg, usermsg, 0, MB_CUACRITICAL | MB_OK);
WinFreeErrorInfo(perriBlk);
return(TRUE);
}
/***************************************************************************/
/* FUNCTION SQLthread */
/***************************************************************************/
VOID _CDECL FAR SQLthread(hWndDlg)
HWND hWndDlg;
{
USHORT rc=0;
switch(demo_num)
{
case DEMO_INDICES:
rc = indices();
break;
case DEMO_ARI:
rc = ari();
break;
case DEMO_RBLOCK:
rc = rblock();
break;
case DEMO_STATDYN:
rc = stat_dyn();
break;
default:
rc = DB_DEMO_NOT_AVAIL;
break;
}
switch(rc)
{
case DB_RETURN_OK:
if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DISPLAY_TIME), 0L))
PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
break;
case DB_RETURN_BAD:
WinAlarm(HWND_DESKTOP, WA_ERROR);
if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DEMO_DIED), 0L))
PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
break;
case DB_DEMO_NOT_AVAIL:
WinAlarm(HWND_DESKTOP, WA_ERROR);
if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DEMO_NOT_AVAIL), 0L))
PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
break;
default:
WinAlarm(HWND_DESKTOP, WA_ERROR);
if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DEMO_NOT_AVAIL), 0L))
PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
break;
}
_endthread();
}
VOID FAR StartDB(sqlca)
struct sqlca *sqlca;
{
unsigned char label[23]; /* store db api CALL */
strcpy(label,"start_db");
sqlestrd("bank",'S',sqlca);
if(sqlca->sqlcode != 0)
{
WinAlarm(HWND_DESKTOP, WA_ERROR);
}
}/* end StartDB */
VOID FAR StopDB(sqlca)
struct sqlca *sqlca;
{
sqlestpd(sqlca);
}