Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

"Block" a webbrowser object?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sam - 22 Mar 2006 04:22 GMT
I am trying to create a webbrowser object that will a) not respond to clicks
on links, but b) will allow me to programatically navigate via the URL
property or Navigate() method.

I have tried to set AllowNavigation to false, but this restricts all
navigation, even by the methods and property.

I have also tried to use a boolean variable to indicate whether the
navigation request is "allowed" and cancel it in a Navigating event handler,
but I'm not sure where to reset the variable to not allow further
navigation.  My first attempt was to do this in the DocumentCompleted event
handler, but I get multiple DocumentCompleted events on same web pages, so
if I clear the variable on the first DocumentCompleted, the further
navigations are cancelled...  If I had a way to know when an "entire" page
was loaded, that might work, but I haven't found that event yet.

Is there a way to trap the mouse events within the webbrowser?  Is there a
way to block them (I've thought of a transparent panel sitting in front of
the browser (not in front of the scroll bars, though!), but the transparency
doesn't seem to accomplish this.

Any ideas of how I can accomplish this?

Thanks in advance for any help you can provide!
Signature

Sam
(remove .nospam to reply email)

mabster - 22 Mar 2006 07:48 GMT
This might be a terrible kludge compared to what you want, but could you
cancel *every* navigation, and simply write to the DocumentText
property? That way the WebBrowser never actually navigates. If you need
to show actual web pages then perhaps you could drag them down with a
WebClient object and pump in the HTML manually.

> I am trying to create a webbrowser object that will a) not respond to clicks
> on links, but b) will allow me to programatically navigate via the URL
[quoted text clipped - 20 lines]
>
> Thanks in advance for any help you can provide!
AMercer - 22 Mar 2006 12:26 GMT
> I am trying to create a webbrowser object that will a) not respond to clicks
> on links, but b) will allow me to programatically navigate via the URL
> property or Navigate() method.

I have no direct experience with what I am about to suggest, so use caution.
Maybe you could use the webbrowser's BeforeNavigate2 which allows for
cancellation of a navigation.  Make a boolean variable indicating validity of
a navigation, and let its usual state be false.  When the user tries to
navigate in a way that is ok with you, set it to true.  In the event handler,
cancel the navigation or let it pass based on the validity flag.  When the
navigation is complete or canceled, revert the flag to false.

This sounds plausible to me, but it is complicated by the fuzziness
webbrowser event sequencing.  For example, maybe you will get two
BeforeNavigate2 events fired for one user navigation action.  As I said, this
suggestion comes without any warranties.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.