Results 1 to 8 of 8

Thread: Common Dialog - I thought I had the problem solved, but there's another wrinkle!

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Thumbs down

    The question boils down to this:

    I want to use the Common Dialog Print box to allow the user to select a printer (i.e., network vs. local) and allow them to change the number of copies, etc. BUT ONLY FOR THE DURATION OF MY APP. (What's happening is that whatever settings they make with my app become the default printer settings for the computer that the app is running on.)

    Before I end my app, I want to be able to restore the printer settings to whatever they were before my app started. How do I go about doing this???

    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Before you call the dialog box try this:

    Code:
    CommonDialog1.PrinterDefault = False
    The Printer default option = false tells the computer not to save the settings.

    Hope this helps

  3. #3

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I appreciate your response, Negative0, but I've tried that, and what happens is that when PrinterDefault = False, whatever the changes the user makes in the dialog box has NO EFFECT.

    I have it set up right now with that PrinterDefault set to false, and I am able to save the Copies property to a variable after I do a ShowPrinter, so that I use that variable to print X number of copies. However, I'm stuck on what to do if the user changes the printer (for example, if they want to print to the network printer instead of to their local printer). Unlike the Copies property, I can't see how to save the printer name from the dialog box, then subsequently use that printer name to direct the output to.

    Any ideas?
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Bruce,

    The hDC property contains the Device Context for the printer. If you are using API calls to print you should be able to use this.

    Hope this helps

  5. #5

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    OK, Negative0, if you can stay with me on this, I'd appreciate it:

    Given the hDC that I would get back from the Common Dialog box, what API function would I pass it to to get back the name of the printer that the user selected in the box?
    "It's cold gin time again ..."

    Check out my website here.

  6. #6
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    How are you directing the output to the printer, maybe I can help more if I see some code.



  7. #7

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I was directing my output to the printer via Crystal Reports. Anyway, I was able to find a satisfactory workaround by using the VB Printers collection and the Printer object. I gave up the Common Dialog box and created a form which allowed the user to select a printer and specify number of copies.

    My solution was basically as follows:
    - When the user initiates a print action, load the custom form with a combo box containing that computer's available printers (using the Printers collection) and an up/down control letting them select # of copies
    - When user clicks OK, do a For-Each loop with the Printers collection until the one they selected in the combo box is found. Then set the Printer object to that printer. (The Printer object settings remain current only for the duration of the app, which is what I wanted.)
    - Set the Crystal Reports devicename, driver, and port properties to those of the Printer object and print the report.

    Anyway, thanks for your responses, Negative0.
    "It's cold gin time again ..."

    Check out my website here.

  8. #8
    Guest

    Angry Bruce depends if you want to be MS compliant

    Tested this out over our net...NT4 servers, mixture of Win95, Win98, Unix boxes.....Excel and Word change the default settings...therefore to be perfectly Windows compatiable you should leave the copies to what the user sets. Got a call out now to see if this is standard, or if there is a setting somewhere to control it

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