Results 1 to 2 of 2

Thread: Printing with common dialog

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    4

    Printing with common dialog

    I am trying to print with the common dialog control, however I have a problem. The printer's hDC property changes each time i check it, so there is never a printer who's hDC matches that of the common dialog. Here is my code:

    VB Code:
    1. cdlg.Flags = cdlPDReturnDC
    2. cdlg.ShowPrinter
    3.  
    4.     For Each X In Printers
    5.        If X.hDC = cdlg.hDC Then Set Printer = X
    6.     Next
    7.     Printer.Orientation = cdlg.Orientation
    8.    
    9.     Me.PrintForm
    10.     Printer.EndDoc

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You actually don't have to do anything. CommonDialog controll will change the printer object for you. The only thing you have to consider is if you want the common dialog printer to change the selected printer to be a default printer. So if you don't want it to change it then you have to use PrinterDefault property:
    VB Code:
    1. Private Sub Command1_Click()
    2.    
    3.     With CommonDialog1
    4.         'make sure that CommonDialog will not change it
    5.         'to be a default printer
    6.         .PrinterDefault = False
    7.  
    8.         .ShowPrinter
    9.        
    10.         Printer.Print "hi"
    11.     End With
    12. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width