Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html editor control

Status
Not open for further replies.

flbos

Programmer
Sep 15, 2005
41
NL
I use the microsoft.consultingservices.htmleditor.htmleditorcontrol in my application. It works fine except for handling the return key. Here's the problem:

- I first press a button outside the htmleditor control (so just any button on my form outside the htmleditor) so that this specific button gets the focus (and of course the click event of that button is handled)

- After this I click with my mouse pointer inside the textbox of the htmleditorcontrol so that I can type text in the box

- I type a few characters and they appear in the textbox as they should

- Now I press the return key to go to a new line

- Somehow this return key calls the click event of the button outside the htmleditor control that had the focus before I clicked in the htmleditor. No new line appears but instead the click event of the button outside the htmleditor is handled! It acts the very same way as when I press the return key while the button has still got the focus...

I don't really understand this because the other characters I type DO appear in the htmleditor textbox but when I press the return key... Maybe somehow the keys are previewed by the form and when it's a return key the button click event is handled??? I don't understand this however, because I've got keypreview for the form configured as FALSE.

Someone who can help me out here?
 
Where did you get the Microsoft.ConsultingServices.HtmlEditor.HtmlEditorControl control from?
 
a textbox has AcceptsReturn and AcceptsTab properties. with these set to false, the textbox won't accept the characters as input.

worth a look.

and, i'm intrigued too, where did you get this control from?


mr s. <;)

 
downloaded and compiled, the default application accepts return by default. what is your problem?



mr s. <;)

 
First of all, thanks for all the reactions!

I got the htmleditor elsewhere I believe but the one that can be found on

shows the same behavior (and maybe the exact same control anyway). Try this in the htmleditor on the website above:

1. Click one of the "insert text button" outside the textarea and hold your mouse button so that the button click event is not called. Now drag your mouse from the "insert text button" to another location while still holding your mouse button (click event has not been called)
2. Now click in the textbox so that this box get the focus and you can type text
3. Type a few chars and now press return key
4. You'll see that now (instead of going to a new line) the "enter text" dialog pops up

That's my problem. And in my application the above also occurs when I do click on the button outside the editor and call the click event. After the event is handled, I click in the editor and still the return key calls the click event again!
 
I am experiencing the same behaviour. I have traced the problem to the fact, that the AxSHDocWw.AxWebBrowser ActiveX (which is used by the HtmlEditorControl - and I believe is part of the InternetExplorer 6.0+ installation) does not fire the Enter and Leave events except for the first time.

It seems that the first time the WebBrowser is activated, it correctly removes focus from the button control. The second time, it does not. Pressing the Return key in the WebBrowser comtrol now activates the buttons Click-event, since the button still has the focus.

I have no solution to the problem though. Maybe someone else can chase the rabbit the next step?
 
I thought about removing the focus by code and then giving the focus to the webbrowser control textbox but I don't succeed in doing so. Maybe someone else who has any ideas on how to do this?

At some point I made a procedure that gave the focus to the webbrowser control at the moment the user left the button (leave event). Now, the click event of the button is not fired when pressing return but I still don't get a new line. I think this is because the webbrowser control has several "subcontrols" on its own but I don't succeed in giving the textbox control within it the focus...
 
Got the ball... Running... Touchdown! (I think)

In the buttons LostFocus event, try setting the parent forms ActiveControl to the HtmlBrowserControl. I.e.:

void btnTo_LostFocus(object sender, EventArgs e)
{
this.ActiveControl = htmlEditorControl1;
}

Please let me know if this solved your problem. It seems to have solved mine!
 
Ah great thank you, it seems that you indeed made the touchdown:)

I just added a lostfocus event, like you suggested, for each button on the form and now it works exactly as it should.

Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top