• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Webcontrol is losing session on new popup

Started by Edwin Knoppert, February 01, 2011, 09:25:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Edwin Knoppert

This seems a common issue but now i have found some comment which may be solving it but i have not idea how to make it work.

I have this website which is not mine and invokes a new window via a javascript click handler, thus not via an anchor.
The window loses the session and i am required to login in that window again.

Is there a way using OLECON code to intercept the new window and make it work properly?
I can abort the new window but in fact i want the window and repair the situation.

The website is about the .NET control bt shows familiar code:
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/d5997238-f72f-472e-a090-e10954c7fb99/

and maybe:
http://msdn.microsoft.com/en-us/library/aa768288(VS.85).aspx

Thanks,

José Roca

The OLE container is generic. It has no code related directly with the WebBrowser Control. The NewWindow2 event is fired by the WebBrowser Control, so you have to add the code in the event class for it.

In my Tabbed MDI Window example, I use this code to keep the new instance of the control inside a new MDI window instead of letting it to open a new instance of Internet Explorer.


CLASS CDWebBrowserEvents2 GUID$("{700B73A2-CCFC-4FE0-B9AC-D5853D71B7B9}") AS EVENT

   ' // Indicates that the qualified url has already been
   ' // set in the URL edit textbox
   INSTANCE bQualifiedUrl AS LONG
   ' // Indicates that the NewWindow3 event as been processed
   INSTANCE bNewWindow3 AS LONG

INTERFACE DWebBrowserEvents2Impl GUID$("{34A715A0-6587-11D0-924A-0020AFC7AC4D}") AS EVENT

...
...


   ' =====================================================================================
   METHOD NewWindow2 <251> ( _
     BYREF ppDisp AS IDispatch _                        ' __in_out IDispatch** ppDisp
   , BYREF bCancel AS INTEGER _                         ' __in-out VARIANT_BOOL* Cancel
   )                                                    ' void

      '  Create the new window in a new MDI child window
      LOCAL hMdi AS DWORD
      LOCAL hWB AS DWORD
      LOCAL pIWebBrowser2 AS IWebBrowser2

      ' Cancel new window creation if the NewWindow3 event has been processed.
      IF bNewWindow3 THEN
         bCancel = %VARIANT_TRUE
         bNewWindow3 = %FALSE
         EXIT METHOD
      END IF

      ' Create an MDI child
      hMdi = CreateMdiChild("WB", ghWndClient, "", %WS_MAXIMIZE)
      ' Get the handle of the control
      hWB = GetDlgItem(hMdi, %IDC_IEWB)
      ' Get the IDispatch of the control
      pIWebBrowser2 = OC_GetDispatch(hWB)
      IF ISOBJECT(pIWebBrowser2) THEN
         ' Register the browser
         pIWebBrowser2.RegisterAsBrowser = %VARIANT_TRUE
         ppDisp = pIWebBrowser2
         pIWebBrowser2 = NOTHING
      END IF

   END METHOD
   ' =====================================================================================

...
...


END INTERFACE

END CLASS
' ========================================================================================


Edwin Knoppert


Edwin Knoppert

It does work, thanks.
Used this kind of code (the only adaptation i made):

        Method NewWindow2 <251> (ByRef In ppDisp As IDispatch, ByRef In Cancel As Integer)

            Local hWB           As Dword
            Local pIWebBrowser2 As IWebBrowser
            Local hWnd          As Long

            hWnd = VD_CreateForm( $FRMPOPUP, hWndMain )
            OC_WebControl_DefaultInit( hWnd, %ID_FRMPOPUP_USERCONTROL1, Nothing, "", 1 )
   
            hWB = GetDlgItem( hWnd, %ID_FRMPOPUP_USERCONTROL1 )
            pIWebBrowser2 = OC_GetDispatch(hWB)
            If IsObject(pIWebBrowser2) Then
                VD_ShowModeless( hWnd )
                pIWebBrowser2.RegisterAsBrowser = -1%
                ppDisp = pIWebBrowser2
            Else
                Cancel = -1
                DestroyWindow( hWnd )
            End If
           
        End Method


For some reason the content is not aligned properly unless i resize the form once.
I may try the hard way but maybe there is a 'suggested' windowsize available?
I mean window.open often has these values and maybe they are retrievable.

I am happy already so no worries to much about this.