WebBroser1.SelectedText

hehe I know the line in subject wont work, but I want to have similar result, how do I know what user has highlighted in WebBrowser ?

Beside that, can I disable 'some' WebBrowser features like do not load picture, do not run activeX, do not play sound, etc ?

Thanks alot.

[277 byte] By [WongJunnKit] at [2008-2-20]
# 1

The following will retrieve the selected text from a WebBrowser control named "wb":


'Grab the unmanaged DomDocument behind the WebBrowser that presents the info we need

Dim domDoc As Object = wb.Document.DomDocument

'Get the IHTMLDocument2 interface from the unmanaged DomDocument object

Dim idoc2 As mshtml.IHTMLDocument2 = domDoc

'Get the Selection object

Dim selection As mshtml.IHTMLSelectionObject = idoc2.selection

'Grab its text

Dim textHTMLSelection As mshtml.IHTMLTxtRange = CType(selection.createRange(), mshtml.IHTMLTxtRange)

'The text property contains the text

'The HtmlText property contains the HTML

MessageBox.Show(textHTMLSelection.text)




For your other customizations, you will have to work a little harder. The following may be helpful:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/overview/Overview.asp, specifically, the section titled Download Control.

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...