Page 1 of 1

Black And White Default Printer Issues

Posted: Wed Mar 01, 2006 7:00 pm
by 9525099
We have found a problem with the tchart if the default printer on the network OR the pc itself is set to a black&white printer and then select a color printer on the network OR pc it prints black&white. :?:

Here is our code:

Public Sub PrintChartOrGrid()
Dim iPrinter As Integer
Dim PrintDlg As PrinterDlg
Dim NewPrinterName As String
Dim objPrinter As Printer
Dim strSetting As String
1
On Error GoTo err_Handler
5
Set PrintDlg = New PrinterDlg
10
' Set the starting information for the dialog box based on the current
' printer settings.
With PrintDlg
.PrinterName = Printer.DeviceName
.DriverName = Printer.DriverName
.Port = Printer.Port
20
' Set the default PaperBin so that a valid value is returned even
' in the Cancel case.
.PaperBin = Printer.PaperBin

' Set the flags for the PrinterDlg object using the same flags as in the
' common dialog control. The structure starts with VBPrinterConstants.
.flags = VBPrinterConstants.cdlPDNoSelection _
Or VBPrinterConstants.cdlPDNoPageNums _
Or VBPrinterConstants.cdlPDReturnDC
Printer.TrackDefault = False
30
' When CancelError is set to True the ShowPrinterDlg will return error
' 32755. You can handle the error to know when the Cancel button was
' clicked. Enable this by uncommenting the lines prefixed with "'**".
.CancelError = True
40
' Add error handling for Cancel.
On Error GoTo err_Printer
45
'Show printer dlg...
If .ShowPrinter(Me.hwnd) Then
'Turn off Error Handling for Cancel.
On Error GoTo err_Handler
50
' Locate the printer that the user selected in the Printers collection.
NewPrinterName = UCase$(.PrinterName)
If Printer.DeviceName <> NewPrinterName Then
For Each objPrinter In Printers
If UCase$(objPrinter.DeviceName) = NewPrinterName Then
Set Printer = objPrinter
End If
Next
End If
60
' Copy user input from the dialog box to the properties of the selected printer.
Printer.Copies = .Copies
Printer.Orientation = .Orientation
Printer.ColorMode = .ColorMode
Printer.Duplex = .Duplex
65
Printer.PaperBin = .PaperBin
Printer.PaperSize = .PaperSize
Printer.PrintQuality = .PrintQuality
70
End If

End With
80
'Print the TCHART!
With Me.TChart1
'Set TCHART printer object to one selected above...
For iPrinter = 0 To .Printer.PrinterCount - 1
If Printer.DeviceName = .Printer.PrinterDescription(iPrinter) Then
.Printer.PrinterIndex = iPrinter
Exit For
90
End If
Next 'iPrinter
100
m_bChartIsPrinting = True
.Printer.MarginLeft = 5
.Printer.MarginRight = 5
.Printer.MarginTop = 5
.Printer.MarginBottom = 5
110
.Printer.PrintChart
DoEvents
120
m_bChartIsPrinting = False
.Environment.InternalRepaint
End With

Me.TChart1.Repaint
DrawAnnotations

Exit Sub
err_Printer:
If Err.Number = 32755 Then
Err.Clear
Exit Sub
End If

err_Handler:
Call HandleError(Erl, ConvertErrToTPCError(Err), "frmRG_CHART:PrintChartOrGrid")
m_bChartIsPrinting = False

End Sub

BTW, we are using the MS VBPrnDlg.DLL control to bypass the anomolies encountered with the normal common dialog control.

Tanks!

Posted: Tue Mar 07, 2006 5:59 pm
by Pep
Hi,

the TeeChart printer isn't designed to reset any defaults, only via the Window's Printer Setup dialogues and characteristics such as Chart dimensions via code. The fact that TeeChart doesn't offer coded access to modify some Printer characteristics may in itself be a limitation, but a problem rather the reverse of the symptom occurring on your system. ie. that if colour were to be Black & White by default then TeeChart doesn't offer a codeable property to convert it to colour.

Notwithstanding, tests here have confirmed to now that TeeChart is picking up the default setting. It may worth a test based on the following property :

eg.
Printer.ColorMode = vbPRCMColor

to confirm what Colormode that property is reporting in the application before TeeChart PrintPreview is called.