/ Forums / Advansys Formativ / Creating Solutions with Formativ / Syntax for webbrowser events

  • Creator
    Topic
  • #4323
    alivingston
    Participant

    What is the right syntax for writing event handlers for the webbrowser control? Can you give me an example?

  • Author
    Replies
  • #7821
    Support 3
    Participant

    Formativ use the TWebBrowser. If you have Delphi available then see the EmbeddedWB in Internet palette. The URL below shows some common methods:
    http://www.cryer.co.uk/brian/delphi/twebbrowser/twebbrowser_methods.htm

    To write webbrowser event handler in Formativ, we will suggest you to see the Events tab in the Object Inspector. You can drop a EmbeddedWB from Additional tab into your Form then select the EmbeddedWB, click Events tab in the Object Inspector. Double click any of the event (i.e OnDownloadBegin, OnDownloadComplete, etc) to generate the code.

    Hope this helps.

    Regards,
    Advansys Support

    #7825
    alivingston
    Participant

    The instructions you’ve given – double-clicking on events in the Object Inspector – don’t work for me. When I double-click on an event, nothing happens. I’m running Creator 2.0.1 with GroupWise 7.0.1 on Windows XP Professional with IE 7. Any idea what I’m doing wrong?

    #7823
    Support 3
    Participant

    I am using Formativ Studio 2.0.1, GroupWise 7.0.1 (Build date: 14/12/2006) & IE 6. I will test with Creator and let you know the results. What is the build date of the GroupWise client (see Help – About GroupWise)?

    Regards,
    Advansys Support

    #7824
    Support 3
    Participant

    I have tested with Formativ Creator 2.0.1 and it works fine. We have sent you an example Applet directly.

    Regards,
    Advansys Support

    #7822
    ctaleck
    Participant

    I am trying to capture EmbeddedWB events but most of them I try never fire.

    Am I missing anything that would make sure such events as OnNavigateError and OnNavigateComplete2 actually fire?

    The only event I have been able to see fired is OnProgressChange.

    Specifically, I am trying to create some code that will determine if the page I browsed using .Navigate was successful. i.e. not a page not found error.

    [This message was edited by ctaleck on November 18, 2009 at 01:42 PM.]

    #7826
    Support 3
    Participant

    Our engineers confirmed the behaviour, we also noticed few other events also not fire. We are not sure what cause this events not to fire, potentially a low level component integration.

    Given OnProgressChange events work, you can use the following workaround to determine page loaded successfully.

    Note:
    – Utilities.IHTMLDocumentFromViewHandle: See Formativ Language Guide for more information. This method return an instance of the IHTMLDocument2 interface obtained from the window.
    – IHTMLDocument2 : http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx
    – Debugging Applet: http://www.advansyscorp.com/forums/topic/9151084651/

      
    dim gURLPrecossed
    
    Sub Main(Client, GWEvent)
    
      gURLPrecossed = false
      Maindlg.embeddedWB.navigate("www.advansyscorp.com")
      Maindlg.ShowModal
    
    End Sub
    
    
    Sub embeddedWBProgressChange(Sender, Progress, ProgressMax)
    
      utilities.trace("-> embeddedWBProgressChange gURLPrecossed: " & gURLPrecossed)
    
      utilities.doevents
    
      ' Event can fired more then once, we will skip if gURLPrecossed global variable
      ' is TRUE. Set gURLPrecossed to FALSE on loading page (i.e. Navigate() method).
      if (not gURLPrecossed) then
    
        ' Skip if engaged in a navigation or downloading operation.
        if (Maindlg.embeddedWB.Busy) then
          utilities.trace("-> embeddedWBProgressChange embeddedWB.Busy")
          exit sub
        end if
    
        dim oDocument
    
        if Utilities.IHTMLDocumentFromViewHandle(Maindlg.Handle, oDocument) = 0 then
          utilities.trace("-> embeddedWBProgressChange oDodument.title: " & oDocument.title)
          if ((Instr(1, oDocument.title, "http 404 not found", vbTextCompare) > 0) or (Instr(1, oDocument.title, "cannot find server", vbTextCompare) > 0)) then
            utilities.trace("-> embeddedWBProgressChange 'Page not found'")
          else
            utilities.trace("-> embeddedWBProgressChange Page loaded")
          end if
          gURLPrecossed = true
        else
            utilities.trace("-> embeddedWBProgressChange 'No handle'")
        end if
    
        set oDocument = nothing
      end if
    
      utilities.trace("<- embeddedWBProgressChange")
    
    End Sub
    

    Hope this helps.

    Regards,
    Advansys Support

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.