The mystery of landscape printing
From: Andrew Mayo (ajmayo_at_my-deja.com)
Date: 07/21/04
- Next message: Ben Rush: "Re: Inject javascript into page C#"
- Previous message: jmcfetridge_at_coast.com: "Re: InternetExplorer and modal windows"
- Next in thread: Igor Tandetnik: "Re: The mystery of landscape printing"
- Reply: Igor Tandetnik: "Re: The mystery of landscape printing"
- Messages sorted by: [ date ] [ thread ]
Date: 21 Jul 2004 09:06:42 -0700
As Microsoft say somewhere 'So you want to have the browser handle
printing, and you're willing to make a Faustian bargain with the
browser to do it...' and they are SO right.
However, I have pretty much tamed the web browser control now, after
some horrendous experiences (it's multithreaded and doesn't always
behave in the VB6 environment as you would expect. Bug of the week is
this...
wbrowser.navigate <some_url>
set hdoc=wbrowser.document 'aarrrggh, bad bug coming up
do until hdoc.readystate="complete"
doevents
loop
where the above piece of code can result in hdoc (defined as
HTMLDocument) intermittently ending up with the PREVIOUSLY loaded
document in the browser, unless you yield BEFORE making the assignment
(sigh!)
[mysterious, I have to say, since once readystate transitions to
complete, reassigning will get you the newly-loaded document as well,
but clearly there's a race condition going on here]
But I digress....
The last mystery now is how you might coerce the browser into printing
landscape. Without pissing around with print templates.
There's one article that implies that there's a registry key for this.
That appears to be untrue. Where the print setup dialogue stores the
portrait/landscape setting is a mystery which even a thorough rogering
with sysinternals regmon didn't reveal. (i.e it ain't going up the
registry, nohow)
So at this stage the other cunning tricks e.g munging margins by
changing the registry, don't work for portrait/landscape.
I know that one commercial product does this by bringing up the
dialogue and poking at it with a stick, but surely to heaven there's
an easier way. Any experts on this one?
PS: other bad browser bugs.
1. A VB application may GPF on termination because of messages
dispatched on one thread being received by the browser control during
program termination. Cure - use the Windows API to terminate the
application as the last line of code (don't call that in the dev.
environment, of course!)
2. Checking for document complete can be problematic. Sometimes
readystate transitions to "complete" early. Trapping the browser event
and setting a boolean on this, combined with a readystate check, often
helps.
3. A VB form with an embedded browser control with contenteditable
fields won't get the focus put back on the correct field when the form
itself loses and regains focus. The cure involves using a
messageblaster and trapping an undocumented windows message to get a
reliable hook for resetting focus.
4. Certain keys are trapped by the browser and (mis)handled e.g F5.
You can use a browser helper object to fix this (MS sample code) but
it will need modification if you want to use the keystrokes in your VB
code otherwise the accelerators will be silently eaten.
- Next message: Ben Rush: "Re: Inject javascript into page C#"
- Previous message: jmcfetridge_at_coast.com: "Re: InternetExplorer and modal windows"
- Next in thread: Igor Tandetnik: "Re: The mystery of landscape printing"
- Reply: Igor Tandetnik: "Re: The mystery of landscape printing"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|