The number of copies that never go from the print dialog is always 1

We have a VB6 application that uses the vbprndlg.dll library to display print selection dialogs for the user. Recently, we received reports from users in Windows Vista and 7 (both 32 and 64 bits), which indicate that the number of copies always remains 1, regardless of what they put in the number of copies box in the dialog box. When you run the same code on an XP Pro computer, the number of instances is transferred, as it should, to the reporting object.

So far, I have run tests using both the general dialog and vbprndlg.dll to raise print dialogs on a Vista and 7 computer, and each time the number of copies is always reported 1, regardless of whether I enter the number in field or use the arrow buttons to increase the number of copies. Other properties — for example, which printer is selected, and the numbers from and to the page — are correct.

When I hard-code the number of copies to a Crystal Report object (shown below), the correct number of copies is printed, so this is more of a dialog management problem, rather than a Crystal Report object.

Here is the code snippet I'm using:

 Dim PD As vbprndlglib.PrinterDlg Set PD = New vbprndlglib.PrinterDlg ''//load default settings PD.PrinterName = Printer.DeviceName PD.DriverName = Printer.DriverName PD.Port = Printer.Port PD.PaperBin = Printer.PaperBin PD.CancelError = True PD.Min = 1 PD.Max = 32767 PD.flags = (vbprndlglib.cdlPDNoSelection Or vbprndlglib.cdlPDHidePrintToFile) If PrintFlags And PrintDialogFlags.DisablePagesButton Then PD.flags = PD.flags Or vbprndlglib.cdlPDNoPageNums PD.ShowPrinter (hwnd) ''//cr is a reference to a CrystalReport object cr.PrinterPort = PD.Port cr.PrinterDriver = PD.DriverName cr.PrinterName = PD.PrinterName cr.CopiesToPrinter = PD.Copies ''//always 1 on Vista/7, correct # on XP If PD.flags And vbprndlglib.cdlPDPageNums Then cr.PrinterStartPage = PD.FromPage ''// these work fine cr.PrinterStopPage = PD.ToPage End If ''//... cr.Action = 1 ''//prints report End If 

I cannot find any information on known compatibility issues between boosting print dialogs in VB6 and Windows Vista / 7. Is there anything else I can try with the dialog controls?

+6
printing vb6
source share
1 answer

The answer popped up on me as soon as I submitted this question.

By changing the Flags property of the VBPrnDlg control to enable the vbprndlglib.cdlPDUseDevModeCopies flag, the number of copies has been fixed.

Hope this helps someone get stuck in a similar problem!

+8
source share

All Articles