Daisy AnalysisWeb Print OCX - Programming

Programming of the ActiveX component is very simple.

The example here refers to Visual Basic but as there are only a few lines of code, it should be easy to adopt to another programming language.

Visual Basic Test Project

If you are using Visual Basic open the project called Daisy Print HTML Test, which is stored in the SourceFiles sub-directory of where the Daisy Web Tools were installed. Typically this will be :-

   C:\Program Files\Daisy Analysis\SourceFiles

This is a very simple program that just prints the same file, DaisyPrintHTML.html.

Print Code

Look at the code below which prints the file in the form, frmDaisyPrintHTML :-

  Private Sub cmdPrint_Click()
      Dim wrkError As String
      Dim wrkPath As String
      On Error Resume Next
      wrkPath = Daisy2006WebPrint1.BuildPath(App.Path, "DaisyPrintHTML.html")
      Daisy2006WebPrint1.ProgramName = "Daisy"
      Daisy2006WebPrint1.NoHeaders = True
      Daisy2006WebPrint1.NoLinks = True
      If (Daisy2006WebPrint1.PrintPageFormatted(wrkPath, wrkError) = False) Then
          Daisy2006WebPrint1.MessageError wrkError
      End If
  End Sub

Note :-

  1. This is the code for the cmdPrint command button labelled Print... on the form, frmDaisyPrintHTML.

  2. Daisy2006WebPrint1 is the instance of the component, Dazy2006PrintHTML, on the form. If you are using older versions, the name will have a 4 or a 5.

  3. Daisy2006WebPrint1 has it's property, Visible, set to False.

  4. The variable, wrkPath, is set to the path of the file to be printed. Note that the file, DaisyPrintHTML.html, is stored in the SourceFiles sub-directory.

  5. The properties, ProgramName, NoHeaders and NoLinks are set accordingly.

  6. The method, PrintPageFormatted, is used to actually print the page.

  7. If an error occurs, it is returned in the variable, wrkError, and then displayed using the method, MessageError.

Unlocking the Control

The code shown here can be used freely, but it will produce a rather annoying message every time it is used.

If you register the control, then you will be supplied with an appropriate method of unlocking the control.

Events, Methods and Properties

The various events, methods and properties in the control do a lot more than just print HTML files and are described separately.

A lot of these have been added, so that Daisy Analysis can write special purpose print programs without using any other controls.