469,934 Members | 2,513 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Kill Internet Explorer axWebbrowser and restart

I have a aplication which hosts an axWebbrowser. This activex component needs about 10 to 15 mb of memory.

Because i have a option to move the aplication to tray icon and do some timer work i don't want that it just spends over 10mb for nothing.

So i remove the axwebbrowser with


which works fine. After show the application back from the tray icon i will
implement the axwebbrowser again with the same i did it before:

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMain));
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();

// Tell the axwebbrowser that the main form controls the ie :)
object obj = axWebBrowser1.GetOcx();
IOleObject oc = obj as IOleObject;

// Some events we want to have
ie_events = (SHDocVw.WebBrowserClass) Marshal.CreateWrapperOfType(axWebBrowser1.GetOcx() , typeof(SHDocVw.WebBrowserClass));
SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandl er BeforeNavigateE = new SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandl er(OnBeforeNavigate);
ie_events.BeforeNavigate += BeforeNavigateE;

// The basic stuff to set the axwebbrowser into the form
((System.ComponentModel.ISupportInitialize)(this.a xWebBrowser1)).BeginInit();
this.axWebBrowser1.ContainingControl = this;
this.axWebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.axWebBrowser1.Enabled = true;
this.axWebBrowser1.Location = new System.Drawing.Point(0, 0);
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.Get Object("axWebBrowser1.OcxState")));
this.axWebBrowser1.Size = new System.Drawing.Size(100, 100);
this.axWebBrowser1.TabIndex = 0;
this.axWebBrowser1.NavigateComplete2 += new AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Even tHandler(this.axWebBrowser1_NavigateComplete2);
((System.ComponentModel.ISupportInitialize)(this.a xWebBrowser1)).EndInit();
If i remove the oc.setclientsite(this) it works without any errors, but i can't control the ie on the full way
(the user content menu doesn't work) - but when i insert this line i get the error:

object not at object instance (translated from my german version :) )
At my app i use the iolecliensite, idochostuihandler, ioledocumentsite and idochostshowui methods.
at the idochostuihandler i implemented the context-menu routine:

public uint ShowContextMenu(uint dwID, ref tagPOINT ppt, object pcmdtReserved, object pdispReserved)
// use this code to show a custom menu
const int MenuHandled = 0;
Point p = new Point(ppt.x, ppt.y);
p = PointToClient(p);
ie_cmenu.Show(this, p);
return MenuHandled;

Or has anyone a idea how to free the memory from the axwebbrowser? But i want the component
back after showing the form again ;)


Nov 15 '05 #1
0 2684

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Joris VI | last post: by
4 posts views Thread by Nicolás Castagnet | last post: by
2 posts views Thread by Graham | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.