HtmlEditor :  Phorum 5 The fastest message board... ever.

This is the discussion forum for the HtmlEditor. See also the HtmlEditor home page, where you can download the control, and the Documentation Wiki, a collaborative project for documenting the control.

Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
one dumb question
Posted by: Jerry Dilfer (
Date: Sunday, 17-Nov-2002, 15:28:13

The control looks very nice. I'd like to work on enhancing it, but have no clue what all that unmanaged code does. Is all the interop stuff neccessary to implement such a control? Thanks.

Re: one dumb question
Posted by: Tim Anderson (
Date: Sunday, 17-Nov-2002, 20:32:15

The interop stuff is necessary unless you have the time to go and write a native C# or VB.Net HTML parser and editor. Another way of looking at it is that by doing the interop stuff and wrapping it in managed code, it saves others the pain of having to deal with it.


Re: one dumb question
Posted by: Jerry Dilfer (
Date: Monday, 18-Nov-2002, 01:37:51

I see.

Can you give example of how the form can subscribe to an event in the control. I've tried several events but can't seem to capture them. What I tried:

this.htmlEditor1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.testing);

this.htmlEditor1.HtmlKeyPress += new onlyconnect.HtmlKeyPressHandler(this.testing2);
public void testing(object sender, System.Windows.Forms.MouseEventArgs e)
public void testing2(object sender, onlyconnect.HtmlKeyPressEventArgs e)


Re: one dumb question
Posted by: Tim Anderson (
Date: Monday, 18-Nov-2002, 08:02:00


As regards HtmlKeyPress, that's my fault. This was first implemented so that it

a) only works in Design (Edit) mode and
b) only fires for Ctrl-... combinations (where ... stands for any key)

You can change this easily. You need to modify the PreHandleEvent method. If you look at the block beginning:

case ComSupport.DISPID_KEYPRESS:

you'll see that InvokeHtmlKeyPress is only called for Ctrl combinations, and even then only when not one of the explicitly handled ones like Ctrl-C. We did this to support shortcut entry of particular HTML content. If you want it to fire on every keystroke, remove the call to InvokeHtmlKeyPress from within the

if (pIEventObj.ctrlKey)

block, and insert it after.

I've modified the download to do this now.

You can get MouseDown using a similar technique. In fact, in debug mode you'll see the MouseDown events written to the Debug window, from the same PreHandleEvent method. However I've not put in the plumbing to invoke an event; you could add this. You'll also find that UpdateUI fires on MouseDown. Again, this only works in Design mode.

I've used an EditDesigner to get these events. The EditDesigner is powerful, but another reason to use it is to get around a bug/problem whereby the control stops responding to keystrokes when you hook up events to the HTMLDocument. The techniques I've used workaround this bug.


Re: one dumb question
Posted by: Jerry Dilfer (
Date: Monday, 18-Nov-2002, 13:32:34

Thanks. I understand the event generation now. The basic key events in new version work well. As it stands, the control is very useful.

Your Name: 
Your Email: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
This is a moderated forum. Your message will remain hidden until it has been approved by a moderator or administrator
This forum powered by Phorum.