Re: Windows Default Printer not being Reset

Tech-Archive recommends: Fix windows errors by optimizing your registry



"jkotuby" <jkotuby@xxxxxxxx> wrote in message
news:OzKEeefPGHA.2816@xxxxxxxxxxxxxxxxxxxxxxx

Thank you for the excellent code. I will take what I can
use to quickly remedy the problem. Your positioning code
is superb.

Thanks for the compliment :-)

I had no intention of changing the Windows Default printer in the first
place. Why would Microsoft force
the CommonDialog control t o change the Windows
Default printer if it provided no easy mechanism in VB
for resetting the original default?

Because the VB printer object is based on some very old fashioned code that
does in some respects seem to be slightly "cobbled together". The VB printer
object has no built in way of knowing what the user has done in the Common
Dialog control, and does not have its own bult in printer dialog, so it
relies on the system allowing the CommonDialog control to alter the Windows
default printer and its settings. The VB printer object then "reads" the
user's desired settings by "looking at" the default printer settings.
Unfortunately, this messes up the system by changing its default prnter,
which is not what we usually want to do. You can prevent the CommonDialog
control from altering the default printer (CommonDialog1.PrinterDefault =
False) but if you do that then the VB printer object will have no way of
knowing what the user has selected. A bit of a "catch 22" situation!

In any case, that system falls down anyway under Win XP, because under XP
the CommonDialog can change the user's default printer, but it cannot change
any of its settings, so the method that used to work in Win98 (standard VB
Printer Object and standard CommonDialog code) no longer works in XP. Under
Win98 your user could select a printer and also change the orientation from
portrait to landscape (for example), but under XP he can only change the
printer, and not the orientation. In any case, as I've mentioned, on both
systems it results in a change of the default printer, which is usually not
a very nice thing to do.

I guess I must study your code more thoroughly first. Maybe
you are showing me a way to use the dialog control such that
it does not affect the Windows Default printer

Yep. That's exactly what the code sample does (although it uses an API
dialog instead of the CommonDialog control because the standard CommonDialog
control does not expose many of its properties).

There are other ways of doing this stuff, but the method I posted is as good
(or perhaps I should say "almost as good"!) as any. If you want to give your
user full and absolute control over every little setting in the printer
dialog, including all of the sometimes rather esoteric "special to printer"
settings, then you really need to be creating a printer device context and
printing all your stuff to that device context using the various API
printing methods. One way of doing this would be to set the appropriate
CommonDialog flag such that it returns a device context, but you will then
have a lot of API code to write in order to print your stuff, and it is
probably a bit of an "overkill" in most situations.

You'll probably find the code I've already posted to be suitable for your
purposes.

Mike



.



Relevant Pages

  • Re: Windows Default Printer not being Reset
    ... the CommonDialog control t o change the Windows ... The VB printer object then "reads" the ... user's desired settings by "looking at" the default printer settings. ...
    (microsoft.public.vb.general.discussion)
  • Re: VB6 under Vista - wont allow printing of more than 1 copy
    ... If you are presenting the user with a CommonDialog printer dialog and you are assuming that all the selections that the user makes in that dialog will automatically be passed onto the VB Printer Object then that method has not worked since Win98, and it certainly did not work in XP. ... The simple "present the user with a dialog and assume that the Printer Object will pick up the settings" did work under Win98 and earlier, but it caused more problems than it was worth. ...
    (microsoft.public.vb.general.discussion)
  • Re: Print Problem
    ... I do have access to the Common Dialog Control in my projects. ... Dim itmX As ListItem, hdrX As ColumnHeader ... Despite all the "knocking" it gets, the VB Printer Object is ... If you've got the CommonDialog control in VBA ...
    (microsoft.public.vb.general.discussion)
  • OT --- But then again maybe someone can help me...
    ... I have a problem with the CommonDialog Control... ... Nothing I've tried using Windows Explorer, thinking it was related to the ... settings in the Registry somewhere, ...
    (microsoft.public.vb.general.discussion)
  • Re: printer.font.size
    ... My VB code sets the printer ... Note The FontSize property is included for use with the CommonDialog ... control and for compatibility with earlier versions of Visual Basic. ... use the new Font object properties (not available ...
    (comp.lang.basic.visual.misc)