D'oh, critical bugfix for yesterday update.
The PrinterDriver/PrinterPort was wrongly extracted from the DEVNAMES structure... (wrong use of the .wOffset members)
This caused the PrinterDriver/PrinterPort to be cut/truncated. For instance the PrinterDriver 'winspool' got cut/truncated to 'spool'.
In my testings yesterday this was not shown up as the print dialog however managed to find it.
But now in a pdf printer I found out that it failed.. (PrinterPort got truncated to null) But with the fix today it is now working.
Another improvement done as following:
PrinterDriver/PrinterName/PrinterPort are on default empty. This indicates that the default printer will be initialized.
However, when a default printer was selected then that default printer got set in the PrinterDriver/PrinterName/PrinterPort.
When then the user in the meantime changes the system default printer then next time the print dialog shows up the non-default will be selected and not the default.
The improved solution is now that after user selection the DEVNAMES structure is checked on the wDefault member if it includes the DN_DEFAULTPRN flag.
If so the PrinterDriver/PrinterName/PrinterPort will be set to empty, if not then they will be set.
That means that the app should check on return if the PrinterName is empty (= default) or not (= specific) and act accordingly.
So it could look like this:
Code:Dim ObjPrinter As VB.Printer With New CommonDialog .PrinterDefault = False .Flags = CdlPDUseDevModeCopiesAndCollate If .ShowPrinter = True Then If .PrinterName = vbNullString Then Set ObjPrinter = VB.Printer ' Default Else For Each ObjPrinter In VB.Printers If ObjPrinter.DeviceName = .PrinterName Then Exit For Next ObjPrinter End If MsgBox ObjPrinter.DeviceName End If End With





Reply With Quote