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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

highlighting text in web browser

Status
Not open for further replies.

srd1984

Programmer
Dec 12, 2004
11
GB
I have a MDI application with one window as a web browser and the other as a text editor. When I copy text over , it stores the URL.

Is there a way that when I click on the URL later, it will take me to the webpage, but with the text that was highlighted previously that was copied, remaining highlighted. So if a webpage contains the text "hello world" and i copied it over and i go back to it, the hello world should still be highlighted?

If possible using different colours for different highlighted text but thats an optional extra

I found the following bits of code of google groups but I coulndt understand how to use them:

mshtml.IHTMLDocument2 HTMLDocument;
HTMLDocument htmlDocument = (mshtml.IHTMLDocument2) browserComp.Document;
mySelection = htmlDocument.selection.ToString();
this.myTextRange = (mshtml.IHTMLTxtRange)mySelection.createRange();
myText = myTextRange.text;


AND I found this:

IHTMLTxtRange range = (IHTMLTxtRange)
dhtmlEditor.DOM.selection.createRange();
String highlighted = range.text;


As you can see I am currently using the axwebbrowser component, however I know c# express has the new WebBrowser component so if its easier to do it in that, I am willing to use that if anybody know the code.

Thank you for any help you can provide.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top