SnTT: using the WebBrowser control to view attachments inline
If you've ever set a form to launch the first attachment upon document
open, but wished (or received requests from users) that it wouldn't
open a separate application window, there's another option. Nathan and I were experimenting with this, and here's what we came up with:
In the standard perweb.nsf there is a form called "WebBrowserForm",
which contains an embedded control of class "Shell.Explorer.1" with its
name set simply to "Browser". When you open a URL within Notes, you're
essentially creating a new document using this form that, during the
PostOpen, gets a handle on the browser control ( Set browserobject=uidoc.GetObject( "Browser" ) ), and tells it to navigate to the web page ( browserobject.navigate doc.url(0)
). Although I've been unable to find a way to create this control using
the Create > Object dialog, you can copy it from the original form
into your own applications and take advantage of its ease of use.
The sample database
is just a basic e-book reader. Its interface is a horizontal preview -
a two frame collapsible frameset, with a table of contents view in the
left frame and an empty preview frame on the right side. So, just like
the standard mail Inbox, when a document is selected, if the preview
frame is expanded, the document is loaded in preview mode. But here's
where it gets a wee bit fancy.
The form's QueryOpen extracts whatever file is attached to the user's
temp directory. The PostOpen gets a handle on the WebBrowser control,
but instead of telling it to navigate to a URL, it navigates to the
extracted file's path, which - if the filetype is one that I.E. can
load inline - launches the file... inside Notes. So if the file is a
PDF, for example, Adobe launches inside the preview pane
instead of opening a separate application window just for itself. And,
since the browser control is set to fill the window, the external
application automatically scales to the preview pane. Imagine Nathan's Sesame Street demo, but a full-fledged Adobe Reader window off to the right instead of Big Bird.
This works not only for PDF's, but for text files, Office (if
installed), and of course, good old HTML files. Even Quicktime movies
and MP3's... AVI's and MPG's launch Media Player in a separate window.
Basically, any file that, if clicked in a web page, would be loaded
within the browser instead of triggering a download prompt or launching
a separate app can be "previewed" in this manner. It's basically the
standard attachment viewer on steroids. NOTE: viewer,
not editor. If you open a Word doc, it'll be fully editable (assuming
no constraints on the original file), but any changes you save are
written back to the extracted copy in the temp folder, not
to the copy attached to the Notes document. You'll probably want to
make this abundantly clear to your users if you implement this approach
in your own applications, particularly if they're now addicted to the
standard in-place attachment editing capability.
(cross-posted from TimTripcony.com)
|
SnTT: using the WebBrowser control to view attachm...
|