|
Introduction
This article looks at functions in DHTMLEdit and
equivalent in MSHTML Edit.
Firstly in order to use MSHTML Editing you need to
add the WebBrowser component to your project and reference
'mshtml.tlb':
Select Menu:Project > Components... Tick the
'Microsoft Internet Controls'
Select Menu:Project > References... Tick the 'Microsoft HTML
Object Library'
Note: The following examples use 'htmDoc' to access
the 'WebBrowser.Document'. In the Form Declarations:
Private htmDoc As HTMLDocument
In the 'DocumentComplete' event of the WebBrowser:
Set htmDoc = WebBrowser.Document
In the 'Unload' event of the Form:
Set htmDoc = Nothing
| DHTMLEdit |
MSHTML Editing equivalent |
| .BrowseMode = False |
htmDoc.designMode = "on"
|
| .BrowseMode = True |
htmDoc.designMode = "off"
|
|
A third option is
available 'inherit' this is the default value. |
| .CurrentDocumentPath |
htmDoc.documentElement.URLUnencoded
although the return value will be prefixed by
the protocol e.g. "http://" or "file://"
|
| .DocumentHTML |
htmDoc.documentElement.outerHTML
|
| .DocumentTitle |
htmDoc.Title
|
| .DOM |
The 'DOM' property of
the DHTMLEdit control was an IHTMLDocument2 object while the
equivalent Document of the WebBrowser is an HTMLDocument
object. |
| .IsDirty |
No equivalent (that I
know of). |
| .LoadDocument |
WebBrowser.Navigate
WebBrowser.Navigate2
|
| .NewDocument |
WebBrowser.Navigate
"about:blank"
WebBrowser.Navigate "about:<html><body
scroll='auto'></body></html>"
htmDoc.DesignMode="on"
Remember that this will be the full unencoded
path of the document. When saving this you will need to
change the URL to the path of the document
|
| .SaveDocument |
Dim iFile As Integer
iFile = FreeFile
Open "Path and Name" For Output As # iFile
Print #iFile, htmDoc.documentElement.outerHTML
Close iFile
htmDoc.URL = "Path and Name"
This last statement will attach the format e.g.
"file://Path and Name" if local so you may want keep
a record of the file location seperately.
|
| .SourceCodePreservation |
MSHTML Editing will
not provide source code preservation this will affect 'white
spaces and asp code'. Check out the qWeb Source Code
Preservation routine - qFormat. |
| |
|
|