Re: Windows Default Printer not being Reset
- From: "Mike Williams" <mike@xxxxxxxxxxxxxxxxx>
- Date: Thu, 2 Mar 2006 13:55:23 -0000
"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
.
- Follow-Ups:
- Re: Windows Default Printer not being Reset
- From: Ron
- Re: Windows Default Printer not being Reset
- From: John Kotuby
- Re: Windows Default Printer not being Reset
- References:
- Windows Default Printer not being Reset
- From: jkotuby
- Re: Windows Default Printer not being Reset
- From: Mike Williams
- Re: Windows Default Printer not being Reset
- From: jkotuby
- Windows Default Printer not being Reset
- Prev by Date: Re: Strange compile problem
- Next by Date: Re: Print to File
- Previous by thread: Re: Windows Default Printer not being Reset
- Next by thread: Re: Windows Default Printer not being Reset
- Index(es):
Relevant Pages
|