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 >
C/C++ Source or Header  |  1995-01-20  |  84KB  |  1,924 lines

  1. /*==============================================================================
  2.    REP_DLG.C
  3.    Report Ease: All dialog box handling routines
  4.  
  5.    Report Ease
  6.    Sub Systems, Inc.
  7.    ReportEase, Copyright (c) 1992, Sub Systems, Inc. All Rights Reserved.
  8.    159 Main Street, #8C, Stoneham,  MA 02180 
  9.    (617) 438-8901.
  10.  
  11.    Software License Agreement  (1992)              
  12.    ----------------------------------
  13.    This license agreement allows the purchaser the right to modify the 
  14.    source code to incorporate in their application.
  15.    The target application must not be distributed as a standalone report writer
  16.    or a mail merge product.
  17.    Sub Systems, Inc. reserves the right to prosecute anybody found to be 
  18.    making illegal copies of the executable software or compiling the source
  19.    code for the purpose of selling there after.
  20. ===============================================================================*/
  21.  
  22. #include "windows.h"
  23.  
  24. #if defined (_WIN32)
  25.    #if !defined(WIN32)
  26.      #define WIN32
  27.    #endif
  28. #endif
  29. #if !defined(WIN32) 
  30.   #include "print.h"
  31. #endif
  32.  
  33. #include "stdio.h"
  34. #include "stdlib.h"
  35. #include "ctype.h"
  36. #include "fcntl.h"
  37. #include "io.h"
  38. #include "string.h"
  39. #include "sys\types.h"
  40. #include "sys\stat.h"
  41. #include "setjmp.h"
  42.  
  43. #include "commdlg.h"
  44.  
  45. #include "rep.h"
  46.  
  47. #define  PREFIX extern
  48. #include "rep1.h"
  49.  
  50. #include "rep_dlg.h"
  51.  
  52. /******************************************************************************
  53.     RepParam:
  54.     Accepts the name, page margins, and other report related parameters.
  55. ******************************************************************************/
  56. BOOL CALLBACK _export RepParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  57. {
  58.  
  59.     switch (message) {
  60.         case WM_INITDIALOG:                  // initialize parameters 
  61.             SetDlgItemText(hDlg,IDC_NAME,(LPSTR)FormHdr.name);
  62.             
  63.             SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_SETCHECK, FormHdr.DateFormat==0, 0L);
  64.             SendMessage(GetDlgItem(hDlg,IDC_DDMMYY),BM_SETCHECK, FormHdr.DateFormat==1, 0L);
  65.  
  66.             SendMessage(GetDlgItem(hDlg,IDC_PRINT_TRIAL),BM_SETCHECK, RFLAG_TRIAL&FormHdr.flags, 0L);
  67.           
  68.             SendMessage(GetDlgItem(hDlg,IDC_RULER_OFF) ,BM_SETCHECK, FormHdr.RulerType==RULER_OFF, 0L);
  69.             SendMessage(GetDlgItem(hDlg,IDC_RULER_INCH),BM_SETCHECK, FormHdr.RulerType==RULER_INCH, 0L);
  70.             SendMessage(GetDlgItem(hDlg,IDC_RULER_CM)  ,BM_SETCHECK, FormHdr.RulerType==RULER_CM, 0L);
  71.  
  72.             SetDlgItemText(hDlg,IDC_LEFT_MARGIN,DoubleToStr((double)FormHdr.LeftMargin,2,msg));
  73.             SetDlgItemText(hDlg,IDC_RIGHT_MARGIN,DoubleToStr((double)FormHdr.RightMargin,2,msg));
  74.             SetDlgItemText(hDlg,IDC_TOP_MARGIN,DoubleToStr((double)FormHdr.TopMargin,2,msg));
  75.             SetDlgItemText(hDlg,IDC_BOT_MARGIN,DoubleToStr((double)FormHdr.BottomMargin,2,msg));
  76.             
  77.             SetFocus(GetDlgItem(hDlg,IDC_NAME));
  78.             return (FALSE);
  79.             
  80.         case WM_COMMAND:
  81.             switch (CONTROL_ID(wParam,lParam)) {
  82.                 case IDOK:
  83.                    // validate margin parameters 
  84.                    if (!CheckDlgValue(hDlg,'F',IDC_LEFT_MARGIN,0,9)) return (TRUE);
  85.                    if (!CheckDlgValue(hDlg,'F',IDC_RIGHT_MARGIN,0,9)) return (TRUE);
  86.                    if (!CheckDlgValue(hDlg,'F',IDC_TOP_MARGIN,0,9)) return (TRUE);
  87.                    if (!CheckDlgValue(hDlg,'F',IDC_BOT_MARGIN,0,9)) return (TRUE);
  88.                    
  89.                    // extract margin parameters 
  90.                    GetDlgItemText(hDlg,IDC_LEFT_MARGIN,msg,100);
  91.                    FormHdr.LeftMargin=(float)atof(msg);
  92.  
  93.                    GetDlgItemText(hDlg,IDC_RIGHT_MARGIN,msg,100);
  94.                    FormHdr.RightMargin=(float)atof(msg);
  95.  
  96.                    GetDlgItemText(hDlg,IDC_TOP_MARGIN,msg,100);
  97.                    FormHdr.TopMargin=(float)atof(msg);
  98.  
  99.                    GetDlgItemText(hDlg,IDC_BOT_MARGIN,msg,100);
  100.                    FormHdr.BottomMargin=(float)atof(msg);
  101.  
  102.                    //***** extract report name *****
  103.                    GetDlgItemText(hDlg,IDC_NAME,FormHdr.name,NAME_WIDTH);
  104.                    
  105.                    //****** extract date format **
  106.                    if (SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_GETCHECK, 0, 0L)) 
  107.                          FormHdr.DateFormat=0;
  108.                    else  FormHdr.DateFormat=1;
  109.  
  110.                    //****** extract ruler type **
  111.                    if      (SendMessage(GetDlgItem(hDlg,IDC_RULER_OFF) ,BM_GETCHECK, 0, 0L)) FormHdr.RulerType=RULER_OFF;
  112.                    else if (SendMessage(GetDlgItem(hDlg,IDC_RULER_INCH),BM_GETCHECK, 0, 0L)) FormHdr.RulerType=RULER_INCH;
  113.                    else FormHdr.RulerType=RULER_CM;
  114.  
  115.                    //****** extract flags ******
  116.                    if (SendMessage(GetDlgItem(hDlg,IDC_PRINT_TRIAL),BM_GETCHECK, 0, 0L)) 
  117.                          FormHdr.flags=(FormHdr.flags)|RFLAG_TRIAL;
  118.                    else  FormHdr.flags=(FormHdr.flags)&(~((UINT)RFLAG_TRIAL));
  119.                    
  120.                    FrModified=TRUE;
  121.                    EndDialog(hDlg, TRUE);
  122.                    return (TRUE);
  123.         
  124.                 case IDCANCEL:
  125.                    EndDialog(hDlg, FALSE);
  126.                    return (TRUE);
  127.                 default:
  128.                    ;
  129.             }
  130.             break;
  131.     }
  132.     return (FALSE);
  133. }
  134.  
  135. /******************************************************************************
  136.     PrintAbortParam:
  137.     Handles the user request to abort printing.
  138. ******************************************************************************/
  139. BOOL CALLBACK _export PrintAbortParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  140. {
  141.  
  142.     switch (message) {
  143.         case WM_INITDIALOG:                  // initialize parameters 
  144.             hAbortDlg=hDlg;                  // save the dialog window handle 
  145.             
  146.             SetDlgItemText(hDlg,IDC_CUR_PRINTER,PrinterName);
  147.             SetDlgItemText(hDlg,IDC_CUR_PAGE,"0");
  148.             SetDlgItemText(hDlg,IDC_CUR_REC,"0");
  149.             
  150.             SetFocus(GetDlgItem(hDlg,IDCANCEL));
  151.             return (TRUE);
  152.  
  153.         case WM_COMMAND:
  154.             ReportStatus=REP_ABORT;
  155.             return TRUE;
  156.     }
  157.     
  158.     return FALSE;
  159. }
  160.  
  161. /******************************************************************************
  162.     ScrPrintAbortParam:
  163.     Handles the user request to abort screen printing.
  164. ******************************************************************************/
  165. BOOL CALLBACK _export ScrPrintAbortParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  166. {
  167.  
  168.     switch (message) {
  169.         case WM_INITDIALOG:                  // initialize parameters 
  170.             hAbortDlg=hDlg;                  // save the dialog window handle 
  171.             
  172.             SetDlgItemText(hDlg,IDC_CUR_PRINTER,PrinterName);
  173.             SetDlgItemText(hDlg,IDC_CUR_PAGE,"0");
  174.             
  175.             SetFocus(GetDlgItem(hDlg,IDCANCEL));
  176.             return (TRUE);
  177.  
  178.         case WM_COMMAND:
  179.             SetDlgItemText(hDlg,IDC_CUR_PRINTER,"Cancelling..., Please Wait.");
  180.             ReportStatus=REP_ABORT;
  181.             EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE);
  182.             return TRUE;
  183.     }
  184.     
  185.     return FALSE;
  186. }
  187.  
  188. /****************************************************************************
  189.     PrinterParam:
  190.     This dialog box allows the printer selection and setup.
  191. ****************************************************************************/
  192.  
  193. BOOL CALLBACK _export PrinterParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  194. {
  195.     int     i,j;
  196.     LPSTR   PrinterList;
  197.     char    CurPrinter[NAME_WIDTH+2],string[NAME_WIDTH+3];
  198.     int     count,CurSel,idx;
  199.     char    ProfString[3][NAME_WIDTH+2],far *ptr;
  200.     BOOL    CurPrinterFound;
  201.  
  202.  
  203.     switch (message) {
  204.         case WM_INITDIALOG:
  205.             //****************** get the printer list ***********************
  206.             if (NULL==(PrinterList=GetPrinterList(&count))) return FALSE;
  207.  
  208.             // Set initial values of the parameters 
  209.             idx=0;
  210.             CurSel=0;
  211.             CurPrinterFound=FALSE;
  212.             for (i=0;i<count;i++) {
  213.                lstrcpy(CurPrinter,&PrinterList[idx]);
  214.                idx=idx+strlen(CurPrinter)+1;
  215.  
  216.                //**** get the printer ports ****
  217.                ParseProfileString("devices",CurPrinter,ProfString[0],ProfString[1],ProfString[2]);
  218.                for (j=1;j<3;j++) {
  219.                   StrTrim(ProfString[j]);
  220.                   if (ProfString[j][0]!=0) {
  221.                      strcpy(string,CurPrinter);
  222.                      strcat(string," On ");
  223.                      strcat(string,ProfString[j]);
  224.                      SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_ADDSTRING, 0, (DWORD)(LPSTR)string);
  225.                      if (strcmpi(CurPrinter,PrinterName)==0 && strcmp(ProfString[j],PrinterPort)==0) {
  226.                         CurPrinterFound=TRUE;
  227.                      }
  228.                      if (!CurPrinterFound) CurSel++;
  229.                   }
  230.  
  231.                }
  232.             }
  233.  
  234.             SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_SETCURSEL, CurSel,0L);
  235.             SetFocus(GetDlgItem(hDlg,IDC_PRINTER_LIST));
  236.             OurFree(PrinterList);
  237.             return (FALSE);
  238.  
  239.         case WM_COMMAND:
  240.             switch (CONTROL_ID(wParam,lParam)) {
  241.                 case IDC_PRINTER_LIST:
  242.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  243.  
  244.                 case IDC_PRINTER_SETUP:
  245.  
  246.                 case IDOK:
  247.                    CurSel=(int)SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_GETCURSEL, 0,0L);
  248.                    if (SendMessage(GetDlgItem(hDlg,IDC_PRINTER_LIST),LB_GETTEXT, CurSel,(DWORD)(LPSTR)string)==LB_ERR) return TRUE;
  249.                    
  250.                    //**** extract the printer name,driver and port ***
  251.                    if (NULL==(ptr=strstr(string," On "))) return TRUE;
  252.                    strcpy(PrinterPort,&ptr[4]);
  253.                    (*ptr)=0;
  254.                    strcpy(PrinterName,string);
  255.                    ParseProfileString("devices",PrinterName,ProfString[0],ProfString[1],ProfString[2]);
  256.                    strcpy(PrinterDriver,ProfString[0]);
  257.                    if (strstr(PrinterDriver,".DRV")==NULL && strstr(PrinterDriver,".drv")==NULL)
  258.                       strcat(PrinterDriver,".DRV");
  259.                    InitPrinter();          // read the printer characteristics 
  260.  
  261.                    //******** do printer setup ********
  262.                    if (wParam==IDC_PRINTER_SETUP) {
  263.                       if (!CallPrinterDriver(DM_PROMPT|DM_COPY|DM_UPDATE)) return TRUE;
  264.                       SetFocus(GetDlgItem(hDlg,IDOK));
  265.                    }
  266.                    else {
  267.                       ProcessPrinterData();          // calculate report width 
  268.                       EndDialog(hDlg, 1);
  269.                    }
  270.  
  271.                    FrModified=TRUE;
  272.                    return (TRUE);
  273.         
  274.                 case IDCANCEL:
  275.                    EndDialog(hDlg, 0);
  276.                    return (TRUE);
  277.                 default:
  278.                    ;
  279.             }
  280.             break;
  281.     }
  282.     return (FALSE);
  283. }
  284.  
  285. /****************************************************************************
  286.     NewSecParam:
  287.     This dialog box shows a list of section names to choose from. The dialog
  288.     box returns the index of the selected section.
  289. ****************************************************************************/
  290.  
  291. int CALLBACK _export NewSecParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  292. {
  293.     int i;
  294.     char far *(far *SecName);
  295.  
  296.     switch (message) {
  297.         case WM_INITDIALOG:
  298.             // Set initial values of the parameters 
  299.             SecName=(char far * far *)(DWORD)lParam;
  300.  
  301.             i=0;
  302.             while (SecName[i]!=NULL) {
  303.                SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)SecName[i]);
  304.                i++;
  305.             }
  306.             
  307.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
  308.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  309.             return (FALSE);
  310.  
  311.         case WM_COMMAND:
  312.             switch (CONTROL_ID(wParam,lParam)) {
  313.                 case IDC_LIST_BOX:
  314.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  315.  
  316.                 case IDOK:
  317.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  318.                    EndDialog(hDlg, i);
  319.                    FrModified=TRUE;
  320.                    return (TRUE);
  321.         
  322.                 case IDCANCEL:
  323.                    EndDialog(hDlg, -1);
  324.                    return (TRUE);
  325.                 default:
  326.                    ;
  327.             }
  328.             break;
  329.     }
  330.     return (FALSE);
  331. }
  332.  
  333. /****************************************************************************
  334.     SysParam:
  335.     This dialog box shows a list of system fields to choose from.  The dialog
  336.     box returns the index of the selected system field.
  337. ****************************************************************************/
  338.  
  339. int CALLBACK _export SysParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  340. {
  341.     int i;
  342.  
  343.     switch (message) {
  344.         case WM_INITDIALOG:
  345.             // Set initial values of the parameters 
  346.             for (i=0;i<MAX_SYS_FIELDS;i++) {
  347.                SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)SysField[i].name);
  348.             }
  349.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
  350.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  351.             return (FALSE);
  352.  
  353.         case WM_COMMAND:
  354.             switch (CONTROL_ID(wParam,lParam)) {
  355.                 case IDC_LIST_BOX:
  356.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  357.  
  358.                 case IDOK:
  359.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  360.                    EndDialog(hDlg, i);
  361.                    FrModified=TRUE;
  362.                    return (TRUE);
  363.         
  364.                 case IDCANCEL:
  365.                    EndDialog(hDlg, -1);
  366.                    return (TRUE);
  367.                 default:
  368.                    ;
  369.             }
  370.             break;
  371.     }
  372.     return (FALSE);
  373. }
  374.  
  375. /******************************************************************************
  376.     FieldNameParam:
  377.     Accepts a calculation field name. The field name is passed in the 
  378.     global variable 'msg'.
  379. ******************************************************************************/
  380. BOOL CALLBACK _export FieldNameParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  381. {
  382.     char name[NAME_WIDTH+2];
  383.     int i;
  384.  
  385.     switch (message) {
  386.         case WM_INITDIALOG:                  // initialize parameters 
  387.             SetFocus(GetDlgItem(hDlg,IDC_NAME));
  388.             return (FALSE);
  389.  
  390.         case WM_COMMAND:
  391.             switch (CONTROL_ID(wParam,lParam)) {
  392.                 case IDOK:
  393.                    GetDlgItemText(hDlg,IDC_NAME,name,NAME_WIDTH-6);
  394.                    name[NAME_WIDTH-6]=0;
  395.                    strupr(name);
  396.                    StrTrim(name);
  397.                    for(i=0;i<(int)strlen(name);i++)  {
  398.                       if ((name[i]<'A' || name[i]>'Z') 
  399.                         &&(name[i]<'0' || name[i]>'9')
  400.                         && name[i]!='_') {
  401.                          MessageBox(hDlg,"Invalid Character in the Field Name.","Naming Error",MB_OK);
  402.                          return TRUE;
  403.                       }
  404.                    }
  405.                    if (name[0]==0) return TRUE;
  406.                    strcpy(msg,"CALC->");
  407.                    strcat(msg,name);
  408.                    for (i=0;i<TotalFields;i++) {
  409.                       if (field[i].InUse && lstrcmp(field[i].name,msg)==0) {
  410.                          MessageBox(hDlg,"Duplicate Name Not Allowed!","Naming Error",MB_OK);
  411.                          return TRUE;
  412.                       }
  413.                    }
  414.  
  415.                    EndDialog(hDlg, TRUE);
  416.                    FrModified=TRUE;
  417.                    return (TRUE);
  418.         
  419.                 case IDCANCEL:
  420.                    EndDialog(hDlg, FALSE);
  421.                    return (TRUE);
  422.                 default:
  423.                    ;
  424.             }
  425.             break;
  426.     }
  427.     return (FALSE);
  428. }
  429.  
  430. /******************************************************************************
  431.     ExpParam:
  432.     Accepts an expression. An expression can be used to create a calculated
  433.     field, specify record and section selection criteria.
  434. ******************************************************************************/
  435. BOOL CALLBACK _export ExpParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  436. {
  437.     int   idx;
  438.     DWORD CursPos;
  439.     LPSTR SaveDlgExpString;
  440.     struct StrField CurField;
  441.  
  442.     switch (message) {
  443.         case WM_INITDIALOG:                  // initialize parameters 
  444.             if (lParam!=0) SetWindowText(hDlg,(LPSTR)lParam);    // set the header 
  445.             SetDlgItemText(hDlg,IDC_EXP,DlgExpString);
  446.             CursPos=DlgCursPos;
  447.             CursPos=CursPos<<16;
  448.             CursPos=CursPos+DlgCursPos;
  449.             SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_SETSEL,0, CursPos);
  450.             SetFocus(GetDlgItem(hDlg,IDC_EXP));
  451.             return (FALSE);
  452.  
  453.         case WM_COMMAND:
  454.             switch (CONTROL_ID(wParam,lParam)) {
  455.                 case IDC_DATA_FIELD:
  456.                    if ((FormArg.UserSelection)(hDlg,&CurField,0)) {
  457.                       SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
  458.                    }
  459.                    SetFocus(GetDlgItem(hDlg,IDC_EXP));
  460.                    return (TRUE);
  461.  
  462.                 case IDC_SYS_FIELD:
  463.                    if ((idx=CallDialogBox("SysParam",SysParam,0L))>=0) {
  464.                       lstrcpy(CurField.name,"SYS->");
  465.                       lstrcat(CurField.name,SysField[idx].name);
  466.                       SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
  467.                    }
  468.                    SetFocus(GetDlgItem(hDlg,IDC_EXP));
  469.                    return (TRUE);
  470.  
  471.                 case IDC_DLG_FIELD:
  472.                    if ((idx=CallDialogBox("DlgParam",DlgParam,0L))>=0) {
  473.                       lstrcpy(CurField.name,"DLG->");
  474.                       lstrcat(CurField.name,DlgField[idx].name);
  475.                       SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
  476.                    }
  477.                    SetFocus(GetDlgItem(hDlg,IDC_EXP));
  478.                    return (TRUE);
  479.  
  480.                 case IDC_OP:
  481.                    SaveDlgExpString=DlgExpString;
  482.                    DlgExpString=(LPSTR)CurField.name;       // output location 
  483.                    if (CallDialogBox("OpParam",OpParam,0L)) {
  484.                       SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
  485.                    }
  486.                    DlgExpString=SaveDlgExpString;
  487.                    SetFocus(GetDlgItem(hDlg,IDC_EXP));
  488.                    return (TRUE);
  489.  
  490.                 case IDC_FUNCT:
  491.                    SaveDlgExpString=DlgExpString;
  492.                    DlgExpString=(LPSTR)CurField.name;       // output location 
  493.                    if (CallDialogBox("FuctParam",FuctParam,0L)) {
  494.                       SendMessage(GetDlgItem(hDlg,IDC_EXP),EM_REPLACESEL,0, (DWORD)(LPSTR)CurField.name);
  495.                    }
  496.                    DlgExpString=SaveDlgExpString;
  497.                    SetFocus(GetDlgItem(hDlg,IDC_EXP));
  498.                    return (TRUE);
  499.  
  500.                 case IDOK:
  501.                    GetDlgItemText(hDlg,IDC_EXP,DlgExpString,LINE_WIDTH);
  502.                    DlgExpString[LINE_WIDTH]=0;
  503.  
  504.                    EndDialog(hDlg, TRUE);
  505.                    FrModified=TRUE;
  506.                    return (TRUE);
  507.         
  508.                 case IDCANCEL:
  509.                    EndDialog(hDlg, FALSE);
  510.                    return (TRUE);
  511.                 default:
  512.                    ;
  513.             }
  514.             break;
  515.     }
  516.     return (FALSE);
  517. }
  518.  
  519. /****************************************************************************
  520.     OpParam:
  521.     This dialog box shows a list of operators to select from.  The selected
  522.     operator is stored in the location pointed by the DlgExpString global
  523.     variable.
  524. ****************************************************************************/
  525.  
  526. BOOL CALLBACK _export OpParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  527. {
  528.     int  i;
  529.  
  530.     switch (message) {
  531.         case WM_INITDIALOG:
  532.             // Set initial values of the parameters 
  533.             for(i=0;i<MAX_OPS;i++) {
  534.                if (!OpFooter[i] || DlgExpType==EXP_FOOTER) {
  535.                   if (!OpFct[i]) {
  536.                      SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)OpSym[i]);
  537.                   }
  538.                }
  539.             }
  540.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
  541.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  542.             return (FALSE);
  543.  
  544.         case WM_COMMAND:
  545.             switch (CONTROL_ID(wParam,lParam)) {
  546.                 case IDC_LIST_BOX:
  547.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  548.  
  549.                 case IDOK:
  550.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  551.                    SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETTEXT, i,(DWORD)(LPSTR)DlgExpString);
  552.                    EndDialog(hDlg, TRUE);
  553.                    return (TRUE);
  554.         
  555.                 case IDCANCEL:
  556.                    EndDialog(hDlg, FALSE);
  557.                    return (TRUE);
  558.                 default:
  559.                    ;
  560.             }
  561.             break;
  562.     }
  563.     return (FALSE);
  564. }
  565.  
  566. /****************************************************************************
  567.     FuctParam:
  568.     This dialog box shows a list of functions to select from.  The name
  569.     of the selected function is stored in the location pointed by
  570.     the DlgExpString global variable.
  571. ****************************************************************************/
  572.  
  573. BOOL CALLBACK _export FuctParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  574. {
  575.     int  i;
  576.     char string[NAME_WIDTH+2];
  577.  
  578.     switch (message) {
  579.         case WM_INITDIALOG:
  580.             // Set initial values of the parameters 
  581.             for(i=0;i<MAX_OPS;i++) {
  582.                if (!OpFooter[i] || DlgExpType==EXP_FOOTER) {
  583.                   if (OpFct[i]) {
  584.                      SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)OpHelp[i]);
  585.                   }
  586.                }
  587.             }
  588.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
  589.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  590.             return (FALSE);
  591.  
  592.         case WM_COMMAND:
  593.             switch (CONTROL_ID(wParam,lParam)) {
  594.                 case IDC_LIST_BOX:
  595.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  596.  
  597.                 case IDOK:
  598.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  599.                    SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETTEXT, i,(DWORD)(LPSTR)msg);
  600.                    
  601.                    for (i=0;i<MAX_OPS;i++) {       // locate the function symbold 
  602.                       strcpy(string,OpSym[i]);
  603.                       strcat(string,"(");
  604.                       if (strstr(msg,string)==msg) {
  605.                           lstrcpy(DlgExpString,(LPSTR)string);
  606.                           EndDialog(hDlg, TRUE);
  607.                           return (TRUE);
  608.                       }
  609.                    }
  610.  
  611.                    EndDialog(hDlg, FALSE);
  612.                    return (TRUE);
  613.         
  614.                 case IDCANCEL:
  615.                    EndDialog(hDlg, FALSE);
  616.                    return (TRUE);
  617.                 default:
  618.                    ;
  619.             }
  620.             break;
  621.     }
  622.     return (FALSE);
  623. }
  624.  
  625. /****************************************************************************
  626.     DlgParam:
  627.     This dialog box shows a list of dialog fields to select from.  The 
  628.     routine returns the index of the selected dialog field.
  629. ****************************************************************************/
  630.  
  631. BOOL CALLBACK _export DlgParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  632. {
  633.     int  i;
  634.     char name[NAME_WIDTH];
  635.  
  636.     switch (message) {
  637.         case WM_INITDIALOG:
  638.             // Set initial values of the parameters 
  639.             for(i=0;i<MAX_DLGS;i++) {
  640.                if (DlgField[i].InUse) {
  641.                   SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)DlgField[i].name);
  642.                }
  643.             }
  644.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
  645.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  646.             return (FALSE);
  647.  
  648.         case WM_COMMAND:
  649.             switch (CONTROL_ID(wParam,lParam)) {
  650.                 case IDC_LIST_BOX:
  651.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  652.  
  653.                 case IDOK:
  654.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  655.                    SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETTEXT, i,(DWORD)(LPSTR)name);
  656.                    
  657.                    for (i=0;i<MAX_DLGS;i++) {
  658.                       if (DlgField[i].InUse && strcmp(DlgField[i].name,name)==0) {
  659.                          EndDialog(hDlg, i);
  660.                          return (TRUE);
  661.                       }
  662.                    }
  663.                    EndDialog(hDlg, -1);
  664.                    return (TRUE);
  665.         
  666.                 case IDCANCEL:
  667.                    EndDialog(hDlg, -1);
  668.                    return (TRUE);
  669.                 default:
  670.                    ;
  671.             }
  672.             break;
  673.     }
  674.     return (FALSE);
  675. }
  676.  
  677. /******************************************************************************
  678.     CreateDlgParam:
  679.     This dialog box accepts parameters to create a new dialog field in
  680.     the dialog field table.  The dialog fields are used to accept data 
  681.     from user before running a report.
  682.     The index to the dialog table is given by DlgIndex global variable.
  683. ******************************************************************************/
  684. BOOL CALLBACK _export CreateDlgParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  685. {
  686.     char name[NAME_WIDTH+2];
  687.     int i;
  688.  
  689.     switch (message) {
  690.         case WM_INITDIALOG:                  // initialize parameters 
  691.             SetDlgItemText(hDlg,IDC_NAME,(LPSTR)DlgField[DlgIndex].name);
  692.  
  693.             SendMessage(GetDlgItem(hDlg,IDC_TYPE_TEXT),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_TEXT, 0L);
  694.             SendMessage(GetDlgItem(hDlg,IDC_TYPE_NUM),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_NUM, 0L);
  695.             SendMessage(GetDlgItem(hDlg,IDC_TYPE_DBL),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_DBL, 0L);
  696.             SendMessage(GetDlgItem(hDlg,IDC_TYPE_LOGICAL),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_LOGICAL, 0L);
  697.             SendMessage(GetDlgItem(hDlg,IDC_TYPE_DATE),BM_SETCHECK, DlgField[DlgIndex].type==TYPE_DATE, 0L);
  698.  
  699.             SetFocus(GetDlgItem(hDlg,IDC_NAME));
  700.             return (FALSE);
  701.  
  702.         case WM_COMMAND:
  703.             switch (CONTROL_ID(wParam,lParam)) {
  704.                 case IDOK:
  705.                    
  706.                    //***** extract and validate name ******
  707.                    GetDlgItemText(hDlg,IDC_NAME,name,NAME_WIDTH-5);
  708.                    name[NAME_WIDTH-5]=0;
  709.                    strupr(name);
  710.                    StrTrim(name);
  711.                    for(i=0;i<(int)strlen(name);i++)  {
  712.                       if ((name[i]<'A' || name[i]>'Z') 
  713.                         &&(name[i]<'0' || name[i]>'9')
  714.                         && name[i]!='_') {
  715.                          MessageBox(hDlg,"Invalid Character in the Field Name.","Naming Error",MB_OK);
  716.                          return TRUE;
  717.                       }
  718.                    }
  719.                    if (name[0]==0) return TRUE;
  720.                    for (i=0;i<MAX_DLGS;i++) {
  721.                       if (DlgField[i].InUse && strcmp(DlgField[i].name,name)==0) {
  722.                          MessageBox(hDlg,"Duplicate Name Not Allowed!",NULL,MB_OK);
  723.                          return TRUE;
  724.                       }
  725.                    }
  726.                    strcpy(DlgField[DlgIndex].name,name);
  727.                    
  728.                    //************ accept field type ***********
  729.                    if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_TEXT)   ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_TEXT;
  730.                    if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_NUM)    ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_NUM;
  731.                    if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_DBL)    ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_DBL;
  732.                    if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_LOGICAL),BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_LOGICAL;
  733.                    if (SendMessage(GetDlgItem(hDlg,IDC_TYPE_DATE)   ,BM_GETCHECK, 0, 0L)) DlgField[DlgIndex].type=TYPE_DATE;
  734.  
  735.                    EndDialog(hDlg, TRUE);
  736.                    FrModified=TRUE;
  737.                    return (TRUE);
  738.         
  739.                 case IDCANCEL:
  740.                    EndDialog(hDlg, FALSE);
  741.                    return (TRUE);
  742.                 default:
  743.                    ;
  744.             }
  745.             break;
  746.     }
  747.     return (FALSE);
  748. }
  749.  
  750. /******************************************************************************
  751.     ModifyDlgParam:
  752.     This dialog box accepts parameters about a dialog box.  The dialog
  753.     table is updated with the new information.
  754. ******************************************************************************/
  755. BOOL CALLBACK _export ModifyDlgParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  756. {
  757.  
  758.     switch (message) {
  759.         case WM_INITDIALOG:                  // initialize parameters 
  760.             SetWindowText(hDlg,(LPSTR)DlgField[DlgIndex].name);    // set the header 
  761.  
  762.             SetDlgItemText(hDlg,IDC_NAME,(LPSTR)DlgField[DlgIndex].prompt);
  763.  
  764.             SetDlgItemInt(hDlg,IDC_PROMPT_ORDER,DlgField[DlgIndex].PromptOrder,FALSE);
  765.             SetDlgItemInt(hDlg,IDC_FIELD_WIDTH,DlgField[DlgIndex].width,FALSE);
  766.  
  767.             SetFocus(GetDlgItem(hDlg,IDC_NAME));
  768.             return (FALSE);
  769.  
  770.         case WM_COMMAND:
  771.             switch (CONTROL_ID(wParam,lParam)) {
  772.                 case IDOK:
  773.                    GetDlgItemText(hDlg,IDC_NAME,DlgField[DlgIndex].prompt,NAME_WIDTH);
  774.                    
  775.                    DlgField[DlgIndex].PromptOrder=GetDlgItemInt(hDlg,IDC_PROMPT_ORDER,NULL,FALSE);
  776.                    DlgField[DlgIndex].width=GetDlgItemInt(hDlg,IDC_FIELD_WIDTH,NULL,FALSE);
  777.  
  778.                    EndDialog(hDlg, TRUE);
  779.                    FrModified=TRUE;
  780.                    return (TRUE);
  781.         
  782.                 case IDCANCEL:
  783.                    EndDialog(hDlg, FALSE);
  784.                    return (TRUE);
  785.                 default:
  786.                    ;
  787.             }
  788.             break;
  789.     }
  790.     return (FALSE);
  791. }
  792.  
  793. /******************************************************************************
  794.     SecSortParam:
  795.     This routine accepts a sort field for a sort header section.  The calling
  796.     routine passes the section number using the lParam argument.
  797.     The index of the sort field is passed using the DlgIndex global variable.
  798. ******************************************************************************/
  799. BOOL CALLBACK _export SecSortParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  800. {
  801.     switch (message) {
  802.         case WM_INITDIALOG:                    // initialize parameters 
  803.             
  804.             strcpy(msg,"Sort Field for Section: ");
  805.             strcat(msg,SectionName[lParam]);
  806.             SetWindowText(hDlg,(LPSTR)msg);    // set the header 
  807.            
  808.             DlgTempField=field[DlgIndex];          // make a working copy of the field 
  809.              
  810.             SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
  811.             SetFocus(GetDlgItem(hDlg,IDC_NAME));
  812.  
  813.             return (FALSE);
  814.  
  815.         case WM_COMMAND:
  816.             switch (CONTROL_ID(wParam,lParam)) {
  817.                 case IDC_DATA_FIELD:
  818.                    if ((FormArg.UserSelection)(hDlg,&DlgTempField,DlgTempField.section-SEC_HDR_LVL1+1)) {
  819.                       SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
  820.                    }
  821.                    SetFocus(GetDlgItem(hDlg,IDC_NAME));
  822.                    return (TRUE);
  823.  
  824.                 case IDOK:
  825.                    GetDlgItemText(hDlg,IDC_NAME,DlgTempField.name,NAME_WIDTH);
  826.                    strupr(DlgTempField.name);
  827.                    if ((FormArg.VerifyField)(&DlgTempField,DlgTempField.section-SEC_HDR_LVL1+1)) {
  828.                       field[DlgIndex]=DlgTempField;
  829.                       EndDialog(hDlg, TRUE);
  830.                       FrModified=TRUE;
  831.                       return (TRUE);
  832.                    }
  833.                    else {
  834.                       MessageBox(hDlg,"Invalid Sort Field!",NULL,MB_OK);
  835.                       SetFocus(GetDlgItem(hDlg,IDC_NAME));
  836.                       return (TRUE);
  837.                    }
  838.         
  839.                 case IDCANCEL:
  840.                    EndDialog(hDlg, FALSE);
  841.                    return (TRUE);
  842.                 default:
  843.                    ;
  844.             }
  845.             break;
  846.     }
  847.     return (FALSE);
  848. }
  849.  
  850. /******************************************************************************
  851.     SecBreakParam:
  852.     This routine accepts a break field for a sort header section. The break
  853.     field is used to determine the section breaks. 
  854.     The calling routine passes the section number using the lParam argument.
  855.     The index of the sort field is passed using the DlgIndex global variable.
  856. ******************************************************************************/
  857. BOOL CALLBACK _export SecBreakParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  858. {
  859.  
  860.     switch (message) {
  861.         case WM_INITDIALOG:                    // initialize parameters 
  862.             
  863.             strcpy(msg,"Break Field for Section: ");
  864.             strcat(msg,SectionName[lParam]);
  865.             SetWindowText(hDlg,(LPSTR)msg);    // set the header 
  866.            
  867.             SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
  868.             SetFocus(GetDlgItem(hDlg,IDC_NAME));
  869.  
  870.             return (FALSE);
  871.  
  872.         case WM_COMMAND:
  873.             switch (CONTROL_ID(wParam,lParam)) {
  874.                 case IDC_DATA_FIELD:
  875.                    if ((FormArg.UserSelection)(hDlg,&DlgTempField,0)) {
  876.                       SetDlgItemText(hDlg,IDC_NAME,DlgTempField.name);
  877.                    }
  878.                    SetFocus(GetDlgItem(hDlg,IDC_NAME));
  879.                    return (TRUE);
  880.  
  881.                 case IDC_CALC_FIELD:
  882.                    lstrcpy(DlgTempField.name,"");
  883.                    EndDialog(hDlg, 2);
  884.                    FrModified=TRUE;
  885.                    return (TRUE);
  886.  
  887.                 case IDOK:
  888.                    GetDlgItemText(hDlg,IDC_NAME,DlgTempField.name,NAME_WIDTH);
  889.                    strupr(DlgTempField.name);
  890.                    //****** check if valid data field provided ****
  891.                    if ((FormArg.VerifyField)(&DlgTempField,0)) {
  892.                       field[DlgIndex]=DlgTempField;
  893.                       EndDialog(hDlg, 1);
  894.                       FrModified=TRUE;
  895.                       return (TRUE);
  896.                    }
  897.                    else {
  898.                       MessageBox(hDlg,"Invalid Break Field!",NULL,MB_OK);
  899.                       SetFocus(GetDlgItem(hDlg,IDC_NAME));
  900.                       return (TRUE);
  901.                    }
  902.         
  903.                 case IDCANCEL:
  904.                    EndDialog(hDlg, 0);
  905.                    return (TRUE);
  906.                 default:
  907.                    ;
  908.             }
  909.             break;
  910.     }
  911.  
  912.     return FALSE;
  913. }
  914.  
  915. /****************************************************************************
  916.     EditSecParam:
  917.     This dialog box allows the user to edit section control parameters.
  918.     The calling routine passes the index of the section using the DlgIndex
  919.     global variable.
  920. ****************************************************************************/
  921. BOOL CALLBACK _export EditSecParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  922. {
  923.     int records;
  924.  
  925.     switch (message) {
  926.         case WM_INITDIALOG:
  927.             SetWindowText(hDlg,(LPSTR)SectionName[DlgIndex]);    // set the header 
  928.  
  929.             SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_BEF),BM_SETCHECK, SFLAG_PAGE_BEF§ion[DlgIndex].flags, 0L);
  930.             SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_AFT),BM_SETCHECK, SFLAG_PAGE_AFT§ion[DlgIndex].flags, 0L);
  931.             SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_BEFORE),BM_SETCHECK, SFLAG_TRIM_BEFORE§ion[DlgIndex].flags, 0L);
  932.             SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_AFTER),BM_SETCHECK, SFLAG_TRIM_AFTER§ion[DlgIndex].flags, 0L);
  933.  
  934.             if (DlgIndex<SEC_HDR_LVL1 || DlgIndex>SEC_HDR_LVL9) 
  935.                 EnableWindow(GetDlgItem(hDlg,IDC_SEC_REPRINT),FALSE);
  936.             else SendMessage(GetDlgItem(hDlg,IDC_SEC_REPRINT),BM_SETCHECK, SFLAG_REPRINT§ion[DlgIndex].flags, 0L);
  937.             
  938.             if (DlgIndex==SEC_DETAIL1 && !(section[SEC_DETAIL2].InUse)) { // multiple column allowed for single detail section report only
  939.                   SetDlgItemInt(hDlg,IDC_SEC_RECORDS,section[DlgIndex].columns,FALSE);
  940.             }
  941.             else  EnableWindow(GetDlgItem(hDlg,IDC_SEC_RECORDS),FALSE);
  942.  
  943.             SetFocus(GetDlgItem(hDlg,IDC_SEC_PAGE_BEF));
  944.             return (FALSE);
  945.  
  946.         case WM_COMMAND:
  947.             switch (CONTROL_ID(wParam,lParam)) {
  948.                 case IDOK:
  949.                    if (DlgIndex==SEC_DETAIL1 && !(section[SEC_DETAIL2].InUse)){
  950.                        records=GetDlgItemInt(hDlg,IDC_SEC_RECORDS,NULL,FALSE);
  951.                        if (records<1) {
  952.                            SetFocus(GetDlgItem(hDlg,IDC_SEC_RECORDS));
  953.                            return TRUE;
  954.                        }
  955.                        section[DlgIndex].columns=records;
  956.                    }
  957.  
  958.                    if (SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_BEF),BM_GETCHECK, 0, 0L)) 
  959.                          section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_PAGE_BEF;
  960.                    else  section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_PAGE_BEF));
  961.                    if (SendMessage(GetDlgItem(hDlg,IDC_SEC_PAGE_AFT),BM_GETCHECK, 0, 0L)) 
  962.                          section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_PAGE_AFT;
  963.                    else  section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_PAGE_AFT));
  964.                    if (SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_BEFORE),BM_GETCHECK, 0, 0L)) 
  965.                          section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_TRIM_BEFORE;
  966.                    else  section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_TRIM_BEFORE));
  967.                    if (SendMessage(GetDlgItem(hDlg,IDC_SEC_TRIM_AFTER),BM_GETCHECK, 0, 0L)) 
  968.                          section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_TRIM_AFTER;
  969.                    else  section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_TRIM_AFTER));
  970.  
  971.                    if (DlgIndex>=SEC_HDR_LVL1 && DlgIndex<=SEC_HDR_LVL9) {
  972.                       if (SendMessage(GetDlgItem(hDlg,IDC_SEC_REPRINT),BM_GETCHECK, 0, 0L)) 
  973.                             section[DlgIndex].flags=(section[DlgIndex].flags)|SFLAG_REPRINT;
  974.                       else  section[DlgIndex].flags=(section[DlgIndex].flags)&(~((UINT)SFLAG_REPRINT));
  975.                    }
  976.  
  977.                    EndDialog(hDlg, TRUE);
  978.                    FrModified=TRUE;
  979.                    return TRUE;
  980.            
  981.                 case IDCANCEL:
  982.                    EndDialog(hDlg, FALSE);
  983.                    return (TRUE);
  984.                 default:
  985.                    ;
  986.             }
  987.             break;
  988.     }
  989.     return (FALSE);
  990. }
  991.  
  992. /****************************************************************************
  993.     SumParam:
  994.     This dialog box shows a list of summary types and allos the user to 
  995.     select one item.  The index of the selected field is returned to the
  996.     calling routine.
  997. ****************************************************************************/
  998. int CALLBACK _export SumParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  999. {
  1000.     int i;
  1001.  
  1002.     switch (message) {
  1003.         case WM_INITDIALOG:
  1004.             // Set initial values of the parameters 
  1005.             for (i=0;i<MAX_VALS;i++) {
  1006.                 SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)SumName[i]);
  1007.             }
  1008.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, (WPARAM)lParam,0L);
  1009.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  1010.             return (FALSE);
  1011.  
  1012.         case WM_COMMAND:
  1013.             switch (CONTROL_ID(wParam,lParam)) {
  1014.                 case IDC_LIST_BOX:
  1015.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  1016.  
  1017.                 case IDOK:
  1018.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  1019.                    EndDialog(hDlg, i);
  1020.                    FrModified=TRUE;
  1021.                    return (TRUE);
  1022.         
  1023.                 default:
  1024.                    ;
  1025.             }
  1026.             break;
  1027.     }
  1028.     return (FALSE);
  1029. }
  1030.  
  1031. /****************************************************************************
  1032.     DeviceParam:
  1033.     This dialog box allows the user to select a output device for the
  1034.     current report.
  1035. ****************************************************************************/
  1036. int CALLBACK _export DeviceParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1037. {
  1038.     int i;
  1039.  
  1040.     switch (message) {
  1041.         case WM_INITDIALOG:
  1042.             // Set initial values of the parameters 
  1043.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)"Screen");
  1044.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_ADDSTRING, 0, (DWORD)(LPSTR)"Printer");
  1045.             SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_SETCURSEL, 0,0L);
  1046.             SetFocus(GetDlgItem(hDlg,IDC_LIST_BOX));
  1047.             return (FALSE);
  1048.  
  1049.         case WM_COMMAND:
  1050.             switch (CONTROL_ID(wParam,lParam)) {
  1051.                 case IDC_LIST_BOX:
  1052.                     if (NOTIFY_MSG(wParam,lParam)!=LBN_DBLCLK) break;
  1053.  
  1054.                 case IDOK:
  1055.                    i=(int)SendMessage(GetDlgItem(hDlg,IDC_LIST_BOX),LB_GETCURSEL, 0,0L);
  1056.                    EndDialog(hDlg, i);
  1057.                    FrModified=TRUE;
  1058.                    return (TRUE);
  1059.         
  1060.                 case IDCANCEL:
  1061.                    EndDialog(hDlg, -1);
  1062.                    return (TRUE);
  1063.                 
  1064.                 default:
  1065.                    ;
  1066.             }
  1067.             break;
  1068.     }
  1069.     return (FALSE);
  1070. }
  1071.  
  1072. /****************************************************************************
  1073.     NumFieldParam:
  1074.     This dialog box allows the user to modify the field attributes for 
  1075.     a numeric and double field.  The calling routine passes the index of the 
  1076.     field to be modified using the DlgIndex global variable.
  1077. ****************************************************************************/
  1078. BOOL CALLBACK _export NumFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1079. {
  1080.     int idx,flag;
  1081.  
  1082.     switch (message) {
  1083.         case WM_INITDIALOG:
  1084.             
  1085.             DlgTempField=field[DlgIndex];      // make a working copy of the field 
  1086.  
  1087.             strcpy(msg,"[");                   // display the field name 
  1088.             strcat(msg,"Field: ");
  1089.             strcat(msg,DlgTempField.name);
  1090.             strcat(msg,"]");
  1091.             SetWindowText(hDlg,(LPSTR)msg);    // set the header 
  1092.  
  1093.             // Set initial values of the parameters 
  1094.  
  1095.             SetDlgItemInt(hDlg,IDC_DEC_PLACES,DlgTempField.DecPlaces,FALSE);
  1096.             SetDlgItemText(hDlg,IDC_DOLLAR_SYM,(LPSTR)DlgTempField.CurrencySymbol);
  1097.  
  1098.             SetDlgItemText(hDlg,IDC_NEG_PREFIX,(LPSTR)DlgTempField.NegSignPrefix);
  1099.             SetDlgItemText(hDlg,IDC_NEG_SUFFIX,(LPSTR)DlgTempField.NegSignSuffix);
  1100.             SetDlgItemText(hDlg,IDC_POS_PREFIX,(LPSTR)DlgTempField.PosSignPrefix);
  1101.             SetDlgItemText(hDlg,IDC_POS_SUFFIX,(LPSTR)DlgTempField.PosSignSuffix);
  1102.  
  1103.             SendMessage(GetDlgItem(hDlg,IDC_SUP_ZERO),BM_SETCHECK, FLAG_SUP_ZERO&DlgTempField.flags, 0L);
  1104.             SendMessage(GetDlgItem(hDlg,IDC_PAD_ZERO),BM_SETCHECK, FLAG_PAD_ZERO&DlgTempField.flags, 0L);
  1105.             SendMessage(GetDlgItem(hDlg,IDC_USE_COMMA),BM_SETCHECK, FLAG_COMMA&DlgTempField.flags, 0L);
  1106.  
  1107.             if (DlgSec>=SEC_FTR_LVL9) {       // footer sections 
  1108.                SetDlgItemText(hDlg,IDC_SUM_TYPE,(LPSTR)SumName[DlgTempField.SumType]);
  1109.                SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_SETCHECK, FLAG_RETAIN&DlgTempField.flags, 0L);
  1110.             }
  1111.  
  1112.             SetFocus(GetDlgItem(hDlg,IDC_ALIGN_LEFT));
  1113.             return (FALSE);
  1114.  
  1115.         case WM_COMMAND:
  1116.             switch (CONTROL_ID(wParam,lParam)) {
  1117.                 case IDC_SUM_TYPE:
  1118.                    if (DlgSec>=SEC_FTR_LVL9) {
  1119.                       EnableWindow(hDlg,FALSE);   // disable our dialog box
  1120.                       idx=CallDialogBox("SumParam",SumParam,(long)DlgTempField.SumType);
  1121.                       EnableWindow(hDlg,TRUE);    // enable our dialog box
  1122.                       if (idx>=0) {
  1123.                          DlgTempField.SumType=idx;
  1124.                          SetDlgItemText(hDlg,IDC_SUM_TYPE,(LPSTR)SumName[DlgTempField.SumType]);
  1125.                          return TRUE;
  1126.                       }
  1127.                    }
  1128.                    else {
  1129.                       SetFocus(GetDlgItem(hDlg,IDC_USE_COMMA));
  1130.                       return TRUE;
  1131.                    }
  1132.  
  1133.                 case IDC_RETAIN_VAL:
  1134.                    if (DlgSec>=SEC_FTR_LVL9) {
  1135.                       flag=(int)SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_GETCHECK, 0, 0L); 
  1136.                       if (flag) flag=FALSE;  // toggle 
  1137.                       else      flag=TRUE;
  1138.                       SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_SETCHECK, flag, 0L);
  1139.                       return TRUE;
  1140.                    }
  1141.                    else {
  1142.                       SetFocus(GetDlgItem(hDlg,IDC_USE_COMMA));
  1143.                       return TRUE;
  1144.                    }
  1145.  
  1146.                 case IDOK:
  1147.                    DlgTempField.DecPlaces=GetDlgItemInt(hDlg,IDC_DEC_PLACES,NULL,FALSE);
  1148.                    GetDlgItemText(hDlg,IDC_DOLLAR_SYM,(LPSTR)(DlgTempField.CurrencySymbol),4);
  1149.  
  1150.                    GetDlgItemText(hDlg,IDC_NEG_PREFIX,(LPSTR)(DlgTempField.NegSignPrefix),4);
  1151.                    GetDlgItemText(hDlg,IDC_NEG_SUFFIX,(LPSTR)(DlgTempField.NegSignSuffix),4);
  1152.                    GetDlgItemText(hDlg,IDC_POS_PREFIX,(LPSTR)(DlgTempField.PosSignPrefix),4);
  1153.                    GetDlgItemText(hDlg,IDC_POS_SUFFIX,(LPSTR)(DlgTempField.PosSignSuffix),4);
  1154.                    
  1155.                    if (SendMessage(GetDlgItem(hDlg,IDC_SUP_ZERO),BM_GETCHECK, 0, 0L)) 
  1156.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_SUP_ZERO;
  1157.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_SUP_ZERO));
  1158.                    if (SendMessage(GetDlgItem(hDlg,IDC_PAD_ZERO),BM_GETCHECK, 0, 0L)) 
  1159.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_PAD_ZERO;
  1160.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_PAD_ZERO));
  1161.                    if (SendMessage(GetDlgItem(hDlg,IDC_USE_COMMA),BM_GETCHECK, 0, 0L)) 
  1162.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_COMMA;
  1163.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_COMMA));
  1164.  
  1165.                    if (SendMessage(GetDlgItem(hDlg,IDC_RETAIN_VAL),BM_GETCHECK, 0, 0L)) 
  1166.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_RETAIN;
  1167.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_RETAIN));
  1168.  
  1169.                    field[DlgIndex]=DlgTempField;  // transfer to the field array 
  1170.                    
  1171.                    EndDialog(hDlg, TRUE);
  1172.                    FrModified=TRUE;
  1173.                    return TRUE;
  1174.         
  1175.                 case IDCANCEL:
  1176.                    EndDialog(hDlg, FALSE);
  1177.                    return (TRUE);
  1178.                 default:
  1179.                    ;
  1180.             }
  1181.             break;
  1182.  
  1183.     }
  1184.     return (FALSE);
  1185. }
  1186.  
  1187. /****************************************************************************
  1188.     TextFieldParam:
  1189.     This dialog box allows the user to modify the field attributes for 
  1190.     a text field.  The calling routine passes the index of the 
  1191.     field to be modified using the DlgIndex global variable.
  1192. ****************************************************************************/
  1193. BOOL CALLBACK _export TextFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1194. {
  1195.     int flag1,flag2,flag3;
  1196.  
  1197.     switch (message) {
  1198.         case WM_INITDIALOG:
  1199.             
  1200.             DlgTempField=field[DlgIndex];      // make a working copy of the field 
  1201.  
  1202.             strcpy(msg,"[");                   // display the field name 
  1203.             strcat(msg,"Field: ");
  1204.             strcat(msg,DlgTempField.name);
  1205.             strcat(msg,"]");
  1206.             SetWindowText(hDlg,(LPSTR)msg);    // set the header 
  1207.  
  1208.             // Set initial values of the parameters 
  1209.             SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_SETCHECK, FLAG_WRAP&DlgTempField.flags, 0L);
  1210.             SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_SETCHECK, FLAG_WORD_WRAP&DlgTempField.flags, 0L);
  1211.             SendMessage(GetDlgItem(hDlg,IDC_FLEX_SIZE),BM_SETCHECK, FLAG_FLEX_SIZE&DlgTempField.flags, 0L);
  1212.  
  1213.             SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_SETCHECK, FLAG_CAPS&DlgTempField.flags, 0L);
  1214.             SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_SETCHECK, FLAG_FIRST_CAP&DlgTempField.flags, 0L);
  1215.             SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_SETCHECK, FLAG_SMALL&DlgTempField.flags, 0L);
  1216.  
  1217.             SendMessage(GetDlgItem(hDlg,IDC_TRIM_SPACES),BM_SETCHECK, FLAG_TRIM&DlgTempField.flags, 0L);
  1218.  
  1219.             // disable word wrap field size field for non word wrap fields
  1220.             if (!((FLAG_WRAP|FLAG_WORD_WRAP)&DlgTempField.flags)) {
  1221.                EnableWindow(GetDlgItem(hDlg,IDC_FLEX_SIZE),FALSE);
  1222.             }
  1223.  
  1224.             SetFocus(GetDlgItem(hDlg,IDC_ALIGN_LEFT));
  1225.             return (FALSE);
  1226.  
  1227.         case WM_COMMAND:
  1228.             switch (CONTROL_ID(wParam,lParam)) {
  1229.                 case IDC_WRAP:
  1230.                    flag1=(int)SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_GETCHECK, 0, 0L);
  1231.                    flag2=(int)SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_GETCHECK, 0, 0L);
  1232.                    if (flag1 && flag2) {          // maintain exclusive flags 
  1233.                       SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_SETCHECK, FALSE, 0L);
  1234.                    }
  1235.                    EnableWindow(GetDlgItem(hDlg,IDC_FLEX_SIZE),flag1|flag2);
  1236.  
  1237.                    return TRUE;
  1238.  
  1239.                 case IDC_WORD_WRAP:
  1240.                    flag1=(int)SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_GETCHECK, 0, 0L);
  1241.                    flag2=(int)SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_GETCHECK, 0, 0L);
  1242.                    if (flag1 && flag2) {          // maintain exclusive flags 
  1243.                       SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_SETCHECK, FALSE, 0L);
  1244.                    }
  1245.                    EnableWindow(GetDlgItem(hDlg,IDC_FLEX_SIZE),flag1|flag2);
  1246.  
  1247.                    return TRUE;
  1248.                 
  1249.                 case IDC_CAP_ALL:                 // maintain exclusive flags 
  1250.                 case IDC_CAP_FIRST:
  1251.                 case IDC_LOWER:
  1252.                    flag1=(int)SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_GETCHECK, 0, 0L);
  1253.                    flag2=(int)SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_GETCHECK, 0, 0L);
  1254.                    flag3=(int)SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_GETCHECK, 0, 0L);
  1255.  
  1256.                    if (wParam==IDC_CAP_ALL && flag1 && (flag2 || flag3)) {          // maintain exclusive flags 
  1257.                       SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_SETCHECK, FALSE, 0L);
  1258.                       SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_SETCHECK, FALSE, 0L);
  1259.                    }
  1260.                    if (wParam==IDC_CAP_FIRST && flag2 && (flag1 || flag3)) {          // maintain exclusive flags 
  1261.                       SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_SETCHECK, FALSE, 0L);
  1262.                       SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_SETCHECK, FALSE, 0L);
  1263.                    }
  1264.                    if (wParam==IDC_LOWER && flag3 && (flag1 || flag2)) {          // maintain exclusive flags 
  1265.                       SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_SETCHECK, FALSE, 0L);
  1266.                       SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_SETCHECK, FALSE, 0L);
  1267.                    }
  1268.                    return TRUE;
  1269.                 
  1270.                 case IDOK:
  1271.                    if (SendMessage(GetDlgItem(hDlg,IDC_WRAP),BM_GETCHECK, 0, 0L)) 
  1272.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_WRAP;
  1273.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_WRAP));
  1274.                    if (SendMessage(GetDlgItem(hDlg,IDC_WORD_WRAP),BM_GETCHECK, 0, 0L)) 
  1275.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_WORD_WRAP;
  1276.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_WORD_WRAP));
  1277.                    if (SendMessage(GetDlgItem(hDlg,IDC_FLEX_SIZE),BM_GETCHECK, 0, 0L)) 
  1278.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_FLEX_SIZE;
  1279.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_FLEX_SIZE));
  1280.  
  1281.                    if (SendMessage(GetDlgItem(hDlg,IDC_CAP_ALL),BM_GETCHECK, 0, 0L)) 
  1282.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_CAPS;
  1283.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_CAPS));
  1284.                    if (SendMessage(GetDlgItem(hDlg,IDC_CAP_FIRST),BM_GETCHECK, 0, 0L)) 
  1285.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_FIRST_CAP;
  1286.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_FIRST_CAP));
  1287.                    if (SendMessage(GetDlgItem(hDlg,IDC_LOWER),BM_GETCHECK, 0, 0L)) 
  1288.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_SMALL;
  1289.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_SMALL));
  1290.  
  1291.                    if (SendMessage(GetDlgItem(hDlg,IDC_TRIM_SPACES),BM_GETCHECK, 0, 0L)) 
  1292.                          DlgTempField.flags=(DlgTempField.flags)|FLAG_TRIM;
  1293.                    else  DlgTempField.flags=(DlgTempField.flags)&(~((UINT)FLAG_TRIM));
  1294.  
  1295.                    field[DlgIndex]=DlgTempField;  // transfer to the field array 
  1296.                    
  1297.                    EndDialog(hDlg, TRUE);
  1298.                    FrModified=TRUE;
  1299.                    return TRUE;
  1300.         
  1301.                 case IDCANCEL:
  1302.                    EndDialog(hDlg, FALSE);
  1303.                    return (TRUE);
  1304.                 default:
  1305.                    ;
  1306.             }
  1307.             break;
  1308.  
  1309.     }
  1310.  
  1311.     return (FALSE);
  1312. }
  1313.  
  1314. /****************************************************************************
  1315.     DateFieldParam:
  1316.     This dialog box allows the user to modify the field attributes for 
  1317.     a date field.  The calling routine passes the index of the 
  1318.     field to be modified using the DlgIndex global variable.
  1319. ****************************************************************************/
  1320. BOOL CALLBACK _export DateFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1321. {
  1322.     switch (message) {
  1323.         case WM_INITDIALOG:
  1324.             
  1325.             DlgTempField=field[DlgIndex];      // make a working copy of the field 
  1326.  
  1327.             strcpy(msg,"[");                   // display the field name 
  1328.             strcat(msg,"Field: ");
  1329.             strcat(msg,DlgTempField.name);
  1330.             strcat(msg,"]");
  1331.             SetWindowText(hDlg,(LPSTR)msg);    // set the header 
  1332.  
  1333.             // Set initial values of the parameters 
  1334.             SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_SETCHECK, DlgTempField.DateFormat==DT_MMDDYY, 0L);
  1335.             SendMessage(GetDlgItem(hDlg,IDC_DDMMYY),BM_SETCHECK, DlgTempField.DateFormat==DT_DDMMYY, 0L);
  1336.             SendMessage(GetDlgItem(hDlg,IDC_MMDDYYYY),BM_SETCHECK, DlgTempField.DateFormat==DT_MMDDYYYY, 0L);
  1337.             SendMessage(GetDlgItem(hDlg,IDC_MMMDDYYYY),BM_SETCHECK, DlgTempField.DateFormat==DT_MMMDDYYYY, 0L);
  1338.  
  1339.             SetDlgItemText(hDlg,IDC_DATE_DELIM,(LPSTR)DlgTempField.DateDelim);
  1340.  
  1341.             SetFocus(GetDlgItem(hDlg,IDC_MMDDYY));
  1342.             return (FALSE);
  1343.  
  1344.         case WM_COMMAND:
  1345.             switch (CONTROL_ID(wParam,lParam)) {
  1346.                 case IDOK:
  1347.                    if (SendMessage(GetDlgItem(hDlg,IDC_MMDDYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_MMDDYY;
  1348.                    if (SendMessage(GetDlgItem(hDlg,IDC_DDMMYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_DDMMYY;
  1349.                    if (SendMessage(GetDlgItem(hDlg,IDC_MMDDYYYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_MMDDYYYY;
  1350.                    if (SendMessage(GetDlgItem(hDlg,IDC_MMMDDYYYY),BM_GETCHECK, 0, 0L)) DlgTempField.DateFormat=DT_MMMDDYYYY;
  1351.  
  1352.                    GetDlgItemText(hDlg,IDC_DATE_DELIM,(LPSTR)(DlgTempField.DateDelim),2);
  1353.  
  1354.                    field[DlgIndex]=DlgTempField;  // transfer to the field array 
  1355.                    
  1356.                    EndDialog(hDlg, TRUE);
  1357.                    FrModified=TRUE;
  1358.                    return TRUE;
  1359.         
  1360.                 case IDCANCEL:
  1361.                    EndDialog(hDlg, FALSE);
  1362.                    return (TRUE);
  1363.                 default:
  1364.                    ;
  1365.             }
  1366.             break;
  1367.  
  1368.     }
  1369.  
  1370.     return (FALSE);
  1371. }
  1372.  
  1373. /****************************************************************************
  1374.     LogFieldParam:
  1375.     This dialog box allows the user to modify the field attributes for 
  1376.     a logical field.  The calling routine passes the index of the 
  1377.     field to be modified using the DlgIndex global variable.
  1378. ****************************************************************************/
  1379. BOOL CALLBACK _export LogFieldParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1380. {
  1381.  
  1382.     switch (message) {
  1383.         case WM_INITDIALOG:
  1384.             
  1385.             DlgTempField=field[DlgIndex];      // make a working copy of the field 
  1386.  
  1387.             strcpy(msg,"[");                   // display the field name 
  1388.             strcat(msg,"Field: ");
  1389.             strcat(msg,DlgTempField.name);
  1390.             strcat(msg,"]");
  1391.             SetWindowText(hDlg,(LPSTR)msg);    // set the header 
  1392.  
  1393.             // Set initial values of the parameters 
  1394.             msg[1]=0;
  1395.             msg[0]=DlgTempField.LogicalSymbols[0]; // TRUE symbol 
  1396.             SetDlgItemText(hDlg,IDC_TRUE,(LPSTR)msg);
  1397.             msg[0]=DlgTempField.LogicalSymbols[1]; // FALSE symbol 
  1398.             SetDlgItemText(hDlg,IDC_FALSE,(LPSTR)msg);
  1399.  
  1400.             SetFocus(GetDlgItem(hDlg,IDC_TRUE));
  1401.             return (FALSE);
  1402.  
  1403.         case WM_COMMAND:
  1404.             switch (CONTROL_ID(wParam,lParam)) {
  1405.                 case IDOK:
  1406.                    GetDlgItemText(hDlg,IDC_TRUE,(LPSTR)msg,2);
  1407.                    DlgTempField.LogicalSymbols[0]=msg[0];  // TRUE symbol 
  1408.                    GetDlgItemText(hDlg,IDC_FALSE,(LPSTR)msg,2);
  1409.                    DlgTempField.LogicalSymbols[1]=msg[0];  // FALSE symbol 
  1410.  
  1411.                    field[DlgIndex]=DlgTempField;  // transfer to the field array 
  1412.                    
  1413.                    EndDialog(hDlg, TRUE);
  1414.                    FrModified=TRUE;
  1415.                    return TRUE;
  1416.         
  1417.                 case IDCANCEL:
  1418.                    EndDialog(hDlg, FALSE);
  1419.                    return (TRUE);
  1420.                 default:
  1421.                    ;
  1422.             }
  1423.             break;
  1424.  
  1425.     }
  1426.     return (FALSE);
  1427. }
  1428.  
  1429. /****************************************************************************
  1430.     DlgInputParam:
  1431.     This dialog box input the specified user input field.  The input of
  1432.     the input field is passed using the DlgIndex global variable.  The long
  1433.     parameters specifies first (0) or the last (MAX_DLGS) input field.
  1434. ****************************************************************************/
  1435. BOOL CALLBACK _export DlgInputParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1436. {
  1437.     RECT rect1,rect2;
  1438.     int  FieldWidth,DlgBoxWidth,FrameWidth,FrameHeight;
  1439.     DWORD XBaseUnits;
  1440.  
  1441.     switch (message) {
  1442.         case WM_INITDIALOG:
  1443.             
  1444.             // Set initial values of the parameters 
  1445.             SetDlgItemText(hDlg,IDC_DLG_PROMPT,(LPSTR)DlgField[DlgIndex].prompt);
  1446.             
  1447.             //***** set the input field width *****
  1448.             GetWindowRect(hDlg,(LPRECT) &rect1);  // get outer dimensions 
  1449.             FrameWidth=GetSystemMetrics(SM_CXDLGFRAME);
  1450.             FrameHeight=GetSystemMetrics(SM_CYDLGFRAME);
  1451.             rect1.left+=FrameWidth;               // calculate absolute dimensions of the client window 
  1452.             rect1.right-=FrameWidth;
  1453.             rect1.top+=FrameHeight;
  1454.             rect1.bottom-=FrameHeight;
  1455.  
  1456.             GetWindowRect(GetDlgItem(hDlg,IDC_DLG_INPUT),(LPRECT) &rect2);
  1457.             XBaseUnits=GetDialogBaseUnits();
  1458.             FieldWidth=(DlgField[DlgIndex].width+1)*(LOWORD(XBaseUnits));
  1459.             DlgBoxWidth=rect1.right-rect1.left;
  1460.             if (FieldWidth>DlgBoxWidth) FieldWidth=DlgBoxWidth;
  1461.             rect2.left=rect1.left+(DlgBoxWidth-FieldWidth)/2;
  1462.             SetWindowPos(GetDlgItem(hDlg,IDC_DLG_INPUT),NULL,
  1463.                          rect2.left-rect1.left,rect2.top-rect1.top,
  1464.                          FieldWidth,rect2.bottom-rect2.top,
  1465.                          SWP_NOREDRAW|SWP_NOZORDER);
  1466.  
  1467.             SetDlgItemText(hDlg,IDC_DLG_INPUT,(LPSTR)DlgField[DlgIndex].CharData);
  1468.  
  1469.             if (lParam==0 || DlgIndex==0) SetDlgItemText(hDlg,IDC_DLG_PREV,(LPSTR)"Cancel");
  1470.             if (lParam==MAX_DLGS)         SetDlgItemText(hDlg,IDC_DLG_NEXT,(LPSTR)"Ok");
  1471.  
  1472.             SetFocus(GetDlgItem(hDlg,IDC_DLG_INPUT));
  1473.             return (FALSE);
  1474.  
  1475.         case WM_COMMAND:
  1476.             switch (CONTROL_ID(wParam,lParam)) {
  1477.  
  1478.                 case IDC_DLG_NEXT:
  1479.                    GetDlgItemText(hDlg,IDC_DLG_INPUT,(LPSTR)DlgField[DlgIndex].CharData,NAME_WIDTH);
  1480.                    EndDialog(hDlg, TRUE);
  1481.                    FrModified=TRUE;
  1482.                    return TRUE;
  1483.         
  1484.                 case IDC_DLG_PREV:
  1485.                    GetDlgItemText(hDlg,IDC_DLG_INPUT,(LPSTR)DlgField[DlgIndex].CharData,NAME_WIDTH);
  1486.                    EndDialog(hDlg, FALSE);
  1487.                    return (TRUE);
  1488.                 default:
  1489.                    ;
  1490.             }
  1491.             break;
  1492.  
  1493.     }
  1494.     return (FALSE);
  1495. }
  1496.  
  1497. /****************************************************************************
  1498.     PosParam:
  1499.     This dialog box edits the text position within the current item outlines
  1500. ****************************************************************************/
  1501. BOOL CALLBACK _export PosParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1502. {
  1503.     UINT flags;
  1504.  
  1505.     switch (message) {
  1506.         case WM_INITDIALOG:
  1507.             
  1508.             flags=item[SelItem].flags;
  1509.  
  1510.             // Set horizontal position flag
  1511.             SendDlgItemMessage(hDlg,IDC_HLEFT,BM_SETCHECK, flags&OFLAG_HLEFT, 0L);
  1512.             SendDlgItemMessage(hDlg,IDC_HCENTER,BM_SETCHECK, flags&OFLAG_HCENTER, 0L);
  1513.             SendDlgItemMessage(hDlg,IDC_HRIGHT,BM_SETCHECK, flags&OFLAG_HRIGHT, 0L);
  1514.             
  1515.             // Set vertical position flag
  1516.             SendDlgItemMessage(hDlg,IDC_VTOP,BM_SETCHECK, flags&OFLAG_VTOP, 0L);
  1517.             SendDlgItemMessage(hDlg,IDC_VCENTER,BM_SETCHECK, flags&OFLAG_VCENTER, 0L);
  1518.             SendDlgItemMessage(hDlg,IDC_VBOTTOM,BM_SETCHECK, flags&OFLAG_VBOTTOM, 0L);
  1519.             
  1520.             SetFocus(GetDlgItem(hDlg,IDOK));
  1521.             return (FALSE);
  1522.  
  1523.         case WM_COMMAND:
  1524.             switch (CONTROL_ID(wParam,lParam)) {
  1525.                 case IDOK:
  1526.                    // set the position flags
  1527.                    flags=(item[SelItem].flags)&(~((UINT)OFLAG_HLEFT|OFLAG_HCENTER|OFLAG_HRIGHT|OFLAG_VTOP|OFLAG_VCENTER|OFLAG_VBOTTOM));
  1528.                    if (SendDlgItemMessage(hDlg,IDC_HLEFT,BM_GETCHECK, 0, 0L)) flags|=OFLAG_HLEFT;
  1529.                    if (SendDlgItemMessage(hDlg,IDC_HRIGHT,BM_GETCHECK, 0, 0L)) flags|=OFLAG_HRIGHT;
  1530.                    if (SendDlgItemMessage(hDlg,IDC_HCENTER,BM_GETCHECK, 0, 0L)) flags|=OFLAG_HCENTER;
  1531.                    if (SendDlgItemMessage(hDlg,IDC_VTOP,BM_GETCHECK, 0, 0L)) flags|=OFLAG_VTOP;
  1532.                    if (SendDlgItemMessage(hDlg,IDC_VCENTER,BM_GETCHECK, 0, 0L)) flags|=OFLAG_VCENTER;
  1533.                    if (SendDlgItemMessage(hDlg,IDC_VBOTTOM,BM_GETCHECK, 0, 0L)) flags|=OFLAG_VBOTTOM;
  1534.                    item[SelItem].flags=flags;
  1535.  
  1536.                    EndDialog(hDlg, TRUE);
  1537.                    return TRUE;
  1538.                 
  1539.                 case IDCANCEL:
  1540.                    EndDialog(hDlg, FALSE);
  1541.                    return TRUE;
  1542.                 default:
  1543.                    ;
  1544.             }
  1545.             break;
  1546.  
  1547.     }
  1548.     return (FALSE);
  1549. }
  1550.  
  1551. /****************************************************************************
  1552.     LineParam:
  1553.     This dialog box edits the line properties for a line type item.
  1554. ****************************************************************************/
  1555. BOOL CALLBACK _export LineParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1556. {
  1557.     int style,angle;
  1558.  
  1559.     switch (message) {
  1560.         case WM_INITDIALOG:
  1561.             
  1562.             // set the initial values
  1563.  
  1564.             angle=item[SelItem].LineAngle;   // outline style
  1565.             SendDlgItemMessage(hDlg,IDC_LINE_HORZ,BM_SETCHECK, angle==ANGLE_HORZ, 0L);
  1566.             SendDlgItemMessage(hDlg,IDC_LINE_VERT,BM_SETCHECK, angle==ANGLE_VERT, 0L);
  1567.             SendDlgItemMessage(hDlg,IDC_LINE_FDIAG,BM_SETCHECK, angle==ANGLE_FDIAG, 0L);
  1568.             SendDlgItemMessage(hDlg,IDC_LINE_BDIAG,BM_SETCHECK, angle==ANGLE_BDIAG, 0L);
  1569.  
  1570.             style=item[SelItem].LineStyle;   // outline style
  1571.             SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_SETCHECK, style==PS_SOLID, 0L);
  1572.             SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_SETCHECK, style==PS_DASH, 0L);
  1573.             SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_SETCHECK, style==PS_DOT, 0L);
  1574.             SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_SETCHECK, style==PS_DASHDOT, 0L);
  1575.  
  1576.             SetDlgItemInt(hDlg,IDC_LINE_WIDTH,item[SelItem].LineWidth,FALSE);
  1577.  
  1578.             return (FALSE);
  1579.  
  1580.         case WM_COMMAND:
  1581.             switch (CONTROL_ID(wParam,lParam)) {
  1582.                 case IDC_LINE_COLOR:
  1583.                    item[SelItem].LineColor=EditColor(hDlg,item[SelItem].LineColor,FALSE);
  1584.                    break;
  1585.  
  1586.                 case IDOK:
  1587.                    angle=item[SelItem].LineAngle;
  1588.                    if (SendDlgItemMessage(hDlg,IDC_LINE_HORZ,BM_GETCHECK, 0, 0L)) angle=ANGLE_HORZ;
  1589.                    if (SendDlgItemMessage(hDlg,IDC_LINE_VERT,BM_GETCHECK, 0, 0L)) angle=ANGLE_VERT;
  1590.                    if (SendDlgItemMessage(hDlg,IDC_LINE_FDIAG,BM_GETCHECK, 0, 0L)) angle=ANGLE_FDIAG;
  1591.                    if (SendDlgItemMessage(hDlg,IDC_LINE_BDIAG,BM_GETCHECK, 0, 0L)) angle=ANGLE_BDIAG;
  1592.                    item[SelItem].LineAngle=angle;
  1593.  
  1594.                    style=item[SelItem].LineStyle;
  1595.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_GETCHECK, 0, 0L)) style=PS_SOLID;
  1596.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_GETCHECK, 0, 0L)) style=PS_DASH;
  1597.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_GETCHECK, 0, 0L)) style=PS_DOT;
  1598.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_GETCHECK, 0, 0L)) style=PS_DASHDOT;
  1599.                    item[SelItem].LineStyle=style;
  1600.  
  1601.                    item[SelItem].LineWidth=GetDlgItemInt(hDlg,IDC_LINE_WIDTH,NULL,FALSE);
  1602.  
  1603.                    EndDialog(hDlg, TRUE);
  1604.                    return TRUE;
  1605.                 
  1606.                 case IDCANCEL:
  1607.                    EndDialog(hDlg, FALSE);
  1608.                    return TRUE;
  1609.                 default:
  1610.                    ;
  1611.             }
  1612.             break;
  1613.  
  1614.     }
  1615.     return (FALSE);
  1616. }
  1617.  
  1618. /****************************************************************************
  1619.     OutlineParam:
  1620.     This dialog box edits the item outline style and color
  1621. ****************************************************************************/
  1622. BOOL CALLBACK _export OutlineParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1623. {
  1624.     UINT flags;
  1625.     int style;
  1626.  
  1627.     switch (message) {
  1628.         case WM_INITDIALOG:
  1629.             
  1630.             // set the initial values
  1631.             flags=item[SelItem].OutlineSelect;
  1632.             SendDlgItemMessage(hDlg,IDC_LINE_LEFT,BM_SETCHECK, flags&OUTLINE_LEFT, 0L);
  1633.             SendDlgItemMessage(hDlg,IDC_LINE_RIGHT,BM_SETCHECK, flags&OUTLINE_RIGHT, 0L);
  1634.             SendDlgItemMessage(hDlg,IDC_LINE_TOP,BM_SETCHECK, flags&OUTLINE_TOP, 0L);
  1635.             SendDlgItemMessage(hDlg,IDC_LINE_BOT,BM_SETCHECK, flags&OUTLINE_BOT, 0L);
  1636.  
  1637.             SetDlgItemInt(hDlg,IDC_LINE_WIDTH,item[SelItem].OutlineWidth,FALSE);
  1638.  
  1639.             style=item[SelItem].OutlineStyle;   // outline style
  1640.             SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_SETCHECK, style==PS_SOLID, 0L);
  1641.             SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_SETCHECK, style==PS_DASH, 0L);
  1642.             SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_SETCHECK, style==PS_DOT, 0L);
  1643.             SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_SETCHECK, style==PS_DASHDOT, 0L);
  1644.  
  1645.             //disable options whne outline not selected
  1646.             if (!flags) {
  1647.                EnableWindow(GetDlgItem(hDlg,IDC_LINE_WIDTH),FALSE);
  1648.                EnableWindow(GetDlgItem(hDlg,IDC_LSTY_SOLID),FALSE);
  1649.                EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASH),FALSE);
  1650.                EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DOT),FALSE);
  1651.                EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASHDOT),FALSE);
  1652.                EnableWindow(GetDlgItem(hDlg,IDC_LINE_COLOR),FALSE);
  1653.             }
  1654.  
  1655.             SetFocus(GetDlgItem(hDlg,IDC_LINE_LEFT));
  1656.             return (FALSE);
  1657.  
  1658.         case WM_COMMAND:
  1659.             switch (CONTROL_ID(wParam,lParam)) {
  1660.                 case IDC_LINE_LEFT:  // disable enable controls
  1661.                 case IDC_LINE_RIGHT:
  1662.                 case IDC_LINE_TOP:
  1663.                 case IDC_LINE_BOT:
  1664.                    flags=FALSE;
  1665.                    if (SendDlgItemMessage(hDlg,IDC_LINE_LEFT,BM_GETCHECK, 0, 0L) 
  1666.                     || SendDlgItemMessage(hDlg,IDC_LINE_RIGHT,BM_GETCHECK, 0, 0L) 
  1667.                     || SendDlgItemMessage(hDlg,IDC_LINE_TOP,BM_GETCHECK, 0, 0L) 
  1668.                     || SendDlgItemMessage(hDlg,IDC_LINE_BOT,BM_GETCHECK, 0, 0L)) flags=TRUE;  
  1669.                    EnableWindow(GetDlgItem(hDlg,IDC_LINE_WIDTH),flags);
  1670.                    EnableWindow(GetDlgItem(hDlg,IDC_LSTY_SOLID),flags);
  1671.                    EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASH),flags);
  1672.                    EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DOT),flags);
  1673.                    EnableWindow(GetDlgItem(hDlg,IDC_LSTY_DASHDOT),flags);
  1674.                    EnableWindow(GetDlgItem(hDlg,IDC_LINE_COLOR),flags);
  1675.                    break;
  1676.  
  1677.                 case IDC_LINE_COLOR:
  1678.                    item[SelItem].OutlineColor=EditColor(hDlg,item[SelItem].OutlineColor,FALSE);
  1679.                    break;
  1680.  
  1681.                 case IDOK:
  1682.                    flags=0;
  1683.                    if (SendDlgItemMessage(hDlg,IDC_LINE_LEFT,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_LEFT;
  1684.                    if (SendDlgItemMessage(hDlg,IDC_LINE_RIGHT,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_RIGHT;
  1685.                    if (SendDlgItemMessage(hDlg,IDC_LINE_TOP,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_TOP;
  1686.                    if (SendDlgItemMessage(hDlg,IDC_LINE_BOT,BM_GETCHECK, 0, 0L)) flags|=OUTLINE_BOT;
  1687.                    item[SelItem].OutlineSelect=flags;
  1688.  
  1689.                    style=item[SelItem].OutlineStyle;
  1690.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_SOLID,BM_GETCHECK, 0, 0L)) style=PS_SOLID;
  1691.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_DASH,BM_GETCHECK, 0, 0L)) style=PS_DASH;
  1692.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_DOT,BM_GETCHECK, 0, 0L)) style=PS_DOT;
  1693.                    if (SendDlgItemMessage(hDlg,IDC_LSTY_DASHDOT,BM_GETCHECK, 0, 0L)) style=PS_DASHDOT;
  1694.                    item[SelItem].OutlineStyle=style;
  1695.  
  1696.                    item[SelItem].OutlineWidth=GetDlgItemInt(hDlg,IDC_LINE_WIDTH,NULL,FALSE);
  1697.  
  1698.                    EndDialog(hDlg, TRUE);
  1699.                    return TRUE;
  1700.                 
  1701.                 case IDCANCEL:
  1702.                    EndDialog(hDlg, FALSE);
  1703.                    return TRUE;
  1704.                 default:
  1705.                    ;
  1706.             }
  1707.             break;
  1708.  
  1709.     }
  1710.     return (FALSE);
  1711. }
  1712.  
  1713. /****************************************************************************
  1714.     BackgroundParam:
  1715.     This dialog box edits the item background brush style and color
  1716. ****************************************************************************/
  1717. BOOL CALLBACK _export BackgroundParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1718. {
  1719.     UINT flags;
  1720.     int style,hatch;
  1721.  
  1722.     switch (message) {
  1723.         case WM_INITDIALOG:
  1724.             
  1725.             // set the initial values
  1726.             flags=item[SelItem].flags;
  1727.             SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_SETCHECK, flags&OFLAG_FILL, 0L);
  1728.  
  1729.             style=item[SelItem].brush.lbStyle;   // brush style
  1730.             hatch=item[SelItem].brush.lbHatch;   // brush hatch type
  1731.             SendDlgItemMessage(hDlg,IDC_BRUSH_SOLID,BM_SETCHECK, style==BS_SOLID, 0L);
  1732.             SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_HORZ,BM_SETCHECK, style==BS_HATCHED && hatch==HS_HORIZONTAL, 0L);
  1733.             SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_VERT,BM_SETCHECK, style==BS_HATCHED && hatch==HS_VERTICAL, 0L);
  1734.             SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_CROSS,BM_SETCHECK, style==BS_HATCHED && hatch==HS_CROSS, 0L);
  1735.             SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS,BM_SETCHECK, style==BS_HATCHED && hatch==HS_DIAGCROSS, 0L);
  1736.             SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_FDIAG,BM_SETCHECK, style==BS_HATCHED && hatch==HS_FDIAGONAL, 0L);
  1737.             SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_BDIAG,BM_SETCHECK, style==BS_HATCHED && hatch==HS_BDIAGONAL, 0L);
  1738.  
  1739.             //disable options whne outline not selected
  1740.             if (!SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_GETCHECK, 0, 0L)) {
  1741.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_SOLID),FALSE);
  1742.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_HORZ),FALSE);
  1743.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_VERT),FALSE);
  1744.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_CROSS),FALSE);
  1745.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS),FALSE);
  1746.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_FDIAG),FALSE);
  1747.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_BDIAG),FALSE);
  1748.                EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_COLOR),FALSE);
  1749.             }
  1750.  
  1751.             SetFocus(GetDlgItem(hDlg,IDC_PAINT_BACKGROUND));
  1752.             return (FALSE);
  1753.  
  1754.         case WM_COMMAND:
  1755.             switch (CONTROL_ID(wParam,lParam)) {
  1756.                 case IDC_PAINT_BACKGROUND:  // disable enable controls
  1757.                    flags=(UINT)SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_GETCHECK, 0, 0L);
  1758.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_SOLID),flags);
  1759.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_HORZ),flags);
  1760.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_VERT),flags);
  1761.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_CROSS),flags);
  1762.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS),flags);
  1763.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_FDIAG),flags);
  1764.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_HATCH_BDIAG),flags);
  1765.                    EnableWindow(GetDlgItem(hDlg,IDC_BRUSH_COLOR),flags);
  1766.                    break;
  1767.  
  1768.                 case IDC_BRUSH_COLOR:
  1769.                    item[SelItem].brush.lbColor=EditColor(hDlg,item[SelItem].brush.lbColor,FALSE);
  1770.                    break;
  1771.  
  1772.                 case IDOK:
  1773.                    flags=(item[SelItem].flags)&(~((UINT)OFLAG_FILL));
  1774.                    if (SendDlgItemMessage(hDlg,IDC_PAINT_BACKGROUND,BM_GETCHECK, 0, 0L)) flags|=OFLAG_FILL;
  1775.                    item[SelItem].flags=flags;
  1776.  
  1777.                    hatch=item[SelItem].brush.lbHatch;
  1778.                    if (SendDlgItemMessage(hDlg,IDC_BRUSH_SOLID,BM_GETCHECK, 0, 0L)) style=BS_SOLID;
  1779.                    else {
  1780.                        style=BS_HATCHED;          // hatched brush
  1781.                        if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_HORZ,BM_GETCHECK, 0, 0L)) hatch=HS_HORIZONTAL;
  1782.                        if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_VERT,BM_GETCHECK, 0, 0L)) hatch=HS_VERTICAL;
  1783.                        if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_CROSS,BM_GETCHECK, 0, 0L)) hatch=HS_CROSS;
  1784.                        if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_DIAG_CROSS,BM_GETCHECK, 0, 0L)) hatch=HS_DIAGCROSS;
  1785.                        if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_FDIAG,BM_GETCHECK, 0, 0L)) hatch=HS_FDIAGONAL;
  1786.                        if (SendDlgItemMessage(hDlg,IDC_BRUSH_HATCH_BDIAG,BM_GETCHECK, 0, 0L)) hatch=HS_BDIAGONAL;
  1787.                    }
  1788.                    item[SelItem].brush.lbStyle=style;
  1789.                    item[SelItem].brush.lbHatch=hatch;
  1790.  
  1791.                    EndDialog(hDlg, TRUE);
  1792.                    return TRUE;
  1793.                 
  1794.                 case IDCANCEL:
  1795.                    EndDialog(hDlg, FALSE);
  1796.                    return TRUE;
  1797.                 default:
  1798.                    ;
  1799.             }
  1800.             break;
  1801.  
  1802.     }
  1803.     return (FALSE);
  1804. }
  1805.  
  1806. /****************************************************************************
  1807.     EditColor:
  1808.     This dialog box allows the user to select the new color.  The third
  1809.     option when TRUE allows for customized colors.
  1810. ****************************************************************************/
  1811. COLORREF EditColor(HWND hDlg,COLORREF InColor,BOOL FullOpen)
  1812. {
  1813.     CHOOSECOLOR cColor;
  1814.     DWORD CustColors[16];
  1815.     BYTE  clr;
  1816.     int i;
  1817.     float increment;
  1818.  
  1819.     // fill the CustColors array with 16 shades of gray
  1820.     increment=(float)255/(float)16;
  1821.     for (i=0;i<16;i++) {
  1822.        clr=(BYTE)((i+1)*increment);
  1823.        CustColors[i]=RGB(clr,clr,clr);
  1824.     }                  
  1825.  
  1826.     // fill the CHOOSECOLOR structure
  1827.     FarMemSet(&cColor,0,sizeof(CHOOSECOLOR));
  1828.     cColor.lStructSize=sizeof(CHOOSECOLOR);
  1829.     cColor.hwndOwner=hDlg;
  1830.     cColor.rgbResult=InColor;
  1831.     cColor.lpCustColors=CustColors;
  1832.     if (FullOpen) cColor.Flags=CC_FULLOPEN|CC_RGBINIT;
  1833.     else          cColor.Flags=CC_PREVENTFULLOPEN|CC_RGBINIT;
  1834.  
  1835.     if (ChooseColor(&cColor)) return cColor.rgbResult;
  1836.     else                      return InColor;
  1837.  
  1838. }
  1839.  
  1840. /******************************************************************************
  1841.     PrintParam:
  1842.     Select pages to print.
  1843. ******************************************************************************/
  1844. BOOL CALLBACK _export PrintParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1845. {
  1846.     int LastCompletePage;
  1847.  
  1848.     switch (message) {
  1849.         case WM_INITDIALOG:                  // initialize parameters 
  1850.             SetDlgItemInt(hDlg,IDC_FIRST_PAGE,ScrPage+1,FALSE);
  1851.             SetDlgItemInt(hDlg,IDC_LAST_PAGE,ScrPage+1,FALSE);
  1852.  
  1853.             SetFocus(GetDlgItem(hDlg,IDC_FIRST_PAGE));
  1854.             return (FALSE);
  1855.  
  1856.         case WM_COMMAND:
  1857.             switch (CONTROL_ID(wParam,lParam)) {
  1858.                 case IDOK:
  1859.                    FirstPrintPage=GetDlgItemInt(hDlg,IDC_FIRST_PAGE,NULL,FALSE);
  1860.                    LastPrintPage=GetDlgItemInt(hDlg,IDC_LAST_PAGE,NULL,FALSE);
  1861.  
  1862.                    // validate
  1863.                    if (ReportStage==IN_EXIT) LastCompletePage=PageCount;
  1864.                    else                      LastCompletePage=PageCount-1;
  1865.                    if (FirstPrintPage<1 || FirstPrintPage>LastPrintPage || LastPrintPage>LastCompletePage) { 
  1866.                       MessageBox(hDlg,"Invalid Page Selection!",NULL,MB_OK);
  1867.                       SetFocus(GetDlgItem(hDlg,IDC_FIRST_PAGE));
  1868.                       break;
  1869.                    }
  1870.                    EndDialog(hDlg, TRUE);
  1871.                    return (TRUE);
  1872.         
  1873.                 case IDCANCEL:
  1874.                    EndDialog(hDlg, FALSE);
  1875.                    return (TRUE);
  1876.                 default:
  1877.                    ;
  1878.             }
  1879.             break;
  1880.     }
  1881.     return (FALSE);
  1882. }
  1883.  
  1884. /******************************************************************************
  1885.     JumpParam:
  1886.     Request the page number to jump to.  The function returns 0 when the
  1887.     user selects cancel.
  1888. ******************************************************************************/
  1889. int CALLBACK _export JumpParam(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
  1890. {
  1891.     int LastCompletePage,page;
  1892.  
  1893.     switch (message) {
  1894.         case WM_INITDIALOG:                  // initialize parameters 
  1895.             SetDlgItemInt(hDlg,IDC_JUMP_PAGE,ScrPage+1,FALSE);
  1896.  
  1897.             SetFocus(GetDlgItem(hDlg,IDC_FIRST_PAGE));
  1898.             return (FALSE);
  1899.  
  1900.         case WM_COMMAND:
  1901.             switch (CONTROL_ID(wParam,lParam)) {
  1902.                 case IDOK:
  1903.                    page=GetDlgItemInt(hDlg,IDC_JUMP_PAGE,NULL,FALSE);
  1904.  
  1905.                    // validate page range
  1906.                    if (ReportStage==IN_EXIT) LastCompletePage=PageCount;
  1907.                    else                      LastCompletePage=PageCount-1;
  1908.                    if (page<1) page=1;
  1909.                    if (page>LastCompletePage) page=LastCompletePage;
  1910.                    EndDialog(hDlg, page);
  1911.                    return (TRUE);
  1912.         
  1913.                 case IDCANCEL:
  1914.                    EndDialog(hDlg, 0);
  1915.                    return (TRUE);
  1916.                 default:
  1917.                    ;
  1918.             }
  1919.             break;
  1920.     }
  1921.     return (FALSE);
  1922. }
  1923.  
  1924.