Nikolay Nikolay - 1 year ago 191
C# Question

Change webbrowser Cursor

I have a form that contains WebBrowser control.
I need to change the cursor to WebBrowser.

I try

this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
this.TopLevelControl.Cursor = Cursors.WaitCursor;

The cursor changes form only, but not for WebBrowser.

How can I change the cursor in WebBrowser control?

Answer Source

Add a reference to your solution to "mshtml.dll". After you load your Document, try this:

IHTMLDocument2 doc = (webDocument1.Document.DomDocument) as IHTMLDocument2;
IHTMLStyleSheet style = doc.createStyleSheet("", 0);
style.cssText = @"body { cursor: wait; }";

Please bear in mind that the result depends also on the way you load the web page (load a local/embedded file, set the DocumentStream, etc.).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download