tags:

views:

47

answers:

1

We have a VB6 application that uses the vbprndlg.dll library to show print selection dialogs to the user. Here recently we've received reports from users on Windows Vista and 7 (both 32 and 64 bit) stating that the number of copies always stays 1 no matter what they put in the number of copies box on the dialog. When running the exact same code on an XP Pro machine, the number of copies passes like it should to the reporting object.

So far I've run tests using both the common dialog control and vbprndlg.dll to raise print dialogs on both a Vista and a 7 computer, and each time the number of copies is always reported to be 1 no matter if I type the number in the box or use the arrow toggle buttons to increase the number of copies. Other properties - such as which printer is selected and the from and to page numbers report correctly.

When I hard code the number of copies to the Crystal Report object (shown below), the correct # of copies print - so this seems more of a problem with the dialog control instead of the Crystal Report object.

Here is a snippet of the code 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 can't seem to find any information about known compatibility problems between raising print dialogs in VB6 and Windows Vista/7. Is there anything else I can try with the dialog controls?

+4  A: 

The answer popped out at me just as soon as I submitted this question.

Changing the Flags property of the VBPrnDlg control to include the vbprndlglib.cdlPDUseDevModeCopies flag fixed it, the number of copies works again.

Hopefully this helps someone stuck in a similar problem!

Heather