• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 731
  • Last Modified:

DHTML Edit Control for IE 5 - Few Questions

Hi there, I have a couple of questions about this control, or rather the two controls it allows you to use once you load it in vb6.

Firstly what's the difference between the DHTMLEdit and DHTMLSafe controls.

Secondly is it possible to lock the control so that it can't be edited, only updated by using the .DocumentHTML property.

Thirdly how do I access the HTML that is within the contro, for e.g. I tried msgbox DHTMLEdit1.DocumentHTML which works fine if I haven't changed the HTML within the control, however if I change it using DHTMLEdit1.DocumentHTML = "<html>..." then try to MsgBox it's contents and I get the following error:

Run-time error '-2147418113'

Property 'DocumentHTML' of object 'DHTMLEdit1' failed.

Any answers to these questions would be brilliant thank you, the third one isn't as important as the others as basically I'm going to be using the control in a messenger program to show the messages received from other users, and I'm creating a strHTML which is added to when a new message arrives then passed through the .DocumentHTML property to update the control.  Therefore I can use this strHTML variable to output the conversation to a HTML file for archiving, but it would be handy to know how to access the HTML within the control for future references.

Many thanks

-Matt-
0
ShelfieldCollege
Asked:
ShelfieldCollege
  • 4
  • 3
  • 2
2 Solutions
 
ShelfieldCollegeAuthor Commented:
Please ignore the third question, by placing a DoEvents before the msgbox DHTMLEdit1.DocumentHTML it's solved the problem, should've tried that before I posted I think.  Sorry

Thanks

-Matt-
0
 
edwardiiiCommented:
Hi, ShelfieldCollege.

1)  "Firstly what's the difference between the DHTMLEdit and DHTMLSafe controls."

     Please see:  http://members.shaw.ca/iedelphi/dhtmledit.htm#basics4

0
 
ShelfieldCollegeAuthor Commented:
Thanks kindly, i'l accept your comment as the answer to the first question soon as I get answers to the others or finalise the question if no one else posts.

Hope others or yourself can help me out with the other question as well, the one about locking the control in VB6.

Many thanks

-Matt-
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
edwardiiiCommented:
2)  "Secondly is it possible to lock the control so that it can't be edited, only updated by using the .DocumentHTML property"

I haven't used this control, so I'm not understanding why we're presenting end-users with the control (which allows them to make edits to HTML content, e.g. that's this control's purpose).  So, my first thought would be to grab the continuously updated HTML data and present it to users in either a WebBrowser control, RichTextBox, etc. Alternatively, perhaps you can use the DTHMLEdit control's onkeypress and onmousedown properties to control what happens when users try to add data to the control:

     onkeypress: http://visualbasicforum.com/showthread.php?t=14302&highlight=DHTMLEdit1
     
     onmousedown; http://visualbasicforum.com/showthread.php?t=164414&highlight=DHTMLEdit1

If I've entirely misunderstood what you meant by locking this control, please clarify:)

0
 
lowRiderCommented:
You can access the document BODY like this:

dHTML.DOM.body.innerhtml would =
<P>This is a new task 2</P>

dHTML.DOM.body.innertext would =
This is a new task 2

dHTML.DOM.body.outerHTML would =
<BODY><P>This is a new task 2</P></BODY>

I think you'll get it when you see the properties popup in VB while you are typing. Also note, the DHTML ActiveX for IE5 is no longer supported by MS. You should be using the followinig components:

- MS HTML Object Library
- MS Internet Controls

The DHTML ActiveX is just a wrpper to the real thing. If you use the above components instead, it's a bit more difficult to use, but worth the effort. You'll also have a lot more control over the document.

Regards,
lowRider
0
 
lowRiderCommented:
Oh ya...  if you want to stop the user from editing the data, set the browse mode to false like this:

dHTML.BrowseMode=true

The dHTML control is actually the IE webBrowser object.

1. make a button to turn editing on:
    dHTML.BrowseMode=False

2. user edits the document and when they're done, clicks save. At this point, you
    access the document to save the changes

3. then set the browsemode = true


lowRider
0
 
lowRiderCommented:
Would you like a sample project that demonstrates editing a document, etc.?  If so, send me an e-mail to yaremchl@edocshare.com

lowRider
0
 
ShelfieldCollegeAuthor Commented:
Thanks all, points have been split between parties who answered questions for me.

I've tested the code and everything works fine, and finally the user is unable to edit the HTMLEdit control (if you're wondering the reason for this is because I'm using this control in the chat window of a messenger application and I know that I could simply use a webbrowser, but wouldn't that require outputting the conversation to a html file the browsing to that file, as apposed to passing the HTML through the DocumentHTML property without any need for external files).

Anyway, thanks everyone for your comments and help, yet another problem solved :)

Cheers

-Matt-
0
 
ShelfieldCollegeAuthor Commented:
Appologies, I meant to select Edwardiii's answer to the first question as his assisted answer, however he's still been awarded the points to no harm done.

Cheers

-Matt-
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now