home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / repease / rep.bas < prev    next >
BASIC Source File  |  1995-07-19  |  16KB  |  341 lines

  1. '*****************************************************************************
  2. '   The parameter structure definition that is used by your application
  3. '   to specify the operation parameters and text data to the 'form' routine.
  4. '   For an example for using this structure, refer to the demo.c file.
  5. '*****************************************************************************
  6.  
  7. Type TypeForm
  8.        x      As Integer    'Initial x position of the editing window,
  9.                              'you may specify CW_USEDEFAULT to use default values.
  10.        y      As Integer    'Initial y position of the editing window.
  11.        width  As Integer    'Initial width of the window in device units,
  12.                             'you may specify CW_USEDEFAULT to use default values.
  13.        height As Integer    'Initial height of the editing window.  When you
  14.                             ' use CW_USEDEFAULT for width, the height parameter is
  15.                             ' ingnored.
  16.  
  17.        reserved1 As Long    ' Reserved for internal use. Do not modify the
  18.                             ' value in this field
  19.  
  20.  
  21.        reserved2 As Long    ' Reserved for internal use. Do do not modify the
  22.                             ' value in this field.
  23.  
  24.        file As String * 130 ' form file name. If an existing file is specified,
  25.                             ' the following fields are ignored.
  26.                              ' You must append chr(0) to NULL terminate this string
  27.                                             
  28.        DataSetName As String * 20' (Specify for a new file) Your application can
  29.                              ' specify a data set name which can be used to
  30.                              ' associate the application data to the form.  This
  31.                              ' is an optional field.
  32.                              ' You must append chr(0) to NULL terminate this string
  33.  
  34.         ShowMenu  As Integer  ' show the menu bar
  35.         ShowHorBar As Integer ' show the horizonatal scroll bar
  36.         ShowVerBar As Integer ' show the vertical scroll bar
  37.  
  38.         hInst As Integer      ' Handle of the current instanaces.
  39.         hPrevInst As Integer  ' Handle of the previous instances.
  40.         hParentWnd As Integer ' Handle to the parent window
  41.         hFrWnd As Integer     ' Form main window handle, will be filled by RE later
  42.         style As Long         ' Editor window style
  43.         FontTypeFace As String * 32' Default type face, example: TmwRmn Courier, etc
  44.                               ' You must append chr(0) to NULL terminate this string
  45.  
  46.         open As Integer       ' TRUE indicates an open window (parameter block in use)
  47.         modified As Integer   ' TRUE when the file modified, and needs to be saved
  48. End Type
  49.  
  50.  
  51. '*****************************************************************************
  52. '   The parameter structure definition that is used by your application
  53. '   to specify the operation parameters to start a report execution session.
  54. '   For an example for using this structure, refer to the demo.c file.
  55. '*****************************************************************************
  56.  
  57. Type TypeRep
  58.        file   As String * 129 ' form file name
  59.                               ' You must append chr(0) to NULL terminate this field
  60.  
  61.        device As String * 1   ' P=Printer,S=Screen,A=Ask the user. The following
  62.                               ' 4 parameters are not used if the device is
  63.                               ' set to 'P'
  64.  
  65.        x      As Integer      ' Initial x position of the report window,
  66.                               ' you may specify CW_USEDEFAULT to use default values.
  67.        y      As Integer      ' Initial y position of the report window.
  68.        width  As Integer      ' Initial width of the window in device units,
  69.                               ' you may specify CW_USEDEFAULT to use default values.
  70.        height As Integer      ' Initial height of the editing window.  When you
  71.                               ' use CW_USEDEFAULT for width, the height parameter is
  72.                               ' ingnored.
  73.        
  74.        reserved1 As Long      ' Reserved for internal use.  Do not modify this field
  75.  
  76.        TotalFields As Integer ' (OUTPUT) Number of fields in the 'field' array.
  77.  
  78.        reserved2 As Long      ' Reserved for internal use. Do not modify this field
  79.  
  80.        TotalSortFields As Integer ' (OUTPUT) Number of fields in the 'SortField' array.
  81.        
  82.        DataSetName As String * 20' (OUTPUT) This field returns the data set name
  83.                               ' associated with the form.  Your application
  84.                               ' may use this information to prepare data for
  85.                               ' the report executer
  86.                               ' This field is NULL terminated
  87.  
  88.        SwapDir As String * 60 ' Directory path to store swapped screen pages
  89.                               ' When this variable is equal to NULL, RE will use
  90.                               ' the current working directory for swapping.
  91.                               ' You must append chr(0) to NULL terminate this field
  92.  
  93.        hInst As Integer       ' Handle of the current instanaces.
  94.        hPrevInst As Integer   ' Handle of the previous instances.
  95.        hParentWnd As Integer  ' Handle to the parent window
  96.        style As Long          ' Report window style - needed for screen output only
  97.  
  98.        reserved3 As Long      ' Reserved for internal use. Do not modify the
  99.                               ' value in this field
  100.  
  101. End Type
  102.  
  103. '*****************************************************************************
  104. '                      Global Constants
  105. '*****************************************************************************
  106.  
  107. Global Const UNITS_PER_INCH =  250
  108.  
  109. Global Const FORM_SIGN = &HDEBC
  110. Global Const NAME_WIDTH = 50
  111.  
  112. Global Const SRC_APPL = 0
  113. Global Const SRC_CALC = 1
  114. Global Const SRC_SYS = 2
  115. Global Const SRC_CONST = 3
  116. Global Const SRC_NONE = 4
  117. Global Const SRC_DLG = 5
  118.  
  119. Global Const TYPE_NUM = 1
  120. Global Const TYPE_DBL = 2
  121. Global Const TYPE_TEXT = 3
  122. Global Const TYPE_LOGICAL = 4
  123. Global Const TYPE_DATE = 5
  124. Global Const TYPE_PICT = 6
  125.  
  126. Global Const SUM_NONE = 0
  127. Global Const SUM_TOTAL = 1
  128. Global Const SUM_AVERAGE = 2
  129. Global Const SUM_COUNT = 3
  130. Global Const SUM_MAX = 4
  131. Global Const SUM_MIN = 5
  132.  
  133. Global Const DT_MMDDYY = 0
  134. Global Const DT_DDMMYY = 1
  135. Global Const DT_MMDDYYYY = 2
  136. Global Const DT_MMMDDYYYY = 3
  137.  
  138. Global Const FLAG_TRIM = &H1
  139. Global Const FLAG_SUP_ZERO = &H2
  140. Global Const FLAG_PAD_ZERO = &H4
  141. Global Const FLAG_CAPS = &H8
  142. Global Const FLAG_FIRST_CAP = &H10
  143. Global Const FLAG_SMALL = &H20
  144. Global Const FLAG_COMMA = &H40
  145. Global Const FLAG_WRAP = &H80
  146. Global Const FLAG_WORD_WRAP = &H100
  147. Global Const FLAG_RETAIN = &H200
  148. Global Const FLAG_FLEX_SIZE = &H400
  149.  
  150. Global Const RFLAG_TRIAL = &H1
  151.  
  152. Global Const REP_CLOSE = &H400
  153.  
  154. Global Const ERR_NO_FILE = 1
  155. Global Const ERR_NO_DEVICE = 2
  156. Global Const ERR_NO_MEM = 3
  157. Global Const ERR_BAD_EXP = 4
  158. Global Const ERR_SUSPEND = 5
  159. Global Const ERR_ZERO_DIVIDE = 6
  160. Global Const ERR_TYPE_MISMATCH = 7
  161. Global Const ERR_INCOMPLETE = 8
  162. Global Const ERR_DUPLICATE = 9
  163. Global Const ERR_PRINTER = 10
  164. Global Const ERR_IO = 11
  165. Global Const ERR_DISPLAY = 12
  166. Global Const ERR_WRAP = 13
  167. Global Const ERR_FONT = 14
  168. Global Const ERR_OTHER = 15
  169.  
  170. Global Const ERR_BAD_WND = 16
  171.  
  172. Global Const WS_OVERLAPPEDWINDOW = &HCF0000
  173. Global Const WS_CHILD = &H40000000
  174. Global Const MF_ENABLED = 0
  175. Global Const MF_GRAYED = 1
  176. Global Const MF_CHECKED = 8
  177. Global Const MF_UNCHECKED = 0
  178.  
  179. '******************************************************************************
  180. '                       Form Header Structure
  181. '******************************************************************************
  182. Type TypeFormHdr
  183.        FormSign As Integer       ' Form File Signature
  184.        
  185.        name As String * 52       ' report name (NAME_WIDTH+2)
  186.                                        ' This field is NULL terminated
  187.  
  188.        DataSetName As String * 20' Your application can specify a data set
  189.                                  ' name which can be used to associate the
  190.                                  ' application data to the form.  This
  191.                                  ' is an optional information.
  192.                                  ' This field is NULL terminated
  193.        
  194.        TotalItems As Integer     ' screen items in the form template
  195.        FieldCount As Integer     ' total number of fields
  196.        BreakFieldCount As Integer ' total number of break fields
  197.        FontCount As Integer      ' number of entries in the font table
  198.  
  199.        LeftMargin As Single      ' margins in inches
  200.        RightMargin As Single
  201.        TopMargin As Single
  202.        BottomMargin As Single
  203.  
  204.        SelExp As String * 104    ' record selection expression 2*(NAME_WIDTH+2)
  205.  
  206.        Orientation As Integer    ' DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE
  207.        PaperSize As Integer      ' paper size given by DMPAPER_* variables used for DEVMODE
  208.        PaperLength As Integer    ' specified in tenths of millimeter, used only if PaperSize = 0
  209.        PaperWidth As Integer     ' specified in tenths of millimeter, used only if PaperSize = 0
  210.        PrintQuality As Integer   ' print quality
  211.  
  212.        PrinterName As String * 104' name of the printer 2*(NAME_WIDTH+2)
  213.        PrinterDriver As String * 104' printer driver name 2*(NAME_WIDTH+2)
  214.  
  215.        flags As Integer          ' RFLAG_ series flags
  216.  
  217.        DateFormat As Integer     ' 0=MM/DD/YY, 1=DD/MM/YY
  218.        
  219.        RulerType As Integer      ' RULER_OFF,RULER_INCH,RULER_CM
  220.        
  221.        SecBannerHeight As Integer ' height (logical units) of the section banner
  222.        FileFormatId As Integer    ' records the file format changes
  223.        reserved1 As String * 146  ' reserved bytes
  224. End Type
  225.  
  226. '******************************************************************************
  227. '                        Field Structure
  228. '******************************************************************************
  229. Type TypeField                    ' define each field
  230.        source As Integer        ' source of field data: application,calculation,system, constant etc
  231.  
  232.        name As String * 52      ' field name (NAME_WIDTH+2)
  233.                                 ' Append chr (0) to NULL terminate this field
  234.  
  235.        FileId As Integer        ' an optional id that may be defined by the calling application
  236.        FieldId As Integer       ' another optional id that may be defined by the calling application
  237.        type As Integer          ' numeric/alphanumeric/logical/date
  238.        width As Integer         ' field data width as stored in your database
  239.        DecPlaces As Integer     ' decimal places for numeric fields
  240.        AllowChanges As Integer  ' Allow modification of the following fields
  241.  
  242.        InUse As Integer         ' TRUE=in use, FALSE=not in use
  243.        flags As Integer         ' flags
  244.        SumType As Integer       ' summary type: total/average/minmum/maximum/none
  245.        SysIdx As Integer        ' index into the system field table for system fields
  246.  
  247.        DateFormat As Integer    ' date format
  248.        DateDelim As String * 2  ' date delimiter character, i.e. / or -
  249.  
  250.        CurrencySymbol As String * 4' currency symbol
  251.        LogicalSymbols As String * 2' logical TRUE and FALSE symbols
  252.  
  253.        NegSignPrefix As String * 4 ' negative sign prefix
  254.        NegSignSuffix As String * 4 ' negative sign suffix
  255.        PosSignPrefix As String * 4 ' positive sign prefix
  256.        PosSignSuffix As String * 4 ' positive sign suffix
  257.  
  258.        CalcExp As String * 104  ' expression for the calculated fields 2*(NAME_WIDTH+2)
  259.        
  260.        reserved1 As Long        ' character data, pointer to an object of size = field.width+1
  261.        NumData As Long          ' numeric data (long)
  262.        DblData As Double        ' numeric data for field = TYPE_DBL
  263.  
  264.        HoldNum As Long          ' long accumulater: total,minimum,maximum,etc...
  265.        HoldDbl As Double        ' double accumulater: total,minimum,maximum,etc...
  266.        count As Long            ' number of records in a group during execution
  267.  
  268.        section As Integer       ' section that holds the field (report time only)
  269.        misc As Integer          ' used for miscellaneous purposes
  270.  
  271.        ParaChar As String * 2   ' specify the new paragraph indicator character
  272.                                 ' in the first byte.  Needed only for a word/wrapped
  273.                                 ' text field.
  274.                                 ' You must append chr(0) to NULL terminate this field
  275.  
  276.        reserved2 As String * 14 ' reserved to pad to 256
  277. End Type
  278.  
  279. '******************************************************************************
  280. '                        Picture information structure
  281. '******************************************************************************
  282. Type TypePict 
  283.       hDC     As Integer        ' Device Context of the report output device
  284.       PictId  As Integer        ' picture id value
  285.       FileId  As Integer        ' FileId of the picture
  286.       FieldId As Integer        ' FieldId of the picture
  287.       x       As Integer        ' picture location
  288.       y       As Integer        ' picture location
  289.       width   As Integer        ' picture width
  290.       height  As Integer        ' picture height
  291. End Type
  292.  
  293. Rem *****************************************************************************
  294. Rem                    Function Prototype
  295. Rem ******************************************************************************
  296. Declare Function RvbForm Lib "RVB.VBX" (FormParm As TypeForm) As Integer
  297. Declare Function RvbInit Lib "RVB.VBX" (ByVal hWnd As Integer, RepParm As TypeRep) As Integer
  298. Declare Function RvbRec  Lib "RVB.VBX" (ByVal hWnd As Integer) As Integer
  299. Declare Function RvbExit Lib "RVB.VBX" (ByVal hWnd As Integer) As Integer
  300.  
  301. Declare Function RvbGetFormField    Lib "RVB.VBX" (ByVal hWnd As Integer, field As TypeField, SortLevel As Integer) As Integer
  302. Declare Function RvbGetDataField    Lib "RVB.VBX" (ByVal hWnd As Integer, ByVal FieldNo As Integer, field As TypeField) As Integer
  303. Declare Function RvbGetSortField    Lib "RVB.VBX" (ByVal hWnd As Integer, ByVal FieldNo As Integer, field As TypeField) As Integer
  304. Declare Function RvbSetFormField    Lib "RVB.VBX" (ByVal hWnd As Integer, field As TypeField, ByVal valid As Integer) As Integer
  305.  
  306. Declare Function RvbSetTextField    Lib "RVB.VBX"  (ByVal hWnd As Integer, ByVal FieldNo As Integer, ByVal TextData As string, ByVal TextDataLen As Integer) As Integer
  307. Declare Function RvbSetNumField     Lib "RVB.VBX"  (ByVal hWnd As Integer, ByVal FieldNo As Integer, ByVal NumData As Long) As Integer
  308. Declare Function RvbSetDoubleField  Lib "RVB.VBX"  (ByVal hWnd As Integer, ByVal FieldNo As Integer, ByVal DoubleData As Double) As Integer
  309.  
  310. Declare Function RvbGetPictureInfo  Lib "RVB.VBX" (ByVal hWnd As Integer, PictInfo as TypePict) As Integer
  311. Declare Function RvbDrawBitmap      Lib "RVB.VBX" (ByVal hWnd As Integer, ByVal hWnd As Integer, ByVal hBM as Integer, ByVal PictX as Integer, ByVal PictY as Integer, ByVal PictWidth As Integer, ByVal PictHeight As Integer) As Integer
  312.  
  313. Rem **************************************************
  314. Rem When a string is passed for OUTPUT to the DLL
  315. Rem ,the output string created by the DLL has an extra
  316. Rem NULL character.  For such strings, you must call
  317. Rem this routine to strip the null character from the
  318. Rem given string
  319. Rem **************************************************
  320. Function DiscardNull (InText As String) As String
  321.    Dim i As Integer
  322.    Dim StrLen As Integer
  323.    Dim CurChar As String
  324.    
  325.    StrLen = Len(InText)
  326.  
  327.    For i = 1 To StrLen
  328.       CurChar = Left(InText, i)
  329.       CurChar = Right(CurChar, 1)
  330.  
  331.       If Asc(CurChar) = 0 Then
  332.          DiscardNull = Left(InText, i - 1)
  333.          Exit Function
  334.       End If
  335.    Next i
  336.  
  337.    DiscardNull = InText
  338.                        
  339. End Function
  340.  
  341.