Question how can i disable webbrowser control's text selection and pic drag?

catdance

Member
Joined
Aug 5, 2009
Messages
13
Programming Experience
Beginner
I have been googled for couple of hours but couldn't find a solution

I m doing a touch screen interface, to browser a page I used a webbrowser control, and in order to get ride of the ugly scrollbar, i m trying to use mousedown and mousemove event on the webbrowser to move the page around, it worked but when i m doing it, it select and highlight the content on the web too, how can i stop that?

do I need to create a extended webbrowser control by Inherits the orginal one?
if so, which event should i capture and override the handler?

or
is there any simple way?


thanks, boss needs it to be done today,,,,,
 
solution 1:
Inject Javascript to do it.

[HIGHLIGHT]
in webbrowser documentcompelted event
'
'disable text selection
'
Dim head As HtmlElement = wb.Document.GetElementsByTagName("head")(0)
Dim scriptEl As HtmlElement = wb.Document.CreateElement("script")
Dim script_element As IHTMLScriptElement = scriptEl.DomElement

script_element.text = " function disableSelection(){document.body.onselectstart=function(){return false;}; " _
& "document.body.ondragstart=function(){return false}}"
head.AppendChild(scriptEl)
wb.Document.InvokeScript("disableSelection")

[/HIGHLIGHT]
 
Back
Top