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
Moved the caret, but lost focus
Posted by: Duncan Bayne (---.agile.co.nz)
Date: Friday, 29-Sep-2006, 06:59:11

Hi All,

I am using the following code (with error-handling removed for clarity) to insert some text and then move the caret back to the top of the document, so that the user can begin typing.

However, although this happens, and the caret can be seen to be at the top of the document, keystrokes are ignored; I can type to my heart's content and no characters appear. In order to make it work, I must click in the HtmlEditor control, at which point the keystrokes are recognised.

I suspect I'm missing something obvious?

TIA for any suggestions.

Yours,
Duncan Bayne




// add the signature to the top of the HTML editor

onlyconnect.IHTMLSelectionObject selection = replyHtmlEditor.HtmlDocument2.GetSelection();
onlyconnect.IHTMLTxtRange textRange = (onlyconnect.IHTMLTxtRange)selection.createRange();

textRange.text = signature;

// now move the cursor back to the top

onlyconnect.IHTMLElement documentElement = textRange.parentElement();
onlyconnect.IHTMLCaret caret;
onlyconnect.IDisplayServices dsServices = (onlyconnect.IDisplayServices)replyHtmlEditor.Document;
dsServices.GetCaret(out caret);

onlyconnect.IDisplayPointer displayPointer;
dsServices.CreateDisplayPointer(out displayPointer);

caret.MoveCaretToPointer(displayPointer, true, onlyconnect.CARET_DIRECTION.CARET_DIRECTION_BACKWARD);

Re: Moved the caret, but lost focus
Posted by: Duncan Bayne (---.agile.co.nz)
Date: Friday, 29-Sep-2006, 07:11:49

Okay, I am *definitely* doing something wrong ... because later on I see the following:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at onlyconnect.IHTMLCaret.GetLocation(win32POINT& pPoint, Boolean fTranslate)
at onlyconnect.HtmlSite.UpdateUI()

Re: Moved the caret, but lost focus
Posted by: Duncan Bayne (---.agile.co.nz)
Date: Tuesday, 03-Oct-2006, 22:47:03

The solution is here:

[itwriting.com]

Re: Moved the caret, but lost focus
Posted by: Tim (---.gotadsl.co.uk)
Date: Thursday, 05-Oct-2006, 13:35:19

Glad you got it sorted.

Tim



Your Name: 
Your Email: 
Subject: 
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.
uGCtX
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.