/*****************************************************************************
    This file should be included into your application modules which call
    the Report Right interface functions.
*************************************** **************************************/
#if defined (_WIN32)
   #if !defined(WIN32)
     #define WIN32
   #endif
#endif
/******************************************************************************
    WIN32 specific defines
*******************************************************************************/
#define huge
#define _export
#define FR_CLASS  "FrClass8"
#define REP_CLASS "RepClass8"

/****************************************************************************
   Control style bits
*****************************************************************************/
#define REP_HSCROLL         0x1
#define REP_VSCROLL         0x2
#define REP_MENU            0x4
#define REP_USE_PARAMS      0x8
#define REP_INVISIBLE       0x100
#define REP_NO_CLOSE        0x200
#define REP_TOOLBAR         0x400
#define REP_DESIGN_MODE     0x800
#define REP_NUM_STYLES      8

#define ACTION_COMMAND        1
#define ACTION_VSCROLL        2
#define ACTION_HSCROLL        3
#define ACTION_LBUTTONDOWN    5
#define ACTION_RBUTTONDOWN    6
#define ACTION_LBUTTONUP      7
#define ACTION_RBUTTONUP      8
#define ACTION_LBUTTONDBLCLK  9
#define ACTION_RBUTTONDBLCLK  10
#define ACTION_SIZE           11
#define ACTION_SETFOCUS       12
#define ACTION_KILLFOCUS      13
#define ACTION_MOUSEMOVE      14

#define FILE_RTF              1
#define FILE_HTML             2
#define FILE_TXT              3
#define FILE_NATIVE           4
#define FILE_PDF              5

#define REP_BOLD              0x1
#define REP_ULINE             0x2
#define REP_ITALIC            0x4
#define REP_STRIKE            0x8

#define MAX_WIDTH             300

#define MENU_FILE           0
#define MENU_EDIT           1
#define MENU_VIEW           2
#define MENU_INSERT         3
#define MENU_FORMAT         4
#define MENU_SECTION        5
#define MENU_REPORT         6
#define MENU_ARRANGE        7
#define MENU_HELP           8
#define MENU_OTHER          9

#define FILE_MASTER_DEF       0
#define FILE_DETAIL_DEF       1
#define FILE_OTHER_DEF        2
#define FILE_MASTER_DATA      3
#define FILE_DETAIL_DATA      4
#define FILE_OTHER_DATA       5
#define FILE_TEMPLATE         6
#define FILE_PICTURE_NAMES    7
#define FILE_DATA_MAP_PICT    8

#define PDFFLAG_COMPRESS_TEXT  0x1    // the flag used by the TerPdcStart function

#define TLB_LINE             1              // vertical line
#define TLB_TYPEFACE         2
#define TLB_POINTSIZE        3
#define TLB_BOLD             4
#define TLB_ITALIC           5
#define TLB_ULINE            6
#define TLB_ALIGN_LEFT       7
#define TLB_ALIGN_BOT        8
#define TLB_ALIGN_CENTER     9
#define TLB_ALIGN_RIGHT      10
#define TLB_ALIGN_TOP        11
#define TLB_CALC             12
#define TLB_DATA             13
#define TLB_DLG              14
#define TLB_CUT              15
#define TLB_COPY             16
#define TLB_PASTE            17
#define TLB_SPACER           18              // icon separator
#define TLB_NEW              19
#define TLB_OPEN             20
#define TLB_SAVE             21
#define TLB_INSERT_LINE      22
#define TLB_HELP             23
#define TLB_LABEL            24
#define TLB_PREVIEW          25
#define TLB_NUMBER           26
#define TLB_BULLET           27
#define TLB_UNDO             28
#define TLB_REDO             29
#define TLB_FIND             30
#define TLB_DATE             31
#define TLB_PAGE_NUM         32
#define TLB_PAGE_COUNT       33
#define TLB_TEXT_CLR         34
#define TLB_FILL_CLR         35
#define TLB_BRDR_CLR         36
#define TLB_RUN              37
#define TLB_JUMP             38
#define TLB_PRINT            39
#define MAX_TLB              40     // one more than the last

/****************************************************************************
   Instructions for packing the following structure
*****************************************************************************/
#ifndef RC_INVOKED
   #pragma pack(1)
#endif

/*****************************************************************************
   The parameter structure definition that is used by your application
   to specify the operation parameters and text data to the 'form' routine.
   For an example for using this structure, refer to the demo.c file.
*****************************************************************************/

struct StrForm {
       int    x;         // Initial x position of the editing window,
                         // you may specify CW_USEDEFAULT to use default values.
       int    y;         // Initial y position of the editing window.
       int    width;     // Initial width of the window in device units,
                         // you may specify CW_USEDEFAULT to use default values.
       int    height;    // Initial height of the editing window.  When you
                         // use CW_USEDEFAULT for width, the height parameter is
                         // ingnored.*/

       int (FAR PASCAL _export *UserSelection)(HWND, struct StrField huge *,int);
                           /* a pointer to the function returning the user
                           selected field through the structure pointer.
                           Your application returns the chosen field through
                           the first parameter.  The second argument indicates
                           the sort field number. If it is equal to zero,
                           it means that the field being sought is not a sort
                           field. The function returns a TRUE value if
                           successful.

                           When using ReportEase as a DLL, this pointer must
                           be passed using the MakeProcInstance function.  Your
                           application must define this function as exportatable
                           and include it it the EXPORT section of the
                           definition file
                           */

       int (FAR PASCAL _export *VerifyField)(HWND, struct StrField huge *,int);
                           /* a pointer to the user routine that validate a
                           field name.  The field name is passed to the routine
                           by the 'name' variable in the StrField structure.
                           This routine should also fill the 'type' variable
                           in the structure. The second arguement indicates the
                           sort field number. If it is equal to zero, it means
                           that the field to verify is not a sort field.  The
                           function returns TRUE to indicate a valid field.

                           When using ReportEase as a DLL, this pointer must
                           be passed using the MakeProcInstance function.  Your
                           application must define this function as exportatable
                           and include it it the EXPORT section of the
                           definition file
                           */


       char file[MAX_WIDTH];  // form file name. If an existing file is specified,
                        // the following fields are ignored.

       char DataSetName[20];/* (Specify for a new file) Your application can
                           specify a data set name which can be used to
                           associate the application data to the form.  This
                           is an optional field. */

        BOOL   ShowMenu;  // show the menu bar ?
        BOOL   ShowHorBar;// show the horizonatal scroll bar
        BOOL   ShowVerBar;// show the vertical scroll bar

        HANDLE hInst;     //  Handle of the current instanaces.
        HANDLE hPrevInst; //  Handle of the previous instances.
        HWND   hParentWnd;// Handle to the parent window
        HWND   hFrWnd;    //  Form main window handle, will be filled by RE later
        DWORD  style;     //  Editor window style
        char   FontTypeFace[32]; // Default type face, example: TmwRmn Courier, etc
        BOOL   open;      // TRUE indicates an open window (parameter block in use)
        BOOL   modified;  // TRUE when the file modified, and needs to be saved
        BOOL   ShowToolbar; // show the toolbar

        char   MasterDefFile[MAX_WIDTH];  // Master data definition file
        char   DetailDefFile[MAX_WIDTH];  // Detail data definition file
        char   OtherDefFiles[4*MAX_WIDTH]; // other data definition file - a list of comma delimited file names

        char   DataMapPictFile[MAX_WIDTH]; // jpeg picture file which shows the database diagram to the user

       };

typedef int (FAR PASCAL _export *USER_SELECTION)(HWND, struct StrField huge *,int);
typedef int (FAR PASCAL _export *VERIFY_FIELD)(HWND, struct StrField huge *,int);

/*****************************************************************************
   The parameter structure definition that is used by your application
   to specify the operation parameters to start a report execution session.
   For an example for using this structure, refer to the demo.c file.
*****************************************************************************/

struct StrRep {
       char file[MAX_WIDTH];   // form file name

       char device;      // P=Printer,S=Screen, F=Native Format File,
                         // R=Rtf Format File, H=Html File, T=Text file,
                         // C=Comma delimited text file, B=tab delimted text file
                         // D=PDF format file (must install WinPDF Converter), A=Ask the user.
                         // The following 4 parameters are not used if the
                         // device is set to 'P', 'F' ,'R', 'H', 'T', 'D', or 'C'.
       char pad[3];      // to make the next integer item align on 4 bytes boundary - to accommodate the TypeRep struture in rep.bas

       int    x;         // Initial x position of the report window,
                         // you may specify CW_USEDEFAULT to use default values.
       int    y;         // Initial y position of the report window.
       int    width;     // Initial width of the window in device units,
                         // you may specify CW_USEDEFAULT to use default values.
       int    height;    // Initial height of the editing window.  When you
                         // use CW_USEDEFAULT for width, the height parameter is
                         // ingnored.

       struct StrField huge *field; // (OUTPUT) pointer to an array of fields used by the
                                    // form
       int TotalFields;     // (OUTPUT) Number of fields in the 'field' array.

       struct StrField huge *SortField; // (OUTPUT) pointer to an array of fields used for
                                        // sorting.
       int TotalSortFields; // (OUTPUT) Number of fields in the 'SortField' array.

       char DataSetName[20];// (OUTPUT) This field returns the data set name
                            // associated with the form.  Your application
                            // may use this information to prepare data for
                            // the report executer

       char   SwapDir[MAX_WIDTH];  // Directory path to store swapped screen pages
                            // When this variable is equal to NULL, RE will use
                            // the current working directory for swapping.

       HANDLE hInst;        //  Handle of the current instanaces.
       HANDLE hPrevInst;    //  Handle of the previous instances.
       HWND   hParentWnd;   //  Handle to the parent window
       DWORD  style;        //  Report window style - needed for screen output only

       int (FAR PASCAL _export *DrawPicture)(HDC, int, int, int, RECT far *,int,UINT);

       BOOL   SuppressPrintMessages;  // TRUE to suppress print time messages
       BOOL   UseCurrentPrinter; // TRUE to use current printer instead of one form the form
       int    ReportId;          // (OUTPUT) current report id
       char   OutFile[MAX_WIDTH];      // Output file name.  This field should
                                 // specify a output file name when the device
                                 // variable is set to 'F'.  If a file name
                                 // is not specified, then this field should
                                 // have a 0 in the first character position.
       int    TextPitch;         // text pitch to use when the output is directed to a text file.  Set to
                                 // 0  to use default.
       BOOL   ShowMenu;          // show built-in menu
       BOOL   ShowToolbar;       // show the toolbar
       BOOL   DoPreprocessPass;  // a preprocess pass required for this report

       char   MasterDefFile[MAX_WIDTH];  // Master data definition file
       char   DetailDefFile[MAX_WIDTH];  // Detail data definition file
       char   OtherDefFiles[4*MAX_WIDTH]; // other data definition file - a list of comma delimited file names

       char   MasterDataFile[MAX_WIDTH];  // Master data file
       char   DetailDataFile[MAX_WIDTH];  // Detail data file
       char   OtherDataFiles[4*MAX_WIDTH]; // other data files - a list of comma delimited file names

       char   PictureNameFile[MAX_WIDTH]; // text file holding picture ids and picture file names

       BOOL   AutoRun;           // run the report automatically using the datafile and template specified in this structure
   };

typedef int (FAR PASCAL _export *DRAW_PICTURE)(HDC, int , int, int, RECT far *,int,UINT);

/*****************************************************************************
   The parameter structure definition that is used by your application
   to specify the operation parameters to view a report file.
   For an example for using this structure, refer to the demo.c file.
*****************************************************************************/
struct StrView {
       char file[MAX_WIDTH];   // formated report file name

       char device;      // P=Printer,S=Screen, A=Ask the user.
                         // The following 4 parameters are not used if the
                         // device is set to 'P' or 'F'.
       char pad[3];      // to make the next integer item align on 4 bytes boundary - to accommodate the TypeRep struture in rep.bas

       int    x;         // Initial x position of the report window,
                         // you may specify CW_USEDEFAULT to use default values.
       int    y;         // Initial y position of the report window.
       int    width;     // Initial width of the window in device units,
                         // you may specify CW_USEDEFAULT to use default values.
       int    height;    // Initial height of the editing window.  When you
                         // use CW_USEDEFAULT for width, the height parameter is
                         // ingnored.

       char   SwapDir[MAX_WIDTH];  // Directory path to store swapped screen pages
                            // When this variable is equal to NULL, RE will use
                            // the current working directory for swapping.

       HANDLE hInst;        //  Handle of the current instanaces.
       HANDLE hPrevInst;    //  Handle of the previous instances.
       HWND   hParentWnd;   //  Handle to the parent window
       DWORD  style;        //  Report window style - needed for screen output only

       BOOL   SuppressPrintMessages;  // TRUE to suppress print time messages
       int    ReportId;          // (OUTPUT) current report id
       int    TextPitch;        // text pitch to use when the output is directed to a text file.  Set to
                                // 0  to use default.
       BOOL   ShowToolbar; // show the toolbar
   };

/*****************************************************************************
                       Global Constants
*****************************************************************************/

#if defined (WIN32)
  #define FORM_SIGN       0xDEBA
#else
  #define FORM_SIGN       0xDEBC
#endif

// User flags
#define REPFLAG_NO_PICT_PATH    0x1
#define REPFLAG_NO_OVERLAP_MSG  0x2
#define REPFLAG_PRT_FONTS       0x4  // use printer fonts

// Screen object types
#define GROUP         0x0
#define LABEL         0x10
#define FIELD         0x20
#define SECTION       0x40
#define PICT          0x80
#define LINE          0x100


#define PAINT_MIN       1
#define PAINT_LINE      2
#define PAINT_ITEMS     2
#define PAINT_WIN       3
#define PAINT_PARTIAL_LINE 4
#define PAINT_PARTIAL_WIN  5

#define UNITS_PER_INCH  250
#define NAME_WIDTH      50

#define SRC_APPL        0
#define SRC_CALC        1
#define SRC_SYS         2
#define SRC_CONST       3
#define SRC_NONE        4
#define SRC_DLG         5

#define TYPE_NUM        1
#define TYPE_DBL        2
#define TYPE_TEXT       3
#define TYPE_LOGICAL    4
#define TYPE_DATE       5
#define TYPE_PICT       6

#define SUM_NONE        0
#define SUM_TOTAL       1
#define SUM_AVERAGE     2
#define SUM_COUNT       3
#define SUM_MAX         4
#define SUM_MIN         5
#define SUM_FTR_TOTAL   6       // accumulate when the previous section breaks
#define SUM_LAST        6

#define DT_MMDDYY       0
#define DT_DDMMYY       1
#define DT_MMDDYYYY     2
#define DT_MMMDDYYYY    3
#define DT_YYYYMMDD     4
#define DT_DDMMYYYY     5
#define DT_WINSHORT     6   // windows short format
#define DT_WINLONG      7   // windows long format
#define DT_NONE        99

#define TM_NONE         0x000    // uses second byte
#define TM_HHMMAM       0x100
#define TM_HHMMSSAM     0x200
#define TM_HHMM         0x300
#define TM_HHMMSS       0x400

#define FLAG_TRIM       0x1
#define FLAG_SUP_ZERO   0x2
#define FLAG_PAD_ZERO   0x4
#define FLAG_CAPS       0x8
#define FLAG_FIRST_CAP  0x10
#define FLAG_SMALL      0x20
#define FLAG_COMMA      0x40
#define FLAG_WRAP       0x80
#define FLAG_WORD_WRAP  0x100
#define FLAG_RETAIN     0x200
#define FLAG_FLEX_SIZE  0x400
#define FLAG_NO_CONT_CALC 0x800
#define FLAG_SHARED     0x1000
#define FLAG_NO_CALC    0x2000
#define FLAG_NULL       0x4000   // indicates a field with null value
#define FLAG_SUP_TRAIL_ZERO 0x8000    // suppress trailing zeros from a decimal field,ex: 1.50 prints as 1.5
#define FLAG_AUTOSIZE      0x10000    // autosize the picture to fit the picture box
#define FLAG_KEEP_ASPECT   0x20000    // maintain aspect ratio of the picture when doing autosizing
#define FLAG_RESERVE_EMPTY_SPACE 0x40000    // do not maintain empty picture space
#define FLAG_SORT_DESCEND  0x80000
#define FLAG_DATE_ONLY    0x100000

#define FLAG1_DEF_STYLE      0x1      // this field provies style information to a newly created field
#define FLAG1_CALC_DONE      0x2      // calculation done
#define FLAG1_CURRENCY_AFTER 0x4      // currency symbol after the amount
#define FLAG1_INVISIBLE      0x8      // invisible field in the report
#define FLAG1_SWAPPED        0x10     // total/value swapped during calculation
#define FLAG1_ITEM_FIELD     0x20     // used by an item

#define RFLAG_TRIAL             0x1
#define RFLAG_REPORT_HDR_FIRST  0x2
#define RFLAG_AUTO_COL_HDR      0x4
#define RFLAG_SUP_HDR_WITH_REP_FTR 0x8
#define RFLAG_SUP_FTR_WITH_REP_FTR 0x10
#define RFLAG_SUP_PAGE_BREAK    0x20  // suppress page break on text output - suitable for export
#define RFLAG_USE_DEFAULT_PRINTER 0x40
#define RFLAG_ALLOW_DESCEND_SORT  0x80  // allow descending sort
#define RFLAG_NO_CLEAR_SPL_HIST   0x100 // clear the SpellTime history buffer
#define RFLAG_ALT_NUM_DECIMAL     0x200 // decimal zeros after the numberic value
#define RFLAG_CENTER_DLGS_ON_SCR  0x400 // position the dialog boxes centered on screen
#define RFLAG_CUSTOM_COLORS_SAVED 0x800 // TRUE when custom colors saved with the report

// Section Constants
#define MAX_SECTIONS    56
#define SEC_HDR_PAGE    0
#define SEC_HDR_REP1    1
#define SEC_HDR_REP2    2
#define SEC_HDR_REP3    3
#define SEC_HDR_REP4    4
#define SEC_HDR_REP5    5
#define SEC_HDR_REP6    6
#define SEC_HDR_REP7    7
#define SEC_HDR_REP8    8
#define SEC_HDR_REP9    9
#define SEC_HDR_LVL1    10
#define SEC_HDR_LVL2    11
#define SEC_HDR_LVL3    12
#define SEC_HDR_LVL4    13
#define SEC_HDR_LVL5    14
#define SEC_HDR_LVL6    15
#define SEC_HDR_LVL7    16
#define SEC_HDR_LVL8    17
#define SEC_HDR_LVL9    18
#define SEC_DETAIL1     19
#define SEC_DETAIL2     20
#define SEC_DETAIL3     21
#define SEC_DETAIL4     22
#define SEC_DETAIL5     23
#define SEC_DETAIL6     24
#define SEC_DETAIL7     25
#define SEC_DETAIL8     26
#define SEC_DETAIL9     27
#define SEC_DETAIL10    28
#define SEC_DETAIL11    29
#define SEC_DETAIL12    30
#define SEC_DETAIL13    31
#define SEC_DETAIL14    32
#define SEC_DETAIL15    33
#define SEC_DETAIL16    34
#define SEC_DETAIL17    35
#define SEC_DETAIL18    36
#define SEC_FTR_LVL9    37
#define SEC_FTR_LVL8    38
#define SEC_FTR_LVL7    39
#define SEC_FTR_LVL6    40
#define SEC_FTR_LVL5    41
#define SEC_FTR_LVL4    42
#define SEC_FTR_LVL3    43
#define SEC_FTR_LVL2    44
#define SEC_FTR_LVL1    45
#define SEC_FTR_REP1    46
#define SEC_FTR_REP2    47
#define SEC_FTR_REP3    48
#define SEC_FTR_REP4    49
#define SEC_FTR_REP5    50
#define SEC_FTR_REP6    51
#define SEC_FTR_REP7    52
#define SEC_FTR_REP8    53
#define SEC_FTR_REP9    54
#define SEC_FTR_PAGE    55


#define SEC_HDR_REP_LAST  SEC_HDR_REP9
#define SEC_FTR_REP_LAST  SEC_FTR_REP9
#define SEC_HDR_REP_COUNT 9

#define SEC_HDR_LAST     SEC_HDR_LVL9
#define SEC_FTR_LAST     SEC_FTR_LVL9
#define SEC_LEVEL_COUNT  9

#define SEC_DETAIL_LAST   SEC_DETAIL18
#define SEC_DETAIL_COUNT  18

#define SFLAG_PAGE_BEF    0x1
#define SFLAG_PAGE_AFT    0x2
#define SFLAG_REPRINT     0x4
#define SFLAG_TRIM_BEFORE 0x8
#define SFLAG_TRIM_AFTER  0x10
#define SFLAG_RESET_PAGE_NO 0x20
#define SFLAG_KEEP_WITH_NEXT 0x40
#define SFLAG_RESET_HEIGHT 0x80     // start detail section at the same Y - applicable to sort header only
#define SFLAG_KEEP        0x100     // don't let this section split because of any variable height fields
#define SFLAG_VAR_HEIGHT  0x200     // temporary flag used during report to denote sections that have variblae height fields
#define SFLAG_CAP         0x400     // cap section
#define SFLAG_ALIGN_BOT   0x800     // bottom alignment for the report footer section

// Screen object flags
#define OFLAG_FILL    0x2
#define OFLAG_HLEFT   0x4
#define OFLAG_HRIGHT  0x8
#define OFLAG_HCENTER 0x10
#define OFLAG_VTOP    0x20
#define OFLAG_VCENTER 0x40
#define OFLAG_VBOTTOM 0x80
#define OFLAG_SELECT_TOGGLE 0x100
#define OFLAG_MULTILINE 0x200
#define OFLAG_VERT    0x400
#define OFLAG_INVISIBLE 0x800
#define OFLAG_DEF_STYLE 0x1000     // this item provides style information to a newly created item
#define OFLAG_MARKED    0x2000     // marked for selection
#define OFLAG_HLINK     0x4000
#define OFLAG_CUR_ITEM  0x8000     // currently selected item
#define OFLAG_HJUSTIFY 0x10000

// Screen object outline selection
#define OUTLINE_LEFT  0x1
#define OUTLINE_RIGHT 0x2
#define OUTLINE_TOP   0x4
#define OUTLINE_BOT   0x8

#define CB_USER_SELECTION   1
#define CB_VERIFY_FIELD     2
#define CB_DRAW_PICTURE     3

#define ERR_NO_FILE     1
#define ERR_NO_DEVICE   2
#define ERR_NO_MEM      3
#define ERR_BAD_EXP     4
#define ERR_SUSPEND     5
#define ERR_ZERO_DIVIDE 6
#define ERR_TYPE_MISMATCH 7
#define ERR_INCOMPLETE  8
#define ERR_DUPLICATE   9
#define ERR_PRINTER     10
#define ERR_IO          11
#define ERR_DISPLAY     12
#define ERR_WRAP        13
#define ERR_FONT        14
#define ERR_OTHER       15
#define ERR_MAX_SCR_PAGES_EXCEEDED 16

#define ERR_BAD_WND     16
#define ERR_NO_REP_ID   17
#define ERR_BAD_REP_ID  18
#define ERR_NO_OUTFILE  19
#define ERR_NO_TER      20
#define ERR_IN_TER      21
#define ERR_OVERLAPPING_ITEMS 22
#define ERR_NO_PRINTER  23
#define ERR_EXPIRED     24
#define ERR_LICENSE_EXPIRED 25
#define ERR_BAD_LICENSE_NUMBER 26
#define ERR_INVALID_SERVER_LICENSE 27
#define ERR_LICENSE_EXCEEDED 28

typedef long (FAR PASCAL _export *MSG_CALLBACK)(HWND,UINT,WPARAM,LPARAM);
typedef long (FAR PASCAL _export *RVDDRAWPICT_CALLBACK)(UINT);
typedef long (FAR PASCAL _export *RVD_PRINT_PROGRESS_CALLBACK)(UINT,int,LPINT);

/******************************************************************************
                        Form Header Structure
******************************************************************************/
struct StrFormHdr {
           unsigned FormSign;     // Form File Signature

           char name[NAME_WIDTH+2]; // report name

           char DataSetName[20];  // Your application can specify a data set
                                  // name which can be used to associate the
                                  // application data to the form.  This
                                  // is an optional information.

           int   ItemCount;       // screen items in the form template
           int   TotalFields;      // total number of fields
           int   BreakFieldCount; // total number of break fields
           int   FontCount;       // number of entries in the font table

           float LeftMarg;        // margins in inches
           float RightMarg;
           float TopMarg;
           float BottomMarg;

           LPINT SelExp;          // record selection expression
           int   SelExpRem[51];   // remaining storage from old expression

           int   Orientation;     // DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE
           int   PprSize;         // paper size given by DMPAPER_* variables used for DEVMODE
           int   PprLength;       // specified in tenths of millimeter, used only if PaperSize = 0
           int   PprWidth;        // specified in tenths of millimeter, used only if PaperSize = 0
           int   PrintQuality;    // print quality

           char OldPrtName[NAME_WIDTH+2],      // old name of the printer
                OldPrtDriver[NAME_WIDTH+2];    // old printer driver name

           unsigned flags;        // RFLAG_ series flags

           int  DateFmt;          // 0=MM/DD/YY, 1=DD/MM/YY

           int  RulerType;        // RULER_OFF,RULER_INCH,RULER_CM

           int  SecBannerHeight;  // height (logical units) of the section banner
           int  FileFormatId;     // records the file format changes
           int  PaperBin;         // paper bin
           char PrtName[MAX_WIDTH+2],      // name of the printer
                PrtDriver[MAX_WIDTH+2];    // printer driver name
           COLORREF CustColors[16];  // 20091002: custom colors

           char   reserved[78];   // 20091002: reduced from 142 to 78; reserved
       };

/******************************************************************************
                        Field Structure
******************************************************************************/
struct StrField {                 // define each field
         int source;              // source of field data: application,calculation,system, constant etc

         char OldName[NAME_WIDTH+2]; // field name
         int FileId;              // an optional id that may be defined by the calling application
         int FieldId;             // another optional id that may be defined by the calling application
         int type;                // numeric/alphanumeric/logical/date
         int width;               // field data width as stored in your database
         int DecPlaces;           // decimal places for numeric fields
         int AllowChanges;        // Allow modification of the following fields

         int InUse;               // TRUE=in use, FALSE=not in use
         unsigned flags;          // FLAG_ constants
         int SumType;             // summary type: total/average/minmum/maximum/none
         int SysIdx;              // index into the system field table for system fields

         int  DateFmt;            // date format, lowest byte=DT_ cosntants, second byte=TM_ constants
         char DateDelim[2];       // date delimiter character, i.e. / or -

         char CurrencySymbol[4];  // currency symbol
         char LogicalSymbols[2];  // logical TRUE and FALSE symbols

         char NegSignPrefix[4];   // negative sign prefix
         char NegSignSuffix[4];   // negative sign suffix
         char PosSignPrefix[4];   // positive sign prefix
         char PosSignSuffix[4];   // positive sign suffix

         LPINT  CalcExp;          // expression for the calculated fields
         int    CalcExpRem[51];   // remaining space from old CalcExp

         LPSTR  CharData;         // character data, pointer to an object of size = field.width+1
         long   NumData;          // numeric data (long)
         double DblData;          // numeric data for field = TYPE_DBL

         long   HoldNum;          // long accumulater: total,minimum,maximum,etc...
         double HoldDbl;          // double accumulater: total,minimum,maximum,etc...
         long   count;            // number of records in a group during execution

         int   SectId;            // section that holds the field (report time only)
         int   misc;              // used for miscellaneous purposes

         char  ParaChar[2];       // specify the new paragraph indicator character
                                  // in the first byte.  Needed only for a word/wrapped
                                  // text field.
         int   UseCount;          // use count for the shared fields - lost 4 byte alignment - this field not visible in vb or delphi

         DWORD OldFlags1;         // FLAG1_ constants - moved to new field 'flags1'
         BYTE  filler[2];         // to regain 4 byte alignement for the next field onward
         DWORD flags1;            // new flags1
         char  name[2*NAME_WIDTH+2]; // field name

       };

/****************************************************************************
   Instructions to resume the default structure packing.
*****************************************************************************/
#ifndef RC_INVOKED
   #pragma pack()
#endif

/******************************************************************************
                        Calleable Function Prototypes
   When calling REP from a C program, leave the REP_CPLUSPLUS symbol undefined.

   When calling REP from a C++ program, define the REP_CPLUSPLUS as following:

   #define REP_CPLUSPLUS extern "C"
   #include "rep.h"
******************************************************************************/
#ifndef REP_CPLUSPLUS
   #if defined(__cplusplus)
      #define REP_CPLUSPLUS extern "C"
   #else
      #define REP_CPLUSPLUS
   #endif
#endif

REP_CPLUSPLUS int  WINAPI _export form(struct StrForm far *);
REP_CPLUSPLUS int  WINAPI _export RepEditForm(struct StrForm far *);
REP_CPLUSPLUS HWND WINAPI _export RepEditForm2(struct StrForm far *);
REP_CPLUSPLUS int  WINAPI _export RepInit(struct StrRep far *);
REP_CPLUSPLUS int  WINAPI _export RepInit2(HWND,struct StrRep far *);
REP_CPLUSPLUS int  WINAPI _export RepRec(int);
REP_CPLUSPLUS int  WINAPI _export RepExit(int);
REP_CPLUSPLUS int  WINAPI _export RepView(struct StrView far *);
REP_CPLUSPLUS int  WINAPI _export RepView2(HWND,struct StrView far *);
REP_CPLUSPLUS int  WINAPI _export RepDrawTerText(int,LPBYTE,HGLOBAL,DWORD,LPBYTE,LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepEnableCommand(int,BOOL);

REP_CPLUSPLUS int  WINAPI _export RepInsertSection(HWND,int,LPBYTE,BOOL);
REP_CPLUSPLUS int  WINAPI _export RepInsertLabel(HWND,LPBYTE,int,int,int,int,int,UINT,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSave(HWND,LPSTR);
REP_CPLUSPLUS int  WINAPI _export RepInsertLine(HWND,int,int,int,int,BOOL);
REP_CPLUSPLUS int  WINAPI _export RepInsertField(HWND hWnd,int,LPSTR,int,int,int,int,int,BOOL);
REP_CPLUSPLUS UINT WINAPI _export RepSetFormFlags(HWND,BOOL,UINT);
REP_CPLUSPLUS BOOL WINAPI _export RepListInit(HWND,LPBYTE,int,int);
REP_CPLUSPLUS BOOL WINAPI _export RepListAppend(HWND,LPBYTE);
REP_CPLUSPLUS int  WINAPI _export RepListShow(HWND);

REP_CPLUSPLUS BOOL WINAPI _export RepCommand(HWND,int);
REP_CPLUSPLUS BOOL WINAPI _export RepCommand2(HWND,int,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepMenuEnable(HWND,int);
REP_CPLUSPLUS BOOL WINAPI _export RepMenuSelect(HWND,int);
REP_CPLUSPLUS BOOL WINAPI _export RepOpenForm(HWND,struct StrForm far *);
REP_CPLUSPLUS BOOL WINAPI _export RepClearForm(HWND,int);
REP_CPLUSPLUS BOOL WINAPI _export RepLoadControl(void);
REP_CPLUSPLUS BOOL WINAPI _export RepModified(HWND);
REP_CPLUSPLUS BOOL WINAPI _export RepSetModify(HWND,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepQueryExit(HWND);

REP_CPLUSPLUS BOOL WINAPI _export RepIgnoreCommand(HWND);
REP_CPLUSPLUS BOOL WINAPI _export RepIgnoreCommand2(HWND, int);
REP_CPLUSPLUS int  WINAPI _export RepGetItemInfo(HWND,int,LPBYTE,LPINT,LPINT,LPINT,LPINT,LPINT,LPINT,LPINT);
REP_CPLUSPLUS BOOL WINAPI _export RepGetPageInfo(HWND,LPINT,LPINT,LPLONG);
REP_CPLUSPLUS BOOL WINAPI _export RepDebugMsg(LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepSetDefPrinter(LPBYTE,LPBYTE,LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepSaveReport(HWND,int,LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepSetRtfAttach(int,LPBYTE,BOOL,LPBYTE,LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepGetField(HWND,int,int,struct StrField far *);
REP_CPLUSPLUS BOOL WINAPI _export RepSetField(HWND,int,int,struct StrField far *);

REP_CPLUSPLUS HWND WINAPI _export RepGetParent(HWND,int);
REP_CPLUSPLUS int  WINAPI _export RepSetMsgCallback(HWND,int, MSG_CALLBACK);
REP_CPLUSPLUS LPVOID WINAPI _export RepGetParentPtr(HWND,int);
REP_CPLUSPLUS BOOL WINAPI _export RepSetParentPtr(HWND,int,LPVOID);
REP_CPLUSPLUS BOOL WINAPI _export RepRepaint(HWND,int);
REP_CPLUSPLUS BOOL WINAPI _export RepSetCallback(HWND,int,int,LPVOID);
REP_CPLUSPLUS BOOL WINAPI _export RepDrawBitmap(int,HBITMAP,HDC,LPRECT,int,int,int,int);

REP_CPLUSPLUS BOOL WINAPI _export RepSetHdrPos(BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepAllowPageCountField(BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepBeginPreprocessPass(int);
REP_CPLUSPLUS BOOL WINAPI _export RepEndPreprocessPass(int);
REP_CPLUSPLUS BOOL WINAPI _export RepInPreprocess(int);

REP_CPLUSPLUS BOOL WINAPI _export RepCanInsertSect(int,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepShrinkWrapFieldSpace(BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSetPrinter(HWND,BOOL,LPBYTE,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepPrintFromPreview(HWND,LPBYTE,LPBYTE,LPBYTE,int,int);

REP_CPLUSPLUS BOOL WINAPI _export RepSetItemFont(HWND,int,LPBYTE,int,UINT,COLORREF,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSetDefPrinterFlag(BOOL);
REP_CPLUSPLUS int  WINAPI _export RepInsertSection2(HWND,int,LPBYTE,int,int,UINT,BOOL);
REP_CPLUSPLUS int  WINAPI _export RepInsertField2(HWND hWnd,int,LPSTR,int,int,int,int,int,LPBYTE,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepDeleteSection(HWND,int);
REP_CPLUSPLUS DWORD WINAPI _export RepSetFlags(HWND,int,BOOL,DWORD);
REP_CPLUSPLUS BOOL WINAPI _export RepSetItemInfo(HWND,int,int,COLORREF,COLORREF,UINT,int,int,COLORREF,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSetRtfAttach2(int,LPBYTE,BOOL,LPBYTE FieldName,LPBYTE,BOOL);

REP_CPLUSPLUS BOOL WINAPI _export RepIsPrinting(int);
REP_CPLUSPLUS BOOL WINAPI _export RepGetCurPrinter(LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepRenameField(HWND,LPBYTE, LPBYTE,int,int);
REP_CPLUSPLUS BOOL WINAPI _export RepSetLicenseKey(LPBYTE);

REP_CPLUSPLUS BOOL WINAPI _export RepPdfSetDllName(LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepSetPdfInfo(LPBYTE, LPBYTE, LPBYTE, LPBYTE, LPBYTE, LPBYTE);


// Undocumented functions - do not use them without consultation with Sub Systems, Inc.
REP_CPLUSPLUS BOOL WINAPI _export RepResetPrinterSelection(void);
REP_CPLUSPLUS BOOL WINAPI _export RepSpellCheck(HWND,int,BOOL,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepAddToolbarIcon(HWND,int,int,int,LPBYTE,LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepRecreateToolbar(HWND,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepHideToolbarIcon(HWND,int,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepEditTooltip(HWND,int,LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepAddToolbarItem(HWND,int,int,LPBYTE,LPBYTE,LPBYTE,int,int);
REP_CPLUSPLUS BOOL WINAPI _export RepFileName(HWND, int, int, BOOL, LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepInternetGet(HWND , int, LPBYTE , LPBYTE , BOOL );
REP_CPLUSPLUS BOOL WINAPI _export RepInternetPut(HWND , int, LPBYTE , LPBYTE, BOOL );
REP_CPLUSPLUS BOOL WINAPI _export RepInternetPutHttp(HWND , int, LPBYTE , LPBYTE, BOOL );
REP_CPLUSPLUS BOOL WINAPI _export RepInternetOpen(HWND, int);
REP_CPLUSPLUS BOOL WINAPI _export RepInternetClose(HWND,int );
REP_CPLUSPLUS BOOL WINAPI _export RepIsHttpFile(LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepShowSubMenu(HWND,int, int, int);
REP_CPLUSPLUS BOOL WINAPI _export RepSetMenuItemDesc(HWND, int, LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepIsInIE(HWND,BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSetWinBorder(HWND, int);
REP_CPLUSPLUS BOOL WINAPI _export RepGetSelectedPrinter(HWND, int, LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepSaveReport2(HWND, int, int, LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepSetItemFont2(HWND, int, LPBYTE, int, UINT, COLORREF, int, BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSetCharSet(HWND, int);
REP_CPLUSPLUS int  WINAPI _export RepInitContinue(struct StrRep far *);
REP_CPLUSPLUS BOOL WINAPI _export RepLastPrinterSelectionResult(HWND);
REP_CPLUSPLUS BOOL WINAPI _export RepImportCustomColors(HWND, LPBYTE);
REP_CPLUSPLUS COLORREF WINAPI _export RepGetPageBorderColor(HWND);
REP_CPLUSPLUS DWORD WINAPI _export RepGetPageBorderOleColor(HWND);
REP_CPLUSPLUS BOOL WINAPI _export RepSetPageBorderColor(HWND, COLORREF, BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepSetPageBorderOleColor(HWND, DWORD, BOOL);
REP_CPLUSPLUS BOOL WINAPI _export RepEnlargeTextField(int, int, int);
REP_CPLUSPLUS HGLOBAL WINAPI _export RepFileToMem(LPSTR, DWORD *);
REP_CPLUSPLUS HGLOBAL WINAPI _export RepFileToMem2(HWND, LPSTR, DWORD *);
REP_CPLUSPLUS BOOL WINAPI _export RepInitPdf(LPBYTE, LPBYTE, LPBYTE, LPBYTE, LPBYTE,LPBYTE, LPBYTE, DWORD, DWORD, LPBYTE, LPBYTE);
REP_CPLUSPLUS BOOL WINAPI _export RepInitPdf2(LPBYTE, LPBYTE, LPBYTE, LPBYTE, LPBYTE,LPBYTE, LPBYTE, DWORD, DWORD, LPBYTE, LPBYTE,COLORREF, BOOL);


REP_CPLUSPLUS int     WINAPI _export RepSetLicenseInfo(LPBYTE, LPBYTE, LPBYTE);
REP_CPLUSPLUS int     WINAPI _export RepGetLicenseStatus();



REP_CPLUSPLUS BOOL WINAPI _export RvdPictureListAdd(int, LPBYTE, LPBYTE, HANDLE );
REP_CPLUSPLUS BOOL WINAPI _export RvdPictureListRemove(int, LPBYTE );
REP_CPLUSPLUS BOOL WINAPI _export RvdPictureListReplace(int, LPBYTE, LPBYTE, HANDLE );
REP_CPLUSPLUS HANDLE WINAPI _export RvdPictureListGet(int, LPBYTE );
REP_CPLUSPLUS BOOL WINAPI _export RvdPictureListGetTag(int, LPBYTE, LPBYTE );
REP_CPLUSPLUS BOOL WINAPI _export RvdPictureListExists(int, LPBYTE );
REP_CPLUSPLUS BOOL WINAPI _export RvdPictureListRemoveAll(int );

REP_CPLUSPLUS int CALLBACK _export RvdMsgCallback(HWND,UINT,WPARAM,LPARAM);
REP_CPLUSPLUS BOOL WINAPI _export RvdSetProgressCallback(int, RVD_PRINT_PROGRESS_CALLBACK );

/******************************************************************************
               REP Messages
*******************************************************************************/

/*******************************************************************************
   REP_CLOSE:
   This message is sent to your application by the form editor and
   report executer.

   Form Editor sends this messages before closing the form editor window.

   The report executer sends this message before after writing the last
   report line.
*******************************************************************************/
#define REP_CLOSE    (WM_USER)

/*******************************************************************************
   REP_SAVE_AS:
   This message is sent to your application by the form editor when a
   new name is being assigned to the form.
*******************************************************************************/
#define REP_SAVE_AS   (WM_USER+1)
#define REP_UPDATE_TOOLBAR (WM_USER+1300)
#define REP_PREPROCESS     (WM_USER+1301)
#define REP_POSTPROCESS    (WM_USER+1302)
#define REP_FIELD_DROP     (WM_USER+1303)
#define REP_ACTION         (WM_USER+1304)
#define REP_CREATED        (WM_USER+1305)
#define REP_PRINT_PROGRESS (WM_USER+1306)

