Thursday, December 8, 2011

Opening documents in a browser on a form

It was handy to have a preview version of a document on a form.
This is easy for pictures, but not so easy for things like word or PDF

By invoking the webbrowser control, I was able to do that for a PDF file pretty simply
It handles the basic PDF navigation

For Word, its opened up word from the browser pane
To suppress that, I had to change the registry entries for the document class

BrowserFlags 0x8 or 0x9 indicates that a particular app should open in its own window when its associated file is clicked (as opposed to opening within IE. For eg: MS Office docs). 0x10 indicates that when a link is clicked, the existing window should be reused instead of opening a new window. (0x22 in windows explorer - when you open a folder, it opens in an existing window instead of opening a new one). 0x24 or 0x00 indicates that the viewer should be embedded in the browser. 


EditFlags indicates what explorer should do with a particular filetype and/or defines what class it is.
00 01 00 00 turns off the "Confirm open after download" box in IE.
00 00 00 means no special attributes have been defined for that class.
02 00 00 00 is used for the mailto: protocol for mail clients.


The following settings work for the various MS apps


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.8] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.RTF.8] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.12] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.DocumentMacroEnabled.12] "BrowserFlags"=dword:80000024 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.8] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.12] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.SheetMacroEnabled.12] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.SheetBinaryMacroEnabled.12] "BrowserFlags"=dword:80000A00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.Show.8] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.Show.12] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.ShowMacroEnabled.12] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShow.8] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShow.12] "BrowserFlags"=dword:800000A0 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PowerPoint.SlideShowMacroEnabled.12] "BrowserFlags"=dword:800000A0

No comments:

Post a Comment