Help Debuging

Started by J P Eskdale, December 04, 2013, 09:15:30 PM

Previous topic - Next topic

J P Eskdale

I have a program that consists of 2 areas
I developed part 1 and was all working
I developed part 2 and is working


Both parts make a call to a form which contains a WebBrowser control.  This used to work perfectly but has stopped working in that as soon as the Form containing the WebBrowser is called the program just completely hangs. The Task bar does show an additional window has been created but that is all.

So Instead of calling the form with the WebBrowser I created an empty form and called that instead and this worked.
So Next I added a WebBrowser control nothing else and set the browser properties to display the www.bbc.co.uk which it does in design view.  I put a debug statement immediately before the call to
FrmWeb_show( HWND_FORMMAIN, %False) and put one after.  The one before gets displayed but not the one after

I tried putting a debug statement in the FRMWEB_WM_CREATE handler but this doesn't get called

The question is how is the best way to debug this as its getting lost in the Firefly generated code.

The problem only occurs when the webbrowser control is on the form.  And it works fine in other programs and it did originally in this program.  I need to put some debug code in the Firefly generated code to find out where it is going. How?  Unless some genius has a great idea of what could be crashing it.

Thanks
Jon

J P Eskdale

OK got the generated code to compile in the

Function FRMWEB_Show(
I added the 2 outputdebugstring commands
The initial one gets displayed but it never returns from the pWindow.CreateWindow

Any idea where should I look now

Thanks

Jon


      outputdebugstring "FrmWeb_Show about to CreateWindow"
    ' // Create the main window
    pWindow.CreateWindow( hWndParent, _
                          "Web viewer", _
                          0, 0, 500, 370, _
                          %WS_POPUP Or %WS_THICKFRAME Or %WS_CAPTION Or %WS_SYSMENU _
                                  Or %WS_MINIMIZEBOX Or %WS_MAXIMIZEBOX Or %WS_CLIPSIBLINGS _
                                  Or %WS_CLIPCHILDREN , _
                          %WS_EX_WINDOWEDGE Or %WS_EX_CONTROLPARENT _
                                  Or %WS_EX_LEFT Or %WS_EX_LTRREADING Or %WS_EX_RIGHTSCROLLBAR _
                                 , _
                          CodePtr( FRMWEB_FORMPROCEDURE ) )
    outputdebugstring "FrmWeb_Show back from CreateWindow"
    If IsWindow(pWindow.hWnd) = 0 Then
       Function = -1: Exit Function
    End If

J P Eskdale

OK Narrowed it down more but even more confused now

Problem is in AddControl in cWindow

Program flow is it calls AddWebrowserControl
which then calls AddControl
which calls CreateWindowEx but this never returns
This is the AddContol method from cWindow

     LOCAL hCtl AS DWORD
      outputdebugstring "AddControl -1"
      IF hParent = 0 THEN hParent = m_hwnd
      IF BITS(LONG, dwStyle) = -1 THEN dwStyle = %WS_VISIBLE OR %WS_TABSTOP
      IF BITS(LONG, dwExStyle) = -1 THEN dwExStyle = 0
      ' // Make sure that the control has the WS_CHILD style
      dwStyle = dwStyle OR %WS_CHILD
      ' // Create the control
      IF bNoScale THEN
      outputdebugstring "AddControl -2"
         hCtl = CreateWindowEx(dwExStyle, BYCOPY strClassName, BYCOPY strTitle, _
                dwStyle, x, y, nWidth, nHeight, _
                hParent, cID, m_hInstance, BYVAL lpParam)
      ELSE
      outputdebugstring "AddControl -3 " + hex$(dwExStyle) + ", " + strClassName + ", " + strTitle + ", " + _
                        hex$(dwStyle) + ", " + str$(x * m_rx) + ", " + str$(y * m_ry) + ", " + str$(nWidth * m_rx) + _
                        ", " + str$( nHeight * m_ry) + ", " + hex$(hParent) + ", " + str$(cID) + _
                        ", " + hex$(m_hInstance) + ", " + hex$(lpParam)
         hCtl = CreateWindowEx(dwExStyle, BYCOPY strClassName, BYCOPY strTitle, _
                dwStyle, x * m_rx, y * m_ry, nWidth * m_rx, nHeight * m_ry, _
                hParent, cID, m_hInstance, BYVAL lpParam)
      END IF
      outputdebugstring "AddControl -4 " + str$(hCtl)


The Debug output is this
[16056] AddWebBrowserControl - 1
[16056] AddControl -1
[16056] AddControl -3 0, OC_WIN32, Shell.Explorer, 56000000,  80,  54,  360,  218, 3C1840,  1000, 200000, 70
But it never returns we don't get the AddControl -4

On a simpler program that works
The Debug output is this
[13364] AddWebBrowserControl - 1
[13364] AddControl -1
[13364] AddControl -3 0, OC_WIN32, Shell.Explorer, 56000000,  31,  26,  425,  318, 1407DC,  1000, 200000, 70
[13364] AddControl -4  3020910

So what is wrong?

Thanks for any help
Jon

José Roca

Almost always the problem is in the code not shown. In pWindow.CreateWindow, from where comes pWindow?

J P Eskdale

Hi Jose - Thanks

This is the beginning of the function all generated by FireFly apart from the outputdebug strings I added for debugging


Function FRMWEB_Show( _
                    ByVal hWndParent As Dword, _
                    ByVal ShowModalFlag As Long, _
                    Optional ByVal UserData As Long _
                    )  As Long

    Local IsMDIForm as Long
   
    ' // Create an instance of the class
    Local pWindow As IWindow
    pWindow = Class "CWindow"
    If IsNothing(pWindow) Then Function = -1: Exit Function
   
    pWindow.ClassName = "FORM_ISAF EVENTS_FRMWEB_CLASS"
   
    ' // Set the flag if this is an MDI form we are creating
    IsMDIForm = %FALSE

    ' // Save the optional UserData to be checked in the Form Procedure CREATE message
    App.ReturnValue = UserData
   

    ' // Always ensure that we enable High DPI
    pWindow.DPI = -1

      outputdebugstring "FrmWeb_Show about to CreateWindow"
    ' // Create the main window
    pWindow.CreateWindow( hWndParent, _


I've attached the whole include file for the form which is generated by FireFly

Thanks Jon

J P Eskdale

I've been trying to step through the disassembled code
If it helps anyone it locked up while making a subroutine call from within the OLE32 module

Attached is a screen shot when the createWindowEx was called showing the Stack which looks OK

Regards

David Kenny

Jon,

Have you tried the PB debugger?  It's got to be more useful than a generic win32 disassembler\debugger.

J P Eskdale

Thanks David,
But its not that simple - I have determined at what point it crashes/hangs in PowerBasic

The code is PowerBasic code but generated by FireFly not code that I've written - It makes an API call to CreateWindowEx but this call never returns.

If I generate a simple program to test the feature it works fine but when its part of a larger program it does not.

Question is where to look

Jon

J P Eskdale

Still in trouble with this  :(
What is the significance of Shell.Explorer as the Title when adding the control.  In desperation I tried making this blank just to see what would happen and although I don't get a browser it doesn't hang

Jon


José Roca

> What is the significance of Shell.Explorer as the Title when adding the control

It is the ProgID of Internet Explorer. Without it, an instance of the WebBrowser control can't be created.

Which version of IE are you using? It has been working until version 10. I have not tested it with version 11.

If you make a simple test that uses the WebBrowser control, does it work?

J P Eskdale

Hi Jose,

It is version 11 but as I said in the earlier posts a simple test works.  That is what is so frustrating.  I'm not saying that is not my code that is causing it but I can't see how - This part of it is the simple bit - I've even recreated the forms to test it out - Any suggestions welcome

And it was working with this program until recently.  I don't understand why it stopped I didn't change any of the web form at all

I've spent ages on this program and I need to get it finished and on with other things - Its not as if I was even selling it.  But I said I would do it for the sailing community so I need to get done.
Jon

José Roca

I'm trying to figure it. I don't have all the code, so I can't know if something is missing.

Does your program use %USEWEBBROWSER = 1 at the beginning? This is essential.

J P Eskdale

Hi  Jose

Yes it does as this is put in by FireFly

I've PM'd you a link to a zip of the release directory which has all the code in it.  It's got in a bit of a mess at the moment as I've been trying all sorts of things to get it to work but the code then should compile and run.

If you run it and click on the "Click here to contact ISAF" button that should open the browser and it used to but now hangs

Thanks Jon
I am away tomorrow but back Saturday

José Roca

The only part in the AddWebBrowser method that could hang the application is


               DO
                  ' // Processes pending messages
                  AfxPumpMessages
                  ' // Retrieves the ready state
                  IF pIWebBrowser2.ReadyState = %READYSTATE_COMPLETE THEN EXIT DO
               LOOP


but it should not happen, since you said that a simple test works.

J P Eskdale

Hi Thanks -
But it doesn't get that far as it never returns from the
hCtl = ME.AddControl ($OC_CLASSNAME, hParent, cID, strTitle, x, y, nWidth, nHeight, dwStyle, dwExStyle, lpParam, %NULL, bNoScale)
About 22 source code line before the Do in your message

Jon