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.
Get selection bounds in source code
Posted by:
Adrian (---.rdsnet.ro)
Date: Wednesday, 24-Dec-2008, 22:06:46
Hi,
I'm building an app which, at a certain point, needs to split a HTML page in three parts - a header, a footer and a body. To do this, I want to allow the user to highlight the body part. I can't seem to manage that.
Here's something I've tried:
IHTMLTxtRange tr = (IHTMLTxtRange)sel.createRange();
String content = tr.htmlText;
IHTMLTxtRange beg = tr.duplicate();
beg.collapse(true);
beg.moveStart("character", -int.MaxValue);
String header = beg.htmlText;
IHTMLTxtRange ndg = tr.duplicate();
ndg.collapse(false);
ndg.moveEnd("character", int.MaxValue);
String footer = ndg.htmlText;
Hacky, indeed - inspired from a solution posted in this forum.
This works somewhat, but seems to add additional markup (meaning header+content+body is not a valid HTML page).
Is there any way to get the exact location in the original source (not the one returned from an IHTMLTxtRange's htmlText) that the caret is positioned at?
If not, can you suggest a workaround? (I don't care about header+body+footer being identical as source to the original, but it should be equivalent).
Thanks a lot!