longzu / csexwb2

Automatically exported from code.google.com/p/csexwb2
0 stars 0 forks source link

Using LoadHtmlIntoBrowser() immediately after creation. #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello, I'm having some difficulty using the LoadHtmlIntoBrowser() method
immediately after creating the browser object. If I wait until it is
created and then do it I have no trouble, but if I create a window with a
cEXWB control on it, I cannot seem to use this method.

I've tried navigating to about:blank (or rather, waiting until the implicit
navigation completes), then attempting LoadHtml...() in the
DocumentComplete event, but still to no avail.

Could you please give me a hint as to where and when this method becomes
"available" after the object is created?

Original issue reported on code.google.com by murray.l...@gmail.com on 30 Aug 2007 at 1:54

GoogleCodeExporter commented 8 years ago
Aha, the problem may have had to do with another change I made. This is a bit 
tricky
though because the LoadHtmlIntoBrowser() method actually results in more events 
being
fired, including another DocumentComplete event, so I had to be sure to set a 
flag in
order to avoid infinite looping.

Original comment by murray.l...@gmail.com on 30 Aug 2007 at 2:31

GoogleCodeExporter commented 8 years ago
The document object is not available until the very first time webbrower 
becomes 
visible. This is by design and has nothing to do with this control.

Here are two possible solutions:

Use LoadHtmlIntoBrowser in Shown event which fires when the form is shown for 
the 
first time.

or

Subscribe to HTMLWindowEvents2.OnLoad event which fires immediately after the 
browser loads the object.

//In form load, setup the event:
int[] dispids = { (int)HTMLEventDispIds.ID_ONLOAD };
m_CurWB.ActivateHTMLEvents(HTMLEventType.HTMLWindowEvent, dispids);

//Subscribe to HTMLEvent
m_CurWB.HTMLEvent += new csExWB.HTMLEventHandler(m_CurWB_HTMLEvent);

//Handle the event
void m_CurWB_HTMLEvent(object sender, csExWB.HTMLEventArgs e)
{
  //Window events are not cancellable
  if (e.m_EventType == HTMLEventType.HTMLWindowEvent)
  {
    if (e.m_EventDispId == HTMLEventDispIds.ID_ONLOAD)
    {
      csExWB.cEXWB pWB = (csExWB.cEXWB)sender;
      //Start processing
    }
  }
}

MH

Original comment by mehr...@gmail.com on 30 Aug 2007 at 11:19