Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Webbrowser w/o external Dlls

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Webbrowser w/o external Dlls

    Requires IE4 or higher.
    Supports up to 3 web windows (you can increase)

    Code:
       ' Used : SDK (atl) samples, [url="http://www.codeguru.com/ieprogram/cwebpage.html"]http://www.codeguru.com/ieprogram/cwebpage.html[/url]  and PB implementations, posted by Jose Roca
    
       #Compile Exe
       #Dim All
       #Include "win32api.inc"
       #Include "ComObj.Inc"
    
       '--------------------------------------------------------
    
       %maxWebBrowsers = 3
    
       Type WebBrowserData
          hWndParent                                  As Dword
          hWndIE                                      As Dword
          pIOleObject                                 As IOleObject Ptr
          pIConnectionPointContainer                  As IConnectionPointContainer Ptr
          pIConnectionPoint                           As IConnectionPoint Ptr
          pIOleClientSite                             As IOleClientSite Ptr
          pIWebBrowser2                               As IWebBrowser2 Ptr
          dwCookie                                    As Dword
          Msg                                         As tagMsg
          szTmpHtmlFile                               As Asciiz * %MAX_PATH
       End Type
    
       Global szWebBrowserData As String
    
       '--------------------------------------------------------------------------------
    
       Function IOleClientSite_GetVtbl(ByVal IdWB As Dword) As Dword
    
          Dim uIOleClientSiteVtbl(%maxWebBrowsers - 1) As Static IOleClientSiteVtbl
          Dim uIOleClientSite(%maxWebBrowsers - 1)     As Static IOleClientSite
    
          If uIOleClientSite(IdWB - 1).lpVtbl = 0 Then
             uIOleClientSite(IdWB - 1).lpVtbl                     = VarPtr(uIOleClientSiteVtbl(IdWB - 1))
    
             uIOleClientSiteVtbl(IdWB - 1).AddRef                 = CodePtr(IOleClientSite_AddRef)
             uIOleClientSiteVtbl(IdWB - 1).Release                = CodePtr(IOleClientSite_Release)
             uIOleClientSiteVtbl(IdWB - 1).SaveObject             = CodePtr(IOleClientSite_SaveObject)
             uIOleClientSiteVtbl(IdWB - 1).GetMoniker             = CodePtr(IOleClientSite_GetMoniker)
             uIOleClientSiteVtbl(IdWB - 1).GetContainer           = CodePtr(IOleClientSite_GetContainer)
             uIOleClientSiteVtbl(IdWB - 1).ShowObject             = CodePtr(IOleClientSite_ShowObject)
             uIOleClientSiteVtbl(IdWB - 1).OnShowWindow           = CodePtr(IOleClientSite_OnShowWindow)
             uIOleClientSiteVtbl(IdWB - 1).RequestNewObjectLayout = CodePtr(IOleClientSite_RequestNewObjectLayout)
             Select Case As Long IdWB
                Case 1 : uIOleClientSiteVtbl(IdWB - 1).QueryInterface         = CodePtr(IOleClientSite_QueryInterface1)
                Case 2 : uIOleClientSiteVtbl(IdWB - 1).QueryInterface         = CodePtr(IOleClientSite_QueryInterface2)
                Case 3 : uIOleClientSiteVtbl(IdWB - 1).QueryInterface         = CodePtr(IOleClientSite_QueryInterface3)
             End Select
          End If
    
          Function = VarPtr(uIOleClientSite(IdWB - 1))
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function IOleInPlaceSite_GetVtbl (ByVal IdWB As Dword) As Dword
    
          Dim uIOleInPlaceSiteVtbl(%maxWebBrowsers - 1) As Static IOleInPlaceSiteVtbl
          Dim uIOleInPlaceSite    (%maxWebBrowsers - 1) As Static IOleInPlaceSite
    
          If uIOleInPlaceSite(IdWB - 1).lpVtbl = 0 Then
             uIOleInPlaceSite(IdWB - 1).lpVtbl                    = VarPtr(uIOleInPlaceSiteVtbl(IdWB - 1))
    
             uIOleInPlaceSiteVtbl(IdWB - 1).QueryInterface        = CodePtr(IOleInPlaceSite_QueryInterface)
             uIOleInPlaceSiteVtbl(IdWB - 1).AddRef                = CodePtr(IOleInPlaceSite_AddRef)
             uIOleInPlaceSiteVtbl(IdWB - 1).Release               = CodePtr(IOleInPlaceSite_Release)
             uIOleInPlaceSiteVtbl(IdWB - 1).ContextSensitiveHelp  = CodePtr(IOleInPlaceSite_ContextSensitiveHelp)
             uIOleInPlaceSiteVtbl(IdWB - 1).CanInPlaceActivate    = CodePtr(IOleInPlaceSite_CanInPlaceActivate)
             uIOleInPlaceSiteVtbl(IdWB - 1).OnInPlaceActivate     = CodePtr(IOleInPlaceSite_OnInPlaceActivate)
             uIOleInPlaceSiteVtbl(IdWB - 1).OnUIActivate          = CodePtr(IOleInPlaceSite_OnUIActivate)
             uIOleInPlaceSiteVtbl(IdWB - 1).GetWindowContext      = CodePtr(IOleInPlaceSite_GetWindowContext)
             uIOleInPlaceSiteVtbl(IdWB - 1).Scroll                = CodePtr(IOleInPlaceSite_Scroll)
             uIOleInPlaceSiteVtbl(IdWB - 1).OnUIDeactivate        = CodePtr(IOleInPlaceSite_OnUIDeactivate)
             uIOleInPlaceSiteVtbl(IdWB - 1).OnInPlaceDeactivate   = CodePtr(IOleInPlaceSite_OnInPlaceDeactivate)
             uIOleInPlaceSiteVtbl(IdWB - 1).DeactivateAndUndo     = CodePtr(IOleInPlaceSite_DeactivateAndUndo)
             uIOleInPlaceSiteVtbl(IdWB - 1).DeactivateAndUndo     = CodePtr(IOleInPlaceSite_DeactivateAndUndo)
             Select Case As Long IdWB
                Case 1 : uIOleInPlaceSiteVtbl(IdWB - 1).GetWindow             = CodePtr(IOleInPlaceSite_GetWindow1)
                         uIOleInPlaceSiteVtbl(IdWB - 1).OnPosRectChange       = CodePtr(IOleInPlaceSite_OnPosRectChange1)
                Case 2 : uIOleInPlaceSiteVtbl(IdWB - 1).GetWindow             = CodePtr(IOleInPlaceSite_GetWindow2)
                         uIOleInPlaceSiteVtbl(IdWB - 1).OnPosRectChange       = CodePtr(IOleInPlaceSite_OnPosRectChange2)
                Case 3 : uIOleInPlaceSiteVtbl(IdWB - 1).GetWindow             = CodePtr(IOleInPlaceSite_GetWindow3)
                         uIOleInPlaceSiteVtbl(IdWB - 1).OnPosRectChange       = CodePtr(IOleInPlaceSite_OnPosRectChange3)
             End Select
    
    
          End If
    
          Function = VarPtr(uIOleInPlaceSite(IdWB - 1))
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function DWebBrowserEvents2_GetVtbl (ByVal IdWB As Dword) As Dword
    
          Dim uDWebBrowserEvents2Vtbl(%maxWebBrowsers - 1) As Static DWebBrowserEvents2Vtbl
          Dim uDWebBrowserEvents2(%maxWebBrowsers - 1)     As Static DWebBrowserEvents2
    
          If uDWebBrowserEvents2(IdWB - 1).lpVtbl = 0 Then
             uDWebBrowserEvents2(IdWB - 1).lpVtbl               = VarPtr(uDWebBrowserEvents2Vtbl(IdWB - 1))
    
             uDWebBrowserEvents2Vtbl(IdWB - 1).AddRef           = CodePtr(DWebBrowserEvents2_AddRef)
             uDWebBrowserEvents2Vtbl(IdWB - 1).Release          = CodePtr(DWebBrowserEvents2_Release)
             uDWebBrowserEvents2Vtbl(IdWB - 1).GetTypeInfoCount = CodePtr(DWebBrowserEvents2_GetTypeInfoCount)
             uDWebBrowserEvents2Vtbl(IdWB - 1).GetTypeInfo      = CodePtr(DWebBrowserEvents2_GetTypeInfo)
             uDWebBrowserEvents2Vtbl(IdWB - 1).GetIDsOfNames    = CodePtr(DWebBrowserEvents2_GetIDsOfNames)
             Select Case As Long IdWB
                Case 1 : uDWebBrowserEvents2Vtbl(IdWB - 1).QueryInterface   = CodePtr(DWebBrowserEvents2_QueryInterface1)
                         uDWebBrowserEvents2Vtbl(IdWB - 1).Invoke           = CodePtr(DWebBrowserEvents2_Invoke1)
                Case 2 : uDWebBrowserEvents2Vtbl(IdWB - 1).QueryInterface   = CodePtr(DWebBrowserEvents2_QueryInterface2)
                         uDWebBrowserEvents2Vtbl(IdWB - 1).Invoke           = CodePtr(DWebBrowserEvents2_Invoke2)
                Case 3 : uDWebBrowserEvents2Vtbl(IdWB - 1).QueryInterface   = CodePtr(DWebBrowserEvents2_QueryInterface3)
                         uDWebBrowserEvents2Vtbl(IdWB - 1).Invoke           = CodePtr(DWebBrowserEvents2_Invoke3)
             End Select
          End If
    
          Function = VarPtr(uDWebBrowserEvents2(IdWB - 1))
    
       End Function
       '--------------------------------------------------------------------------------
    
       Function IOleInPlaceSite_QueryInterface (ByVal This As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          ppVObj = 0: Function = %E_NOINTERFACE
       End Function
    
       Function IOleInPlaceSite_AddRef (ByVal This As Dword) As Dword
          Function = 1
       End Function
    
       Function IOleInPlaceSite_Release (ByVal This As Dword) As Dword
          Function = 1
       End Function
    
       Function IOleInPlaceSite_GetWindow1 (ByVal This As Dword, ByRef hwnd As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          hWnd = @pWebBrowserData[0].hWndIE
    
       End Function
    
       Function IOleInPlaceSite_GetWindow2 (ByVal This As Dword, ByRef hwnd As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          hWnd = @pWebBrowserData[1].hWndIE
    
       End Function
    
       Function IOleInPlaceSite_GetWindow3 (ByVal This As Dword, ByRef hwnd As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          hWnd = @pWebBrowserData[2].hWndIE
    
       End Function
    
       Function IOleInPlaceSite_ContextSensitiveHelp (ByVal This As Dword, ByVal fEnterMode As Long) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleInPlaceSite_CanInPlaceActivate (ByVal This As Dword) As Dword
          Function = %S_OK
       End Function
    
       Function IOleInPlaceSite_OnInPlaceActivate (ByVal This As Dword) As Dword
          Function = %S_OK
       End Function
    
       Function IOleInPlaceSite_OnUIActivate (ByVal This As Dword) As Dword
          Function = %S_OK
       End Function
    
       Function IOleInPlaceSite_GetWindowContext (ByVal This As Dword, ByVal ppFrame As Dword, ppDoc As Dword, rcPosRect As RECT, rcClipRect As RECT, ByVal lpFrameInfo As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleInPlaceSite_Scroll (ByVal This As Dword, ByVal scrollExtantX As Dword, ByVal scrollExtantY As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleInPlaceSite_OnUIDeactivate (ByVal This As Dword, ByVal fUndoable As Long) As Dword
          Function = %S_OK
       End Function
    
       Function IOleInPlaceSite_OnInPlaceDeactivate (ByVal This As Dword) As Dword
          Function = %S_OK
       End Function
    
       Function IOleInPlaceSite_DiscardUndoState (ByVal This As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleInPlaceSite_DeactivateAndUndo (ByVal This As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleInPlaceSite_OnPosRectChange1 (ByVal This As Dword, ByRef rcPosRect As RECT) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
          Dim IID_IOleInPlaceObject                   As Local Guid
          Dim pIOleInPlaceObject                      As Local IOleInPlaceObject Ptr
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          IID_IOleInPlaceObject = $IID_IOleInPlaceObject
    
          Call Dword @pWebBrowserData[0][email protected]@lpVtbl.QueryInterface Using ComFunction2 (ByVal @pWebBrowserData[0].pIOleObject, IID_IOleInPlaceObject, pIOleInPlaceObject)
          Call Dword @[email protected] Using ComFunction2 (ByVal pIOleInPlaceObject, rcPosRect, rcPosRect)
          Call Dword @[email protected] Using ComFunction0 (ByVal pIOleInPlaceObject)
    
       End Function
    
       Function IOleInPlaceSite_OnPosRectChange2 (ByVal This As Dword, ByRef rcPosRect As RECT) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
          Dim IID_IOleInPlaceObject                   As Local Guid
          Dim pIOleInPlaceObject                      As Local IOleInPlaceObject Ptr
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          IID_IOleInPlaceObject = $IID_IOleInPlaceObject
    
          Call Dword @pWebBrowserData[1][email protected]@lpVtbl.QueryInterface Using ComFunction2 (ByVal @pWebBrowserData[1].pIOleObject, IID_IOleInPlaceObject, pIOleInPlaceObject)
          Call Dword @[email protected] Using ComFunction2 (ByVal pIOleInPlaceObject, rcPosRect, rcPosRect)
          Call Dword @[email protected] Using ComFunction0 (ByVal pIOleInPlaceObject)
    
       End Function
    
       Function IOleInPlaceSite_OnPosRectChange3 (ByVal This As Dword, ByRef rcPosRect As RECT) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
          Dim IID_IOleInPlaceObject                   As Local Guid
          Dim pIOleInPlaceObject                      As Local IOleInPlaceObject Ptr
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          IID_IOleInPlaceObject = $IID_IOleInPlaceObject
    
          Call Dword @pWebBrowserData[2][email protected]@lpVtbl.QueryInterface Using ComFunction2 (ByVal @pWebBrowserData[2].pIOleObject, IID_IOleInPlaceObject, pIOleInPlaceObject)
          Call Dword @[email protected] Using ComFunction2 (ByVal pIOleInPlaceObject, rcPosRect, rcPosRect)
          Call Dword @[email protected] Using ComFunction0 (ByVal pIOleInPlaceObject)
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function IOleClientSite_QueryInterface1 (ByVal this As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          Select Case riid
             Case $IID_IOleInPlaceSite  : ppvObj = IOleInPlaceSite_GetVtbl(1) : Function = %S_OK
             Case Else                  : ppVObj = 0                          : Function = %E_NOINTERFACE
          End Select
       End Function
    
       Function IOleClientSite_QueryInterface2 (ByVal this As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          Select Case riid
             Case $IID_IOleInPlaceSite  : ppvObj = IOleInPlaceSite_GetVtbl(2) : Function = %S_OK
             Case Else                  : ppVObj = 0                          : Function = %E_NOINTERFACE
          End Select
       End Function
    
       Function IOleClientSite_QueryInterface3 (ByVal this As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          Select Case riid
             Case $IID_IOleInPlaceSite  : ppvObj = IOleInPlaceSite_GetVtbl(3) : Function = %S_OK
             Case Else                  : ppVObj = 0                          : Function = %E_NOINTERFACE
          End Select
       End Function
    
       Function IOleClientSite_AddRef (ByVal this As Dword) As Dword
          Function = 1
       End Function
    
       Function IOleClientSite_Release (ByVal this As Dword) As Dword
          Function = 1
       End Function
    
       Function IOleClientSite_SaveObject (ByVal this As Dword) As Dword
         Function = %E_NOTIMPL
       End Function
    
       Function IOleClientSite_GetMoniker (ByVal this As Dword, ByVal dwAssign As Dword, ByVal dwWhichMoniker As Dword, ByRef ppmk As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleClientSite_GetContainer (ByVal this As Dword, ByRef ppContainer As Dword) As Dword
         ppContainer = 0: Function = %E_NOINTERFACE
       End Function
    
       Function IOleClientSite_ShowObject (ByVal this As Dword) As Dword
          Function = %NOERROR
       End Function
    
       Function IOleClientSite_OnShowWindow (ByVal this As Dword, ByVal fShow As Integer) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function IOleClientSite_RequestNewObjectLayout (ByVal this As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function DWebBrowserEvents2_QueryInterface1 (ByVal pUnk As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          Select Case riid
             Case $DIID_DWebBrowserEvents2 : ppvObj = DWebBrowserEvents2_GetVtbl(1): Function = %S_OK
             Case Else                     : Function = %E_NOTIMPL
          End Select
       End Function
    
       Function DWebBrowserEvents2_QueryInterface2 (ByVal pUnk As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          Select Case riid
             Case $DIID_DWebBrowserEvents2 : ppvObj = DWebBrowserEvents2_GetVtbl(2): Function = %S_OK
             Case Else                     : Function = %E_NOTIMPL
          End Select
       End Function
    
       Function DWebBrowserEvents2_QueryInterface3 (ByVal pUnk As Dword, ByRef riid As Guid, ByRef ppvObj As Dword) As Dword
          Select Case riid
             Case $DIID_DWebBrowserEvents2 : ppvObj = DWebBrowserEvents2_GetVtbl(3): Function = %S_OK
             Case Else                     : Function = %E_NOTIMPL
          End Select
       End Function
    
       Function DWebBrowserEvents2_AddRef (ByVal pUnk As Dword) As Dword
          Function = 1
       End Function
    
       Function DWebBrowserEvents2_Release (ByVal pUnk As Dword) As Dword
          Function = 1
       End Function
    
       Function DWebBrowserEvents2_GetTypeInfoCount (ByVal pUnk As Dword, ByRef pctInfo As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function DWebBrowserEvents2_GetTypeInfo (ByVal pUnk As Dword, ByVal iTinfo As Dword, ByVal lcid As Dword, ByRef pptinfo As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       Function DWebBrowserEvents2_GetIDsOfNames (ByVal pUnk As Dword, ByRef riid As Guid, ByVal rgszNames As Dword, ByVal cNames As Dword, ByVal lcid As Dword, ByRef rgdispid As Dword) As Dword
          Function = %E_NOTIMPL
       End Function
    
       %UM_DISPLAYSTRING = %WM_USER + 401
    
       Function DWebBrowserEvents2_Invoke1 (ByVal pUnk As Dword, ByVal dispidMember As Dword, ByRef riid As Guid, _
          ByVal lcid As Dword, ByVal wFlags As Word, ByRef pDispparams As DispParams, ByRef pvarResult As Variant, _
          ByVal pexcepinfo As Dword, ByRef puArgErr As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
    
          Dim pVariant                                As Variant Ptr
          Dim pVariantApi                             As VariantApi Ptr
          Dim szUrl                                   As Local String
          Dim i                                       As Local Dword
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          pVariant = pdispparams.VariantArgs
          pVariantApi = pVariant
    
          Function = %S_OK
    
          If VarPtr(pdispparams) Then
             Select Case As Long dispidMember
                Case %DISPID_BEFORENAVIGATE2 ' BeforeNavigate2
                   szURL = Variant$(@pVariant[5])
                   i = InStr(szUrl, "{")
                   If i Then
                      @[email protected] = -1
                      PostMessage @pWebBrowserData[0].hWndParent, %UM_DISPLAYSTRING, Val(Mid$(szUrl, i + 1)), 1
                    End If
             End Select
          End If
    
       End Function
    
    
       Function DWebBrowserEvents2_Invoke2 (ByVal pUnk As Dword, ByVal dispidMember As Dword, ByRef riid As Guid, _
          ByVal lcid As Dword, ByVal wFlags As Word, ByRef pDispparams As DispParams, ByRef pvarResult As Variant, _
          ByVal pexcepinfo As Dword, ByRef puArgErr As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
    
          Dim pVariant                                As Variant Ptr
          Dim pVariantApi                             As VariantApi Ptr
          Dim szUrl                                   As Local String
          Dim i                                       As Local Dword
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          pVariant = pdispparams.VariantArgs
          pVariantApi = pVariant
    
          Function = %S_OK
    
          If VarPtr(pdispparams) Then
             Select Case As Long dispidMember
                Case %DISPID_BEFORENAVIGATE2 ' BeforeNavigate2
                   szURL = Variant$(@pVariant[5])
                   i = InStr(szUrl, "{")
                   If i Then
                      @[email protected] = -1
                      PostMessage @pWebBrowserData[1].hWndParent, %UM_DISPLAYSTRING, Val(Mid$(szUrl, i + 1)), 2
                    End If
             End Select
          End If
    
       End Function
    
       Function DWebBrowserEvents2_Invoke3 (ByVal pUnk As Dword, ByVal dispidMember As Dword, ByRef riid As Guid, _
          ByVal lcid As Dword, ByVal wFlags As Word, ByRef pDispparams As DispParams, ByRef pvarResult As Variant, _
          ByVal pexcepinfo As Dword, ByRef puArgErr As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
    
          Dim pVariant                                As Variant Ptr
          Dim pVariantApi                             As VariantApi Ptr
          Dim szUrl                                   As Local String
          Dim i                                       As Local Dword
    
          pWebBrowserData = StrPtr(szWebBrowserData)
          pVariant = pdispparams.VariantArgs
          pVariantApi = pVariant
    
          Function = %S_OK
    
          If VarPtr(pdispparams) Then
             Select Case As Long dispidMember
                Case %DISPID_BEFORENAVIGATE2 ' BeforeNavigate2
                   szURL = Variant$(@pVariant[5])
                   i = InStr(szUrl, "{")
                   If i Then
                      @[email protected] = -1
                      PostMessage @pWebBrowserData[2].hWndParent, %UM_DISPLAYSTRING, Val(Mid$(szUrl, i + 1)), 3
                    End If
             End Select
          End If
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function DisplayHTMLPage (ByVal IdWB As Dword, szUrl As Asciiz) As Dword ' If success, returns %S_OK
    
          Dim hResult                                As Local  Dword
          Dim vtUrl                                  As Local  Variant
          Dim vtFlags                                As Local  Variant
          Dim vtTargetFrameName                      As Local  Variant
          Dim vtPostData                             As Local  Variant
          Dim vtHeaders                              As Local  Variant
          Dim pWebBrowserData                        As Local  WebBrowserData Ptr
          
          pWebBrowserData = StrPtr(szWebBrowserData)
          vtUrl = szUrl
    
          Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.Navigate2 Using ComFunction5 (ByVal @pWebBrowserData[IdWB - 1].pIWebBrowser2, vtUrl, vtFlags, vtTargetFrameName, vtPostData, vtHeaders) To hResult
    
          Function = hResult
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function DisplayHtmlString (ByVal IdWB As Dword, szTxt As String) As Dword
    
          Dim pWebBrowserData                         As Local  WebBrowserData Ptr
          Dim f                                       As Local  Dword
    
          pWebBrowserData = StrPtr(szWebBrowserData)
    
          f = FreeFile
          Open @pWebBrowserData[IdWB - 1].szTmpHtmlFile For Output As #f Len = 32768
          Print #f, szTxt;
          Close #f
    
          DisplayHtmlPage IdWB, @pWebBrowserData[IdWB - 1].szTmpHtmlFile
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function ResizeBrowser (ByVal IdWB As Dword, ByVal dwWidth As Dword, dwHeight As Dword) As Dword
    
          Dim pWebBrowserData                         As Local  WebBrowserData Ptr
          Dim hResult                                 As Local  Dword
    
          pWebBrowserData = StrPtr(szWebBrowserData)
    
    
          Do
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.put_Left   Using ComFunction1 (ByVal @pWebBrowserData[IdWB - 1].pIWebBrowser2, ByVal 0) To hResult       : If hResult <> %S_OK Then Exit Do
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.put_Top    Using ComFunction1 (ByVal @pWebBrowserData[IdWB - 1].pIWebBrowser2, ByVal 0) To hResult       : If hResult <> %S_OK Then Exit Do
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.put_Width  Using ComFunction1 (ByVal @pWebBrowserData[IdWB - 1].pIWebBrowser2, ByVal dwWidth) To hResult : If hResult <> %S_OK Then Exit Do
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.put_Height Using ComFunction1 (ByVal @pWebBrowserData[IdWB - 1].pIWebBrowser2, ByVal dwHeight) To hResult: If hResult <> %S_OK Then Exit Do
             Exit Do
          Loop
    
          Function = hResult
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function EmbedBrowserObject (ByVal IdWB As Dword, ByVal hDlg As Dword, ByVal IdIE As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
          Dim nCalls                                  As Static Dword
          Dim CLSID_WebBrowser                        As Local  Guid
          Dim IID_IOleObject                          As Local  Guid
          Dim IID_IWebBrowser2                        As Local  Guid
          Dim DIID_DWebBrowserEvents2                 As Local  Guid
          Dim IID_IConnectionPointContainer           As Local  Guid
          Dim hResult                                 As Local  Dword
          Dim rc                                      As Local  RECT
          Dim Er                                      As Local  Dword
          Dim szPath                                  As Asciiz * %MAX_PATH
    
          If Len(szWebBrowserData) = 0 Then szWebBrowserData = String$(%maxWebBrowsers * SizeOf(WebBrowserData), 0)
          pWebBrowserData = StrPtr(szWebBrowserData)
    
          CLSID_WebBrowser              = $CLSID_WebBrowser
          IID_IOleObject                = $IID_IOleObject
          IID_IWebBrowser2              = $IID_IWebBrowser2
          DIID_DWebBrowserEvents2       = $DIID_DWebBrowserEvents2
          IID_IConnectionPointContainer = $IID_IConnectionPointContainer
    
          @pWebBrowserData[IdWB - 1].hWndParent = hDlg
          @pWebBrowserData[IdWB - 1].hWndIE     = GetDlgItem(hDlg, IdIE)
          GetModuleFileName GetModuleHandle(""), szPath, SizeOf(szPath)
          Incr nCalls: @pWebBrowserData[IdWB - 1].szTmpHtmlFile = Left$(szPath, InStr(-1, szPath, "\")) + "~" + Format$(nCalls) + ".htm"
    
          Do
             hResult = CoCreateInstance(CLSID_WebBrowser, ByVal 0, ByVal %CLSCTX_INPROC, IID_IOleObject, @pWebBrowserData[IdWB - 1].pIOleObject)
             If hResult <> %S_OK Then @pWebBrowserData[IdWB - 1].pIOleObject = 0: Er = 1: Exit Do
    
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.QueryInterface Using ComFunction2 (ByVal @pWebBrowserData[IdWB - 1].pIOleObject, IID_IWebBrowser2, @pWebBrowserData[IdWB - 1].pIWebBrowser2) To hResult
             If hResult <> %S_OK Then @pWebBrowserData[IdWB - 1].pIWebBrowser2 = 0: Er = 1: Exit Do
    
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.QueryInterface Using ComFunction2 (ByVal @pWebBrowserData[IdWB - 1].pIOleObject, IID_IConnectionPointContainer, @pWebBrowserData[IdWB - 1].pIConnectionPointContainer) To hResult
             If hResult <> %S_OK Then @pWebBrowserData[IdWB - 1].pIConnectionPointContainer = 0: Er = 1: Exit Do
    
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.FindConnectionPoint Using ComFunction2 (ByVal @pWebBrowserData[IdWB - 1].pIConnectionPointContainer, DIID_DWebBrowserEvents2, _
                @pWebBrowserData[IdWB - 1].pIConnectionPoint) To hResult
             If hResult <> %S_OK Then @pWebBrowserData[IdWB - 1].pIConnectionPoint = 0: Er = 1: Exit Do
    
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.Advise Using ComFunction2 (ByVal @pWebBrowserData[IdWB - 1].pIConnectionPoint, ByVal DWebBrowserEvents2_GetVtbl(IdWB), @pWebBrowserData[IdWB - 1].dwCookie) To hResult
             If hResult <> %S_OK Then @pWebBrowserData[IdWB - 1].dwCookie = 0: Er = 1: Exit Do
    
             @pWebBrowserData[IdWB - 1].pIOleClientSite = IOleClientSite_GetVtbl(IdWB)
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.SetClientSite Using ComFunction1 (ByVal @pWebBrowserData[IdWB - 1].pIOleObject, ByVal @pWebBrowserData[IdWB - 1].pIOleClientSite) To HResult
    
             GetClientRect @pWebBrowserData[IdWB - 1].hWndIE, rc
             Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.DoVerb Using ComFunction6 (ByVal @pWebBrowserData[IdWB - 1].pIOleObject, _
                ByVal %OLEIVERB_INPLACEACTIVATE, @pWebBrowserData[IdWB - 1].Msg, ByVal @pWebBrowserData[IdWB - 1].pIOleClientSite, ByVal 0, ByVal @pWebBrowserData[IdWB - 1].hWndIE, rc) To hResult
             If hResult <> %S_OK Then Er = 1: Exit Do
    
             Exit Do
          Loop
    
          Function = Er
    
       End Function
    
       Function UnEmbedBrowserObject (ByVal IdWB As Dword) As Dword
    
          Dim pWebBrowserData                         As Local WebBrowserData Ptr
          Dim hResult                                 As Local Dword
    
          pWebBrowserData = StrPtr(szWebBrowserData)
    
          If @pWebBrowserData[IdWB - 1].dwCookie                   Then Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.UnAdvise         Using ComFunction1 _
             (ByVal @pWebBrowserData[IdWB - 1].pIConnectionPoint, ByVal @pWebBrowserData[IdWB - 1].dwCookie) To hResult: @pWebBrowserData[IdWB - 1].dwCookie = 0
          If @pWebBrowserData[IdWB - 1].pIConnectionPoint          Then Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.Release          Using ComFunction0 _
             (ByVal @pWebBrowserData[IdWB - 1].pIConnectionPoint) To hResult                    : @pWebBrowserData[IdWB - 1].pIConnectionPoint = 0
          If @pWebBrowserData[IdWB - 1].pIConnectionPointContainer Then Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.Release Using ComFunction0 _
             (ByVal @pWebBrowserData[IdWB - 1].pIConnectionPointContainer) To hResult           : @pWebBrowserData[IdWB - 1].pIConnectionPointContainer = 0
          If @pWebBrowserData[IdWB - 1].pIOleObject                Then Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.Release                Using ComFunction0 _
             (ByVal @pWebBrowserData[IdWB - 1].pIOleObject) To hResult                          : @pWebBrowserData[IdWB - 1].pIOleObject = 0
          If @pWebBrowserData[IdWB - 1].pIWebBrowser2              Then Call Dword @pWebBrowserData[IdWB - 1][email protected]@lpVtbl.Release              Using ComFunction0 _
             (ByVal @pWebBrowserData[IdWB - 1].pIWebBrowser2) To hResult                        : @pWebBrowserData[IdWB - 1].pIWebBrowser2 = 0
          Kill @pWebBrowserData[IdWB - 1].szTmpHtmlFile
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       Function MakeHtmlPage (ByVal PageId As Dword) As String
    
          Select Case As Long PageId
             Case 1 : Function = "<center><b>Popular web sites</b></center><br><br>" + $CrLf + _
                                 "<a href=""{2}"">Power Basic</a></a>.<br>" + $CrLf + _
                                 "<a href=""{3}"">The rest"
             Case 2 : Function = "<a href=""{4}"">Microsoft</a></a>.<br>" + $CrLf + _
                                 "<a href=""{5}"">Altavista</a></a>.<br>" + $CrLf + _
                                 "<p align=right><a href=""{6}"">Back</a></a>.</p>"
          End Select
    
       End Function
    
       '--------------------------------------------------------------------------------
    
       %ID_IE1                                        =  101
       %ID_IE2                                        =  102
       %ID_PREVIEW                                    =  201
       %ID_PRINT                                      =  202
       %ID_SAVEAS                                     =  203
    
       CallBack Function DlgProc
    
          Dim dlgWidth                                As Local  Dword
          Dim dlgHeight                               As Local  Dword
          Dim rc                                      As Local  RECT
          Dim pWebBrowserData                         As Local  WebBrowserData Ptr
    
          Select Case CbMsg
             Case %WM_INITDIALOG
                Control Add Label,  CbHndl, %ID_IE1, "",                  5,  5, 50, 50, %SS_SUNKEN
                Control Add Label,  CbHndl, %ID_IE2, "",                  5, 55, 50, 90, %SS_SUNKEN
                Control Add Button, CbHndl, %ID_PREVIEW, "Preview",     145, 30, 45, 15
                Control Add Button, CbHndl, %ID_PRINT,   "Print",       145, 50, 45, 15
                Control Add Button, CbHndl, %ID_SAVEAS,  "Save as ...", 145, 70, 45, 15
    
                If EmbedBrowserObject (1, CbHndl, %ID_IE1) Or EmbedBrowserObject (2, CbHndl, %ID_IE2) Then _
                   Dialog Post CbHndl, %WM_SYSCOMMAND, %SC_CLOSE, 0: Exit Function
                
                DisplayHtmlPage 1, "http://www.powerbasic.com"
                DisplayHtmlString 2, MakeHtmlPage(1)
                Dialog Show State CbHndl, %SW_MAXIMIZE
    
             Case %WM_SIZE
                Dialog Get Client CbHndl To dlgWidth, dlgHeight
                If dlgHeight < 150 Or dlgWidth < 200 Then Exit Function
    
                Control Set Size CbHndl, %ID_IE1,     dlgWidth - 60, dlgHeight - 100
                Control Set Loc  CbHndl, %ID_IE2,     5,             dlgHeight - 95
                Control Set Size CbHndl, %ID_IE2,     dlgWidth - 60, 90
                Control Set Loc  CbHndl, %ID_PREVIEW, dlgWidth - 50, 30
                Control Set Loc  CbHndl, %ID_PRINT,   dlgWidth - 50, 50
                Control Set Loc  CbHndl, %ID_SAVEAS,  dlgWidth - 50, 70
    
                GetClientRect GetDlgItem(CbHndl, %ID_IE1), rc
                ResizeBrowser 1, rc.nRight, rc.nBottom
                GetClientRect GetDlgItem(CbHndl, %ID_IE2), rc
                ResizeBrowser 2, rc.nRight, rc.nBottom
    
             Case %UM_DISPLAYSTRING
                Select Case As Long CbWParam
                   Case 2 : DisplayHtmlPage 1, "http://www.powerbasic.com/support/forums/Ultimate.cgi"
                   Case 3 : DisplayHtmlString 2, MakeHtmlPage(2)
                   Case 4 : DisplayHtmlPage 1, "http://www.microsoft.com"
                   Case 5 : DisplayHtmlPage 1, "http://www.av.com"
                   Case 6 : DisplayHtmlString 2, MakeHtmlPage(1)
                End Select
             
             Case %WM_COMMAND
                pWebBrowserData = StrPtr(szWebBrowserData)
    
                Select Case As Long CbCtl
                    Case %ID_PRINT
                       Select Case As Long CbCtlMsg
                         Case %BN_CLICKED, 1
                            Call Dword @pWebBrowserData[0][email protected]@lpVtbl.ExecWB Using ComFunction4 (ByVal @pWebBrowserData[0].pIWebBrowser2, ByVal %OLECMDID_PRINT, ByVal 0, ByVal 0, ByVal 0)
                       End Select
    
                    Case %ID_PREVIEW
                       Select Case As Long CbCtlMsg
                          Case %BN_CLICKED, 1
                             Call Dword @pWebBrowserData[0][email protected]@lpVtbl.ExecWB Using ComFunction4 (ByVal @pWebBrowserData[0].pIWebBrowser2, ByVal %OLECMDID_PRINTPREVIEW, ByVal 0, ByVal 0, ByVal 0)
                       End Select
    
                    Case %ID_SAVEAS
                       Select Case As Long CbCtlMsg
                          Case %BN_CLICKED, 1
                             Call Dword @pWebBrowserData[0][email protected]@lpVtbl.ExecWB Using ComFunction4 (ByVal @pWebBrowserData[0].pIWebBrowser2, ByVal %OLECMDID_SAVEAS, ByVal 0, ByVal 0, ByVal 0)
                       End Select
                End Select
    
            Case %WM_DESTROY
                UnEmbedBrowserObject 1
                UnEmbedBrowserObject 2
         End Select
    
      End Function
    
      Function PBMain
    
          Dim hDlg                                   As Local  Dword
    
          Dialog New 0, " WebBrowser Experiment ", , , 300, 200, %WS_OVERLAPPEDWINDOW Or %DS_MODALFRAME Or %WS_CLIPSIBLINGS To hDlg
          Dialog Show State hDlg, %SW_HIDE
          Dialog Show Modal hDlg Call DlgProc
    
       End Function

    ------------------

  • #2
    Declarations for COM interfaces (ComObj.Inc)

    Code:
       '--- IDispatch interface ---
    
       Type IDispatchVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
          GetTypeInfoCount                            As Dword
          GetTypeInfo                                 As Dword
          GetIDsOfNames                               As Dword
          Invoke                                      As Dword
       End Type
    
       Type IDispatchApi
          lpVtbl                                      As IDispatchVtbl Ptr
       End Type
    
    
       '--- IOleObject interface ---
    
       $IID_IOleObject                                = Guid$("{00000112-0000-0000-C000-000000000046}")
    
       Type IOleObjectVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
    
          SetClientSite                               As Dword
          GetClientSite                               As Dword
          SetHostNames                                As Dword
          Close_                                      As Dword
          SetMoniker                                  As Dword
          GetMoniker                                  As Dword
          InitFromData                                As Dword
          GetClipboardData                            As Dword
          DoVerb                                      As Dword
          EnumVerbs                                   As Dword
          Update                                      As Dword
          IsUpToDate                                  As Dword
          GetUserClassID                              As Dword
          GetUserType                                 As Dword
          SetExtent                                   As Dword
          GetExtent                                   As Dword
          Advise                                      As Dword
          Unadvise                                    As Dword
          EnumAdvise                                  As Dword
          GetMiscStatus                               As Dword
          SetColorScheme                              As Dword
       End Type
    
       Type IOleObject
          lpVtbl                                      As IOleObjectVtbl Ptr
       End Type
    
       '--- IOleClientSite inteface ---
    
       $IID_IOleClientSite                            = Guid$("{00000118-0000-0000-C000-000000000046}")
    
       Type IOleClientSiteVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
          SaveObject                                  As Dword
          GetMoniker                                  As Dword
          GetContainer                                As Dword
          ShowObject                                  As Dword
          OnShowWindow                                As Dword
          RequestNewObjectLayout                      As Dword
       End Type
    
       Type IOleClientSite
          lpVtbl                                      As IOleClientSiteVtbl Ptr
       End Type
    
       '--- IOleInPlaceSite interface ---
    
       $IID_IOleInPlaceSite                           = Guid$("{00000119-0000-0000-C000-000000000046}")
    
       Type IOleInPlaceSiteVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
          GetWindow                                   As Dword
          ContextSensitiveHelp                        As Dword
          CanInPlaceActivate                          As Dword
          OnInPlaceActivate                           As Dword
          OnUIActivate                                As Dword
          GetWindowContext                            As Dword
          Scroll                                      As Dword
          OnUIDeactivate                              As Dword
          OnInPlaceDeactivate                         As Dword
          DiscardUndoState                            As Dword
          DeactivateAndUndo                           As Dword
          OnPosRectChange                             As Dword
       End Type
    
       Type IOleInPlaceSite
          lpVtbl                                      As IOleInPlaceSiteVtbl Ptr
       End Type
    
       '--- IOleInPlaceObject interface ---
    
       $IID_IOleInPlaceObject                         = Guid$("{00000113-0000-0000-C000-000000000046}")
    
       Type IOleInPlaceObjectVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
          GetWindow                                   As Dword
          ContextSensitiveHelp                        As Dword
          InPlaceDeactivate                           As Dword
          UIDeactivate                                As Dword
          SetObjectRects                              As Dword
          ReactivateAndUndo                           As Dword
       End Type
    
       Type IOleInPlaceObject
          lpVtbl As IOleInPlaceObjectVtbl Ptr
       End Type
    
       ' --- OLEIVERB constants ---
    
       %OLEIVERB_PRIMARY                              =  0&
       %OLEIVERB_SHOW                                 = -1&
       %OLEIVERB_OPEN                                 = -2&
       %OLEIVERB_HIDE                                 = -3&
       %OLEIVERB_UIACTIVATE                           = -4&
       %OLEIVERB_INPLACEACTIVATE                      = -5&
       %OLEIVERB_DISCARDUNDOSTATE                     = -6&
    
       '--- OLECMDID constants ---
       %OLECMDID_OPEN                                 = 1
       %OLECMDID_NEW                                  = 2
       %OLECMDID_SAVE                                 = 3
       %OLECMDID_SAVEAS                               = 4
       %OLECMDID_SAVECOPYAS                           = 5
       %OLECMDID_PRINT                                = 6
       %OLECMDID_PRINTPREVIEW                         = 7
       %OLECMDID_PAGESETUP                            = 8
       %OLECMDID_SPELL                                = 9
       %OLECMDID_PROPERTIES                           = 10
       %OLECMDID_CUT                                  = 11
       %OLECMDID_COPY                                 = 12
       %OLECMDID_PASTE                                = 13
       %OLECMDID_PASTESPECIAL                         = 14
       %OLECMDID_UNDO                                 = 15
       %OLECMDID_REDO                                 = 16
       %OLECMDID_SELECTALL                            = 17
       %OLECMDID_CLEARSELECTION                       = 18
       %OLECMDID_ZOOM                                 = 19
       %OLECMDID_GETZOOMRANGE                         = 20
       %OLECMDID_UPDATECOMMANDS                       = 21
       %OLECMDID_REFRESH                              = 22
       %OLECMDID_STOP                                 = 23
       %OLECMDID_HIDETOOLBARS                         = 24
       %OLECMDID_SETPROGRESSMAX                       = 25
       %OLECMDID_SETPROGRESSPOS                       = 26
       %OLECMDID_SETPROGRESSTEXT                      = 27
       %OLECMDID_SETTITLE                             = 28
       %OLECMDID_SETDOWNLOADSTATE                     = 29
       %OLECMDID_STOPDOWNLOAD                         = 30
       %OLECMDID_ONTOOLBARACTIVATED                   = 31
       %OLECMDID_FIND                                 = 32
       %OLECMDID_DELETE                               = 33
       %OLECMDID_HTTPEQUIV                            = 34
       %OLECMDID_HTTPEQUIV_DONE                       = 35
       %OLECMDID_ENABLE_INTERACTION                   = 36
       %OLECMDID_ONUNLOAD                             = 37
       %OLECMDID_PROPERTYBAG2                         = 38
       %OLECMDID_PREREFRESH                           = 39
       %OLECMDID_SHOWSCRIPTERROR                      = 40
       %OLECMDID_SHOWMESSAGE                          = 41
       %OLECMDID_SHOWFIND                             = 42
       %OLECMDID_SHOWPAGESETUP                        = 43
       %OLECMDID_SHOWPRINT                            = 44
       %OLECMDID_CLOSE                                = 45
       %OLECMDID_ALLOWUILESSSAVEAS                    = 46
       %OLECMDID_DONTDOWNLOADCSS                      = 47
       %OLECMDID_UPDATEPAGESTATUS                     = 48
       %OLECMDID_PRINT2                               = 49
       %OLECMDID_PRINTPREVIEW2                        = 50
       %OLECMDID_SETPRINTTEMPLATE                     = 51
       %OLECMDID_GETPRINTTEMPLATE                     = 52
    
       '--- IConnectionPointContainer interface ---
    
       $IID_IConnectionPointContainer                 = Guid$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
    
       Type IConnectionPointContainerVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
    
          EnumConnectionPoints                        As Dword
          FindConnectionPoint                         As Dword
       End Type
    
       Type IConnectionPointContainer
          lpVtbl                                      As IConnectionPointContainerVtbl Ptr
       End Type
    
       '--- IConnectionPoint interface ---
    
       Type IConnectionPointVtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
    
          GetConnectionInterface                      As Dword
          GetConnectionPointContainer                 As Dword
          Advise                                      As Dword
          Unadvise                                    As Dword
          EnumConnections                             As Dword
       End Type
    
       Type IConnectionPoint
          lpVtbl                                      As IConnectionPointVtbl Ptr
       End Type
    
       '--- IWebBrowser2 interface ---
    
       $CLSID_WebBrowser                              = Guid$("{8856F961-340A-11D0-A96B-00C04FD705A2}")
       $IID_IWebBrowser2                              = Guid$("{D30C1661-CDAF-11d0-8A3E-00C04FC9E26E}")
    
       Type IWebBrowser2Vtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
    
          GetTypeInfoCount                            As Dword
          GetTypeInfo                                 As Dword
          GetIDsOfNames                               As Dword
          Invoke                                      As Dword
    
          GoBack                                      As Dword
          GoForward                                   As Dword
          GoHome                                      As Dword
          GoSearch                                    As Dword
          Navigate                                    As Dword
          Refresh                                     As Dword
          Refresh2                                    As Dword
          Stop                                        As Dword
          get_Application                             As Dword
          get_Parent                                  As Dword
          get_Container                               As Dword
          get_Document                                As Dword
          get_TopLevelContainer                       As Dword
          get_Type                                    As Dword
          get_Left                                    As Dword
          put_Left                                    As Dword
          get_Top                                     As Dword
          put_Top                                     As Dword
          get_Width                                   As Dword
          put_Width                                   As Dword
          get_Height                                  As Dword
          put_Height                                  As Dword
          get_LocationName                            As Dword
          get_LocationURL                             As Dword
          get_Busy                                    As Dword
          Quit                                        As Dword
          ClientToWindow                              As Dword
          PutProperty                                 As Dword
          GetProperty                                 As Dword
          get_Name                                    As Dword
          get_HWND                                    As Dword
          get_FullName                                As Dword
          get_Path                                    As Dword
          get_Visible                                 As Dword
          put_Visible                                 As Dword
          get_StatusBar                               As Dword
          put_StatusBar                               As Dword
          get_StatusText                              As Dword
          put_StatusText                              As Dword
          get_ToolBar                                 As Dword
          put_ToolBar                                 As Dword
          get_MenuBar                                 As Dword
          put_MenuBar                                 As Dword
          get_FullScreen                              As Dword
          put_FullScreen                              As Dword
          Navigate2                                   As Dword
          QueryStatusWB                               As Dword
          ExecWB                                      As Dword
          ShowBrowserBar                              As Dword
          get_ReadyState                              As Dword
          get_Offline                                 As Dword
          put_Offline                                 As Dword
          get_Silent                                  As Dword
          put_Silent                                  As Dword
          get_RegisterAsBrowser                       As Dword
          put_RegisterAsBrowser                       As Dword
          get_RegisterAsDropTarget                    As Dword
          put_RegisterAsDropTarget                    As Dword
          get_TheaterMode                             As Dword
          put_TheaterMode                             As Dword
          get_AddressBar                              As Dword
          put_AddressBar                              As Dword
          get_Resizable                               As Dword
          put_Resizable                               As Dword
       End Type
    
       Type IWebBrowser2
          lpVtbl                                      As IWebBrowser2Vtbl Ptr
       End Type
    
      '--- DWebBrowser2Events ---
    
       $DIID_DWebBrowserEvents2                       = Guid$("{34A715A0-6587-11D0-924A-0020AFC7AC4D}")
    
       Type DWebBrowserEvents2Vtbl
          QueryInterface                              As Dword
          AddRef                                      As Dword
          Release                                     As Dword
    
          GetTypeInfoCount                            As Dword
          GetTypeInfo                                 As Dword
          GetIDsOfNames                               As Dword
          Invoke                                      As Dword
       End Type
    
       Type DWebBrowserEvents2
          lpVtbl                                      As DWebBrowserEvents2Vtbl Ptr
       End Type
    
      '--- Dispatch IDS for IExplorer Dispatch Events ---
       %DISPID_BEFORENAVIGATE                         = 100 ' this is sent before navigation to give a chance to abort
       %DISPID_NAVIGATECOMPLETE                       = 101 ' in async, this is sent when we have enough to show
       %DISPID_STATUSTEXTCHANGE                       = 102
       %DISPID_QUIT                                   = 103
       %DISPID_DOWNLOADCOMPLETE                       = 104
       %DISPID_COMMANDSTATECHANGE                     = 105
       %DISPID_DOWNLOADBEGIN                          = 106
       %DISPID_NEWWINDOW                              = 107 ' sent when a new window should be created
       %DISPID_PROGRESSCHANGE                         = 108 ' sent when download progress is updated
       %DISPID_WINDOWMOVE                             = 109 ' sent when main window has been moved
       %DISPID_WINDOWRESIZE                           = 110 ' sent when main window has been sized
       %DISPID_WINDOWACTIVATE                         = 111 ' sent when main window has been activated
       %DISPID_PROPERTYCHANGE                         = 112 ' sent when the PutProperty method is called
       %DISPID_TITLECHANGE                            = 113 ' sent when the document title changes
       %DISPID_TITLEICONCHANGE                        = 114 ' sent when the top level window icon may have changed.
    
       %DISPID_FRAMEBEFORENAVIGATE                    = 200
       %DISPID_FRAMENAVIGATECOMPLETE                  = 201
       %DISPID_FRAMENEWWINDOW                         = 204
    
       %DISPID_BEFORENAVIGATE2                        = 250 '  // hyperlink clicked on
       %DISPID_NEWWINDOW2                             = 251
       %DISPID_NAVIGATECOMPLETE2                      = 252 ' UIActivate new document
       %DISPID_ONQUIT                                 = 253 '
       %DISPID_ONVISIBLE                              = 254 ' sent when the window goes visible/hidden
       %DISPID_ONTOOLBAR                              = 255 ' sent when the toolbar should be shown/hidden
       %DISPID_ONMENUBAR                              = 256 ' sent when the menubar should be shown/hidden
       %DISPID_ONSTATUSBAR                            = 257 ' sent when the statusbar should be shown/hidden
       %DISPID_ONFULLSCREEN                           = 258 ' sent when kiosk mode should be on/off
       %DISPID_DOCUMENTCOMPLETE                       = 259 ' new document goes ReadyState_Complete
       %DISPID_ONTHEATERMODE                          = 260 ' sent when theater mode should be on/off
       %DISPID_ONADDRESSBAR                           = 261 ' sent when the address bar should be shown/hidden
       %DISPID_WINDOWSETRESIZABLE                     = 262 ' sent to set the style of the host window frame
       %DISPID_WINDOWCLOSING                          = 263 ' sent before script window.close closes the window
       %DISPID_WINDOWSETLEFT                          = 264 ' sent when the put_left method is called on the WebOC
       %DISPID_WINDOWSETTOP                           = 265 ' sent when the put_top method is called on the WebOC
       %DISPID_WINDOWSETWIDTH                         = 266 ' sent when the put_width method is called on the WebOC
       %DISPID_WINDOWSETHEIGHT                        = 267 ' sent when the put_height method is called on the WebOC
       %DISPID_CLIENTTOHOSTWINDOW                     = 268 ' sent during window.open to request conversion of dimensions
       %DISPID_SETSECURELOCKICON                      = 269 ' sent to suggest the appropriate security icon to show
       %DISPID_FILEDOWNLOAD                           = 270 ' Fired to indicate the File Download dialog is opening
       %DISPID_NAVIGATEERROR                          = 271 ' Fired to indicate the a binding error has occured
       %DISPID_PRIVACYIMPACTEDSTATECHANGE             = 272 ' Fired when the user's browsing experience is impacted
    
       '--- CLSCTX constants ---
    
       %CLSCTX_INPROC_SERVER                          = &H00001
       %CLSCTX_INPROC_HANDLER                         = &H00002
       %CLSCTX_LOCAL_SERVER                           = &H00004
       %CLSCTX_INPROC_SERVER16                        = &H00008
       %CLSCTX_REMOTE_SERVER                          = &H00010
       %CLSCTX_INPROC_HANDLER16                       = &H00020
       %CLSCTX_INPROC_SERVERX86                       = &H00040
       %CLSCTX_INPROC_HANDLERX86                      = &H00080
       %CLSCTX_ESERVER_HANDLER                        = &H00100
       %CLSCTX_RESERVED                               = &H00200
       %CLSCTX_NO_CODE_DOWNLOAD                       = &H00400
       %CLSCTX_NO_WX86_TRANSLATION                    = &H00800
       %CLSCTX_NO_CUSTOM_MARSHAL                      = &H01000
       %CLSCTX_ENABLE_CODE_DOWNLOAD                   = &H02000
       %CLSCTX_NO_FAILURE_LOG                         = &H04000
       %CLSCTX_DISABLE_AAA                            = &H08000
       %CLSCTX_ENABLE_AAA                             = &H10000
       %CLSCTX_FROM_DEFAULT_CONTEXT                   = &H20000
    
       %CLSCTX_INPROC                                 = %CLSCTX_INPROC_SERVER Or %CLSCTX_INPROC_HANDLER
    '------------------------------------------------------------------------------------------
    
       Declare Function ComFunction0                  (Any)                               As Dword
       Declare Function ComFunction1                  (Any, Any)                          As Dword
       Declare Function ComFunction2                  (Any, Any, Any)                     As Dword
       Declare Function ComFunction3                  (Any, Any, Any, Any)                As Dword
       Declare Function ComFunction4                  (Any, Any, Any, Any, Any)           As Dword
       Declare Function ComFunction5                  (Any, Any, Any, Any, Any, Any)      As Dword
       Declare Function ComFunction6                  (Any, Any, Any, Any, Any, Any, Any) As Dword

    ------------------

    Comment

    Working...
    X