How to use the BlackIceDEVMODE.OCX

The BlackIceDEVMODE.OCX can be used like any other standard OCX control.

First, load the printer settings using the LoadBlackIceDEVMODE() method.

 

Dim pBlackIceDEVMODE As Long 'pointer to the devmode.

 

pBlackIceDEVMODE = Form1.BlackIceDEVMODE1.LoadBlackIceDEVMODE(PrinterName)

If pBlackIceDEVMODE = 0 Then

   MsgBox "Cannot open '" & PrinterName & "' Printer driver", _

            vbExclamation + vbOKOnly

   End

End If

 

In this sample you can see how to read or modify the page orientation of the printer

 

    'read the Orientation

    If Form1.BlackIceDEVMODE1.GetOrientation(pBlackIceDEVMODE) = 1 Then

        'Portrait

        . . .

    Else

        'Landscape

        . . .

    End If

 

 

    'set to Portrait

    bSuccess = Form1.BlackIceDEVMODE1.SetOrientation(1, pBlackIceDEVMODE)

    If (bSuccess = False) Then

        MsgBox "Error in calling Active X function: 'SetOrientation'"

    End If

 

 

To save the settings, call the SaveBlackIceDEVMODE function. The return value specifies whether the changes were successfully saved or not.

 

bSuccess = Form1.BlackIceDEVMODE1.SaveBlackIceDEVMODE(PrinterName, pBlackIceDEVMODE)

If (bSuccess = False) Then

        MsgBox ("Error saving the devmode")

        Exit Sub

End If

 

 

When you are finished you have to release the memory allocated by the LoadBlackIceDEVMODE method. You can use the ReleaseBlackIceDEVMODE method:

 

Call Form1.BlackIceDEVMODE1.ReleaseBlackIceDEVMODE(pBlackIceDEVMODE)