Changing the Selection of iHTMLTxtRange

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Still working on this HTML Editor control. I have a problem when the user
selects some hyperlinks. Sometimes the selection includes other tags. I
figured that I could use movestart and moveend functions to re-select just
the hyperlink.

As an example, the txtRangeobject contains something like:

<FONT face=Verdana size=1><A href="http://test.com">Click to View</A></FONT>

I have tried multiple solutions.

First I tried to use the findtext function but it would not find "<A
href="http://test.com">Click to view</A>"

oTxtRange = DirectCast(oSelection.createRange(), mshtml.IHTMLTxtRange)
Dim bFound as boolean=oTxtRange.findText("<A.....")
if bFound=true then oTxtRange.Select()

The code above never finds the Text I'm looking for...

I then tried to narrow the selection by using movestart.

Dim nPos As Integer = oTxtRange.moveStart("character", 10)

I was expecting this code to move the start of the selection 10 characters.
however, what it did was reset the HTMLText and text to nothing. MoveEnd did
the same..

Can you tell me how I can easily reselect the child element?

Thanks
Jason
 
Hi Jason,

Thanks for your post!

Based on the MSDN link below, "You can modify the extent of the text range
by moving its start and end positions with methods such as
IHTMLTxtRange::move, IHTMLTxtRange::moveToElementText, and
IHTMLTxtRange::findText."
http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/txtrange/
txtrange.asp

For efficiency purpose, can you please provide a little sample project to
demonstrate the problem? Then I will review your project and give it a
research.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Jason,

Have you received my reply? Is your problem resolved? Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top