home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Unleashed
/
Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso
/
repease
/
rep_dlg.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-20
|
84KB
|
1,924 lines
/*==============================================================================
REP_DLG.C
Report Ease: All dialog box handling routines
Report Ease
Sub Systems, Inc.
ReportEase, Copyright (c) 1992, Sub Systems, Inc. All Rights Reserved.
159 Main Street, #8C, Stoneham, MA 02180
(617) 438-8901.
Software License Agreement (1992)
----------------------------------
This license agreement allows the purchaser the right to modify the
source code to incorporate in their application.
The target application must not be distributed as a standalone report writer
or a mail merge product.
Sub Systems, Inc. reserves the right to prosecute anybody found to be
making illegal copies of the executable software or compiling the source
code for the purpose of selling there after.
===============================================================================*/
#include "windows.h"
#if defined (_WIN32)
#if !defined(WIN32)
#define WIN32
#endif
#endif
#if !defined(WIN32)
#include "print.h"
#endif
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "fcntl.h"
#include "io.h"
#include "string.h"
#include "sys\types.h"
#include "sys\stat.h"
#include "setjmp.h"
#include "commdlg.h"
#include "rep.h"
#define PREFIX extern
#include "rep1.h"
#include "rep_dlg.h"
/******************************************************************************
RepParam:
Accepts the name, page margins, and other report related parameters.
******************************************************************************/
BOOL CALLBACK _export RepParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG: // initialize parameters
SetDlgItemText(hDlg,IDC_NAME,(LPSTR)FormHdr.name);
SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_SETCHECK, FormHdr.DateFormat==0, 0L);
SendMessage(GetDlgItem(hDlg,IDC_DDMMYY),BM_SETCHECK, FormHdr.DateFormat==1, 0L);
SendMessage(GetDlgItem(hDlg,IDC_PRINT_TRIAL),BM_SETCHECK, RFLAG_TRIAL&FormHdr.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_RULER_OFF) ,BM_SETCHECK, FormHdr.RulerType==RULER_OFF, 0L);
SendMessage(GetDlgItem(hDlg,IDC_RULER_INCH),BM_SETCHECK, FormHdr.RulerType==RULER_INCH, 0L);
SendMessage(GetDlgItem(hDlg,IDC_RULER_CM) ,BM_SETCHECK, FormHdr.RulerType==RULER_CM, 0L);
SetDlgItemText(hDlg,IDC_LEFT_MARGIN,DoubleToStr((double)FormHdr.LeftMargin,2,msg));
SetDlgItemText(hDlg,IDC_RIGHT_MARGIN,DoubleToStr((double)FormHdr.RightMargin,2,msg));
SetDlgItemText(hDlg,IDC_TOP_MARGIN,DoubleToStr((double)FormHdr.TopMargin,2,msg));
SetDlgItemText(hDlg,IDC_BOT_MARGIN,DoubleToStr((double)FormHdr.BottomMargin,2,msg));
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
// validate margin parameters
if (!CheckDlgValue(hDlg,'F',IDC_LEFT_MARGIN,0,9)) return (TRUE);
if (!CheckDlgValue(hDlg,'F',IDC_RIGHT_MARGIN,0,9)) return (TRUE);
if (!CheckDlgValue(hDlg,'F',IDC_TOP_MARGIN,0,9)) return (TRUE);
if (!CheckDlgValue(hDlg,'F',IDC_BOT_MARGIN,0,9)) return (TRUE);
// extract margin parameters
GetDlgItemText(hDlg,IDC_LEFT_MARGIN,msg,100);
FormHdr.LeftMargin=(float)atof(msg);
GetDlgItemText(hDlg,IDC_RIGHT_MARGIN,msg,100);
FormHdr.RightMargin=(float)atof(msg);
GetDlgItemText(hDlg,IDC_TOP_MARGIN,msg,100);
FormHdr.TopMargin=(float)atof(msg);
GetDlgItemText(hDlg,IDC_BOT_MARGIN,msg,100);
FormHdr.BottomMargin=(float)atof(msg);
//***** extract report name *****
GetDlgItemText(hDlg,IDC_NAME,FormHdr.name,NAME_WIDTH);
//****** extract date format **
if (SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_GETCHECK, 0, 0L))
FormHdr.DateFormat=0;
else FormHdr.DateFormat=1;
//****** extract ruler type **
if (SendMessage(GetDlgItem(hDlg,IDC_RULER_OFF) ,BM_GETCHECK, 0, 0L)) FormHdr.RulerType=RULER_OFF;
else if (SendMessage(GetDlgItem(hDlg,IDC_RULER_INCH),BM_GETCHECK, 0, 0L)) FormHdr.RulerType=RULER_INCH;
else FormHdr.RulerType=RULER_CM;
//****** extract flags ******
if (SendMessage(GetDlgItem(hDlg,IDC_PRINT_TRIAL),BM_GETCHECK, 0, 0L))
FormHdr.flags=(FormHdr.flags)|RFLAG_TRIAL;
else FormHdr.flags=(FormHdr.flags)&(~((UINT)RFLAG_TRIAL));
FrModified=TRUE;
EndDialog(hDlg, TRUE);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
PrintAbortParam:
Handles the user request to abort printing.
******************************************************************************/
BOOL CALLBACK _export PrintAbortParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG: // initialize parameters
hAbortDlg=hDlg; // save the dialog window handle
SetDlgItemText(hDlg,IDC_CUR_PRINTER,PrinterName);
SetDlgItemText(hDlg,IDC_CUR_PAGE,"0");
SetDlgItemText(hDlg,IDC_CUR_REC,"0");
SetFocus(GetDlgItem(hDlg,IDCANCEL));
return (TRUE);
case WM_COMMAND:
ReportStatus=REP_ABORT;
return TRUE;
}
return FALSE;
}
/******************************************************************************
ScrPrintAbortParam:
Handles the user request to abort screen printing.
******************************************************************************/
BOOL CALLBACK _export ScrPrintAbortParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG: // initialize parameters
hAbortDlg=hDlg; // save the dialog window handle
SetDlgItemText(hDlg,IDC_CUR_PRINTER,PrinterName);
SetDlgItemText(hDlg,IDC_CUR_PAGE,"0");
SetFocus(GetDlgItem(hDlg,IDCANCEL));
return (TRUE);
case WM_COMMAND:
SetDlgItemText(hDlg,IDC_CUR_PRINTER,"Cancelling..., Please Wait.");
ReportStatus=REP_ABORT;
EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE);
return TRUE;
}
return FALSE;
}
/****************************************************************************
PrinterParam:
This dialog box allows the printer selection and setup.
****************************************************************************/
BOOL CALLBACK _export PrinterParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i,j;
LPSTR PrinterList;
char CurPrinter[NAME_WIDTH+2],string[NAME_WIDTH+3];
int count,CurSel,idx;
char ProfString[3][NAME_WIDTH+2],far *ptr;
BOOL CurPrinterFound;
switch (message) {
case WM_INITDIALOG:
//****************** get the printer list ***********************
if (NULL==(PrinterList=GetPrinterList(&count))) return FALSE;
// Set initial values of the parameters
idx=0;
CurSel=0;
CurPrinterFound=FALSE;
for (i=0;i<count;i++) {
lstrcpy(CurPrinter,&PrinterList[idx]);
idx=idx+strlen(CurPrinter)+1;
//**** get the printer ports ****
ParseProfileString("devices",CurPrinter,ProfString[0],ProfString[1],ProfString[2]);
for (j=1;j<3;j++) {
StrTrim(ProfString[j]);
if (ProfString[j][0]!=0) {
strcpy(string,CurPrinter);
strcat(string," On ");
strcat(string,ProfString[j]);
SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_ADDSTRING, 0, (DWORD)(LPSTR)string);
if (strcmpi(CurPrinter,PrinterName)==0 && strcmp(ProfString[j],PrinterPort)==0) {
CurPrinterFound=TRUE;
}
if (!CurPrinterFound) CurSel++;
}
}
}
SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_SETCURSEL, CurSel,0L);
SetFocus(GetDlgItem(hDlg,IDC_PRINTER_LIST));
OurFree(PrinterList);
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_PRINTER_LIST:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDC_PRINTER_SETUP:
case IDOK:
CurSel=(int)SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_GETCURSEL, 0,0L);
if (SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_GETTEXT, CurSel,(DWORD)(LPSTR)string)==LB_ERR) return TRUE;
//**** extract the printer name,driver and port ***
if (NULL==(ptr=strstr(string," On "))) return TRUE;
strcpy(PrinterPort,&ptr[4]);
(*ptr)=0;
strcpy(PrinterName,string);
ParseProfileString("devices",PrinterName,ProfString[0],ProfString[1],ProfString[2]);
strcpy(PrinterDriver,ProfString[0]);
if (strstr(PrinterDriver,".DRV")==NULL && strstr(PrinterDriver,".drv")==NULL)
strcat(PrinterDriver,".DRV");
InitPrinter(); // read the printer characteristics
//******** do printer setup ********
if (wParam==IDC_PRINTER_SETUP) {
if (!CallPrinterDriver(DM_PROMPT|DM_COPY|DM_UPDATE)) return TRUE;
SetFocus(GetDlgItem(hDlg,IDOK));
}
else {
ProcessPrinterData(); // calculate report width
EndDialog(hDlg, 1);
}
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, 0);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
NewSecParam:
This dialog box shows a list of section names to choose from. The dialog
box returns the index of the selected section.
****************************************************************************/
int CALLBACK _export NewSecParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
char far *(far *SecName);
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
SecName=(char far * far *)(DWORD)lParam;
i=0;
while (SecName[i]!=NULL) {
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)SecName[i]);
i++;
}
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
EndDialog(hDlg, i);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, -1);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
SysParam:
This dialog box shows a list of system fields to choose from. The dialog
box returns the index of the selected system field.
****************************************************************************/
int CALLBACK _export SysParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
for (i=0;i<MAX_SYS_FIELDS;i++) {
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)SysField[i].name);
}
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
EndDialog(hDlg, i);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, -1);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
FieldNameParam:
Accepts a calculation field name. The field name is passed in the
global variable 'msg'.
******************************************************************************/
BOOL CALLBACK _export FieldNameParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
char name[NAME_WIDTH+2];
int i;
switch (message) {
case WM_INITDIALOG: // initialize parameters
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
GetDlgItemText(hDlg,IDC_NAME,name,NAME_WIDTH-6);
name[NAME_WIDTH-6]=0;
strupr(name);
StrTrim(name);
for(i=0;i<(int)strlen(name);i++) {
if ((name[i]<'A' || name[i]>'Z')
&&(name[i]<'0' || name[i]>'9')
&& name[i]!='_') {
MessageBox(hDlg,"Invalid Character in the Field Name.","Naming Error",MB_OK);
return TRUE;
}
}
if (name[0]==0) return TRUE;
strcpy(msg,"CALC->");
strcat(msg,name);
for (i=0;i<TotalFields;i++) {
if (field[i].InUse && lstrcmp(field[i].name,msg)==0) {
MessageBox(hDlg,"Duplicate Name Not Allowed!","Naming Error",MB_OK);
return TRUE;
}
}
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
ExpParam:
Accepts an expression. An expression can be used to create a calculated
field, specify record and section selection criteria.
******************************************************************************/
BOOL CALLBACK _export ExpParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int idx;
DWORD CursPos;
LPSTR SaveDlgExpString;
struct StrField CurField;
switch (message) {
case WM_INITDIALOG: // initialize parameters
if (lParam!=0) SetWindowText(hDlg,(LPSTR)lParam); // set the header
SetDlgItemText(hDlg,IDC_EXP,DlgExpString);
CursPos=DlgCursPos;
CursPos=CursPos<<16;
CursPos=CursPos+DlgCursPos;
SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_SETSEL,0, CursPos);
SetFocus(GetDlgItem(hDlg,IDC_EXP));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_DATA_FIELD:
if ((FormArg.UserSelection)(hDlg,&CurField,0)) {
SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
}
SetFocus(GetDlgItem(hDlg,IDC_EXP));
return (TRUE);
case IDC_SYS_FIELD:
if ((idx=CallDialogBox("SysParam",SysParam,0L))>=0) {
lstrcpy(CurField.name,"SYS->");
lstrcat(CurField.name,SysField[idx].name);
SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
}
SetFocus(GetDlgItem(hDlg,IDC_EXP));
return (TRUE);
case IDC_DLG_FIELD:
if ((idx=CallDialogBox("DlgParam",DlgParam,0L))>=0) {
lstrcpy(CurField.name,"DLG->");
lstrcat(CurField.name,DlgField[idx].name);
SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
}
SetFocus(GetDlgItem(hDlg,IDC_EXP));
return (TRUE);
case IDC_OP:
SaveDlgExpString=DlgExpString;
DlgExpString=(LPSTR)CurField.name; // output location
if (CallDialogBox("OpParam",OpParam,0L)) {
SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
}
DlgExpString=SaveDlgExpString;
SetFocus(GetDlgItem(hDlg,IDC_EXP));
return (TRUE);
case IDC_FUNCT:
SaveDlgExpString=DlgExpString;
DlgExpString=(LPSTR)CurField.name; // output location
if (CallDialogBox("FuctParam",FuctParam,0L)) {
SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
}
DlgExpString=SaveDlgExpString;
SetFocus(GetDlgItem(hDlg,IDC_EXP));
return (TRUE);
case IDOK:
GetDlgItemText(hDlg,IDC_EXP,DlgExpString,LINE_WIDTH);
DlgExpString[LINE_WIDTH]=0;
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
OpParam:
This dialog box shows a list of operators to select from. The selected
operator is stored in the location pointed by the DlgExpString global
variable.
****************************************************************************/
BOOL CALLBACK _export OpParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
for(i=0;i<MAX_OPS;i++) {
if (!OpFooter[i] || DlgExpType==EXP_FOOTER) {
if (!OpFct[i]) {
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)OpSym[i]);
}
}
}
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETTEXT, i,(DWORD)(LPSTR)DlgExpString);
EndDialog(hDlg, TRUE);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
FuctParam:
This dialog box shows a list of functions to select from. The name
of the selected function is stored in the location pointed by
the DlgExpString global variable.
****************************************************************************/
BOOL CALLBACK _export FuctParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
char string[NAME_WIDTH+2];
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
for(i=0;i<MAX_OPS;i++) {
if (!OpFooter[i] || DlgExpType==EXP_FOOTER) {
if (OpFct[i]) {
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)OpHelp[i]);
}
}
}
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETTEXT, i,(DWORD)(LPSTR)msg);
for (i=0;i<MAX_OPS;i++) { // locate the function symbold
strcpy(string,OpSym[i]);
strcat(string,"(");
if (strstr(msg,string)==msg) {
lstrcpy(DlgExpString,(LPSTR)string);
EndDialog(hDlg, TRUE);
return (TRUE);
}
}
EndDialog(hDlg, FALSE);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
DlgParam:
This dialog box shows a list of dialog fields to select from. The
routine returns the index of the selected dialog field.
****************************************************************************/
BOOL CALLBACK _export DlgParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
char name[NAME_WIDTH];
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
for(i=0;i<MAX_DLGS;i++) {
if (DlgField[i].InUse) {
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)DlgField[i].name);
}
}
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETTEXT, i,(DWORD)(LPSTR)name);
for (i=0;i<MAX_DLGS;i++) {
if (DlgField[i].InUse && strcmp(DlgField[i].name,name)==0) {
EndDialog(hDlg, i);
return (TRUE);
}
}
EndDialog(hDlg, -1);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, -1);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
CreateDlgParam:
This dialog box accepts parameters to create a new dialog field in
the dialog field table. The dialog fields are used to accept data
from user before running a report.
The index to the dialog table is given by DlgIndex global variable.
******************************************************************************/
BOOL CALLBACK _export CreateDlgParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
char name[NAME_WIDTH+2];
int i;
switch (message) {
case WM_INITDIALOG: // initialize parameters
SetDlgItemText(hDlg,IDC_NAME,(LPSTR)DlgField[DlgIndex].name);
SendMessage(GetDlgItem(hDlg,IDC_TYPE_TEXT),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_TEXT, 0L);
SendMessage(GetDlgItem(hDlg,IDC_TYPE_NUM),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_NUM, 0L);
SendMessage(GetDlgItem(hDlg,IDC_TYPE_DBL),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_DBL, 0L);
SendMessage(GetDlgItem(hDlg,IDC_TYPE_LOGICAL),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_LOGICAL, 0L);
SendMessage(GetDlgItem(hDlg,IDC_TYPE_DATE),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_DATE, 0L);
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
//***** extract and validate name ******
GetDlgItemText(hDlg,IDC_NAME,name,NAME_WIDTH-5);
name[NAME_WIDTH-5]=0;
strupr(name);
StrTrim(name);
for(i=0;i<(int)strlen(name);i++) {
if ((name[i]<'A' || name[i]>'Z')
&&(name[i]<'0' || name[i]>'9')
&& name[i]!='_') {
MessageBox(hDlg,"Invalid Character in the Field Name.","Naming Error",MB_OK);
return TRUE;
}
}
if (name[0]==0) return TRUE;
for (i=0;i<MAX_DLGS;i++) {
if (DlgField[i].InUse && strcmp(DlgField[i].name,name)==0) {
MessageBox(hDlg,"Duplicate Name Not Allowed!",NULL,MB_OK);
return TRUE;
}
}
strcpy(DlgField[DlgIndex].name,name);
//************ accept field type ***********
if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_TEXT) ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_TEXT;
if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_NUM) ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_NUM;
if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_DBL) ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_DBL;
if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_LOGICAL),BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_LOGICAL;
if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_DATE) ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_DATE;
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
ModifyDlgParam:
This dialog box accepts parameters about a dialog box. The dialog
table is updated with the new information.
******************************************************************************/
BOOL CALLBACK _export ModifyDlgParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG: // initialize parameters
SetWindowText(hDlg,(LPSTR)DlgField[DlgIndex].name); // set the header
SetDlgItemText(hDlg,IDC_NAME,(LPSTR)DlgField[DlgIndex].prompt);
SetDlgItemInt(hDlg,IDC_PROMPT_ORDER,DlgField[DlgIndex].PromptOrder,FALSE);
SetDlgItemInt(hDlg,IDC_FIELD_WIDTH,DlgField[DlgIndex].width,FALSE);
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
GetDlgItemText(hDlg,IDC_NAME,DlgField[DlgIndex].prompt,NAME_WIDTH);
DlgField[DlgIndex].PromptOrder=GetDlgItemInt(hDlg,IDC_PROMPT_ORDER,NULL,FALSE);
DlgField[DlgIndex].width=GetDlgItemInt(hDlg,IDC_FIELD_WIDTH,NULL,FALSE);
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
SecSortParam:
This routine accepts a sort field for a sort header section. The calling
routine passes the section number using the lParam argument.
The index of the sort field is passed using the DlgIndex global variable.
******************************************************************************/
BOOL CALLBACK _export SecSortParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG: // initialize parameters
strcpy(msg,"Sort Field for Section: ");
strcat(msg,SectionName[lParam]);
SetWindowText(hDlg,(LPSTR)msg); // set the header
DlgTempField=field[DlgIndex]; // make a working copy of the field
SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_DATA_FIELD:
if ((FormArg.UserSelection)(hDlg,&DlgTempField,DlgTempField.section-SEC_HDR_LVL1+1)) {
SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
}
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (TRUE);
case IDOK:
GetDlgItemText(hDlg,IDC_NAME,DlgTempField.name,NAME_WIDTH);
strupr(DlgTempField.name);
if ((FormArg.VerifyField)(&DlgTempField,DlgTempField.section-SEC_HDR_LVL1+1)) {
field[DlgIndex]=DlgTempField;
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return (TRUE);
}
else {
MessageBox(hDlg,"Invalid Sort Field!",NULL,MB_OK);
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (TRUE);
}
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
SecBreakParam:
This routine accepts a break field for a sort header section. The break
field is used to determine the section breaks.
The calling routine passes the section number using the lParam argument.
The index of the sort field is passed using the DlgIndex global variable.
******************************************************************************/
BOOL CALLBACK _export SecBreakParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG: // initialize parameters
strcpy(msg,"Break Field for Section: ");
strcat(msg,SectionName[lParam]);
SetWindowText(hDlg,(LPSTR)msg); // set the header
SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_DATA_FIELD:
if ((FormArg.UserSelection)(hDlg,&DlgTempField,0)) {
SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
}
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (TRUE);
case IDC_CALC_FIELD:
lstrcpy(DlgTempField.name,"");
EndDialog(hDlg, 2);
FrModified=TRUE;
return (TRUE);
case IDOK:
GetDlgItemText(hDlg,IDC_NAME,DlgTempField.name,NAME_WIDTH);
strupr(DlgTempField.name);
//****** check if valid data field provided ****
if ((FormArg.VerifyField)(&DlgTempField,0)) {
field[DlgIndex]=DlgTempField;
EndDialog(hDlg, 1);
FrModified=TRUE;
return (TRUE);
}
else {
MessageBox(hDlg,"Invalid Break Field!",NULL,MB_OK);
SetFocus(GetDlgItem(hDlg,IDC_NAME));
return (TRUE);
}
case IDCANCEL:
EndDialog(hDlg, 0);
return (TRUE);
default:
;
}
break;
}
return FALSE;
}
/****************************************************************************
EditSecParam:
This dialog box allows the user to edit section control parameters.
The calling routine passes the index of the section using the DlgIndex
global variable.
****************************************************************************/
BOOL CALLBACK _export EditSecParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int records;
switch (message) {
case WM_INITDIALOG:
SetWindowText(hDlg,(LPSTR)SectionName[DlgIndex]); // set the header
SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_BEF),BM_SETCHECK, SFLAG_PAGE_BEF§ion[DlgIndex].flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_AFT),BM_SETCHECK, SFLAG_PAGE_AFT§ion[DlgIndex].flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_BEFORE),BM_SETCHECK, SFLAG_TRIM_BEFORE§ion[DlgIndex].flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_AFTER),BM_SETCHECK, SFLAG_TRIM_AFTER§ion[DlgIndex].flags, 0L);
if (DlgIndex<SEC_HDR_LVL1 || DlgIndex>SEC_HDR_LVL9)
EnableWindow(GetDlgItem(hDlg,IDC_SEC_REPRINT),FALSE);
else SendMessage(GetDlgItem(hDlg,IDC_SEC_REPRINT),BM_SETCHECK, SFLAG_REPRINT§ion[DlgIndex].flags, 0L);
if (DlgIndex==SEC_DETAIL1 && !(section[SEC_DETAIL2].InUse)) { // multiple column allowed for single detail section report only
SetDlgItemInt(hDlg,IDC_SEC_RECORDS,section[DlgIndex].columns,FALSE);
}
else EnableWindow(GetDlgItem(hDlg,IDC_SEC_RECORDS),FALSE);
SetFocus(GetDlgItem(hDlg,IDC_SEC_PAGE_BEF));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
if (DlgIndex==SEC_DETAIL1 && !(section[SEC_DETAIL2].InUse)){
records=GetDlgItemInt(hDlg,IDC_SEC_RECORDS,NULL,FALSE);
if (records<1) {
SetFocus(GetDlgItem(hDlg,IDC_SEC_RECORDS));
return TRUE;
}
section[DlgIndex].columns=records;
}
if (SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_BEF),BM_GETCHECK, 0, 0L))
section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_PAGE_BEF;
else section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_PAGE_BEF));
if (SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_AFT),BM_GETCHECK, 0, 0L))
section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_PAGE_AFT;
else section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_PAGE_AFT));
if (SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_BEFORE),BM_GETCHECK, 0, 0L))
section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_TRIM_BEFORE;
else section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_TRIM_BEFORE));
if (SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_AFTER),BM_GETCHECK, 0, 0L))
section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_TRIM_AFTER;
else section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_TRIM_AFTER));
if (DlgIndex>=SEC_HDR_LVL1 && DlgIndex<=SEC_HDR_LVL9) {
if (SendMessage(GetDlgItem(hDlg,IDC_SEC_REPRINT),BM_GETCHECK, 0, 0L))
section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_REPRINT;
else section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_REPRINT));
}
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
SumParam:
This dialog box shows a list of summary types and allos the user to
select one item. The index of the selected field is returned to the
calling routine.
****************************************************************************/
int CALLBACK _export SumParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
for (i=0;i<MAX_VALS;i++) {
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)SumName[i]);
}
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, (WPARAM)lParam,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
EndDialog(hDlg, i);
FrModified=TRUE;
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
DeviceParam:
This dialog box allows the user to select a output device for the
current report.
****************************************************************************/
int CALLBACK _export DeviceParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int i;
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)"Screen");
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)"Printer");
SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LIST_BOX:
if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
case IDOK:
i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
EndDialog(hDlg, i);
FrModified=TRUE;
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, -1);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
NumFieldParam:
This dialog box allows the user to modify the field attributes for
a numeric and double field. The calling routine passes the index of the
field to be modified using the DlgIndex global variable.
****************************************************************************/
BOOL CALLBACK _export NumFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int idx,flag;
switch (message) {
case WM_INITDIALOG:
DlgTempField=field[DlgIndex]; // make a working copy of the field
strcpy(msg,"["); // display the field name
strcat(msg,"Field: ");
strcat(msg,DlgTempField.name);
strcat(msg,"]");
SetWindowText(hDlg,(LPSTR)msg); // set the header
// Set initial values of the parameters
SetDlgItemInt(hDlg,IDC_DEC_PLACES,DlgTempField.DecPlaces,FALSE);
SetDlgItemText(hDlg,IDC_DOLLAR_SYM,(LPSTR)DlgTempField.CurrencySymbol);
SetDlgItemText(hDlg,IDC_NEG_PREFIX,(LPSTR)DlgTempField.NegSignPrefix);
SetDlgItemText(hDlg,IDC_NEG_SUFFIX,(LPSTR)DlgTempField.NegSignSuffix);
SetDlgItemText(hDlg,IDC_POS_PREFIX,(LPSTR)DlgTempField.PosSignPrefix);
SetDlgItemText(hDlg,IDC_POS_SUFFIX,(LPSTR)DlgTempField.PosSignSuffix);
SendMessage(GetDlgItem(hDlg,IDC_SUP_ZERO),BM_SETCHECK, FLAG_SUP_ZERO&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_PAD_ZERO),BM_SETCHECK, FLAG_PAD_ZERO&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_USE_COMMA),BM_SETCHECK, FLAG_COMMA&DlgTempField.flags, 0L);
if (DlgSec>=SEC_FTR_LVL9) { // footer sections
SetDlgItemText(hDlg,IDC_SUM_TYPE,(LPSTR)SumName[DlgTempField.SumType]);
SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_SETCHECK, FLAG_RETAIN&DlgTempField.flags, 0L);
}
SetFocus(GetDlgItem(hDlg,IDC_ALIGN_LEFT));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_SUM_TYPE:
if (DlgSec>=SEC_FTR_LVL9) {
EnableWindow(hDlg,FALSE); // disable our dialog box
idx=CallDialogBox("SumParam",SumParam,(long)DlgTempField.SumType);
EnableWindow(hDlg,TRUE); // enable our dialog box
if (idx>=0) {
DlgTempField.SumType=idx;
SetDlgItemText(hDlg,IDC_SUM_TYPE,(LPSTR)SumName[DlgTempField.SumType]);
return TRUE;
}
}
else {
SetFocus(GetDlgItem(hDlg,IDC_USE_COMMA));
return TRUE;
}
case IDC_RETAIN_VAL:
if (DlgSec>=SEC_FTR_LVL9) {
flag=(int)SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_GETCHECK, 0, 0L);
if (flag) flag=FALSE; // toggle
else flag=TRUE;
SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_SETCHECK, flag, 0L);
return TRUE;
}
else {
SetFocus(GetDlgItem(hDlg,IDC_USE_COMMA));
return TRUE;
}
case IDOK:
DlgTempField.DecPlaces=GetDlgItemInt(hDlg,IDC_DEC_PLACES,NULL,FALSE);
GetDlgItemText(hDlg,IDC_DOLLAR_SYM,(LPSTR)(DlgTempField.CurrencySymbol),4);
GetDlgItemText(hDlg,IDC_NEG_PREFIX,(LPSTR)(DlgTempField.NegSignPrefix),4);
GetDlgItemText(hDlg,IDC_NEG_SUFFIX,(LPSTR)(DlgTempField.NegSignSuffix),4);
GetDlgItemText(hDlg,IDC_POS_PREFIX,(LPSTR)(DlgTempField.PosSignPrefix),4);
GetDlgItemText(hDlg,IDC_POS_SUFFIX,(LPSTR)(DlgTempField.PosSignSuffix),4);
if (SendMessage(GetDlgItem(hDlg,IDC_SUP_ZERO),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_SUP_ZERO;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_SUP_ZERO));
if (SendMessage(GetDlgItem(hDlg,IDC_PAD_ZERO),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_PAD_ZERO;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_PAD_ZERO));
if (SendMessage(GetDlgItem(hDlg,IDC_USE_COMMA),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_COMMA;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_COMMA));
if (SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_RETAIN;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_RETAIN));
field[DlgIndex]=DlgTempField; // transfer to the field array
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
TextFieldParam:
This dialog box allows the user to modify the field attributes for
a text field. The calling routine passes the index of the
field to be modified using the DlgIndex global variable.
****************************************************************************/
BOOL CALLBACK _export TextFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int flag1,flag2,flag3;
switch (message) {
case WM_INITDIALOG:
DlgTempField=field[DlgIndex]; // make a working copy of the field
strcpy(msg,"["); // display the field name
strcat(msg,"Field: ");
strcat(msg,DlgTempField.name);
strcat(msg,"]");
SetWindowText(hDlg,(LPSTR)msg); // set the header
// Set initial values of the parameters
SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_SETCHECK, FLAG_WRAP&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_SETCHECK, FLAG_WORD_WRAP&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_FLEX_SIZE),BM_SETCHECK, FLAG_FLEX_SIZE&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_SETCHECK, FLAG_CAPS&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_SETCHECK, FLAG_FIRST_CAP&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_SETCHECK, FLAG_SMALL&DlgTempField.flags, 0L);
SendMessage(GetDlgItem(hDlg,IDC_TRIM_SPACES),BM_SETCHECK, FLAG_TRIM&DlgTempField.flags, 0L);
// disable word wrap field size field for non word wrap fields
if (!((FLAG_WRAP|FLAG_WORD_WRAP)&DlgTempField.flags)) {
EnableWindow(GetDlgItem(hDlg,IDC_FLEX_SIZE),FALSE);
}
SetFocus(GetDlgItem(hDlg,IDC_ALIGN_LEFT));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_WRAP:
flag1=(int)SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_GETCHECK, 0, 0L);
flag2=(int)SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_GETCHECK, 0, 0L);
if (flag1 && flag2) { // maintain exclusive flags
SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_SETCHECK, FALSE, 0L);
}
EnableWindow(GetDlgItem(hDlg,IDC_FLEX_SIZE),flag1|flag2);
return TRUE;
case IDC_WORD_WRAP:
flag1=(int)SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_GETCHECK, 0, 0L);
flag2=(int)SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_GETCHECK, 0, 0L);
if (flag1 && flag2) { // maintain exclusive flags
SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_SETCHECK, FALSE, 0L);
}
EnableWindow(GetDlgItem(hDlg,IDC_FLEX_SIZE),flag1|flag2);
return TRUE;
case IDC_CAP_ALL: // maintain exclusive flags
case IDC_CAP_FIRST:
case IDC_LOWER:
flag1=(int)SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_GETCHECK, 0, 0L);
flag2=(int)SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_GETCHECK, 0, 0L);
flag3=(int)SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_GETCHECK, 0, 0L);
if (wParam==IDC_CAP_ALL && flag1 && (flag2 || flag3)) { // maintain exclusive flags
SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_SETCHECK, FALSE, 0L);
SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_SETCHECK, FALSE, 0L);
}
if (wParam==IDC_CAP_FIRST && flag2 && (flag1 || flag3)) { // maintain exclusive flags
SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_SETCHECK, FALSE, 0L);
SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_SETCHECK, FALSE, 0L);
}
if (wParam==IDC_LOWER && flag3 && (flag1 || flag2)) { // maintain exclusive flags
SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_SETCHECK, FALSE, 0L);
SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_SETCHECK, FALSE, 0L);
}
return TRUE;
case IDOK:
if (SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_WRAP;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_WRAP));
if (SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_WORD_WRAP;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_WORD_WRAP));
if (SendMessage(GetDlgItem(hDlg,IDC_FLEX_SIZE),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_FLEX_SIZE;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_FLEX_SIZE));
if (SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_CAPS;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_CAPS));
if (SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_FIRST_CAP;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_FIRST_CAP));
if (SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_SMALL;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_SMALL));
if (SendMessage(GetDlgItem(hDlg,IDC_TRIM_SPACES),BM_GETCHECK, 0, 0L))
DlgTempField.flags=(DlgTempField.flags)|FLAG_TRIM;
else DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_TRIM));
field[DlgIndex]=DlgTempField; // transfer to the field array
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
DateFieldParam:
This dialog box allows the user to modify the field attributes for
a date field. The calling routine passes the index of the
field to be modified using the DlgIndex global variable.
****************************************************************************/
BOOL CALLBACK _export DateFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
DlgTempField=field[DlgIndex]; // make a working copy of the field
strcpy(msg,"["); // display the field name
strcat(msg,"Field: ");
strcat(msg,DlgTempField.name);
strcat(msg,"]");
SetWindowText(hDlg,(LPSTR)msg); // set the header
// Set initial values of the parameters
SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_SETCHECK, DlgTempField.DateFormat==DT_MMDDYY, 0L);
SendMessage(GetDlgItem(hDlg,IDC_DDMMYY),BM_SETCHECK, DlgTempField.DateFormat==DT_DDMMYY, 0L);
SendMessage(GetDlgItem(hDlg,IDC_MMDDYYYY),BM_SETCHECK, DlgTempField.DateFormat==DT_MMDDYYYY, 0L);
SendMessage(GetDlgItem(hDlg,IDC_MMMDDYYYY),BM_SETCHECK, DlgTempField.DateFormat==DT_MMMDDYYYY, 0L);
SetDlgItemText(hDlg,IDC_DATE_DELIM,(LPSTR)DlgTempField.DateDelim);
SetFocus(GetDlgItem(hDlg,IDC_MMDDYY));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
if (SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_MMDDYY;
if (SendMessage(GetDlgItem(hDlg,IDC_DDMMYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_DDMMYY;
if (SendMessage(GetDlgItem(hDlg,IDC_MMDDYYYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_MMDDYYYY;
if (SendMessage(GetDlgItem(hDlg,IDC_MMMDDYYYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_MMMDDYYYY;
GetDlgItemText(hDlg,IDC_DATE_DELIM,(LPSTR)(DlgTempField.DateDelim),2);
field[DlgIndex]=DlgTempField; // transfer to the field array
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
LogFieldParam:
This dialog box allows the user to modify the field attributes for
a logical field. The calling routine passes the index of the
field to be modified using the DlgIndex global variable.
****************************************************************************/
BOOL CALLBACK _export LogFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
DlgTempField=field[DlgIndex]; // make a working copy of the field
strcpy(msg,"["); // display the field name
strcat(msg,"Field: ");
strcat(msg,DlgTempField.name);
strcat(msg,"]");
SetWindowText(hDlg,(LPSTR)msg); // set the header
// Set initial values of the parameters
msg[1]=0;
msg[0]=DlgTempField.LogicalSymbols[0]; // TRUE symbol
SetDlgItemText(hDlg,IDC_TRUE,(LPSTR)msg);
msg[0]=DlgTempField.LogicalSymbols[1]; // FALSE symbol
SetDlgItemText(hDlg,IDC_FALSE,(LPSTR)msg);
SetFocus(GetDlgItem(hDlg,IDC_TRUE));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
GetDlgItemText(hDlg,IDC_TRUE,(LPSTR)msg,2);
DlgTempField.LogicalSymbols[0]=msg[0]; // TRUE symbol
GetDlgItemText(hDlg,IDC_FALSE,(LPSTR)msg,2);
DlgTempField.LogicalSymbols[1]=msg[0]; // FALSE symbol
field[DlgIndex]=DlgTempField; // transfer to the field array
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
DlgInputParam:
This dialog box input the specified user input field. The input of
the input field is passed using the DlgIndex global variable. The long
parameters specifies first (0) or the last (MAX_DLGS) input field.
****************************************************************************/
BOOL CALLBACK _export DlgInputParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
RECT rect1,rect2;
int FieldWidth,DlgBoxWidth,FrameWidth,FrameHeight;
DWORD XBaseUnits;
switch (message) {
case WM_INITDIALOG:
// Set initial values of the parameters
SetDlgItemText(hDlg,IDC_DLG_PROMPT,(LPSTR)DlgField[DlgIndex].prompt);
//***** set the input field width *****
GetWindowRect(hDlg,(LPRECT) &rect1); // get outer dimensions
FrameWidth=GetSystemMetrics(SM_CXDLGFRAME);
FrameHeight=GetSystemMetrics(SM_CYDLGFRAME);
rect1.left+=FrameWidth; // calculate absolute dimensions of the client window
rect1.right-=FrameWidth;
rect1.top+=FrameHeight;
rect1.bottom-=FrameHeight;
GetWindowRect(GetDlgItem(hDlg,IDC_DLG_INPUT),(LPRECT) &rect2);
XBaseUnits=GetDialogBaseUnits();
FieldWidth=(DlgField[DlgIndex].width+1)*(LOWORD(XBaseUnits));
DlgBoxWidth=rect1.right-rect1.left;
if (FieldWidth>DlgBoxWidth) FieldWidth=DlgBoxWidth;
rect2.left=rect1.left+(DlgBoxWidth-FieldWidth)/2;
SetWindowPos(GetDlgItem(hDlg,IDC_DLG_INPUT),NULL,
rect2.left-rect1.left,rect2.top-rect1.top,
FieldWidth,rect2.bottom-rect2.top,
SWP_NOREDRAW|SWP_NOZORDER);
SetDlgItemText(hDlg,IDC_DLG_INPUT,(LPSTR)DlgField[DlgIndex].CharData);
if (lParam==0 || DlgIndex==0) SetDlgItemText(hDlg,IDC_DLG_PREV,(LPSTR)"Cancel");
if (lParam==MAX_DLGS) SetDlgItemText(hDlg,IDC_DLG_NEXT,(LPSTR)"Ok");
SetFocus(GetDlgItem(hDlg,IDC_DLG_INPUT));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_DLG_NEXT:
GetDlgItemText(hDlg,IDC_DLG_INPUT,(LPSTR)DlgField[DlgIndex].CharData,NAME_WIDTH);
EndDialog(hDlg, TRUE);
FrModified=TRUE;
return TRUE;
case IDC_DLG_PREV:
GetDlgItemText(hDlg,IDC_DLG_INPUT,(LPSTR)DlgField[DlgIndex].CharData,NAME_WIDTH);
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
PosParam:
This dialog box edits the text position within the current item outlines
****************************************************************************/
BOOL CALLBACK _export PosParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
UINT flags;
switch (message) {
case WM_INITDIALOG:
flags=item[SelItem].flags;
// Set horizontal position flag
SendDlgItemMessage(hDlg,IDC_HLEFT,BM_SETCHECK, flags&OFLAG_HLEFT, 0L);
SendDlgItemMessage(hDlg,IDC_HCENTER,BM_SETCHECK, flags&OFLAG_HCENTER, 0L);
SendDlgItemMessage(hDlg,IDC_HRIGHT,BM_SETCHECK, flags&OFLAG_HRIGHT, 0L);
// Set vertical position flag
SendDlgItemMessage(hDlg,IDC_VTOP,BM_SETCHECK, flags&OFLAG_VTOP, 0L);
SendDlgItemMessage(hDlg,IDC_VCENTER,BM_SETCHECK, flags&OFLAG_VCENTER, 0L);
SendDlgItemMessage(hDlg,IDC_VBOTTOM,BM_SETCHECK, flags&OFLAG_VBOTTOM, 0L);
SetFocus(GetDlgItem(hDlg,IDOK));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
// set the position flags
flags=(item[SelItem].flags)&(~((UINT)OFLAG_HLEFT|OFLAG_HCENTER|OFLAG_HRIGHT|OFLAG_VTOP|OFLAG_VCENTER|OFLAG_VBOTTOM));
if (SendDlgItemMessage(hDlg,IDC_HLEFT,BM_GETCHECK, 0, 0L)) flags|=OFLAG_HLEFT;
if (SendDlgItemMessage(hDlg,IDC_HRIGHT,BM_GETCHECK, 0, 0L)) flags|=OFLAG_HRIGHT;
if (SendDlgItemMessage(hDlg,IDC_HCENTER,BM_GETCHECK, 0, 0L)) flags|=OFLAG_HCENTER;
if (SendDlgItemMessage(hDlg,IDC_VTOP,BM_GETCHECK, 0, 0L)) flags|=OFLAG_VTOP;
if (SendDlgItemMessage(hDlg,IDC_VCENTER,BM_GETCHECK, 0, 0L)) flags|=OFLAG_VCENTER;
if (SendDlgItemMessage(hDlg,IDC_VBOTTOM,BM_GETCHECK, 0, 0L)) flags|=OFLAG_VBOTTOM;
item[SelItem].flags=flags;
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
LineParam:
This dialog box edits the line properties for a line type item.
****************************************************************************/
BOOL CALLBACK _export LineParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int style,angle;
switch (message) {
case WM_INITDIALOG:
// set the initial values
angle=item[SelItem].LineAngle; // outline style
SendDlgItemMessage(hDlg,IDC_LINE_HORZ,BM_SETCHECK, angle==ANGLE_HORZ, 0L);
SendDlgItemMessage(hDlg,IDC_LINE_VERT,BM_SETCHECK, angle==ANGLE_VERT, 0L);
SendDlgItemMessage(hDlg,IDC_LINE_FDIAG,BM_SETCHECK, angle==ANGLE_FDIAG, 0L);
SendDlgItemMessage(hDlg,IDC_LINE_BDIAG,BM_SETCHECK, angle==ANGLE_BDIAG, 0L);
style=item[SelItem].LineStyle; // outline style
SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_SETCHECK, style==PS_SOLID, 0L);
SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_SETCHECK, style==PS_DASH, 0L);
SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_SETCHECK, style==PS_DOT, 0L);
SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_SETCHECK, style==PS_DASHDOT, 0L);
SetDlgItemInt(hDlg,IDC_LINE_WIDTH,item[SelItem].LineWidth,FALSE);
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LINE_COLOR:
item[SelItem].LineColor=EditColor(hDlg,item[SelItem].LineColor,FALSE);
break;
case IDOK:
angle=item[SelItem].LineAngle;
if (SendDlgItemMessage(hDlg,IDC_LINE_HORZ,BM_GETCHECK, 0, 0L)) angle=ANGLE_HORZ;
if (SendDlgItemMessage(hDlg,IDC_LINE_VERT,BM_GETCHECK, 0, 0L)) angle=ANGLE_VERT;
if (SendDlgItemMessage(hDlg,IDC_LINE_FDIAG,BM_GETCHECK, 0, 0L)) angle=ANGLE_FDIAG;
if (SendDlgItemMessage(hDlg,IDC_LINE_BDIAG,BM_GETCHECK, 0, 0L)) angle=ANGLE_BDIAG;
item[SelItem].LineAngle=angle;
style=item[SelItem].LineStyle;
if (SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_GETCHECK, 0, 0L)) style=PS_SOLID;
if (SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_GETCHECK, 0, 0L)) style=PS_DASH;
if (SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_GETCHECK, 0, 0L)) style=PS_DOT;
if (SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_GETCHECK, 0, 0L)) style=PS_DASHDOT;
item[SelItem].LineStyle=style;
item[SelItem].LineWidth=GetDlgItemInt(hDlg,IDC_LINE_WIDTH,NULL,FALSE);
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
OutlineParam:
This dialog box edits the item outline style and color
****************************************************************************/
BOOL CALLBACK _export OutlineParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
UINT flags;
int style;
switch (message) {
case WM_INITDIALOG:
// set the initial values
flags=item[SelItem].OutlineSelect;
SendDlgItemMessage(hDlg,IDC_LINE_LEFT,BM_SETCHECK, flags&OUTLINE_LEFT, 0L);
SendDlgItemMessage(hDlg,IDC_LINE_RIGHT,BM_SETCHECK, flags&OUTLINE_RIGHT, 0L);
SendDlgItemMessage(hDlg,IDC_LINE_TOP,BM_SETCHECK, flags&OUTLINE_TOP, 0L);
SendDlgItemMessage(hDlg,IDC_LINE_BOT,BM_SETCHECK, flags&OUTLINE_BOT, 0L);
SetDlgItemInt(hDlg,IDC_LINE_WIDTH,item[SelItem].OutlineWidth,FALSE);
style=item[SelItem].OutlineStyle; // outline style
SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_SETCHECK, style==PS_SOLID, 0L);
SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_SETCHECK, style==PS_DASH, 0L);
SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_SETCHECK, style==PS_DOT, 0L);
SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_SETCHECK, style==PS_DASHDOT, 0L);
//disable options whne outline not selected
if (!flags) {
EnableWindow(GetDlgItem(hDlg,IDC_LINE_WIDTH),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_SOLID),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASH),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DOT),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASHDOT),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_LINE_COLOR),FALSE);
}
SetFocus(GetDlgItem(hDlg,IDC_LINE_LEFT));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_LINE_LEFT: // disable enable controls
case IDC_LINE_RIGHT:
case IDC_LINE_TOP:
case IDC_LINE_BOT:
flags=FALSE;
if (SendDlgItemMessage(hDlg,IDC_LINE_LEFT,BM_GETCHECK, 0, 0L)
|| SendDlgItemMessage(hDlg,IDC_LINE_RIGHT,BM_GETCHECK, 0, 0L)
|| SendDlgItemMessage(hDlg,IDC_LINE_TOP,BM_GETCHECK, 0, 0L)
|| SendDlgItemMessage(hDlg,IDC_LINE_BOT,BM_GETCHECK, 0, 0L)) flags=TRUE;
EnableWindow(GetDlgItem(hDlg,IDC_LINE_WIDTH),flags);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_SOLID),flags);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASH),flags);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DOT),flags);
EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASHDOT),flags);
EnableWindow(GetDlgItem(hDlg,IDC_LINE_COLOR),flags);
break;
case IDC_LINE_COLOR:
item[SelItem].OutlineColor=EditColor(hDlg,item[SelItem].OutlineColor,FALSE);
break;
case IDOK:
flags=0;
if (SendDlgItemMessage(hDlg,IDC_LINE_LEFT,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_LEFT;
if (SendDlgItemMessage(hDlg,IDC_LINE_RIGHT,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_RIGHT;
if (SendDlgItemMessage(hDlg,IDC_LINE_TOP,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_TOP;
if (SendDlgItemMessage(hDlg,IDC_LINE_BOT,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_BOT;
item[SelItem].OutlineSelect=flags;
style=item[SelItem].OutlineStyle;
if (SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_GETCHECK, 0, 0L)) style=PS_SOLID;
if (SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_GETCHECK, 0, 0L)) style=PS_DASH;
if (SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_GETCHECK, 0, 0L)) style=PS_DOT;
if (SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_GETCHECK, 0, 0L)) style=PS_DASHDOT;
item[SelItem].OutlineStyle=style;
item[SelItem].OutlineWidth=GetDlgItemInt(hDlg,IDC_LINE_WIDTH,NULL,FALSE);
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
BackgroundParam:
This dialog box edits the item background brush style and color
****************************************************************************/
BOOL CALLBACK _export BackgroundParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
UINT flags;
int style,hatch;
switch (message) {
case WM_INITDIALOG:
// set the initial values
flags=item[SelItem].flags;
SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_SETCHECK, flags&OFLAG_FILL, 0L);
style=item[SelItem].brush.lbStyle; // brush style
hatch=item[SelItem].brush.lbHatch; // brush hatch type
SendDlgItemMessage(hDlg,IDC_BRUSH_SOLID,BM_SETCHECK, style==BS_SOLID, 0L);
SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_HORZ,BM_SETCHECK, style==BS_HATCHED && hatch==HS_HORIZONTAL, 0L);
SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_VERT,BM_SETCHECK, style==BS_HATCHED && hatch==HS_VERTICAL, 0L);
SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_CROSS,BM_SETCHECK, style==BS_HATCHED && hatch==HS_CROSS, 0L);
SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS,BM_SETCHECK, style==BS_HATCHED && hatch==HS_DIAGCROSS, 0L);
SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_FDIAG,BM_SETCHECK, style==BS_HATCHED && hatch==HS_FDIAGONAL, 0L);
SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_BDIAG,BM_SETCHECK, style==BS_HATCHED && hatch==HS_BDIAGONAL, 0L);
//disable options whne outline not selected
if (!SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_GETCHECK, 0, 0L)) {
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_SOLID),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_HORZ),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_VERT),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_CROSS),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_FDIAG),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_BDIAG),FALSE);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_COLOR),FALSE);
}
SetFocus(GetDlgItem(hDlg,IDC_PAINT_BACKGROUND));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDC_PAINT_BACKGROUND: // disable enable controls
flags=(UINT)SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_GETCHECK, 0, 0L);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_SOLID),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_HORZ),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_VERT),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_CROSS),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_FDIAG),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_BDIAG),flags);
EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_COLOR),flags);
break;
case IDC_BRUSH_COLOR:
item[SelItem].brush.lbColor=EditColor(hDlg,item[SelItem].brush.lbColor,FALSE);
break;
case IDOK:
flags=(item[SelItem].flags)&(~((UINT)OFLAG_FILL));
if (SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_GETCHECK, 0, 0L)) flags|=OFLAG_FILL;
item[SelItem].flags=flags;
hatch=item[SelItem].brush.lbHatch;
if (SendDlgItemMessage(hDlg,IDC_BRUSH_SOLID,BM_GETCHECK, 0, 0L)) style=BS_SOLID;
else {
style=BS_HATCHED; // hatched brush
if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_HORZ,BM_GETCHECK, 0, 0L)) hatch=HS_HORIZONTAL;
if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_VERT,BM_GETCHECK, 0, 0L)) hatch=HS_VERTICAL;
if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_CROSS,BM_GETCHECK, 0, 0L)) hatch=HS_CROSS;
if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS,BM_GETCHECK, 0, 0L)) hatch=HS_DIAGCROSS;
if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_FDIAG,BM_GETCHECK, 0, 0L)) hatch=HS_FDIAGONAL;
if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_BDIAG,BM_GETCHECK, 0, 0L)) hatch=HS_BDIAGONAL;
}
item[SelItem].brush.lbStyle=style;
item[SelItem].brush.lbHatch=hatch;
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
default:
;
}
break;
}
return (FALSE);
}
/****************************************************************************
EditColor:
This dialog box allows the user to select the new color. The third
option when TRUE allows for customized colors.
****************************************************************************/
COLORREF EditColor(HWND hDlg,COLORREF InColor,BOOL FullOpen)
{
CHOOSECOLOR cColor;
DWORD CustColors[16];
BYTE clr;
int i;
float increment;
// fill the CustColors array with 16 shades of gray
increment=(float)255/(float)16;
for (i=0;i<16;i++) {
clr=(BYTE)((i+1)*increment);
CustColors[i]=RGB(clr,clr,clr);
}
// fill the CHOOSECOLOR structure
FarMemSet(&cColor,0,sizeof(CHOOSECOLOR));
cColor.lStructSize=sizeof(CHOOSECOLOR);
cColor.hwndOwner=hDlg;
cColor.rgbResult=InColor;
cColor.lpCustColors=CustColors;
if (FullOpen) cColor.Flags=CC_FULLOPEN|CC_RGBINIT;
else cColor.Flags=CC_PREVENTFULLOPEN|CC_RGBINIT;
if (ChooseColor(&cColor)) return cColor.rgbResult;
else return InColor;
}
/******************************************************************************
PrintParam:
Select pages to print.
******************************************************************************/
BOOL CALLBACK _export PrintParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int LastCompletePage;
switch (message) {
case WM_INITDIALOG: // initialize parameters
SetDlgItemInt(hDlg,IDC_FIRST_PAGE,ScrPage+1,FALSE);
SetDlgItemInt(hDlg,IDC_LAST_PAGE,ScrPage+1,FALSE);
SetFocus(GetDlgItem(hDlg,IDC_FIRST_PAGE));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
FirstPrintPage=GetDlgItemInt(hDlg,IDC_FIRST_PAGE,NULL,FALSE);
LastPrintPage=GetDlgItemInt(hDlg,IDC_LAST_PAGE,NULL,FALSE);
// validate
if (ReportStage==IN_EXIT) LastCompletePage=PageCount;
else LastCompletePage=PageCount-1;
if (FirstPrintPage<1 || FirstPrintPage>LastPrintPage || LastPrintPage>LastCompletePage) {
MessageBox(hDlg,"Invalid Page Selection!",NULL,MB_OK);
SetFocus(GetDlgItem(hDlg,IDC_FIRST_PAGE));
break;
}
EndDialog(hDlg, TRUE);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}
/******************************************************************************
JumpParam:
Request the page number to jump to. The function returns 0 when the
user selects cancel.
******************************************************************************/
int CALLBACK _export JumpParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int LastCompletePage,page;
switch (message) {
case WM_INITDIALOG: // initialize parameters
SetDlgItemInt(hDlg,IDC_JUMP_PAGE,ScrPage+1,FALSE);
SetFocus(GetDlgItem(hDlg,IDC_FIRST_PAGE));
return (FALSE);
case WM_COMMAND:
switch (CONTROL_ID(wParam,lParam)) {
case IDOK:
page=GetDlgItemInt(hDlg,IDC_JUMP_PAGE,NULL,FALSE);
// validate page range
if (ReportStage==IN_EXIT) LastCompletePage=PageCount;
else LastCompletePage=PageCount-1;
if (page<1) page=1;
if (page>LastCompletePage) page=LastCompletePage;
EndDialog(hDlg, page);
return (TRUE);
case IDCANCEL:
EndDialog(hDlg, 0);
return (TRUE);
default:
;
}
break;
}
return (FALSE);
}