Hi Nick,

Your memory leak could very well be due to the browser control in addition
to the possibility of you not cleaning up COM object references. The
operations you are performing are very expensive because you have to interop
to the browser control, which hooks into the COM-based IE object model. If
your entire app is written as an HTML-based thick client, have you
considered using a binary DHTML behavior[1] instead of that control? IMHO,
you will get much better performance and flexibility without the control
because you can hook directly into IE and you don't have to interop using
VC++ (or VB6 for that matter). All of the MSDN docs show VC++ samples, but I
have created binary behaviors in VB6 as well if you want me to tell you how
to do that. I've written entire apps using behaviors because of the woes
created by that damn browser control. Just a thought. :-)

As far as your <A> tag, maybe try creating a bookmark somewhere on the
current page and set the href to the bookmark, and that way you can handle
what REALLY happens with your onclick event procedure. If that isn't working
for you, try using a DIV or SPAN tag with the cursor style set to "hand" and
hooking the onclick event for that tag.

HTH,

---Sean

[1] http://www.unboxedsolutions.com/sean/posts/150.aspx



-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Nick Howard
Sent: Thursday, February 19, 2004 8:31 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] AxWebBrowser questions

Hello,

I'm working on an application that uses an AxWebBrowser control. I've had a
couple of problems. I dynamically create the HTML that I load into some of
the pages and others are static pages. Sometimes when I click on a link that
should take be to a dynamic page I get a "Page cannot be found" page
instead. Then I click back and click on the link again and it works fine.
It seems to be a timing issue, but I can't quite figure it out. Basically my
code to create the page dynamically looks like this:

//**********
IHTMLDocument2 HTMLDocument = null;
HTMLDocument = (IHTMLDocument2)webMain.Document; HTMLDocument.clear();
HTMLDocument.write(h); HTMLDocument.close(); Thread.Sleep(250);
HookingEvents();
//**********

h is a string that is created in some other functions. HookingEvents loops
through document and creates the events for when someone clicks on a link.
//*********
public void HookingEvents()
{
 IHTMLDocument2 doc;
 object boxDoc = this.webMain.Document;
 doc = (IHTMLDocument2)boxDoc;

 if (doc != null )
 {
  IHTMLElementCollection allElems = doc.all;
  if ( allElems == null ) return;
  int len = allElems.length;

  // DocComplete fires multiple times, check that we have  elements.
  if ( len < 1) return;
  for ( int i = 0; i< len; i++)
  {
   object boxe = allElems.item(i,i);
   IHTMLElement elem = (IHTMLElement)boxe ;

   string tagName = elem.tagName.ToUpper();
   if ( tagName == "A" )
   {
    mshtml.HTMLAnchorEvents2_Event aevent =
     (mshtml.HTMLAnchorEvents2_Event)
boxe;

    aevent.onclick += new

 mshtml.HTMLAnchorEvents2_onclickEventHandler(OnAnchorClick);
   }
  }
 }
}
//*******************


OnAnchorClick calls the code above that writes the document. Does anyone
have any thoughts about this? I'm a complete loss for what to do.

One other issue is that my app seems to use a lot of memory. When I look in
the task manager it will be using 100MB and still growing. It seems like
it's still storing each page in memory as I browse.

I hope this makes sense. Thank you very much for any help, I really
appreciate it.

Thanks,
Nick

===================================
This list is hosted by DevelopMentorR  http://www.develop.com Some .NET
courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to