473,747 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating WebBrowser programmaticall y

5 New Member

Background - I've create a windows application in VS and added a WebBrowser component and all works well.

I'm now trying to do this programmaticall y. My application now listens on a socket and when it receives a request it creates a new Form and adds a new WebBrowser.

The problem - All works well without the WebBrowser, the form is visible, but when I do "Controls.Add(w ebBrowser)" I see nothing, not even something in the windows bar.

Heres the constructor from my class that extends Form...
Expand|Select|Wrap|Line Numbers
  1.     public partial class Browser : Form
  2.     {
  3.         public Browser()
  4.         {
  5. //            InitializeComponent();
  7.             SuspendLayout();
  9.             webBrowser = new WebBrowser();
  10.             webBrowser.AllowWebBrowserDrop = false;
  11.             webBrowser.Dock = DockStyle.Fill;
  12.             webBrowser.IsWebBrowserContextMenuEnabled = false;
  13.             webBrowser.Location = new System.Drawing.Point(0, 0);
  14.             webBrowser.MinimumSize = new System.Drawing.Size(20, 20);
  15.             webBrowser.Name = "webBrowser";
  16.             webBrowser.ScrollBarsEnabled = false;
  17.             webBrowser.Size = new System.Drawing.Size(292, 273);
  18.             webBrowser.TabIndex = 0;
  19.             webBrowser.WebBrowserShortcutsEnabled = false;
  20.             webBrowser.Visible = true;
  22.             AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  23.             AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  24.             ClientSize = new System.Drawing.Size(292, 273);
  25.             Controls.Add(webBrowser);
  26.             Name = "Browser";
  27.             ResumeLayout(true);
  29.             WindowState = FormWindowState.Maximized;
  30.         }
Note as soon as I call Controls.Add(we bBrowser) nothing appears. With that line removed I can see my form.

Nov 27 '08 #1
3 9442
221 Recognized Expert New Member
I've just copied the code sample into a new form and it appears to run fine. I can see the web browser with no problems and it appears in the taskbar as it should. Maybe the problem is elsewhere in your code?
Nov 27 '08 #2
5 New Member
I've been trying to produce some cut down code to illustrate what i'm doing but can not get anything to work :(

So, i'd appreciate it if u could give me some pointers. Ultimately my app will be a console app or service. I started off with a windows app just to get to grips with Form's and WebBrowser. I've been able to produce a very simple windows app that creates a form with a WebBrowser in, easy!!

I tried to modify the Main method from
Expand|Select|Wrap|Line Numbers
  1. Application.Run(new Browser)
Expand|Select|Wrap|Line Numbers
  1. Thread t = new Thread((new Daemon).Start); t.start()
where Daemon listens for a socket connection then calls New Browser().

I believe it is the lack of call to Application.Run () that is at the heart of the problem.

Basically, how would I create a WebBrowser from a console application?
Nov 27 '08 #3
221 Recognized Expert New Member
I think your assumption that the missing Application.Run () statement is to blame would be correct. From what I remember of the top of my head, Application.Run starts a windows message pump for the form that is passed in as a parameter.
With your code example a message pump is not being started, just another thread. I would guess that this is your problem.
This is not something I've ever tried to do myself. Maybe you need to modify your daemon object to initiate an Application.Run for your browser form?
Nov 28 '08 #4

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

Similar topics

by: Victor Hadianto | last post by:
Hi, Is it possible to programmatically add a history link in the web browser control without getting the WebBrowser control to visit a URL? -- Victor Hadianto http://www.synop.com/Products/SauceReader/
by: Chris Bingham | last post by:
Hi everyone, Does anyone know how to fix the paper orientation depending on the paper size used when printing with the WebBrowser control please? What I've got is a HTML file, containing 1 big table of data, created by transforming an XML file using a XSLT file I created in InfoPath (didn't have time to learn XSLT!), the resulting HTML file is fine, except I had to fix the column sizes of the table in cm. Because of this, the table will...
by: philip | last post by:
Is it possible, on a WebBrowser control, to intercept a HyperLink and react programmatically to this click ? That's my first question. In fact, I use the Webbrowser as a sort of report (I write the html code and tables programmatically in a string, and I give the string to the property DocumentText of the WebBrowser, and I insert in this code some Hyperlinks by wich I could react, launching an specific action) The properties...
by: JM | last post by:
I am using the WebBrowser control in .NET 2.0 Windows based application. I want to use the default IE security settings, privacy settings etc. Is there a way by which I can achieve this ? Thanks in advance JM
by: Vadim Rapp | last post by:
Hello, I want to create a webbrowser object programmatically, navigate to a URL, and then analyze the document. I create the following code (simplified): Dim ie as new webbrowser ie.navigate "http://www.google.com" do while isnothing(ie.document)
by: Ludwig Wittgenstein | last post by:
Hi, all. How can i hook up an InternetExplorer object to a WebBrowser control that I have in my windows form. Basically what I want to do is automate the WebBrowser control via the InternetExplorer object (instead of loading iexplorer.exe externally...). Thanks,
by: M R | last post by:
i am writing an application (C#) that automates the process of loading a web page, login into a site and then simulates the navigation of the site. the program uses a winform with a webBrowser control that is used to load the web page. i am able to successfully navigate the site but am having trouble entering data into the fields. the two fields are the username and password. i would like to automatically enter the username and password...
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?
by: Dom | last post by:
I have a prgram with a webBrowser control. The user can click on a Linked Reference and the webBrowser control shows that site. Sometimes the URL (not my program, but the URL I am browsing to) has an "error on page", eg, a javascript error. My program then gives a dialog box, stating the error, and all my users think I wrote a crummy program. IE somehow gets around this. It will simply write the phrase "error on page" at the status...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.