473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can I show an embedded webbrowser only onload?

I'm using the wewbBrowser component on top of a transparent window. I want the browser to remain hidden until the rather extensive page -- with some transparent elements -- has loaded. Currently, while the embedded webbrowser waits for the page to load, it stays white for several seconds. Can anyone give me a tip how to hide the webbrowser until the page readyState is complete?
I'm using Win 7 64-bit. Sharpdevelop 4.41. Net Framework 4.5
Compiler Verwsion C# 3.0 targetting .NET Framework 3.0 (need to use in XP :( )
Apr 9 '14 #1
1 2016
Since this post seems popular but nobody has answered it, I had better post what I have learned:
Everything is based on SharpDevelop 4.4 with NET 4.5 installed on Win 7 Pro with latest Microsoft SDK.
Select Default Layout or Debug Layout from the pulldown menu at top of page.

1. Click on the tab in the main working area that shows the code you are currently working on -- by default Form1.cs
2. At the foot of the main working area, select the Design Tab
4. Your design appears in the main working area. Click on the browser element shown in the design.
5. In the right hand panel, the properties of the web browser appear. In the section Behavior, select "url"
6. To the right of "url" enter "about:blank"
7. Set the next item in the list "visible" to false.
8. Go to the section of your code that describes the design of your application. This may be in a separate file called, for example, Form1.Designer.cs
Here, manually insert the following line at the end of the browser element section (by default it's called webBrowser1):
this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEv entHandler(this.WebBrowser1DocumentCompleted);
This sends a DocumentCompleted signal to your main code. (see point 11)
9. Return to your main code file -- by default Form1.cs
10. Click on the Source tab below left.
11. Add this or similar code to pick up the DocumentCompletedsignal:
Expand|Select|Wrap|Line Numbers
  1.      private void WebBrowser1DocumentCompleted(object sender, EventArgs e)
  2.            {
  3.         /// <summary>
  4.         ///  On page completion. this happens:
  5.         /// </summary>
  6.             string z= webBrowser1.Url.ToString();
  7.             if(z == "about:blank"){  
  8.                    webBrowser1.Document.Write ("<!DOCTYPE html><html><head><meta charset='utf-8'><meta http-equiv='content-type' content='text/html; charset=utf-8'>"+ 
  9.             "<title>Please wait</title></head><body style='background-color:Silver'><div style='text-align:center;padding-right:100px;'>"+
  10.             "<DIV ID=MYDIV style='position:absolute;left:200px;top:60px;width:180px;height:60px;border:1px solid lightslategrey;padding:10px;"+
  11.             "font-family:arial unicode ms;arial;font-size:13px;background-color:#efefef;color:#000;text-align:center;'>"+
  12.             "Please wait<br>Your page is loading"+
  13.             "</DIV></body></html>");
  14.  
  15.             webBrowser1.Visible = true;
  16.             webBrowser1.Navigate("http://duckduckgo.com");
  17.             }
  18.         }
  19.  
12. You can see, I have set here the background color of the body element to Silver.
This color must be the same as the background color of the main form -- the base element of your application.
To make this Silver (or whatever color you prefer) go here:
13. Select the Design tab of Form1.cs
14. In the properties panel to the right, click on the small black down arrow, top right.
15. Choose the main form section from the drop-down menu -- by default called simply "Form1"
16. Select BackColor and change it to "Silver"
17. Scroll down to the foot of this section with the scrollbar on the right. Do not use the mouse wheel: this would change the element you are working on.
18. Last item is Transparency Key. Click the arrow to the right, choose the "Web" tab and then "Silver".
19. Save and run Debug.

Hope it works for you.
Apr 27 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: geotso | last post by:
Hi I'm looking for a javascript with the following operation: if history.length <=2 show "layer1" and hide "layer2" else hide "layer1' and show "layer2"
1
by: Mike Z... | last post by:
Hi! I have a winform with embedded webbrowser control. When a user navigates to a page that has a link or a button that calls windows.close() javascript, the control closes yet the form does not....
0
by: Randy | last post by:
Hi, is it possible to programmatically (from C#) get the value of a JavaScript Variable from a JavaScript running inside the embedded WebBrowser Control? Thanks in advance, Randy
4
by: Randy | last post by:
Hi, ok, I found a way to connect to a running instance of an (external) Internet Explorer and access - for example - the html source. That works fine! But now I have running application with...
1
by: L. Chernov | last post by:
Hello, I am trying to work with .Net 2005 WebBrowser object, and put it on a "Windows control library" (embedded in a user control class) and then I am executing it from an ASP.Net webform(with...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: markclinn | last post by:
I need help with passing a variable from embedded WebBrowser to VB application. I have an interactive map, and when I click on an icon, I need to pass the ID back into the application. Any ideas? ...
1
by: =?Utf-8?B?Q2FtZXJvbiBUYXlsb3I=?= | last post by:
Is there any way to programmatically purge the forward/back history of a .NET 2.0 embedded WebBrowser control?
3
by: simonyong | last post by:
Im a newbie to asp.net, i hav a bit dilemma when thinking about how i should let it work.. My task as below: My task is related to view all data from a table called "employee " i had create a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.