Adding WebBrowser control at runtime 
Author Message
 Adding WebBrowser control at runtime

Hi,

I want to create a WebBrowser control at run time. I tried to use the
code which is added to InitializeComponent function when adding the
control at design time.

I've added the following code:
if (wb != null)
{
        wb.Dispose();

Quote:
}

System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(frmViewer));

this.wb = new AxSHDocVw.AxWebBrowser();
                        ((System.ComponentModel.ISupportInitialize)(this.wb)).BeginInit();

this.Controls.AddRange(new System.Windows.Forms.Control[]
{this.tbViewer,this.wb});

                        ((System.ComponentModel.ISupportInitialize)(this.wb)).EndInit();

this.wb.Anchor = System.Windows.Forms.AnchorStyles.None;
this.wb.Enabled = true;
this.wb.Location = new System.Drawing.Point(8, 32);
this.wb.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("$this.wb.OcxSt
ate"))); // Error!!!
this.wb.Size = new System.Drawing.Size(768, 560);
this.wb.TabIndex = 1;

When running the line which sets OcXState, it crashes because
resources.GetObject("$this.wb.OcxState") returns null.

How can Is solve that?

Thanks
Erez

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Thu, 12 May 2005 22:33:01 GMT  
 Adding WebBrowser control at runtime
    When you drag and drop a Web Browser from the toolbar, it
automatically updates the .resx file, such as Form.resx.  It adds the
resource data for you.  If you're writing this by hand, you also have to
add the information to resx by hand.  Go to the Folder where your
application is stored and click on the .resx file.
    Now, add the following information:
    name:         $this.wb.OcxState
    mimetype:   application/x-microsoft.net.object.binary.base64

    You can leave the other fields blank, value: empty, comment: (null),
type: (null)

    Now, your application should work fine.

Chris R.


Quote:
> Hi,

> I want to create a WebBrowser control at run time. I tried to use the
> code which is added to InitializeComponent function when adding the
> control at design time.

> I've added the following code:
> if (wb != null)
> {
> wb.Dispose();
> }
> System.Resources.ResourceManager resources = new
> System.Resources.ResourceManager(typeof(frmViewer));

> this.wb = new AxSHDocVw.AxWebBrowser();
> ((System.ComponentModel.ISupportInitialize)(this.wb)).BeginInit();

> this.Controls.AddRange(new System.Windows.Forms.Control[]
> {this.tbViewer,this.wb});

> ((System.ComponentModel.ISupportInitialize)(this.wb)).EndInit();

> this.wb.Anchor = System.Windows.Forms.AnchorStyles.None;
> this.wb.Enabled = true;
> this.wb.Location = new System.Drawing.Point(8, 32);
> this.wb.OcxState =

((System.Windows.Forms.AxHost.State)(resources.GetObject("$this.wb.OcxSt

- Show quoted text -

Quote:
> ate"))); // Error!!!
> this.wb.Size = new System.Drawing.Size(768, 560);
> this.wb.TabIndex = 1;

> When running the line which sets OcXState, it crashes because
> resources.GetObject("$this.wb.OcxState") returns null.

> How can Is solve that?

> Thanks
> Erez

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Thu, 12 May 2005 23:58:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ActiveX WebBrowser control creation during runtime

2. adding WebBrowser Control to child window

3. Adding events to MS WebBrowser control generates errors ?

4. Add a control at runtime

5. runtime adding a control

6. Adding controls in runtime

7. Change/add dialog controls at runtime

8. mfc newbie-adding controls at runtime

9. Add control to dialog at runtime

10. add control to dialog at runtime

11. add/remove controls at runtime

12. Controls added to a Dialog at runtime have another text font

 

 
Powered by phpBB® Forum Software