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 wrapper functions

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

  • WebBrowser wrapper functions

    These wrapper functions allow to embed the WebBrowser control in your dialog, sink to the events fired by the control and customize his behavior.

    At the end of the post you will find a minibrowser example that shows how to use the wrappers.

    If you have comments or questions start a new thread in the PowerBasic forum. Don't post them here, please.
    Last edited by José Roca; 30 Aug 2007, 06:34 PM.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

  • #2
    Save as IEWB2.INC
    Code:
    ' ********************************************************************************************
    ' Library name: SHDocVw
    ' Version: 1.1
    ' Documentation string: Microsoft Internet Controls
    ' Path: D:\WINDOWS\system32\shdocvw.dll
    ' Library GUID: {EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}
    ' Reference guide: [URL="http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reflist_cpp.asp"]http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/r eflist_cpp.asp[/URL] 
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' ATL declarations.
    ' Note: If you want to use ATL71.DLL, change "ATL.DLL" for "ATL71.DLL" in the declares and
    ' use "AtlAxWin71" instead of "AtlAxWin" in CreateWindowEx.
    ' ********************************************************************************************
    DECLARE FUNCTION AtlAxWinInit LIB "ATL.DLL" ALIAS "AtlAxWinInit" () AS LONG
    DECLARE FUNCTION AtlAxGetControl LIB "ATL.DLL" ALIAS "AtlAxGetControl" (BYVAL hWnd AS DWORD, BYREF pp AS DWORD) AS LONG
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' CommandStateChangeConstants enum
    ' IID: {34A226E0-DF30-11CF-89A9-00A0C9054129}
    ' Documentation string: Constants for WebBrowser CommandStateChange
    ' ********************************************************************************************
    
    %CSC_UPDATECOMMANDS                                     = -1           ' &HFFFFFFFF
    %CSC_NAVIGATEFORWARD                                    = 1            ' &H00000001
    %CSC_NAVIGATEBACK                                       = 2            ' &H00000002
    
    ' ********************************************************************************************
    ' OLECMDID enum
    ' ********************************************************************************************
    
    %OLECMDID_OPEN                                          = 1            ' &H00000001
    %OLECMDID_NEW                                           = 2            ' &H00000002
    %OLECMDID_SAVE                                          = 3            ' &H00000003
    %OLECMDID_SAVEAS                                        = 4            ' &H00000004
    %OLECMDID_SAVECOPYAS                                    = 5            ' &H00000005
    %OLECMDID_PRINT                                         = 6            ' &H00000006
    %OLECMDID_PRINTPREVIEW                                  = 7            ' &H00000007
    %OLECMDID_PAGESETUP                                     = 8            ' &H00000008
    %OLECMDID_SPELL                                         = 9            ' &H00000009
    %OLECMDID_PROPERTIES                                    = 10           ' &H0000000A
    %OLECMDID_CUT                                           = 11           ' &H0000000B
    %OLECMDID_COPY                                          = 12           ' &H0000000C
    %OLECMDID_PASTE                                         = 13           ' &H0000000D
    %OLECMDID_PASTESPECIAL                                  = 14           ' &H0000000E
    %OLECMDID_UNDO                                          = 15           ' &H0000000F
    %OLECMDID_REDO                                          = 16           ' &H00000010
    %OLECMDID_SELECTALL                                     = 17           ' &H00000011
    %OLECMDID_CLEARSELECTION                                = 18           ' &H00000012
    %OLECMDID_ZOOM                                          = 19           ' &H00000013
    %OLECMDID_GETZOOMRANGE                                  = 20           ' &H00000014
    %OLECMDID_UPDATECOMMANDS                                = 21           ' &H00000015
    %OLECMDID_REFRESH                                       = 22           ' &H00000016
    %OLECMDID_STOP                                          = 23           ' &H00000017
    %OLECMDID_HIDETOOLBARS                                  = 24           ' &H00000018
    %OLECMDID_SETPROGRESSMAX                                = 25           ' &H00000019
    %OLECMDID_SETPROGRESSPOS                                = 26           ' &H0000001A
    %OLECMDID_SETPROGRESSTEXT                               = 27           ' &H0000001B
    %OLECMDID_SETTITLE                                      = 28           ' &H0000001C
    %OLECMDID_SETDOWNLOADSTATE                              = 29           ' &H0000001D
    %OLECMDID_STOPDOWNLOAD                                  = 30           ' &H0000001E
    %OLECMDID_ONTOOLBARACTIVATED                            = 31           ' &H0000001F
    %OLECMDID_FIND                                          = 32           ' &H00000020
    %OLECMDID_DELETE                                        = 33           ' &H00000021
    %OLECMDID_HTTPEQUIV                                     = 34           ' &H00000022
    %OLECMDID_HTTPEQUIV_DONE                                = 35           ' &H00000023
    %OLECMDID_ENABLE_INTERACTION                            = 36           ' &H00000024
    %OLECMDID_ONUNLOAD                                      = 37           ' &H00000025
    %OLECMDID_PROPERTYBAG2                                  = 38           ' &H00000026
    %OLECMDID_PREREFRESH                                    = 39           ' &H00000027
    %OLECMDID_SHOWSCRIPTERROR                               = 40           ' &H00000028
    %OLECMDID_SHOWMESSAGE                                   = 41           ' &H00000029
    %OLECMDID_SHOWFIND                                      = 42           ' &H0000002A
    %OLECMDID_SHOWPAGESETUP                                 = 43           ' &H0000002B
    %OLECMDID_SHOWPRINT                                     = 44           ' &H0000002C
    %OLECMDID_CLOSE                                         = 45           ' &H0000002D
    %OLECMDID_ALLOWUILESSSAVEAS                             = 46           ' &H0000002E
    %OLECMDID_DONTDOWNLOADCSS                               = 47           ' &H0000002F
    %OLECMDID_UPDATEPAGESTATUS                              = 48           ' &H00000030
    %OLECMDID_PRINT2                                        = 49           ' &H00000031
    %OLECMDID_PRINTPREVIEW2                                 = 50           ' &H00000032
    %OLECMDID_SETPRINTTEMPLATE                              = 51           ' &H00000033
    %OLECMDID_GETPRINTTEMPLATE                              = 52           ' &H00000034
    %OLECMDID_PAGEACTIONBLOCKED                             = 55           ' &H00000037
    %OLECMDID_PAGEACTIONUIQUERY                             = 56           ' &H00000038
    %OLECMDID_FOCUSVIEWCONTROLS                             = 57           ' &H00000039
    %OLECMDID_FOCUSVIEWCONTROLSQUERY                        = 58           ' &H0000003A
    %OLECMDID_SHOWPAGEACTIONMENU                            = 59           ' &H0000003B
    
    ' ********************************************************************************************
    ' OLECMDF enum
    ' ********************************************************************************************
    
    %OLECMDF_SUPPORTED                                      = 1            ' &H00000001
    %OLECMDF_ENABLED                                        = 2            ' &H00000002
    %OLECMDF_LATCHED                                        = 4            ' &H00000004
    %OLECMDF_NINCHED                                        = 8            ' &H00000008
    %OLECMDF_INVISIBLE                                      = 16           ' &H00000010
    %OLECMDF_DEFHIDEONCTXTMENU                              = 32           ' &H00000020
    
    ' ********************************************************************************************
    ' OLECMDEXECOPT enum
    ' ********************************************************************************************
    
    %OLECMDEXECOPT_DODEFAULT                                = 0            ' &H00000000
    %OLECMDEXECOPT_PROMPTUSER                               = 1            ' &H00000001
    %OLECMDEXECOPT_DONTPROMPTUSER                           = 2            ' &H00000002
    %OLECMDEXECOPT_SHOWHELP                                 = 3            ' &H00000003
    
    ' ********************************************************************************************
    ' tagREADYSTATE enum
    ' ********************************************************************************************
    
    %READYSTATE_UNINITIALIZED                               = 0            ' &H00000000
    %READYSTATE_LOADING                                     = 1            ' &H00000001
    %READYSTATE_LOADED                                      = 2            ' &H00000002
    %READYSTATE_INTERACTIVE                                 = 3            ' &H00000003
    %READYSTATE_COMPLETE                                    = 4            ' &H00000004
    
    ' ********************************************************************************************
    ' SecureLockIconConstants enum
    ' IID: {65507BE0-91A8-11D3-A845-009027220E6D}
    ' Documentation string: Constants for WebBrowser security icon notification
    ' ********************************************************************************************
    
    %secureLockIconUnsecure                                 = 0            ' &H00000000
    %secureLockIconMixed                                    = 1            ' &H00000001
    %secureLockIconSecureUnknownBits                        = 2            ' &H00000002
    %secureLockIconSecure40Bit                              = 3            ' &H00000003
    %secureLockIconSecure56Bit                              = 4            ' &H00000004
    %secureLockIconSecureFortezza                           = 5            ' &H00000005
    %secureLockIconSecure128Bit                             = 6            ' &H00000006
    
    ' ********************************************************************************************
    ' ShellWindowTypeConstants enum
    ' IID: {F41E6981-28E5-11D0-82B4-00A0C90C29C5}
    ' Documentation string: Constants for ShellWindows registration
    ' ********************************************************************************************
    
    %SWC_EXPLORER                                           = 0            ' &H00000000
    %SWC_BROWSER                                            = 1            ' &H00000001
    %SWC_3RDPARTY                                           = 2            ' &H00000002
    %SWC_CALLBACK                                           = 4            ' &H00000004
    
    ' ********************************************************************************************
    ' ShellWindowFindWindowOptions enum
    ' IID: {7716A370-38CA-11D0-A48B-00A0C90A8F39}
    ' Documentation string: Options for ShellWindows FindWindow
    ' ********************************************************************************************
    
    %SWFO_NEEDDISPATCH                                      = 1            ' &H00000001
    %SWFO_INCLUDEPENDING                                    = 2            ' &H00000002
    %SWFO_COOKIEPASSED                                      = 4            ' &H00000004
    
    ' ********************************************************************************************
    ' NWMF Enumerated Type
    ' Flags used by INewWindowManager::EvaluateNewWindow. These values are taken into account in
    ' the decision of whether to display a pop-up window.
    ' ********************************************************************************************
    
    %NWMF_UNLOADING        = &H0001
    %NWMF_USERINITED       = &H0002
    %NWMF_FIRST_USERINITED = &H0004
    %NWMF_OVERRIDEKEY      = &H0008
    %NWMF_SHOWHELP         = &H0010
    %NWMF_HTMLDIALOG       = &H0020
    %NWMF_FROMPROXY        = &H0040
    
    ' ********************************************************************************************
    ' Global error variable
    ' ********************************************************************************************
    GLOBAL WbResult AS LONG
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' QueryInterface method
    ' ********************************************************************************************
    ' Returns a pointer to a specified interface on an object to which a client currently holds an
    ' interface pointer. You must release the returned interface, when no longer needed, with a call
    ' to the Release method.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_WbQueryInterface (BYVAL pthis AS DWORD PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
    ' ********************************************************************************************
    FUNCTION WbQueryInterface (BYVAL pthis AS DWORD PTR, BYREF riid AS GUID) AS DWORD
        LOCAL ppvObj AS DWORD
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        CALL DWORD @@pthis[0] USING Proto_WbQueryInterface(pthis, riid, ppvObj) TO WbResult
        FUNCTION = ppvObj
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' AddRef method
    ' ********************************************************************************************
    ' The AddRef method increments the reference count for an interface on an object. It should be
    ' called for every new copy of a pointer to an interface on a given object.
    ' ********************************************************************************************
    FUNCTION WbAddRef (BYVAL pthis AS DWORD PTR) AS DWORD
        LOCAL DWRESULT AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        CALL DWORD @@pthis[1] USING WbAddRef(pthis) TO DWRESULT
        FUNCTION = DWRESULT
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Release method
    ' ********************************************************************************************
    ' Decrements the reference count for the calling interface on a object. If the reference count
    ' on the object falls to 0, the object is freed from memory.
    ' ********************************************************************************************
    FUNCTION WbRelease (BYVAL pthis AS DWORD PTR) AS DWORD
        LOCAL DWRESULT AS DWORD
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        CALL DWORD @@pthis[2] USING WbRelease(pthis) TO DWRESULT
        FUNCTION = DWRESULT
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Retrieves the interface of the ActiveX control given the handle of its ATL container
    ' ********************************************************************************************
    FUNCTION WbGetInterfacePointer (BYVAL hCtrl AS DWORD) AS DWORD
    
        LOCAL ppUnk AS DWORD
        LOCAL IID_IDispatch AS GUID
        LOCAL ppDispatch AS DWORD
    
        ' Get the IUnknown of the OCX hosted in the control
        WbResult = AtlAxGetControl(hCtrl, ppUnk)
        IF ISTRUE WbResult OR ISFALSE ppUnk THEN EXIT FUNCTION
        IID_IDispatch = GUID$("{00020400-0000-0000-c000-000000000046}")
    
        ' Query for the existence of the IDispatch interface
        ppDispatch = WbQueryInterface(ppUnk, IID_IDispatch)
    
        ' If not found, return the IUnknown of the control
        IF ISTRUE WbResult OR ISFALSE ppDispatch THEN
           FUNCTION = ppUnk
           EXIT FUNCTION
        END IF
    
        ' Release the IUnknown of the control
        WbRelease ppUnk
    
        ' Return the retrieved address
        FUNCTION = ppDispatch
    
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' IWebBrowser2 interface
    ' IID: {D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}
    ' Interface flags: &H1050 [Hidden] [Dual] [Dispatchable]
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' GoBack method
    ' Navigates to the previous item in the history list.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GoBack (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_GoBack (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[7] USING Proto_IWebBrowser2_GoBack(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' GoForward method
    ' Navigates to the next item in the history list.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GoForward (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_GoForward (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[8] USING Proto_IWebBrowser2_GoForward(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' GoHome method
    ' Go home/start page.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GoHome (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_GoHome (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[9] USING Proto_IWebBrowser2_GoHome(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' GoSearch method
    ' Go Search Page.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GoSearch (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_GoSearch (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[10] USING Proto_IWebBrowser2_GoSearch(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Navigate method
    ' Navigates to a URL or file.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_Navigate (BYVAL pthis AS DWORD PTR, BYVAL URL AS DWORD, BYREF Flags AS VARIANT, BYREF TargetFrameName AS VARIANT, BYREF PostData AS VARIANT, BYREF Headers AS VARIANT) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_Navigate (BYVAL pthis AS DWORD PTR, BYVAL URL AS STRING, OPTIONAL BYREF Flags AS VARIANT, BYREF TargetFrameName AS VARIANT, BYREF PostData AS VARIANT, BYREF Headers AS VARIANT)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        URL = UCODE$(URL)
        DIM var_Flags AS VARIANT : IF VARPTR(Flags) THEN var_Flags = Flags ELSE var_Flags = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_TargetFrameName AS VARIANT : IF VARPTR(TargetFrameName) THEN var_TargetFrameName = TargetFrameName ELSE var_TargetFrameName = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_PostData AS VARIANT : IF VARPTR(PostData) THEN var_PostData = PostData ELSE var_PostData = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_Headers AS VARIANT : IF VARPTR(Headers) THEN var_Headers = Headers ELSE var_Headers = ERROR %DISP_E_PARAMNOTFOUND
        CALL DWORD @@pthis[11] USING Proto_IWebBrowser2_Navigate(pthis, STRPTR(URL), var_Flags, var_TargetFrameName, var_PostData, var_Headers) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Refresh method
    ' Refresh the currently viewed page.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_Refresh (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_Refresh (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[12] USING Proto_IWebBrowser2_Refresh(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Refresh2 method
    ' Refresh the currently viewed page.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_Refresh2 (BYVAL pthis AS DWORD PTR, BYREF Level AS VARIANT) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_Refresh2 (BYVAL pthis AS DWORD PTR, OPTIONAL BYREF Level AS VARIANT)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        DIM var_Level AS VARIANT : IF VARPTR(Level) THEN var_Level = Level ELSE var_Level = ERROR %DISP_E_PARAMNOTFOUND
        CALL DWORD @@pthis[13] USING Proto_IWebBrowser2_Refresh2(pthis, var_Level) TO WbResult
        IF VARPTR(Level) THEN Level = var_Level
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Stop method
    ' Stops opening a file.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_Stop (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_Stop (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[14] USING Proto_IWebBrowser2_Stop(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Application property
    ' Returns the application automation object if accessible, this automation object otherwise..
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetApplication (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS DWORD) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetApplication (BYVAL pthis AS DWORD PTR) AS DWORD
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS DWORD
        CALL DWORD @@pthis[15] USING Proto_IWebBrowser2_GetApplication(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Parent property
    ' Returns the automation object of the container/parent if one exists or this automation object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetParent (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS DWORD) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetParent (BYVAL pthis AS DWORD PTR) AS DWORD
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS DWORD
        CALL DWORD @@pthis[16] USING Proto_IWebBrowser2_GetParent(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Container property
    ' Returns the container/parent automation object, if any.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetContainer (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS DWORD) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetContainer (BYVAL pthis AS DWORD PTR) AS DWORD
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS DWORD
        CALL DWORD @@pthis[17] USING Proto_IWebBrowser2_GetContainer(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Document property
    ' Returns the active Document automation object, if any.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetDocument (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS DWORD) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetDocument (BYVAL pthis AS DWORD PTR) AS DWORD
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS DWORD
        CALL DWORD @@pthis[18] USING Proto_IWebBrowser2_GetDocument(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]TopLevelContainer property
    ' Returns True if this is the top level object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetTopLevelContainer (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetTopLevelContainer (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[19] USING Proto_IWebBrowser2_GetTopLevelContainer(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Type property
    ' Returns the type of the contained document object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetType (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS STRING) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetType (BYVAL pthis AS DWORD PTR) AS STRING
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS STRING
        CALL DWORD @@pthis[20] USING Proto_IWebBrowser2_GetType(pthis, pRetVal) TO WbResult
        FUNCTION = ACODE$(pRetVal)
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Left property
    ' The horizontal position (pixels) of the frame window relative to the screen/container.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetLeft (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetLeft (BYVAL pthis AS DWORD PTR) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[21] USING Proto_IWebBrowser2_GetLeft(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Left property
    ' The horizontal position (pixels) of the frame window relative to the screen/container.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetLeft (BYVAL pthis AS DWORD PTR, BYVAL prmLeft AS LONG) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetLeft (BYVAL pthis AS DWORD PTR, BYVAL prmLeft AS LONG)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[22] USING Proto_IWebBrowser2_SetLeft(pthis, prmLeft) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Top property
    ' The vertical position (pixels) of the frame window relative to the screen/container.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetTop (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetTop (BYVAL pthis AS DWORD PTR) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[23] USING Proto_IWebBrowser2_GetTop(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Top property
    ' The vertical position (pixels) of the frame window relative to the screen/container.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetTop (BYVAL pthis AS DWORD PTR, BYVAL prmTop AS LONG) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetTop (BYVAL pthis AS DWORD PTR, BYVAL prmTop AS LONG)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[24] USING Proto_IWebBrowser2_SetTop(pthis, prmTop) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Width property
    ' The horizontal dimension (pixels) of the frame window/object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetWidth (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetWidth (BYVAL pthis AS DWORD PTR) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[25] USING Proto_IWebBrowser2_GetWidth(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Width property
    ' The horizontal dimension (pixels) of the frame window/object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetWidth (BYVAL pthis AS DWORD PTR, BYVAL prmWidth AS LONG) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetWidth (BYVAL pthis AS DWORD PTR, BYVAL prmWidth AS LONG)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[26] USING Proto_IWebBrowser2_SetWidth(pthis, prmWidth) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Height property
    ' The vertical dimension (pixels) of the frame window/object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetHeight (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetHeight (BYVAL pthis AS DWORD PTR) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[27] USING Proto_IWebBrowser2_GetHeight(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Height property
    ' The vertical dimension (pixels) of the frame window/object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetHeight (BYVAL pthis AS DWORD PTR, BYVAL prmHeight AS LONG) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetHeight (BYVAL pthis AS DWORD PTR, BYVAL prmHeight AS LONG)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[28] USING Proto_IWebBrowser2_SetHeight(pthis, prmHeight) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]LocationName property
    ' Gets the short (UI-friendly) name of the URL/file currently viewed.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetLocationName (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS STRING) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetLocationName (BYVAL pthis AS DWORD PTR) AS STRING
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS STRING
        CALL DWORD @@pthis[29] USING Proto_IWebBrowser2_GetLocationName(pthis, pRetVal) TO WbResult
        FUNCTION = ACODE$(pRetVal)
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]LocationURL property
    ' Gets the full URL/path currently viewed.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetLocationURL (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS STRING) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetLocationURL (BYVAL pthis AS DWORD PTR) AS STRING
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS STRING
        CALL DWORD @@pthis[30] USING Proto_IWebBrowser2_GetLocationURL(pthis, pRetVal) TO WbResult
        FUNCTION = ACODE$(pRetVal)
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Busy property
    ' Query to see if something is still in progress.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetBusy (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetBusy (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[31] USING Proto_IWebBrowser2_GetBusy(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Quit method
    ' Exits application and closes the open document.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_Quit (BYVAL pthis AS DWORD PTR) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_Quit (BYVAL pthis AS DWORD PTR)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        CALL DWORD @@pthis[32] USING Proto_IWebBrowser2_Quit(pthis) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' PutProperty method
    ' Associates vtValue with the name szProperty in the context of the object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_PutProperty (BYVAL pthis AS DWORD PTR, BYVAL Property AS DWORD, BYVAL vtValue AS VARIANT) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_PutProperty (BYVAL pthis AS DWORD PTR, BYVAL Property AS STRING, BYVAL vtValue AS VARIANT)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        Property = UCODE$(Property)
        CALL DWORD @@pthis[34] USING Proto_IWebBrowser2_PutProperty(pthis, STRPTR(Property), vtValue) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' GetProperty method
    ' Retrieve the Associated value for the property vtValue in the context of the object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetProperty (BYVAL pthis AS DWORD PTR, BYVAL Property AS DWORD, BYREF pRetVal AS VARIANT) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_GetProperty (BYVAL pthis AS DWORD PTR, BYVAL Property AS STRING, BYREF pRetVal AS VARIANT)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        Property = UCODE$(Property)
        CALL DWORD @@pthis[35] USING Proto_IWebBrowser2_GetProperty(pthis, STRPTR(Property), pRetVal) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Name property
    ' Returns name of the application.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetName (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS STRING) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetName (BYVAL pthis AS DWORD PTR) AS STRING
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS STRING
        CALL DWORD @@pthis[36] USING Proto_IWebBrowser2_GetName(pthis, pRetVal) TO WbResult
        FUNCTION = ACODE$(pRetVal)
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]HWND property
    ' Returns the HWND of the current IE window.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetHWND (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetHWND (BYVAL pthis AS DWORD PTR) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[37] USING Proto_IWebBrowser2_GetHWND(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]FullName property
    ' Returns file specification of the application, including path.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetFullName (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS STRING) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetFullName (BYVAL pthis AS DWORD PTR) AS STRING
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS STRING
        CALL DWORD @@pthis[38] USING Proto_IWebBrowser2_GetFullName(pthis, pRetVal) TO WbResult
        FUNCTION = ACODE$(pRetVal)
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Path property
    ' Returns the path to the application.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetPath (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS STRING) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetPath (BYVAL pthis AS DWORD PTR) AS STRING
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS STRING
        CALL DWORD @@pthis[39] USING Proto_IWebBrowser2_GetPath(pthis, pRetVal) TO WbResult
        FUNCTION = ACODE$(pRetVal)
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Visible property
    ' Determines whether the application is visible or hidden.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetVisible (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetVisible (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[40] USING Proto_IWebBrowser2_GetVisible(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Visible property
    ' Determines whether the application is visible or hidden.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetVisible (BYVAL pthis AS DWORD PTR, BYVAL pfVisible AS INTEGER) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetVisible (BYVAL pthis AS DWORD PTR, BYVAL pfVisible AS INTEGER)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        IF pfVisible <> 0 THEN pfVisible = -1
        CALL DWORD @@pthis[41] USING Proto_IWebBrowser2_SetVisible(pthis, pfVisible) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' Navigate2 method
    ' Navigates to a URL or file or pidl.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_Navigate2 (BYVAL pthis AS DWORD PTR, BYREF URL AS VARIANT, BYREF Flags AS VARIANT, BYREF TargetFrameName AS VARIANT, BYREF PostData AS VARIANT, BYREF Headers AS VARIANT) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_Navigate2 (BYVAL pthis AS DWORD PTR, BYREF URL AS VARIANT, OPTIONAL BYREF Flags AS VARIANT, BYREF TargetFrameName AS VARIANT, BYREF PostData AS VARIANT, BYREF Headers AS VARIANT)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        DIM var_Flags AS VARIANT : IF VARPTR(Flags) THEN var_Flags = Flags ELSE var_Flags = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_TargetFrameName AS VARIANT : IF VARPTR(TargetFrameName) THEN var_TargetFrameName = TargetFrameName ELSE var_TargetFrameName = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_PostData AS VARIANT : IF VARPTR(PostData) THEN var_PostData = PostData ELSE var_PostData = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_Headers AS VARIANT : IF VARPTR(Headers) THEN var_Headers = Headers ELSE var_Headers = ERROR %DISP_E_PARAMNOTFOUND
        CALL DWORD @@pthis[52] USING Proto_IWebBrowser2_Navigate2(pthis, URL, var_Flags, var_TargetFrameName, var_PostData, var_Headers) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' QueryStatusWB method
    ' IOleCommandTarget::QueryStatus
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_QueryStatusWB (BYVAL pthis AS DWORD PTR, BYVAL cmdID AS LONG, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_QueryStatusWB (BYVAL pthis AS DWORD PTR, BYVAL cmdID AS LONG) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[53] USING Proto_IWebBrowser2_QueryStatusWB(pthis, cmdID, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' ExecWB method
    ' IOleCommandTarget::Exec
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_ExecWB (BYVAL pthis AS DWORD PTR, BYVAL cmdID AS LONG, BYVAL cmdexecopt AS LONG, BYREF pvaIn AS VARIANT, BYREF pvaOut AS VARIANT) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_ExecWB (BYVAL pthis AS DWORD PTR, BYVAL cmdID AS LONG, BYVAL cmdexecopt AS LONG, OPTIONAL BYREF pvaIn AS VARIANT, BYREF pvaOut AS VARIANT)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        DIM var_pvaIn AS VARIANT : IF VARPTR(pvaIn) THEN var_pvaIn = pvaIn ELSE var_pvaIn = ERROR %DISP_E_PARAMNOTFOUND
        DIM var_pvaOut AS VARIANT : IF VARPTR(pvaOut) THEN var_pvaOut = pvaOut ELSE var_pvaOut = ERROR %DISP_E_PARAMNOTFOUND
        CALL DWORD @@pthis[54] USING Proto_IWebBrowser2_ExecWB(pthis, cmdID, cmdexecopt, var_pvaIn, var_pvaOut) TO WbResult
        IF VARPTR(pvaOut) THEN pvaOut = var_pvaOut
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]ReadyState property  [Bindable]
    ' Retrieves the ready state of the object.
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetReadyState (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS LONG) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetReadyState (BYVAL pthis AS DWORD PTR) AS LONG
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS LONG
        CALL DWORD @@pthis[56] USING Proto_IWebBrowser2_GetReadyState(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Offline property
    ' Documentation string: Controls if the frame is offline (read from cache)
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetOffline (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetOffline (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[57] USING Proto_IWebBrowser2_GetOffline(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Offline property
    ' Controls if the frame is offline (read from cache)
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetOffline (BYVAL pthis AS DWORD PTR, BYVAL pfOffline AS INTEGER) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetOffline (BYVAL pthis AS DWORD PTR, BYVAL pfOffline AS INTEGER)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        IF pfOffline <> 0 THEN pfOffline = -1
        CALL DWORD @@pthis[58] USING Proto_IWebBrowser2_SetOffline(pthis, pfOffline) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]Silent property
    ' Controls if any dialog boxes can be shown
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetSilent (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetSilent (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[59] USING Proto_IWebBrowser2_GetSilent(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]Silent property
    ' Controls if any dialog boxes can be shown
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetSilent (BYVAL pthis AS DWORD PTR, BYVAL pfSilent AS INTEGER) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetSilent (BYVAL pthis AS DWORD PTR, BYVAL pfSilent AS INTEGER)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        IF pfSilent <> 0 THEN pfSilent = -1
        CALL DWORD @@pthis[60] USING Proto_IWebBrowser2_SetSilent(pthis, pfSilent) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]RegisterAsBrowser property
    ' Registers OC as a top-level browser (for target name resolution)
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetRegisterAsBrowser (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetRegisterAsBrowser (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[61] USING Proto_IWebBrowser2_GetRegisterAsBrowser(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]RegisterAsBrowser property
    ' Registers OC as a top-level browser (for target name resolution)
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetRegisterAsBrowser (BYVAL pthis AS DWORD PTR, BYVAL pfRegisterAsBrowser AS INTEGER) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetRegisterAsBrowser (BYVAL pthis AS DWORD PTR, BYVAL pfRegisterAsBrowser AS INTEGER)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        IF pfRegisterAsBrowser <> 0 THEN pfRegisterAsBrowser = -1
        CALL DWORD @@pthis[62] USING Proto_IWebBrowser2_SetRegisterAsBrowser(pthis, pfRegisterAsBrowser) TO WbResult
    END SUB
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [get]RegisterAsDropTarget property
    ' Registers OC as a drop target for navigation
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_GetRegisterAsDropTarget (BYVAL pthis AS DWORD PTR, BYREF pRetVal AS INTEGER) AS LONG
    ' ********************************************************************************************
    FUNCTION IWebBrowser2_GetRegisterAsDropTarget (BYVAL pthis AS DWORD PTR) AS INTEGER
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT FUNCTION
        DIM pRetVal AS INTEGER
        CALL DWORD @@pthis[63] USING Proto_IWebBrowser2_GetRegisterAsDropTarget(pthis, pRetVal) TO WbResult
        FUNCTION = pRetVal
    END FUNCTION
    ' ********************************************************************************************
    
    ' ********************************************************************************************
    ' [set]RegisterAsDropTarget property
    ' Registers OC as a drop target for navigation
    ' ********************************************************************************************
    DECLARE FUNCTION Proto_IWebBrowser2_SetRegisterAsDropTarget (BYVAL pthis AS DWORD PTR, BYVAL pfRegisterAsDropTarget AS INTEGER) AS LONG
    ' ********************************************************************************************
    SUB IWebBrowser2_SetRegisterAsDropTarget (BYVAL pthis AS DWORD PTR, BYVAL pfRegisterAsDropTarget AS INTEGER)
        IF pthis = 0 THEN WbResult = %E_POINTER : EXIT SUB
        IF pfRegisterAsDropTarget <> 0 THEN pfRegisterAsDropTarget = -1
        CALL DWORD @@pthis[64] USING Proto_IWebBrowser2_SetRegisterAsDropTarget(pthis, pfRegisterAsDropTarget) TO WbResult
    END SUB
    ' ********************************************************************************************
    Last edited by José Roca; 30 Aug 2007, 06:37 PM.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Save as IDHUIH.INC
      Code:
      ' ****************************************************************************************
      ' ICustomDoc interface
      ' The ICustomDoc interface is implemented by MSHTML to allow a host to set the MSHTML
      ' IDocHostUIHandler interface.
      ' ****************************************************************************************
      
      $IID_ICustomDoc = GUID$("{3050f3f0-98b5-11cf-bb82-00aa00bdce0b}")
      
      ' ****************************************************************************************
      ' ICustomDoc_SetUIHandler method
      ' Sets the IDocHostUIHandler interface for MSHTML.
      ' MSHTML will release its previous IDocHostUIHandler interface (if one is present) and
      ' call pUIHandler's AddRef method.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE *SetUIHandler )(
      '     ICustomDoc * This,
      '     /* [in] */ IDocHostUIHandler *pUIHandler);
      ' ****************************************************************************************
      FUNCTION ICustomDoc_SetUIHandler (BYVAL pthis AS DWORD PTR, BYVAL pUIHandler AS DWORD) AS LONG
          LOCAL HRESULT AS LONG
          CALL DWORD @@pthis[3] USING ICustomDoc_SetUIHandler(pthis, pUIHandler) TO HRESULT
          FUNCTION = HRESULT
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' IDocHostUIHandler interface
      ' IID = ("bd3f23c0-d43e-11cf-893b-00aa00bdce1a")
      ' Minimum avaiability: Internet Explorer 4.0
      ' ****************************************************************************************
      
      $IID_IDocHostUIHandler = GUID$("{bd3f23c0-d43e-11cf-893b-00aa00bdce1a}")
      
      ' ****************************************************************************************
      ' This custom interface enables an application hosting the WebBrowser Control or automating
      ' Microsoft Internet Explorer to replace the menus, toolbars, and context menus used by
      ' MSHTML.
      ' Remarks
      ' On initialization, MSHTML calls QueryInterface on the host's client site, requesting an
      ' IDocHostUIHandler interface. If available, MSHTML will call IDocHostUIHandler methods at
      ' appropriate times during the lifetime of the MSHTML component.
      ' Implementing this interface enables MSHTML to communicate with the host about its user
      ' interface status. The host can use this interface to modify such internal user interface
      ' elements as menus, context menus, and toolbars.
      ' ****************************************************************************************
      
      GLOBAL g_pConSink AS DWORD
      
      ' ****************************************************************************************
      ' enum DOCHOSTUITYPE
      ' ****************************************************************************************
      %DOCHOSTUITYPE_BROWSE = 0
      %DOCHOSTUITYPE_AUTHOR = 1
      
      ' ****************************************************************************************
      ' enum DOCHOSTUIDBLCLK
      ' ****************************************************************************************
      %DOCHOSTUIDBLCLK_DEFAULT        = 0
      %DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1
      %DOCHOSTUIDBLCLK_SHOWCODE       = 2
      
      ' ****************************************************************************************
      ' enum DOCHOSTUIFLAG
      ' ****************************************************************************************
      %DOCHOSTUIFLAG_DIALOG                     = &H1
      %DOCHOSTUIFLAG_DISABLE_HELP_MENU          = &H2
      %DOCHOSTUIFLAG_NO3DBORDER                 = &H4
      %DOCHOSTUIFLAG_SCROLL_NO                  = &H8
      %DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE    = &H10
      %DOCHOSTUIFLAG_OPENNEWWIN                 = &H20
      %DOCHOSTUIFLAG_DISABLE_OFFSCREEN          = &H40
      %DOCHOSTUIFLAG_FLAT_SCROLLBAR             = &H80
      %DOCHOSTUIFLAG_DIV_BLOCKDEFAULT           = &H100
      %DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY    = &H200
      %DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY    = &H400
      %DOCHOSTUIFLAG_CODEPAGELINKEDFONTS        = &H800
      %DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8  = &H1000
      %DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8   = &H2000
      %DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE  = &H4000
      %DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION  = &H10000
      %DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION    = &H20000
      %DOCHOSTUIFLAG_THEME                      = &H40000
      %DOCHOSTUIFLAG_NOTHEME                    = &H80000
      %DOCHOSTUIFLAG_NOPICS                     = &H100000
      %DOCHOSTUIFLAG_NO3DOUTERBORDER            = &H200000
      %DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP      = &H400000
      %DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = &H800000
      %DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL  = &H1000000
      
      ' ****************************************************************************************
      ' DOCHOSTUIINFO Structure
      ' Used by the IDocHostUIHandler::GetHostInfo method to allow MSHTML to retrieve information
      ' about the host's UI requirements.
      ' ****************************************************************************************
      ' Members
      '    cbSize
      '        ULONG containing the size of this structure, in bytes.
      '    dwFlags
      '        One or more of the DOCHOSTUIFLAG values that specify the UI capabilities of the host.
      '    dwDoubleClick
      '        One of the DOCHOSTUIDBLCLK values that specify the operation that should take
      '        place in response to a double-click.
      '    pchHostCss
      '        Pointer to a set of Cascading Style Sheets (CSS) rules sent down by the host.
      '        These CSS rules affect the page containing them.
      '    pchHostNS
      '        Pointer to a semicolon-delimited namespace list. This list allows the host to
      '        supply a namespace declaration for custom tags on the page.
      ' ****************************************************************************************
      TYPE DOCHOSTUIINFO
         cbSize AS DWORD
         dwFlags AS DWORD
         dwDoubleClick AS DWORD
         pchHostCss AS STRING PTR
         pchHostNS AS STRING PTR
      END TYPE
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' IDocHostUIHandler virtual table
      ' ****************************************************************************************
      TYPE IDocHostUIHandlerVTbl
         pQueryInterface AS DWORD
         pAddRef AS DWORD
         pRelease AS DWORD
         pShowContextMenu AS DWORD
         pGetHostInfo AS DWORD
         pShowUI AS DWORD
         pHideUI AS DWORD
         pUpdateUI AS DWORD
         pEnableModeless AS DWORD
         pOnDocWindowActivate AS DWORD
         pOnFrameWindowActivate AS DWORD
         pResizeBorder AS DWORD
         pTranslateAccelerator AS DWORD
         pGetOptionKeyPath AS DWORD
         pGetDropTarget AS DWORD
         pGetExternal AS DWORD
         pTranslateUrl AS DWORD
         pFilterDataObject AS DWORD
      END TYPE
      ' ****************************************************************************************
      
      ' **********************************************************************************************
      ' Builds the Ado connection events vtable
      ' **********************************************************************************************
      SUB IDocHostUIHandlerBuildVTbl(Vt AS IDocHostUIHandlerVTbl)
      
         Vt.pQueryInterface        = CODEPTR(IDocHostUIHandler_QueryInterface)
         Vt.pAddRef                = CODEPTR(IDocHostUIHandler_AddRef)
         Vt.pRelease               = CODEPTR(IDocHostUIHandler_Release)
         Vt.pShowContextMenu       = CODEPTR(IDocHostUIHandler_ShowContextMenu)
         Vt.pGetHostInfo           = CODEPTR(IDocHostUIHandler_GetHostInfo)
         Vt.pShowUI                = CODEPTR(IDocHostUIHandler_ShowUI)
         Vt.pHideUI                = CODEPTR(IDocHostUIHandler_HideUI)
         Vt.pUpdateUI              = CODEPTR(IDocHostUIHandler_UpdateUI)
         Vt.pEnableModeless        = CODEPTR(IDocHostUIHandler_EnableModeless)
         Vt.pOnDocWindowActivate   = CODEPTR(IDocHostUIHandler_OnDocWindowActivate)
         Vt.pOnFrameWindowActivate = CODEPTR(IDocHostUIHandler_OnFrameWindowActivate)
         Vt.pResizeBorder          = CODEPTR(IDocHostUIHandler_ResizeBorder)
         Vt.pTranslateAccelerator  = CODEPTR(IDocHostUIHandler_TranslateAccelerator)
         Vt.pGetOptionKeyPath      = CODEPTR(IDocHostUIHandler_GetOptionKeyPath)
         Vt.pGetDropTarget         = CODEPTR(IDocHostUIHandler_GetDropTarget)
         Vt.pGetExternal           = CODEPTR(IDocHostUIHandler_GetExternal)
         Vt.pTranslateUrl          = CODEPTR(IDocHostUIHandler_TranslateUrl)
         Vt.pFilterDataObject      = CODEPTR(IDocHostUIHandler_FilterDataObject)
      
      END SUB
      ' **********************************************************************************************
      
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ REFIID riid,
      '     /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_QueryInterface (BYVAL pthis AS DWORD PTR, BYREF riid AS GUID, BYREF ppvObject AS DWORD) AS LONG
      
         STATIC pConSink AS DWORD
         STATIC IDocHostUIHandlerEventsVt AS IDocHostUIHandlerVTbl
      
         IF riid <> $IID_IDocHostUIHandler THEN EXIT FUNCTION
      
         IF ISFALSE g_pConSink THEN
            IDocHostUIHandlerBuildVTbl IDocHostUIHandlerEventsVt
              g_pConSink = VARPTR(IDocHostUIHandlerEventsVt)
         END IF
          ppvObject = VARPTR(g_pConSink)
          FUNCTION = %S_OK
      
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
      '     IDocHostUIHandler __RPC_FAR * This);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_AddRef (BYVAL pthis AS DWORD PTR) AS DWORD
         FUNCTION = 1
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
      '     IDocHostUIHandler __RPC_FAR * This);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_Release (BYVAL pthis AS DWORD PTR) AS DWORD
         FUNCTION = 1
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' ShowContextMenu method
      ' ****************************************************************************************
      ' Called by MSHTML to display a shortcut menu.
      ' Parameters
      '    dwID
      '        [in] DWORD that specifies the identifier of the shortcut menu to be displayed.
      '             This identifier is a bitwise shift of the value 0x1 by the shortcut menu
      '             values (e.g., CONTEXT_MENU_DEFAULT) defined in Mshtmhst.h.
      '        0x2
      '            value of (0x1 << CONTEXT_MENU_DEFAULT)
      '        0x4
      '            value of (0x1 << CONTEXT_MENU_CONTROL)
      '        0x8
      '            value of (0x1 << CONTEXT_MENU_TABLE)
      '        0x10
      '            value of (0x1 << CONTEXT_MENU_TEXTSELECT)
      '        0x30
      '            value of (0x1 << CONTEXT_MENU_ANCHOR)
      '        0x20
      '            value of (0x1 << CONTEXT_MENU_UNKNOWN)
      '    ppt
      '        [in] Pointer to a POINT structure containing the screen coordinates for the menu.
      '    pcmdtReserved
      '        [in] Pointer to the IUnknown of an IOleCommandTarget interface used to query
      '             command status and execute commands on this object.
      '    pdispReserved
      '        [in] Pointer to an IDispatch interface of the object at the screen coordinates
      '             specified in ppt. This allows a host to differentiate particular objects to
      '             provide more specific context.
      ' Return Value
      '    Returns one of the following values:
      '    %S_OK                Host displayed its own user interface (UI). MSHTML will not
      '                         attempt to display its UI.
      '    %S_FALSE             Host did not display any UI. MSHTML will display its UI.
      '    %DOCHOST_E_UNKNOWN   Menu identifier is unknown. MSHTML may attempt an alternative
      '                         identifier from a previous version.
      ' Remarks
      '    In Microsoft Internet Explorer 4.0 the pdispReserved parameter supplied no information,
      '    but in Internet Explorer 5 and later the parameter contains the pointer to an IDispatch
      '    interface.
      ' Example
      '    The following code example shows how the pdispReserved parameter is used.
      '
      ' IHTMLElement *pElem;
      ' HRESULT hr;
      ' hr = pdispReserved->QueryInterface(IID_IHTMLElement, (void**)pElem);
      ' if(SUCCEEDED (hr)) {
      '     BSTR bstr;
      '     pElem->get_tagName(bstr);
      '     USES_CONVERSION;
      '     ATLTRACE("TagName:%s\n", OLE2T(bstr));
      '     SysFreeString(bstr);
      '     pElem->Release();
      ' }
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ShowContextMenu )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ DWORD dwID,
      '     /* [in] */ POINT __RPC_FAR *ppt,
      '     /* [in] */ IUnknown __RPC_FAR *pcmdtReserved,
      '     /* [in] */ IDispatch __RPC_FAR *pdispReserved);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_ShowContextMenu (BYVAL pthis AS DWORD PTR, BYVAL dwID AS DWORD, BYVAL ppt AS DWORD PTR, BYVAL pcmdtReserved AS DWORD PTR, BYVAL pdispReserved AS DWORD PTR) AS LONG
      
         ' This event notifies that the user has clicked the right mouse button to show the
          ' context menu. We can anulate it returning %S_OK and show our context menu.
      
         ' Don not allow to show the context menu
          MSGBOX "Sorry! Context menu disabled"
         FUNCTION = %S_OK
      
      '   FUNCTION = %S_FALSE
      
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' GetHostInfo method
      ' ****************************************************************************************
      ' Called by MSHTML to retrieve the user interface (UI) capabilities of the application
      ' that is hosting MSHTML.
      ' Syntax
      ' HRESULT GetHostInfo(
      '     DOCHOSTUIINFO *pInfo
      ' );
      ' Parameters
      '    pInfo
      '        [in, out] Pointer to a DOCHOSTUIINFO structure that receives the host's UI
      '        capabilities.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetHostInfo )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_GetHostInfo (BYVAL pthis AS DWORD PTR, BYREF pInfo AS DOCHOSTUIINFO) AS LONG
         FUNCTION = %E_NOTIMPL
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' ShowUI method
      ' ****************************************************************************************
      ' Called by MSHTML to enable the host to replace MSHTML menus and toolbars.
      ' Parameters
      '    dwID
      '        [in] DWORD that receives a DOCHOSTUITYPE value indicating the type of user
      '        interface (UI).
      '    pActiveObject
      '        [in] Pointer to an IOleInPlaceActiveObject interface for the active object.
      '    pCommandTarget
      '        [in] Pointer to an IOleCommandTarget interface for the object.
      '    pFrame
      '        [in] Pointer to an IOleInPlaceFrame interface for the object. Menus and toolbars
      '        must use this parameter.
      '    pDoc
      '        [in] Pointer to an IOleInPlaceUIWindow interface for the object. Toolbars must
      '        use this parameter.
      ' Return Value
      '    Returns one of the following values:
      '    %S_OK                Host displayed its own UI. MSHTML will not display its UI.
      '    %S_FALSE             Host did not display its own UI. MSHTML will display its UI.
      '    %DOCHOST_E_UNKNOWN   Host did not recognize the UI identifier. MSHTML will either try
      '                         an alternative identifier for compatibility with a previous
      '                         version or display its own UI.
      ' Remarks
      '    If the host uses any of the interfaces handed to it as part of this function, the host
      '    should call the interface's AddRef method to save the interface for later use. If the host
      '    calls the interface's AddRef method, the host must also call the interface's Release
      '    method when the interface is no longer required.
      '    A host can disable modeless UI on MSHTML by calling IOleCommandTarget::Exec with
      '    %IDM_DISABLEMODELESS and %IDM_ENABLEMODELESS.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ShowUI )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ DWORD dwID,
      '     /* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
      '     /* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget,
      '     /* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame,
      '     /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_ShowUI (BYVAL pthis AS DWORD PTR, BYVAL dwID AS DWORD, BYVAL pActiveObject AS DWORD PTR, BYVAL pCommandTarget AS DWORD PTR, BYVAL pFrame AS DWORD PTR, BYVAL pDoc AS DWORD PTR) AS LONG
         FUNCTION = %S_FALSE
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' Called when MSHTML removes its menus and toolbars.
      ' ****************************************************************************************
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' Remarks
      '    If a host displayed menus and toolbars during the call to IDocHostUIHandler::ShowUI,
      '    the host should remove them when this method is called. This method is called
      '    regardless of the return value from the IDocHostUIHandler::ShowUI method.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *HideUI )(
      '     IDocHostUIHandler __RPC_FAR * This);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_HideUI (BYVAL pthis AS DWORD PTR) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' UpdateUI method
      ' ****************************************************************************************
      ' Called by MSHTML to notify the host that the command state has changed.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' Remarks
      '    The host should update the state of toolbar buttons in an implementation of this
      '    method. This method is called regardless of the return value from the
      '    IDocHostUIHandler::ShowUI method.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *UpdateUI )(
      '     IDocHostUIHandler __RPC_FAR * This);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_UpdateUI (BYVAL pthis AS DWORD PTR) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' EnableModeless method
      ' ****************************************************************************************
      ' Called by the MSHTML implementation of IOleInPlaceActiveObject::EnableModeless. Also
      ' called when MSHTML displays a modal UI.
      ' Parameters
      '    fEnable
      '        [in] BOOL that indicates if the host's modeless dialog boxes are enabled or disabled.
      '        %TRUE
      '            Modeless dialog boxes are enabled.
      '        %FALSE
      '            Modeless dialog boxes are disabled.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *EnableModeless )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ BOOL fEnable);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_EnableModeless (BYVAL pthis AS DWORD PTR, BYVAL fEnable AS INTEGER) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' OnDocWindowActivate method
      ' ****************************************************************************************
      ' Called by the MSHTML implementation of IOleInPlaceActiveObject::OnDocWindowActivate.
      ' Parameters
      '    fActivate
      '        [in] BOOL value that indicates the state of the document window.
      '        %TRUE
      '            The window is being activated.
      '        %FALSE
      '            The window is being deactivated.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnDocWindowActivate )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ BOOL fActivate);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_OnDocWindowActivate (BYVAL pthis AS DWORD PTR, BYVAL fActivate AS INTEGER) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' OnFrameWindowActivate method
      ' ****************************************************************************************
      ' Called by the MSHTML implementation of IOleInPlaceActiveObject::OnFrameWindowActivate.
      ' Parameters
      '    fActivate
      '        [in] BOOL value that indicates the state of the container's top-level frame window.
      '        %TRUE
      '            The frame window is being activated.
      '        %FALSE
      '            The frame window is being deactivated.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnFrameWindowActivate )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ BOOL fActivate);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_OnFrameWindowActivate (BYVAL pthis AS DWORD PTR, BYVAL fActivate AS INTEGER) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' ResizeBorder method
      ' ****************************************************************************************
      ' Called by the MSHTML implementation of IOleInPlaceActiveObject::ResizeBorder.
      ' Parameters
      '    prcBorder
      '        [in] Constant pointer to a RECT for the new outer rectangle of the border.
      '    pUIWindow
      '        [in] Pointer to an IOleInPlaceUIWindow interface for the frame or document window
      '             whose border is to be changed.
      '    fFrameWindow
      '        [in] BOOL that is %TRUE if the frame window is calling IDocHostUIHandler::ResizeBorder,
      '             or %FALSE otherwise.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ResizeBorder )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ LPCRECT prcBorder,
      '     /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow,
      '     /* [in] */ BOOL fRameWindow);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_ResizeBorder (BYVAL pthis AS DWORD PTR, BYREF prcBorder AS RECT, BYVAL pUIWindow AS DWORD PTR, BYVAL fRameWindow AS INTEGER) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' TranslateAccelerator method
      ' ****************************************************************************************
      ' Called by MSHTML when IOleInPlaceActiveObject::TranslateAccelerator or
      ' IOleControlSite::TranslateAccelerator is called.
      ' Parameters
      '    lpMsg
      '        [in] Pointer to a MSG structure that specifies the message to be translated.
      '    pguidCmdGroup
      '        [in] Pointer to a GUID for the command group identifier.
      '    nCmdID
      '        [in] DWORD that specifies a command identifier.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' Remarks
      '    When you use accelerator keys such as TAB, you may need to override the default host
      '    behavior. The example shows how to do this.
      ' Example
      '    This example shows how to override the default host behavior that occurs when a user
      '    tabs out of the first or last element.
      '
      ' CYourControlSite::TranslateAccelerator(MSG *pMsg, DWORD dwFlags)
      ' {
      '     if (pMsg && pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB) {
      '             return S_FALSE;
      '     }
      ' }
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *TranslateAccelerator )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ LPMSG lpMsg,
      '     /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
      '     /* [in] */ DWORD nCmdID);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_TranslateAccelerator (BYVAL pthis AS DWORD PTR, lpMsg AS tagMSG, BYREF pguidCmdGroup AS GUID, BYVAL nCmdID AS DWORD) AS LONG
         FUNCTION = %S_OK
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' GetOptionKeyPath method
      ' ****************************************************************************************
      ' Called by the WebBrowser Control to retrieve a registry subkey path that overrides the
      ' default Microsoft Internet Explorer registry settings.
      ' Parameters
      '    pchKey
      '        [out] Pointer to an LPOLESTR that receives the registry subkey string where the
      '              host stores its registry settings.
      '    dw
      '        [in] Reserved. Must be set to %NULL.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' Remarks
      '    A WebBrowser Control instance calls GetOptionKeyPath on the host at initialization so
      '    that the host can specify a registry location containing settings that override the
      '    default Internet Explorer registry settings. If the host returns %S_FALSE for this
      '    method, or if the registry key path returned to the WebBrowser Control in pchKey is
      '    %NULL or empty, the WebBrowser Control reverts to the default Internet Explorer
      '    registry settings.
      '    GetOptionKeyPath and IDocHostUIHandler2::GetOverrideKeyPath provide two alternate
      '    mechanisms for a WebBrowser Control host to make changes in the registry settings for
      '    the WebBrowser Control. With GetOptionKeyPath, a WebBrowser Control instance defaults
      '    to its original settings before registry changes are applied from the registry path
      '    specified by the method. With GetOptionKeyPath, a WebBrowser Control instance
      '    preserves registry settings for the current user. Any registry changes located at the
      '    registry path specified by this method override those located in
      '    HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer.
      '    For example, assume that the user has changed the Internet Explorer default text size
      '    to the largest font. Implementing IDocHostUIHandler2::GetOverrideKeyPath preserves
      '    that change--unless the size has been specifically overridden in the registry settings
      '    located at the registry path specified by the implementation of GetOptionKeyPath.
      '    Implementing GetOptionKeyPath would not preserve the user's text size change. Instead,
      '    the WebBrowser Control defaults back to its original medium-size font before applying
      '    registry settings from the registry path specified by the GetOptionKeyPath
      '    implementation.
      '    An implementation of GetOptionKeyPath must allocate memory for pchKey using
      '    CoTaskMemAlloc. (The WebBrowser Control is responsible for freeing this memory using
      '    CoTaskMemFree). Even if this method is unimplemented, the parameter should be set to
      '    %NULL.
      '    The key specified by this method must be a subkey of the HKEY_CURRENT_USER key.
      ' Example
      '    This example points the WebBrowser Control to a registry key located at
      '    HKEY_CURRENT_USER/Software/YourCompany/YourApp for Internet Explorer registry
      '    overrides. Of course, you need to set registry keys at this location in the registry
      '    for the WebBrowser Control to use them.
      '
      ' HRESULT CBrowserHost::GetOptionKeyPath(LPOLESTR *pchKey, DWORD dwReserved)
      ' {
      '     HRESULT hr;
      '     WCHAR* szKey = L"Software\\MyCompany\\MyApp";
      
      '     //  cbLength is the length of szKey in bytes.
      '     size_t cbLength;
      '     hr = StringCbLengthW(szKey, 1280, &cbLength);
      '     //  TODO: Add error handling code here.
      
      '     if (pchKey)
      '     {
      '         *pchKey = (LPOLESTR)CoTaskMemAlloc(cbLength + sizeof(WCHAR));
      '         if (*pchKey)
      '             hr = StringCbCopyW(*pchKey, cbLength + sizeof(WCHAR), szKey);
      '     }
      '     else
      '         hr = E_INVALIDARG;
      
      '     return hr;
      ' }
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetOptionKeyPath )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [out] */ LPOLESTR __RPC_FAR *pchKey,
      '     /* [in] */ DWORD dw);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_GetOptionKeyPath (BYVAL pthis AS DWORD PTR, BYREF pchKey AS DWORD, BYVAL dw AS DWORD) AS LONG
         pchKey = 0
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' GetDropTarget method
      ' ****************************************************************************************
      ' Called by MSHTML when it is used as a drop target. This method enables the host to
      ' supply an alternative IDropTarget interface.
      ' Parameters
      '    pDropTarget
      '        [in] Pointer to an IDropTarget interface for the current drop target object
      '        supplied by MSHTML.
      '    ppDropTarget
      '        [out] Address of a pointer variable that receives an IDropTarget interface pointer
      '        for the alternative drop target object supplied by the host.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' Remarks
      '    If the host does not supply an alternative drop target, this method should return a
      '    failure code, such as %E_NOTIMPL or %E_FAIL.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetDropTarget )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
      '     /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_GetDropTarget (BYVAL pthis AS DWORD PTR, BYVAL pDropTarget AS DWORD PTR, BYREF ppDropTarget AS DWORD) AS LONG
         pDropTarget = 0
         FUNCTION = %E_NOTIMPL
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' GetExternal method
      ' ****************************************************************************************
      ' Called by MSHTML to obtain the host's IDispatch interface.
      ' Parameters
      '    ppDispatch
      '        [out] Address of a pointer to a variable that receives an IDispatch interface
      '        pointer for the host application.
      ' Return Value
      '    Returns %S_OK if successful, or an error value otherwise.
      ' Remarks
      '    If the host exposes an automation interface, it can provide a reference to MSHTML
      '    through ppDispatch.
      '    If the method implementation does not supply an IDispatch, ppDispatch should be set
      '    to %NULL, even if the method fails or returns %S_FALSE.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetExternal )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_GetExternal (BYVAL pthis AS DWORD PTR, BYREF ppDispatch AS DWORD) AS LONG
         ppDispatch = 0
         FUNCTION = %S_FALSE
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' TranslateUrl method
      ' ****************************************************************************************
      ' Called by MSHTML to give the host an opportunity to modify the URL to be loaded.
      ' Parameters
      '    dwTranslate
      '        [in] Reserved. Must be set to %NULL.
      '    pchURLIn
      '        [in] Pointer to an OLECHAR that specifies the current URL for navigation.
      '    ppchURLOut
      '        [out] Address of a pointer variable that receives an OLECHAR pointer containing
      '        the new URL.
      ' Return Value
      '    Returns %S_OK if the URL was translated, or %S_FALSE if the URL was not translated.
      ' Remarks
      '    The host allocates the buffer ppchURLOut using CoTaskMemAlloc.
      '    If the implementation of this method does not supply a URL, ppchURLOut should be set
      '    to %NULL, even if the method fails or returns %S_FALSE.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *TranslateUrl )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ DWORD dwTranslate,
      '     /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
      '     /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_TranslateUrl (BYVAL pthis AS DWORD PTR, BYVAL dwTranslate AS DWORD, BYVAL pchURLIn AS DWORD, BYREF ppchURLOut AS DWORD) AS LONG
         ppchURLOut = 0
         FUNCTION = %S_FALSE
      END FUNCTION
      ' ****************************************************************************************
      
      ' ****************************************************************************************
      ' FilterDataObject method
      ' ****************************************************************************************
      ' Called by MSHTML to allow the host to replace the MSHTML data object.
      ' Parameters
      '    pDO
      '        [in] Pointer to an IDataObject interface supplied by MSHTML.
      '    ppDORet
      '        [out] Address of a pointer variable that receives an IDataObject interface pointer
      '        supplied by the host.
      ' Return Value
      '    Returns %S_OK if the data object is replaced, or %S_FALSE if it's not replaced.
      ' Remarks
      '    This method enables the host to block certain clipboard formats or support additional
      '    clipboard formats.
      '    If the implementation of this method does not supply its own IDataObject, ppDORet
      '    should be set to %NULL, even if the method fails or returns %S_FALSE.
      ' ****************************************************************************************
      ' HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FilterDataObject )(
      '     IDocHostUIHandler __RPC_FAR * This,
      '     /* [in] */ IDataObject __RPC_FAR *pDO,
      '     /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
      ' ****************************************************************************************
      FUNCTION IDocHostUIHandler_FilterDataObject (BYVAL pthis AS DWORD PTR, BYVAL pDO AS DWORD PTR, BYREF ppDORet AS DWORD) AS LONG
         ppDORet = 0
         FUNCTION = %S_FALSE
      END FUNCTION
      ' ****************************************************************************************
      Last edited by José Roca; 30 Aug 2007, 06:37 PM.
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


      • #4
        Save as IEWBEVT2.INC
        Code:
        ' ********************************************************************************************
        ' DWebBrowserEvents2 dispatch interface
        ' IID = {34A715A0-6587-11D0-924A-0020AFC7AC4D}
        ' Microsoft documentation:
        ' [URL]http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/dwebbrowserevents2.asp[/URL] 
        ' ********************************************************************************************
        
        #INCLUDE "IDHUIH.INC"          ' IDocHostUIHandler interface
        
        ' ********************************************************************************************
        ' EXCEPINFO structure
        ' ********************************************************************************************
        TYPE DWebBrowserEvents2_EXCEPINFO
           wCode AS WORD               ' An error code describing the error.
           wReserved AS WORD           ' Reserved
           bstrSource AS DWORD         ' Source of the exception.
           bstrDescription AS DWORD    ' Textual description of the error.
           bstrHelpFile AS DWORD       ' Help file path.
           dwHelpContext AS DWORD      ' Help context ID.
           pvReserved AS DWORD         ' Reserved.
           pfnDeferredFillIn AS DWORD  ' Pointer to function that fills in Help and description info.
           scode AS DWORD              ' An error code describing the error.
        END TYPE
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Returns a pointer to a specified interface on an object to which a client currently holds an
        ' interface pointer.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_IUnknown_QueryInterface (BYVAL pthis AS DWORD PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
           LOCAL HRESULT AS LONG
           CALL DWORD @@pthis[0] USING DWebBrowserEvents2_IUnknown_QueryInterface(pthis, riid, ppvObj) TO HRESULT
           FUNCTION = HRESULT
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Decrements the reference count for the calling interface on a object. If the reference count
        ' on the object falls to 0, the object is freed from memory.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_IUnknown_Release (BYVAL pthis AS DWORD PTR) AS DWORD
           LOCAL DWRESULT AS DWORD
           CALL DWORD @@pthis[2] USING DWebBrowserEvents2_IUnknown_Release(pthis) TO DWRESULT
           FUNCTION = DWRESULT
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' IConnectionPointContainer::FindConnectionPoint
        ' Returns a pointer to the IConnectionPoint interface of a connection point for a specified IID,
        ' if that IID describes a supported outgoing interface.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_IConnectionPointContainer_FindConnectionPoint ( _
           BYVAL pthis AS DWORD PTR, BYREF riid AS GUID, BYREF ppCP AS DWORD) AS LONG
           LOCAL HRESULT AS LONG
           CALL DWORD @@pthis[4] USING DWebBrowserEvents2_IConnectionPointContainer_FindConnectionPoint(pthis, riid, ppCP) TO HRESULT
           FUNCTION = HRESULT
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' IConnectionPoint::Advise
        ' Establishes a connection between the connection point object and the client's sink.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_IConnectionPoint_Advise (BYVAL pthis AS DWORD PTR, _
           BYVAL pUnkSink AS DWORD, BYREF pdwCookie AS DWORD) AS LONG
           LOCAL HRESULT AS LONG
           CALL DWORD @@pthis[5] USING DWebBrowserEvents2_IConnectionPoint_Advise(pthis, pUnkSink, pdwCookie) TO HRESULT
           FUNCTION = HRESULT
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' IConnectionPoint::Unadvise
        ' Terminates an advisory connection previously established through IConnectionPoint_Advise.
        ' The dwCookie parameter identifies the connection to terminate.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_IConnectionPoint_Unadvise (BYVAL pthis AS DWORD PTR, BYVAL dwCookie AS DWORD) AS LONG
           LOCAL HRESULT AS LONG
           CALL DWORD @@pthis[6] USING DWebBrowserEvents2_IConnectionPoint_Unadvise(pthis, dwCookie) TO HRESULT
           FUNCTION = HRESULT
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' IDispatch virtual table
        ' ********************************************************************************************
        TYPE DWebBrowserEvents2_IDispatchVtbl
           QueryInterface AS DWORD     ' Returns pointers to supported interfaces
           AddRef AS DWORD             ' Increments reference count
           Release AS DWORD            ' Decrements reference count
           GetTypeInfoCount AS DWORD   ' Retrieves the number of type descriptions
           GetTypeInfo AS DWORD        ' Retrieves a description of object's programmable interface
           GetIDsOfNames AS DWORD      ' Maps name of method or property to DispId
           Invoke AS DWORD             ' Calls one of the object's methods, or gets/sets one of its properties
           pVtblAddr AS DWORD          ' Address of the virtual table
           cRef AS DWORD               ' Reference counter
           pthis AS DWORD              ' IUnknown or IDispatch of the control that fires the events
           fNewWindow3 AS LONG         ' Flag - indicates that the NewWindow3 event has been fired
        END TYPE
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' UI4 AddRef()
        ' Increments the reference counter.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_AddRef (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR) AS DWORD
           INCR @@pCookie.cRef
           FUNCTION = @@pCookie.cRef
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' HRESULT QueryInterface([in] *GUID riid, [out] **VOID ppvObj)
        ' Returns the IUnknown of our class and increments the reference counter.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_QueryInterface (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, _
           BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
           ppvObj = pCookie
           DWebBrowserEvents2_AddRef pCookie
           FUNCTION = %S_OK
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' UI4 Release()
        ' Releases our class if there is only a reference to him and decrements the reference counter.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_Release (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR) AS DWORD
           LOCAL pVtblAddr AS DWORD
           IF @@pCookie.cRef = 1 THEN
              pVtblAddr = @@pCookie.pVtblAddr
              IF ISTRUE HeapFree(GetProcessHeap(), 0, BYVAL pVtblAddr) THEN
                 FUNCTION = 0
                 EXIT FUNCTION
              ELSE
                 FUNCTION = @@pCookie.cRef
                 EXIT FUNCTION
              END IF
           END IF
           DECR @@pCookie.cRef
           FUNCTION = @@pCookie.cRef
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' HRESULT GetTypeInfoCount([out] *UINT pctinfo)
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_GetTypeInfoCount (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pctInfo AS DWORD) AS LONG
           FUNCTION = %E_NOTIMPL
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' HRESULT GetTypeInfo([in] UINT itinfo, [in] UI4 lcid, [out] **VOID pptinfo)
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_GetTypeInfo (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, _
           BYVAL itinfo AS DWORD, BYVAL lcid AS DWORD, BYREF pptinfo AS DWORD) AS LONG
           FUNCTION = %E_NOTIMPL
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' HRESULT GetIDsOfNames([in] *GUID riid, [in] **I1 rgszNames, [in] UINT cNames, [in] UI4 lcid, [out] *I4 rgdispid)
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_GetIDsOfNames ( BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, _
           BYREF riid AS GUID, BYVAL rgszNames AS DWORD, BYVAL cNames AS DWORD, BYVAL lcid AS DWORD, BYREF rgdispid AS LONG) AS LONG
           FUNCTION = %E_NOTIMPL
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Builds the IDispatch Virtual Table
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_BuildVtbl (BYVAL pthis AS DWORD) AS DWORD
        
           LOCAL pVtbl AS DWebBrowserEvents2_IDispatchVtbl PTR
           LOCAL pUnk AS DWebBrowserEvents2_IDispatchVtbl PTR
        
           pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
           IF pVtbl = 0 THEN EXIT FUNCTION
        
           @pVtbl.QueryInterface   = CODEPTR(DWebBrowserEvents2_QueryInterface)
           @pVtbl.AddRef           = CODEPTR(DWebBrowserEvents2_AddRef)
           @pVtbl.Release          = CODEPTR(DWebBrowserEvents2_Release)
           @pVtbl.GetTypeInfoCount = CODEPTR(DWebBrowserEvents2_GetTypeInfoCount)
           @pVtbl.GetTypeInfo      = CODEPTR(DWebBrowserEvents2_GetTypeInfo)
           @pVtbl.GetIDsOfNames    = CODEPTR(DWebBrowserEvents2_GetIDsOfNames)
           @pVtbl.Invoke           = CODEPTR(DWebBrowserEvents2_Invoke)
           @pVtbl.pVtblAddr        = pVtbl
           @pVtbl.pthis            = pthis
           @pVtbl.fNewWindow3      = %FALSE
        
           pUnk = VARPTR(@pVtbl.pVtblAddr)
           FUNCTION = pUnk
        
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Establishes a connection between the connection point object and the client's sink.
        ' Returns a token that uniquely identifies this connection.
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_ConnectEvents (BYVAL pthis AS DWORD, BYREF pdwCookie AS DWORD) AS LONG
        
           LOCAL HRESULT AS LONG                 ' HRESULT code
           LOCAL pCPC AS DWORD                   ' IConnectionPointContainer
           LOCAL pCP AS DWORD                    ' IConnectionPoint
           LOCAL IID_CPC AS GUID                 ' IID_IConnectionPointContainer
           LOCAL IID_CP AS GUID                  ' Events dispinterface
           LOCAL dwCookie AS DWORD               ' Returned token
           LOCAL pUnkSink AS DWORD               ' IUnknown of the class
        
           IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
           IID_CP  = GUID$("{34A715A0-6587-11D0-924A-0020AFC7AC4D}")
        
           IF pthis = 0 THEN FUNCTION = -1 : EXIT FUNCTION
           HRESULT = DWebBrowserEvents2_IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
           IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
        
           HRESULT = DWebBrowserEvents2_IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
           DWebBrowserEvents2_IUnknown_Release pCPC
           IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
        
           pUnkSink = DWebBrowserEvents2_BuildVtbl(pthis)
           IF ISTRUE pUnkSink THEN HRESULT = DWebBrowserEvents2_IConnectionPoint_Advise(pCP, pUnkSink, dwCookie)
           DWebBrowserEvents2_IUnknown_Release pCP
           pdwCookie = dwCookie
           FUNCTION = HRESULT
        
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Releases the events connection identified with the cookie returned by the ConnectEvents function
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_DisconnectEvents (BYVAL pthis AS DWORD, BYVAL dwCookie AS DWORD) AS LONG
        
           LOCAL HRESULT AS LONG                 ' HRESULT code
           LOCAL pCPC AS DWORD                   ' IConnectionPointContainer
           LOCAL pCP AS DWORD                    ' IConnectionPoint
           LOCAL IID_CPC AS GUID                 ' IID_IConnectionPointContainer
           LOCAL IID_CP AS GUID                  ' ConnectionEvents dispinterface
        
           IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
           IID_CP  = GUID$("{34A715A0-6587-11D0-924A-0020AFC7AC4D}")
        
           IF pthis = 0 THEN FUNCTION = -1 : EXIT FUNCTION
           HRESULT = DWebBrowserEvents2_IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
           IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
        
           HRESULT = DWebBrowserEvents2_IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
           DWebBrowserEvents2_IUnknown_Release pCPC
           IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
        
           HRESULT = DWebBrowserEvents2_IConnectionPoint_Unadvise(pCP, dwCookie)
           DWebBrowserEvents2_IUnknown_Release pCP
           FUNCTION = HRESULT
        
        END FUNCTION
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' StatusTextChange
        ' Member identifier: &H00000066 (102)
        ' Fires when the status bar text of the object has changed.
        ' The container can use the information provided by this event to update the text of a status bar.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_StatusTextChange (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Status bar text.
           LOCAL strText AS STRING : strText = VARIANT$(@pv[0])
        
        '  ======================================================================================
        '  Show the text in our status bar
        '  ======================================================================================
        
           LOCAL hWndMain AS DWORD
           LOCAL hSB AS DWORD
        
           ' Retrieve the handle of the main window
           hWndMain = phnxGetFormHandle(GetFocus())
           IF ISFALSE hWndMain THEN EXIT SUB
           ' Retrieve the handle of the status bar
           hSB = GetDlgItem(hWndMain, %IDC_FORM1_STATUSBAR1)
           IF ISFALSE hSB THEN EXIT SUB
           ' Show the changed statusbar text
           StatusBar_SetText hSB, 0, strText
        
        '  ======================================================================================
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' ProgressChange
        ' Member identifier: &H0000006C (108)
        ' Fires when the progress of a download operation is updated on the object.
        ' The container can use the information provided by this event to display the number of bytes
        ' downloaded so far or to update a progress indicator.
        ' To calculate the percentage of progress to show in a progress indicator, multiply the value
        ' of Progress by 100 and divide by the value of ProgressMax (unless Progress is -1, in which
        ' case the container can indicate that the operation is finished or hide the progress indicator).
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_ProgressChange (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the values of the parameters.
           LOCAL Progress AS LONG : Progress = VARIANT#(@pv[1])
           LOCAL ProgressMax AS LONG : ProgressMax = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' CommandStateChange
        ' Member identifier: &H00000069 (105)
        ' Fires when the enabled state of a command changes.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_CommandStateChange (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the values of the parameters.
           LOCAL nCommand AS LONG : nCommand = VARIANT#(@pv[1])
           LOCAL pfEnable AS INTEGER : pfEnable = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' DownloadBegin
        ' Member identifier: &H0000006A (106)
        ' Fires when a navigation operation is beginning.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_DownloadBegin (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' DownloadComplete
        ' Member identifier: &H00000068 (104)
        ' Fires when a navigation operation finishes, is halted, or fails.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_DownloadComplete (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' TitleChange
        ' Member identifier: &H00000071 (113)
        ' Fires when the title of a document in the object becomes available or changes.
        ' Because the title might change while an HTML page is downloading, the URL of the document is
        ' set as the title. After the title specified in the HTML page, if there is one, is parsed, the
        ' title is changed to reflect the actual title.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_TitleChange (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL strText AS STRING : strText = VARIANT$(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' BeforeNavigate2
        ' Member identifier: &H000000FA (250)
        ' Fires before navigation occurs in the given object (on either a window or frameset element).
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_BeforeNavigate2 (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           LOCAL pDisp AS DWORD : pDisp = VARIANT#(@pv[6])
           LOCAL URL AS VARIANT : URL = @pv[5]
           LOCAL Flags AS VARIANT : Flags = @pv[4]
           LOCAL TargetFrameName AS VARIANT : TargetFrameName = @pv[3]
           LOCAL PostData AS VARIANT : PostData = @pv[2]
           LOCAL Headers AS VARIANT : Headers = @pv[1]
           STATIC bCancel AS INTEGER : bCancel = VARIANT#(@pv[0])
        '  To return a value, use: bCancel = <value> : @pvapi[0][email protected] = bCancel
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' NewWindow2
        ' Member identifier: &H000000FB (251)
        ' Fires when a new window is to be created.
        ' BUG: [URL]http://support.microsoft.com/kb/294870/EN-US/[/URL] 
        ' When you use the NewWindow2 event in Internet Explorer 5.5, you may encounter the following
        ' problems:
        ' • If you click a link that performs a window.open method to browse to a new site, you receive
        '   an "unspecified error" error message.
        ' • If you right-click a link and then click Open in New Window, it does not navigate at all.
        ' When you use NewWindow2 in Internet Explorer 5, you may encounter the following problems:
        ' • If you click a link that performs a window.open method to browse to a new site, it does
        '   not navigate at all.
        ' • If you right-click a link and then click Open in New Window, you receive an "unspecified
        '    error" error message.
        ' When you use NewWindow2 in Internet Explorer 4.x, you may encounter the following problems:
        ' • If click a link that performs a window.open method to browse to a new site, it does not
        '   navigate.
        ' • If you right-click a link and then click Open in New Window, you receive an "unspecified
        '   error" error message.
        ' To work around this problem, open the link in a new window within your application instead
        ' of opening it in the same window.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_NewWindow2 (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           STATIC ppDisp AS DWORD : ppDisp = VARIANT#(@pv[1])
        '  To return a value, use: ppDisp = <value> : @pvapi[1][email protected] = ppDisp
           STATIC bCancel AS INTEGER : bCancel = VARIANT#(@pv[0])
        '  To return a value, use: bCancel = <value> : @pvapi[0][email protected] = bCancel
        
        '  ======================================================================================
        '  Cancel new window creation if the NewWindow3 event has been processed.
        '  ======================================================================================
           IF @@pCookie.fNewWindow3 = %TRUE THEN
              bCancel = -1 : @pvapi[0][email protected] = bCancel
           END IF
        '  ======================================================================================
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' NavigateComplete2
        ' Member identifier: &H000000FC (252)
        ' Fires after a navigation to a link is completed on either a window or frameSet element.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_NavigateComplete2 (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Variants to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           LOCAL pDisp AS DWORD : pDisp = VARIANT#(@pv[1])
           LOCAL URL AS VARIANT : URL = @pv[0]
        
        '  ======================================================================================
        '  Show the URL in the URL textbox
        '  ======================================================================================
        
           LOCAL hWndMain AS DWORD
           LOCAL hCtrl AS DWORD
        
           ' Retrieve the handle of the main window
           hWndMain = phnxGetFormHandle(GetFocus())
           IF ISFALSE hWndMain THEN EXIT SUB
        '   ' Retrieve the handle of the rebar control
        '   hCtrl = GetDlgItem(hWndMain, %IDC_FORM1_REBAR1)
        '   IF ISFALSE hCtrl THEN EXIT SUB
        '   ' Retrieve the handle of the edit control
        '   hCtrl = GetDlgItem(hCtrl, %IDC_FORM1_EDITURL)
        '   IF ISFALSE hCtrl THEN EXIT SUB
        '   ' Show the canonicalized and qualified URL
        '   SetWindowText hCtrl, VARIANT$(URL)
           SetWindowText hWndMain, VARIANT$(URL)
        
        '  ======================================================================================
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' DocumentComplete
        ' Member identifier: &H00000103 (259)
        ' Fires when a document has been completely loaded and initialized.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_DocumentComplete (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           LOCAL pDisp AS DWORD : pDisp = VARIANT#(@pv[1])
           LOCAL URL AS VARIANT : URL = @pv[0]
        
        '  ======================================================================================
        '  After the MSHTML document has been loaded we retrieve a reference to his CustomDoc
        '  interface and give him a pointer to our IDocHostUIHandler interface to allow for
        '  customization.
        '  ======================================================================================
        
           LOCAL hr AS LONG
           LOCAL ppDoc AS DWORD
           LOCAL ppCustomDoc AS DWORD
           LOCAL IID_ICustomDoc AS GUID
           LOCAL ppDocHostUIHandler AS DWORD
           LOCAL IID_IDocHostUIHandler AS GUID
        
           ' Get a reference to the active document
           ppDoc = IWebBrowser2_GetDocument(pthis)
           IF ISFALSE ppDoc THEN EXIT SUB
        
           ' Get a reference to the CustomDoc interface
           IID_ICustomDoc = GUID$("{3050f3f0-98b5-11cf-bb82-00aa00bdce0b}")
           hr = DWebBrowserEvents2_IUnknown_QueryInterface(ppDoc, IID_ICustomDoc, ppCustomDoc)
           IF ISFALSE ppCustomDoc THEN EXIT SUB
        
           ' Get a reference to our IDocHostUIHandler interface
           IID_IDocHostUIHandler = $IID_IDocHostUIHandler
           hr = IDocHostUIHandler_QueryInterface (ppDoc, IID_IDocHostUIHandler, ppDocHostUIHandler)
        
           ' Set our IDocHostUIHandler interface for MSHTML
           IF ppDocHostUIHandler THEN ICustomDoc_SetUIHandler ppCustomDoc, ppDocHostUIHandler
           DWebBrowserEvents2_IUnknown_Release ppCustomDoc
        
        '  ======================================================================================
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' OnVisible
        ' Member identifier: &H000000FE (254)
        ' Fires when the IWebBrowser2::Visible property of the object is changed.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_OnVisible (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL Visible AS INTEGER : Visible = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' WindowSetResizable
        ' Member identifier: &H00000106 (262)
        ' Fires to indicate whether the host window should allow or disallow resizing of the object.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_WindowSetResizable (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL Resizable AS INTEGER : Resizable = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' WindowSetLeft
        ' Member identifier: &H00000108 (264)
        ' Fires when the object changes its left position.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_WindowSetLeft (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL prmLeft AS LONG : prmLeft = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Function name: WindowSetTop
        ' Dispatch interface name: DWebBrowserEvents2
        ' Member identifier: &H00000109 (265)
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_WindowSetTop (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL Top AS LONG : Top = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' WindowSetWidth
        ' Member identifier: &H0000010A (266)
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_WindowSetWidth (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL nWidth AS LONG : nWidth = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' WindowSetHeight
        ' Member identifier: &H0000010B (267)
        ' Fires when the object changes its height.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_WindowSetHeight (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL Height AS LONG : Height = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' WindowClosing
        ' Member identifier: &H00000107 (263)
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_WindowClosing (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           LOCAL IsChildWindow AS INTEGER : IsChildWindow = VARIANT#(@pv[1])
           STATIC bCancel AS INTEGER : bCancel = VARIANT#(@pv[0])
        '  To return a value, use: bCancel = <value> : @pvapi[0][email protected] = bCancel
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' ClientToHostWindow
        ' Member identifier: &H0000010C (268)
        ' Fires to request that the client window size be converted to the host window size.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_ClientToHostWindow (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           STATIC CX AS LONG : CX = VARIANT#(@pv[1])
        '  To return a value, use: CX = <value> : @pvapi[1][email protected] = CX
           STATIC CY AS LONG : CY = VARIANT#(@pv[0])
        '  To return a value, use: CY = <value> : @pvapi[0][email protected] = CY
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' SetSecureLockIcon
        ' Member identifier: &H0000010D (269)
        ' Fires when there is a change in encryption level.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_SetSecureLockIcon (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL SecureLockIcon AS LONG : SecureLockIcon = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' FileDownload
        ' Member identifier: &H0000010E (270)
        ' Fires to indicate that a file download is about to occur. If a file download dialog is to be
        ' displayed, this event is fired prior to the display of the dialog.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_FileDownload (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the value of the parameter.
           STATIC bCancel AS INTEGER : bCancel = VARIANT#(@pv[0])
        '  To return a value, use: bCancel = <value> : @pvapi[0][email protected] = bCancel
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' NavigateError
        ' Member identifier: &H0000010F (271)
        ' Fires when an error occurs during navigation.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_NavigateError (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
        '  Get the values of the parameters.
           LOCAL pDisp AS DWORD : pDisp = VARIANT#(@pv[4])
           LOCAL URL AS VARIANT : URL = @pv[3]
           LOCAL prmFrame AS VARIANT : prmFrame = @pv[2]
           LOCAL StatusCode AS VARIANT : StatusCode = @pv[1]
           STATIC bCancel AS INTEGER : bCancel = VARIANT#(@pv[0])
        '  To return a value, use: bCancel = <value> : @pvapi[0][email protected] = bCancel
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' PrintTemplateInstantiation
        ' Member identifier: &H000000E1 (225)
        ' Fires when a print template has been instantiated.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_PrintTemplateInstantiation (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL pDisp AS DWORD : pDisp = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' PrintTemplateTeardown
        ' Member identifier: &H000000E2 (226)
        ' Fires when a print template has been destroyed.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_PrintTemplateTeardown (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IDispatch of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL pDisp AS DWORD : pDisp = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' PrivacyImpactedStateChange
        ' Member identifier: &H00000110 (272)
        ' Fired when an event occurs that impacts privacy or when a user navigates away from a URL
        ' that has impacted privacy.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_PrivacyImpactedStateChange (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IUnknown of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointer to access the parameter.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
        '  Get the value of the parameter.
           LOCAL bImpacted AS INTEGER : bImpacted = VARIANT#(@pv[0])
        
        END SUB
        ' ********************************************************************************************
        
        ' ********************************************************************************************
        ' Function name: NewWindow3
        ' Member identifier: &H00000111 (273)
        ' Raised when a new window is to be created. Extends DWebBrowserEvents2::NewWindow2 with
        ' additional information about the new window.
        ' Note: NewWindow3 is available only in Microsoft Windows XP Service Pack 2 (SP2) or later.
        ' ********************************************************************************************
        SUB DWebBrowserEvents2_NewWindow3 (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
        
        '  Retrieve the IUnknown of the control that has fired the event.
           LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
        '  Pointers to access the parameters.
           LOCAL pv AS VARIANT PTR : pv = pdispparams.VariantArgs
           LOCAL pvapi AS VARIANTAPI PTR : pvapi = pv
           STATIC ppDisp AS DWORD : ppDisp = VARIANT#(@pv[4])
        '  To return a value, use: ppDisp = <value> : @pvapi[4][email protected] = ppDisp
           STATIC bCancel AS INTEGER : bCancel = VARIANT#(@pv[3])
        '  To return a value, use: bCancel = <value> : @pvapi[0][email protected] = bCancel
           LOCAL dwFlags AS DWORD : dwFlags = VARIANT#(@pv[2])
           LOCAL strUrlContext AS STRING : strUrlContext = VARIANT$(@pv[1])
           LOCAL strUrl AS STRING : strUrl = VARIANT$(@pv[0])
        
        '  ======================================================================================
        '  Code to force to show the page in the same window.
        '  ======================================================================================
        
        '   LOCAL hr AS LONG
        '   LOCAL hWndMain AS DWORD
        '   LOCAL vURL AS VARIANT
        
        '   ' Cancel new window creation. We will use our own window.
        '   bCancel = -1 : @pvapi[0][email protected] = bCancel
        
        '   ' Returns "?ttp://" instead of "http://" (must be a bug)
        '   IF LEFT$(strURL, 1) <> "h" THEN MID$(strURL, 1, 1) = "h"
        '   vURL = strURL
        
        '   ' The combination of the %NWMF_FIRST_USERINITED and %NWMF_USERINITED flags
        '   ' indicate that is the first query that results of a user-initiated action
        '   ' (a mouse click or key press). Otherwise, it must be a popup.
        '   IF (dwFlags AND %NWMF_FIRST_USERINITED) = %NWMF_FIRST_USERINITED AND _
        '      (dwFlags AND %NWMF_USERINITED) = %NWMF_USERINITED THEN
        '      IWebBrowser2_Navigate2 pthis, vURL
        '      Flag that this event has been fired.
        '      @@pCookie.fNewWindow3 = %TRUE
        '   ELSE
        '      ' Popup blocker.
        '      ' Retrieve the handle of the main window
        '      hWndMain = phnxGetFormHandle(GetFocus())
        '      hr = MessageBox(BYVAL hWndMain, "Do you want to activate the popup window?" & $CRLF & strURL, _
        '           "Popup blocked", %MB_YESNOCANCEL OR %MB_ICONQUESTION OR %MB_APPLMODAL)
        '      IF hr = %IDYES THEN IWebBrowser2_Navigate2 pthis, vURL
        '   END IF
        
        '  ======================================================================================
        
        END SUB
        ' ********************************************************************************************
        
        
        ' ********************************************************************************************
        ' HRESULT Invoke([in] I4 dispidMember, [in] *GUID riid, [in] UI4 lcid, [in] UI2 wFlags, [in] *DISPPARAMS pdispparams, [out] *VARIANT pvarResult, [out] *EXCEPINFO pexcepinfo, [out] *UINT puArgErr)
        ' ********************************************************************************************
        FUNCTION DWebBrowserEvents2_Invoke (BYVAL pCookie AS DWebBrowserEvents2_IDispatchVtbl PTR, BYVAL dispidMember AS LONG, BYREF riid AS GUID, _
           BYVAL lcid AS DWORD, BYVAL wFlags AS WORD, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT, _
           BYREF pexcepinfo AS DWebBrowserEvents2_EXCEPINFO, BYREF puArgErr AS DWORD) AS LONG
        
           FUNCTION = %S_OK
        
           IF VARPTR(pdispparams) THEN
        
              SELECT CASE AS LONG dispidMember
                 CASE &H00000066  ' (102)  ' // StatusTextChange
                    DWebBrowserEvents2_StatusTextChange pCookie, pdispparams
                 CASE &H0000006C  ' (108)  ' // ProgressChange
                    DWebBrowserEvents2_ProgressChange pCookie, pdispparams
                 CASE &H00000069  ' (105)  ' // CommandStateChange
                    DWebBrowserEvents2_CommandStateChange pCookie, pdispparams
                 CASE &H0000006A  ' (106)  ' // DownloadBegin
                    DWebBrowserEvents2_DownloadBegin pCookie, pdispparams
                 CASE &H00000068  ' (104)  ' // DownloadComplete
                    DWebBrowserEvents2_DownloadComplete pCookie, pdispparams
                 CASE &H00000071  ' (113)  ' // TitleChange
                    DWebBrowserEvents2_TitleChange pCookie, pdispparams
                 CASE &H000000FA  ' (250)  ' // BeforeNavigate2
                    DWebBrowserEvents2_BeforeNavigate2 pCookie, pdispparams
                 CASE &H000000FB  ' (251)  ' // NewWindow2
                    DWebBrowserEvents2_NewWindow2 pCookie, pdispparams
                 CASE &H000000FC  ' (252)  ' // NavigateComplete2
                    DWebBrowserEvents2_NavigateComplete2 pCookie, pdispparams
                 CASE &H00000103  ' (259)  ' // DocumentComplete
                    DWebBrowserEvents2_DocumentComplete pCookie, pdispparams
                 CASE &H000000FE  ' (254)  ' // OnVisible
                    DWebBrowserEvents2_OnVisible pCookie, pdispparams
                 CASE &H00000106  ' (262)  ' // WindowSetResizable
                    DWebBrowserEvents2_WindowSetResizable pCookie, pdispparams
                 CASE &H00000108  ' (264)  ' // WindowSetLeft
                    DWebBrowserEvents2_WindowSetLeft pCookie, pdispparams
                 CASE &H00000109  ' (265)  ' // WindowSetTop
                    DWebBrowserEvents2_WindowSetTop pCookie, pdispparams
                 CASE &H0000010A  ' (266)  ' // WindowSetWidth
                    DWebBrowserEvents2_WindowSetWidth pCookie, pdispparams
                 CASE &H0000010B  ' (267)  ' // WindowSetHeight
                    DWebBrowserEvents2_WindowSetHeight pCookie, pdispparams
                 CASE &H00000107  ' (263)  ' // WindowClosing
                    DWebBrowserEvents2_WindowClosing pCookie, pdispparams
                 CASE &H0000010C  ' (268)  ' // ClientToHostWindow
                    DWebBrowserEvents2_ClientToHostWindow pCookie, pdispparams
                 CASE &H0000010D  ' (269)  ' // SetSecureLockIcon
                    DWebBrowserEvents2_SetSecureLockIcon pCookie, pdispparams
                 CASE &H0000010E  ' (270)  ' // FileDownload
                    DWebBrowserEvents2_FileDownload pCookie, pdispparams
                 CASE &H0000010F  ' (271)  ' // NavigateError
                    DWebBrowserEvents2_NavigateError pCookie, pdispparams
                 CASE &H000000E1  ' (225)  ' // PrintTemplateInstantiation
                    DWebBrowserEvents2_PrintTemplateInstantiation pCookie, pdispparams
                 CASE &H000000E2  ' (226)  ' // PrintTemplateTeardown
                    DWebBrowserEvents2_PrintTemplateTeardown pCookie, pdispparams
                 CASE &H00000110  ' (272)  ' // PrivacyImpactedStateChange
                    DWebBrowserEvents2_PrivacyImpactedStateChange pCookie, pdispparams
                 CASE &H00000111  ' (273)  ' // NewWindow3
                    DWebBrowserEvents2_NewWindow3 pCookie, pdispparams
        
              END SELECT
        
           END IF
        
        END FUNCTION
        ' ********************************************************************************************
        Last edited by José Roca; 30 Aug 2007, 06:38 PM.
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          Minibrowser example
          Code:
          #DIM ALL
          #COMPILE EXE
          #OPTION VERSION4
          #INCLUDE "WIN32API.INC"
          #INCLUDE "COMMCTRL.INC"
          #INCLUDE "IEWB2.INC"
          
          ' ========================================================================================
          ' Identifiers
          ' ========================================================================================
          ' Form1
          %IDD_FORM1                                  = 100
          %IDC_FORM1_STATUSBAR1                       = 101
          %IDC_FORM1_REBAR1                           = 102
          %IDC_FORM1_WEBBROWSER1                      = 103
          %IDC_FORM1_TOOLBAR1                         = 104
          %IDC_FORM1_EDITURL                          = 105
          %IDC_FORM1_GOBTN                            = 106
          
          ' Rebar1
          %IDS_STRING0                                = 32770
          %IDS_STRING1                                = 32771
          %IDS_STRING2                                = 32772
          
          ' Command
          %IDM_GOBACK                                 = 28000
          %IDM_GOFORWARD                              = 28001
          %IDM_FIND                                   = 28002
          %IDM_PRINTPREVIEW                           = 28003
          %IDM_PRINT                                  = 28004
          %IDM_PROPERTIES                             = 28005
          %IDM_FILE_SAVE                              = 28006
          %IDM_PAGESETUP                              = 28007
          
          ' ========================================================================================
          ' Globals
          ' ========================================================================================
          GLOBAL  ghInstance              AS DWORD    ' handle of the application instance
          
          GLOBAL  gdwADM_ALIGNCONTROLS    AS DWORD    ' identifier of registered message
          ' Purpose: sent to a form or panel to reposition controls with alignment
          '          styles after the form or panel has been resized or scrolled.
          ' wParam:  N/A
          ' lParam:  the low-order word is the width, and the high-order word the height of the client area
          ' Return:  N/A
          
          GLOBAL  gdwADM_REALIGNPARTS     AS DWORD    ' identifier of registered message
          ' Purpose: posted by the parent of a status bar control to realign
          '          the status bar panels.
          ' wParam:  handle of parent of statusbar
          ' lParam:  handle of statusbar
          ' Return:  N/A
          GLOBAL  gdwCookie               AS DWORD    ' events cookie
          ' ========================================================================================
          
          ' ========================================================================================
          ' PROCEDURE: phnxAdjustWindowRect
          ' PURPOSE:   Adjusts the bounding rectangle of a nonresizeable window, based
          '            on the desired size of the client area, when a system parameter
          '            changes.
          ' ========================================================================================
          FUNCTION phnxAdjustWindowRect _
            ( _
            BYVAL hWnd      AS DWORD, _ ' window handle
            BYVAL cxClient  AS LONG, _  ' desired width of client area in pixels
            BYVAL cyClient  AS LONG _   ' desired height of client area in pixels
            ) AS LONG
          
            LOCAL trc     AS RECT
            LOCAL trcTemp AS RECT
            LOCAL hMenu   AS DWORD
            LOCAL dwStyle AS DWORD
            LOCAL cx      AS LONG
            LOCAL cy      AS LONG
          
            ' Calculate the height of the window taking menu wrap into account
            trc.nLeft   = 0
            trc.nTop    = 0
            trc.nRight  = cxClient
            trc.nBottom = cyClient
            hMenu   = GetMenu(hWnd)
            dwStyle = GetWindowLong(hWnd, %GWL_STYLE)
            AdjustWindowRectEx trc, dwStyle, (hMenu <> %NULL), GetWindowLong(hWnd, %GWL_EXSTYLE)
            ' If there is a menu, check how much wrapping occurs when we set the window
            ' to the width specified by AdjustWindowRect and an infinite amount of height.
            ' An infinite height allows us to see every single menu wrap.
            IF ISTRUE hMenu THEN
              trcTemp = trc
              trcTemp.nBottom = &H7FFF  ' "Infinite" height
              SendMessage hWnd, %WM_NCCALCSIZE, %FALSE, BYVAL VARPTR(trcTemp)
              ' Adjust our previous calculation to compensate for menu wrapping.
              trc.nBottom = trc.nBottom + trcTemp.nTop
            END IF
            ' AdjustWindowRectEx does not take the standard scrollbars into account
            IF (dwStyle AND %WS_HSCROLL) = %WS_HSCROLL THEN
              trc.nBottom = trc.nBottom + GetSystemMetrics(%SM_CYHSCROLL)
            END IF
            IF (dwStyle AND %WS_VSCROLL) = %WS_VSCROLL THEN
              trc.nRight = trc.nRight + GetSystemMetrics(%SM_CXVSCROLL)
            END IF
            cx = trc.nRight - trc.nLeft
            cy = trc.nBottom - trc.nTop
            SetWindowPos hWnd, %NULL, 0, 0, cx, cy, %SWP_NOZORDER OR %SWP_NOMOVE OR %SWP_NOACTIVATE
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: phnxCenterWindow
          ' PURPOSE:   Centers one window over another.  It also ensures that the
          '            placement is within the 'working area', meaning that it is
          '            both within the display limits of the screen, -and- not
          '            obscured by the tray or other frameing elements of the
          '            desktop.
          ' ========================================================================================
          FUNCTION phnxCenterWindow _
            ( _
            BYVAL hWndChild   AS DWORD, _ ' handle of window to center
            BYVAL hWndParent  AS DWORD _  ' handle of reference window or NULL if window is the screen
            ) AS LONG
          
            LOCAL trcChild      AS RECT     ' Child window dimensions
            LOCAL trcParent     AS RECT     ' Parent window dimensions
            LOCAL trcWorkArea   AS RECT     ' Work area dimensions
            LOCAL tpt           AS POINTAPI ' x and y coordinate of centered window
            LOCAL cxChild       AS LONG     ' Width of child window
            LOCAL cyChild       AS LONG     ' Height of child window
            LOCAL cxParent      AS LONG     ' Width of parent window
            LOCAL cyParent      AS LONG     ' Height of parent window
            LOCAL fResult       AS LONG     ' Return flag for SystemParametersInfo()
          
            ' Get the Height and Width of the child window
            GetWindowRect hWndChild, trcChild
            cxChild = trcChild.nRight - trcChild.nLeft
            cyChild = trcChild.nBottom - trcChild.nTop
          
            ' Get the limits of the 'workarea'
            fResult = SystemParametersInfo(%SPI_GETWORKAREA, SIZEOF(trcWorkArea), BYVAL VARPTR(trcWorkArea), 0)
            IF ISFALSE(fResult) THEN
              trcWorkArea.nLeft   = 0
              trcWorkArea.nTop    = 0
              trcWorkArea.nRight  = GetSystemMetrics(%SM_CXSCREEN)
              trcWorkArea.nBottom = GetSystemMetrics(%SM_CYSCREEN)
            END IF
          
            ' Get the Height and Width of the parent window
            IF ISTRUE hWndParent THEN
              GetWindowRect hWndParent, trcParent
            ELSE
              trcParent.nLeft   = trcWorkArea.nLeft
              trcParent.nTop    = trcWorkArea.nTop
              trcParent.nRight  = trcWorkArea.nRight
              trcParent.nBottom = trcWorkArea.nBottom
            END IF
            cxParent = trcParent.nRight - trcParent.nLeft
            cyParent = trcParent.nBottom - trcParent.nTop
          
            ' Calculate new X position, then adjust for workarea
            tpt.x = trcParent.nLeft + ((cxParent - cxChild) \ 2)
            IF (tpt.x < trcWorkArea.nLeft) THEN
              tpt.x = trcWorkArea.nLeft
              ELSEIF ((tpt.x + cxChild) > trcWorkArea.nRight) THEN
                tpt.x = trcWorkArea.nRight - cxChild
            END IF
          
            ' Calculate new Y position, then adjust for workarea
            tpt.y = trcParent.nTop  + ((cyParent - cyChild) \ 2)
            IF (tpt.y < trcWorkArea.nTop) THEN
              tpt.y = trcWorkArea.nTop
              ELSEIF ((tpt.y + cyChild) > trcWorkArea.nBottom) THEN
                tpt.y = trcWorkArea.nBottom - cyChild
            END IF
          
            IF (GetWindowLong(hWndChild, %GWL_STYLE) AND %WS_CHILD) = %WS_CHILD THEN
              ScreenToClient hWndParent, tpt
            END IF
          
            ' Reposition the window
            FUNCTION = SetWindowPos(hWndChild, %NULL, tpt.x, tpt.y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER)
          
          END FUNCTION
          
          ' ========================================================================================
          ' FUNCTION: phnxGetFormHandle
          ' PURPOSE:  Finds the handle of the top-level window or MDI child
          '           window that is the ancestor of the specified window.  The
          '           reference handle is the handle of any control on the form.
          ' RETURNS:  The handle of the form.
          ' ========================================================================================
          
          FUNCTION phnxGetFormHandle _
            ( _
            BYVAL hWnd  AS DWORD _  ' reference handle
            ) AS DWORD
          
            WHILE ISTRUE (GetWindowLong(hWnd, %GWL_STYLE) AND %WS_CHILD)
              IF ISTRUE (GetWindowLong(hWnd, %GWL_EXSTYLE) AND %WS_EX_MDICHILD) THEN EXIT LOOP
              hWnd = GetParent(hWnd)
            WEND
          
            FUNCTION = hWnd
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: RealignStatusPanels
          ' PURPOSE:   Realigns the panels and embedded controls of the specified
          '            statusbar when the control is resized.
          ' ========================================================================================
          
          FUNCTION RealignStatusPanels _
            ( _
            BYVAL hWndParent  AS DWORD, _ ' handle of original parent
            BYVAL hWndStatus  AS DWORD, _ ' handle of statusbar
            BYVAL lOffsetPart AS LONG _   ' TRUE = offset last panel from size grip
            ) AS LONG
          
            LOCAL trc           AS RECT
            LOCAL plEdge        AS LONG PTR             ' address of array of right edges
            LOCAL plInfo        AS LONG PTR
            LOCAL hWndChild     AS DWORD                ' handle of child window
            LOCAL lNumParts     AS LONG
            LOCAL lPartIdx      AS LONG
            LOCAL dx            AS LONG
            DIM   cxBorder(2)   AS LONG
          
            ' Allocate memory for the coordinate of the right edge of each panel
            plEdge = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, 256 * 4)
            IF ISTRUE plEdge THEN
              lNumParts = SendMessage(hWndStatus, %SB_GETPARTS, 0, BYVAL 0)
              IF lNumParts > 0 THEN
                ' Get the right edge of each panel
                SendMessage hWndStatus, %SB_GETPARTS, lNumParts, BYVAL plEdge
                ' Get the spacing between panel
                ' The inter-panel spacing is in cxBorder(2)
                SendMessage hWndStatus, %SB_GETBORDERS, 0, BYVAL VARPTR(cxBorder(0))
                ' Calculate the change in the position of the right edges
                GetClientRect hWndStatus, trc
                dx = trc.nRight - cxBorder(2) - @plEdge[lNumParts - 1]
                IF ISTRUE lOffsetPart THEN
                  IF (GetWindowLong(hWndStatus, %GWL_STYLE) AND %SBARS_SIZEGRIP) = %SBARS_SIZEGRIP THEN
                    IF ISFALSE IsZoomed(hWndParent) THEN dx = dx - GetSystemMetrics(%SM_CXVSCROLL)
                  END IF
                END IF
                lPartIdx = 0
          
                DO UNTIL lPartIdx >= lNumParts
                  @plEdge[lPartIdx] = @plEdge[lPartIdx] + dx
                  INCR lPartIdx
                LOOP
          
                SendMessage hWndStatus, %SB_SETPARTS, lNumParts, BYVAL plEdge
                ' Realign embedded controls
                @plEdge[0] = hWndStatus
                @plEdge[1] = dx
                EnumChildWindows hWndStatus, CODEPTR(RealignStatus_ChildEnumProc), plEdge
              END IF
              ' Free memory that was allocated for the edge info
              HeapFree GetProcessHeap(), 0, BYVAL plEdge
            END IF
          
          END FUNCTION
          
          ' ========================================================================================
          '  TITLE: StatusBar_SetText
          '   DESC: Sets the text in the specified part of a status window.
          ' SYNTAX: StatusBar_SetText hStatus, iPart, sText
          ' Parameters:
          '   hStatus   - The handle of the Status Bar control.
          '   iPart     - Zero-based index of the part to set. If this value is 255,
          '               the status window is assumed to be a simple window having
          '               only one part.
          '   sText     - String that specifies the text to set.
          '   uType     - Type of drawing operation. This parameter can be one of the
          '               following:
          '
          ' Value          Meaning
          ' -------------- ----------------------------------------------------------
          ' 0              The text is drawn with a border to appear lower than the plane of the window.
          ' SBT_NOBORDERS  The text is drawn without borders.
          ' SBT_POPOUT     The text is drawn with a border to appear higher than the plane of the window.
          ' SBT_RTLREADING Displays text using right-to-left reading order on Hebrew or Arabic systems.
          '
          ' Return Values:
          '   If the operation succeeds, the return value is TRUE.
          '   If the operation fails, the return value is FALSE.
          '
          ' Remarks:
          '   The message invalidates the portion of the window that has changed, causing
          '   it to display the new text when the window next receives the WM_PAINT message.
          
          ' ========================================================================================
          
          FUNCTION StatusBar_SetText (BYVAL hStatus AS DWORD, BYVAL iPart AS DWORD, BYVAL strText AS STRING, OPT BYVAL uType AS DWORD) AS LONG
             FUNCTION = SendMessage (hStatus, %SB_SETTEXT, iPart OR uType, BYVAL STRPTR(strText))
          END FUNCTION
          
          ' ========================================================================================
          ' IOleCommandTarget_Exec method
          ' Executes a specified command or displays help for a command.
          ' ========================================================================================
          FUNCTION IOleCommandTarget_Exec (BYVAL pthis AS DWORD PTR, BYREF pguidCmdGroup AS GUID, BYVAL nCmdID AS DWORD, BYVAL nCmdexecopt AS DWORD, BYREF pvaIn AS VARIANT, BYREF pvaOut AS VARIANT) AS LONG
              LOCAL HRESULT AS LONG
              IF pthis = 0 THEN FUNCTION = %E_POINTER : EXIT FUNCTION
              CALL DWORD @@pthis[4] USING IOleCommandTarget_Exec(pthis, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut) TO HRESULT
              FUNCTION = HRESULT
          END FUNCTION
          ' ========================================================================================
          
          ' ========================================================================================
          ' Events code iclude file
          ' ========================================================================================
          #INCLUDE "IEWBEVT2.INC"        ' WebBrowser events
          ' ========================================================================================
          
          ' ========================================================================================
          ' FUNCTION: RealignStatus_ChildEnumProc
          ' PURPOSE:  Enumerates all embedded controls in a statusbar.
          ' ========================================================================================
          
          FUNCTION RealignStatus_ChildEnumProc _
            ( _
            BYVAL hWnd    AS DWORD, _ ' handle of child window
            BYVAL lParam  AS LONG _   ' address of realignment info
            ) AS LONG
          
            LOCAL trc         AS RECT
            LOCAL plEdge      AS LONG PTR
            LOCAL hWndStatus  AS DWORD
            LOCAL dx          AS LONG
            LOCAL x           AS LONG
            LOCAL y           AS LONG
            LOCAL cy          AS LONG
          
            plEdge     = lParam
            hWndStatus = @plEdge[0]
            dx         = @plEdge[1]
          
            IF GetParent(hWnd) = hWndStatus THEN
              ' Get the bounding rectangle of the embedded control
              GetWindowRect hWnd, trc
              MapWindowPoints %NULL, hWndStatus, BYVAL VARPTR(trc), 2
              x  = trc.nLeft + dx
              cy = trc.nBottom - trc.nTop
              ' Get the bounding rectangle of any panel
              SendMessage hWndStatus, %SB_GETRECT, 0, BYVAL VARPTR(trc)
              y = (trc.nTop + trc.nBottom - cy) \ 2
              SetWindowPos hWnd, %NULL, x, y, 0, 0, %SWP_NOZORDER OR %SWP_NOSIZE OR %SWP_DRAWFRAME
            END IF
          
            FUNCTION = %TRUE
          
          END FUNCTION
          
          
          ' ========================================================================================
          ' PROCEDURE: Form1_InitWindow
          ' PURPOSE:   Initializes main window of this application instance.
          ' RETURN:    FALSE if initialization was successful, TRUE to close the window on
          '            failure.
          ' ========================================================================================
          
          FUNCTION Form1_InitWindow _
            ( _
            BYVAL hWnd    AS DWORD, _ ' handle of main window
            BYVAL lParam  AS LONG _   ' address of command line
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_TranslateMessage
          ' PURPOSE:   Preprocesses messages.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_TranslateMessage _
            ( _
            BYVAL hWnd  AS DWORD, _   ' handle of window
                  tmsg  AS tagMsg _   ' message information
            ) AS LONG
          
          ' Retrieve the handle of the window that hosts the WebBrowser control
            LOCAL hCtrl AS DWORD
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            ' Retrieve the ancestor of the control that has the focus
            LOCAL hWndCtrl AS DWORD
            hWndCtrl = GetFocus
            DO
               IF ISFALSE GetParent(hWndCtrl) OR GetParent(hWndCtrl) = hWnd THEN EXIT DO
               hWndCtrl = GetParent(hWndCtrl)
            LOOP
          ' %WM_FORWARDMSG = &H37F
          ' If the focus is in the WebBrowser, forward the message to it
          '  IF hCtrl = GetParent(GetParent(GetParent(GetFocus))) THEN
            IF hCtrl = hWndCtrl THEN
               IF ISTRUE SendMessage(hCtrl, &H37F, 0, VARPTR(tmsg)) THEN FUNCTION = %TRUE
            END IF
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnClose
          ' PURPOSE:   Form1 WM_CLOSE message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnClose _
            ( _
            BYVAL hWnd  AS DWORD _  ' window handle
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnCreate
          ' PURPOSE:   Form1 WM_CREATE message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnCreate _
            ( _
            BYVAL hWnd        AS DWORD, _ ' window handle
            BYVAL lptcs       AS DWORD, _ ' address of CREATESTRUCT structure
                  lMsgResult  AS LONG _   ' value returned to message
            ) AS LONG
          
            LOCAL hr AS LONG
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
            LOCAL dwCookie AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Connect to the events fired by the control
            hr = DWebBrowserEvents2_ConnectEvents(ppvObj, dwCookie)
            ' Store the cookie in the control properties
            SetProp hCtrl, "COOKIE", dwCookie
            ' Call the GoHome method
            IWebBrowser2_GoHome ppvObj
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnDestroy
          ' PURPOSE:   Form1 WM_DESTROY message handler.
          ' ========================================================================================
          
          SUB Form1_OnDestroy _
            ( _
            BYVAL hWnd        AS DWORD, _ ' window handle
                  lMsgResult  AS LONG _   ' value returned to message
            )
          
            LOCAL hr AS LONG
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
            LOCAL dwCookie AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT SUB
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT SUB
            ' Retrieve the events cookie
            dwCookie = GetProp(hCtrl, "COOKIE")
            ' Disconnect events
            IF dwCookie THEN hr = DWebBrowserEvents2_DisconnectEvents(ppvObj, dwCookie)
            ' Remove the cookie from the control
            RemoveProp hCtrl, "COOKIE"
            ' Release the interface
            WbRelease ppvObj
          
          END SUB
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnQueryEndSession
          ' PURPOSE:   Form1 WM_QUERYENDSESSION message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnQueryEndSession _
            ( _
            BYVAL hWnd        AS DWORD, _ ' window handle
            BYVAL lSource     AS LONG, _  ' source of end-session request
            BYVAL fLogOff     AS LONG, _  ' logoff flag
                  lMsgResult  AS LONG _   ' value returned to message
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnSize
          ' PURPOSE:   Form1 WM_SIZE message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnSize _
            ( _
            BYVAL hWnd      AS DWORD, _ ' window handle
            BYVAL lState    AS LONG, _  ' resizing state
            BYVAL cxClient  AS LONG, _  ' width of client area
            BYVAL cyClient  AS LONG _   ' height of client area
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL rc AS RECT
            LOCAL rbh AS LONG
            LOCAL sbh AS LONG
          
            ' Height of the rebar
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_REBAR1)
            GetClientRect hCtrl, rc
            rbh = rc.nBottom - rc.nTop
          
            ' Height of the statusbar
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_STATUSBAR1)
            GetClientRect hCtrl, rc
            sbh = rc.nBottom - rc.nTop
          
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            MoveWindow hCtrl, 0, rbh + 1, cxClient, cyClient - rbh - sbh, %TRUE
          
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnPaint
          ' PURPOSE:   Form1 WM_PAINT message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnPaint _
            ( _
            BYVAL hWnd  AS DWORD _  ' window handle
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_GoBtn_Clicked
          ' PURPOSE:   GoBtn BN_CLICKED notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_GoBtn_Clicked _
            ( _
            BYVAL hWndParent  AS DWORD, _ ' handle of parent window
            BYVAL hWndCtrl    AS DWORD _  ' handle of control
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL szUrl AS ASCIIZ * %INTERNET_MAX_PATH_LENGTH
            LOCAL vUrl AS VARIANT
            LOCAL ppvObj AS DWORD
          
            ' Get the Url
            hCtrl = GetDlgItem(GetDlgItem(hWndParent, %IDC_FORM1_REBAR1), %IDC_FORM1_EDITURL)
            GetWindowText hCtrl, szUrl, SIZEOF(szUrl)
            vUrl = szUrl
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWndParent, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the Navigate2 method
            IWebBrowser2_Navigate2 ppvObj, vUrl
            ' Release the interface
            WbRelease ppvObj
            FUNCTIOn = %TRUE
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnCommand
          ' PURPOSE:   Form1 WM_COMMAND message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnCommand _
            ( _
            BYVAL hWnd        AS DWORD, _ ' window handle
            BYVAL lCtrlId     AS LONG, _  ' identifier of menu item, control, or accelerator
            BYVAL hWndCtrl    AS DWORD, _ ' handle of control
            BYVAL lNotifyCode AS LONG _   ' notification code
            ) AS LONG
          
            SELECT CASE lCtrlId
          '     CASE %IDCANCEL
          '        ' Send a message to close the application
          '        SendMessage hWnd, %WM_CLOSE, 0, 0
          '        FUNCTION = %TRUE
               CASE %IDOK
                  ' If we are in the URL window, load the web page
                  IF GetFocus = GetDlgItem(GetDlgItem(hWnd, %IDC_FORM1_REBAR1), %IDC_FORM1_EDITURL) THEN
                     FUNCTION = Form1_GoBtn_Clicked(hWnd, hWndCtrl)
                  END IF
            END SELECT
          
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnNotify
          ' PURPOSE:   Form1 WM_NOTIFY message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnNotify _
            ( _
            BYVAL hWnd        AS DWORD, _ ' window handle
            BYVAL lCtrlId     AS LONG, _  ' control identifier
            BYVAL lptnmhdr    AS DWORD, _ ' address of NMHDR structure
                  lMsgResult  AS LONG _   ' value returned to message
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnKillFocus
          ' PURPOSE:   Form1 WM_KILLFOCUS message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnKillFocus _
            ( _
            BYVAL hWnd          AS DWORD, _ ' window handle
            BYVAL hWndNewFocus  AS DWORD _  ' handle of window receiving focus
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnSetFocus
          ' PURPOSE:   Form1 WM_SETFOCUS message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnSetFocus _
            ( _
            BYVAL hWnd          AS DWORD, _ ' window handle
            BYVAL hWndOldFocus  AS DWORD _  ' handle of window losing focus
            ) AS LONG
          
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_GoBack
          ' PURPOSE:   Toolbar1 IDM_GOBACK notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_GoBack _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the GoBack method
            IWebBrowser2_GoBack ppvObj
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_GoForward
          ' PURPOSE:   Toolbar1 IDM_GOFORWARD notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_GoForward _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the GoForward method
            IWebBrowser2_GoForward ppvObj
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_Find
          ' PURPOSE:   Toolbar1 IDM_FIND notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_Find _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
            LOCAL hr AS DWORD
            LOCAL CGID_WebBrowser AS GUID
            LOCAL ppDisp AS DWORD
            LOCAL ppCmdTarget AS DWORD
            LOCAL IID_IOleCommandTarget AS GUID
            LOCAL pvaIn AS VARIANT
            LOCAL pvaOut AS VARIANT
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
          
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
          
            ' Warning: This code uses an undocumented command-group GUID that is
            ' subject to change in the future. Currently it works in all versions of
            ' Internet Explorer up to 6. See [URL]http://support.microsoft.com/?kbid=311288[/URL] 
          
            CGID_WebBrowser = GUID$("{ED016940-BD5B-11cf-BA4E-00C04FD70816}")
            IID_IOleCommandTarget = GUID$("{b722bccb-4e68-101b-a2bc-00aa00404770}")
            ppDisp = IWebBrowser2_GetDocument(ppvObj)
            IF ISTRUE ppDisp THEN
               ppCmdTarget = WbQueryInterface(ppDisp, IID_IOleCommandTarget)
               IF ISTRUE ppCmdTarget THEN
                  hr = IOleCommandTarget_Exec(ppCmdTarget, CGID_WebBrowser, 1, 0, pvaIn, pvaOut)
               END IF
            END IF
          
            ' Release the interfaces
            IF ppDisp THEN WbRelease ppDisp
            IF ppCmdTarget THEN WbRelease ppCmdTarget
            IF ppvObj THEN WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_PrintPreview
          ' PURPOSE:   Toolbar1 IDM_PRINT_PREVIEW notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_PrintPreview _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the ExecWb method
            IWebBrowser2_ExecWB ppvObj, %OLECMDID_PRINTPREVIEW, %OLECMDEXECOPT_PROMPTUSER
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_PageSetup
          ' PURPOSE:   Toolbar1 IDM_PAGESETUP notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_PageSetup _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the ExecWb method
            IWebBrowser2_ExecWB ppvObj, %OLECMDID_PAGESETUP, %OLECMDEXECOPT_PROMPTUSER
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_Print
          ' PURPOSE:   Toolbar1 IDM_PAGESETUP notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_Print _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the ExecWb method
            IWebBrowser2_ExecWB ppvObj, %OLECMDID_PRINT, %OLECMDEXECOPT_PROMPTUSER
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_Properties
          ' PURPOSE:   Toolbar1 IDM_PROPERTIES notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_Properties _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the ExecWb method
            IWebBrowser2_ExecWB ppvObj, %OLECMDID_PROPERTIES, %OLECMDEXECOPT_PROMPTUSER
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_Toolbar1_FileSave
          ' PURPOSE:   Toolbar1 IDM_FILE_SAVE notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_Toolbar1_FileSave _
            ( _
            BYVAL hWnd  AS DWORD _  ' handle of window that owns the menu
            ) AS LONG
          
            LOCAL hCtrl AS DWORD
            LOCAL ppvObj AS DWORD
          
            ' Get the handle of the window that hosts the webbrowser
            hCtrl = GetDlgItem(hWnd, %IDC_FORM1_WEBBROWSER1)
            IF ISFALSE hCtrl THEN EXIT FUNCTION
            ' Get the IDispatch of the control
            ppvObj = WbGetInterfacePointer(hCtrl)
            IF ISFALSE ppvObj THEN EXIT FUNCTION
            ' Call the ExecWb method
            IWebBrowser2_ExecWB ppvObj, %OLECMDID_SAVEAS, %OLECMDEXECOPT_PROMPTUSER
            ' Release the interface
            WbRelease ppvObj
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnActivate
          ' PURPOSE:   Form1 WM_ACTIVATE message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnActivate _
            ( _
            BYVAL hWnd          AS DWORD, _ ' window handle
            BYVAL lState        AS LONG, _  ' activation state
            BYVAL hWndActDeact  AS DWORD, _ ' handle of window being activated/deactivated
            BYVAL fMinimized    AS LONG _   ' minimized flag
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_OnSysCommand
          ' PURPOSE:   Form1 WM_SYSCOMMAND message handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_OnSysCommand _
            ( _
            BYVAL hWnd      AS DWORD, _ ' window handle
            BYVAL lCmdType  AS LONG, _  ' type of system command requested
            BYVAL x         AS LONG, _  ' horizontal postion of cursor
            BYVAL y         AS LONG _   ' vertical position of cursor
            ) AS LONG
          
             ' If user has clicked the x button, send a WM_CLOSE message
             IF (lCmdType AND &HFFF0) = %SC_CLOSE THEN
                SendMessage hWnd, %WM_CLOSE, 0, 0
                FUNCTION = %TRUE
             END IF
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_EditUrl_Change
          ' PURPOSE:   EditUrl EN_CHANGE notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_EditUrl_Change _
            ( _
            BYVAL hWndParent  AS DWORD, _ ' handle of parent window
            BYVAL hWndCtrl    AS DWORD _  ' handle of control
            ) AS LONG
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_EditUrl_SetFocus
          ' PURPOSE:   EditUrl EN_SETFOCUS notification handler.
          ' RETURN:    TRUE if message was processed, FALSE if it was not.
          ' ========================================================================================
          
          FUNCTION Form1_EditUrl_SetFocus _
            ( _
            BYVAL hWndParent  AS DWORD, _ ' handle of parent window
            BYVAL hWndCtrl    AS DWORD _  ' handle of control
            ) AS LONG
          
          ' Select all the text of the edit box
            PostMessage hWndCtrl, %EM_SETSEL, 0, -1
            FUNCTION = %TRUE
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Project1_InitApplication
          ' PURPOSE:   Registers window classes and loads dynamic link libraries.
          ' RETURN:    FALSE if initialization was successful, TRUE if it was not.
          ' ========================================================================================
          
          FUNCTION Project1_InitApplication _
            ( _
            BYVAL hInstance   AS DWORD, _       ' handle of current instance
            BYVAL pszCmdLine  AS ASCIIZ PTR _   ' address of command line
            ) AS LONG
          
           ' Initializes ATL
             AtlAxWinInit
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Project1_UnloadInstance
          ' PURPOSE:   Unloads dynamic link libraries and frees memory associated with
          '            this instance.
          ' ========================================================================================
          
          SUB Project1_UnloadInstance _
            ( _
            BYVAL hInstance AS DWORD _  ' handle of current instance
            )
          
          END SUB
          
          ' ========================================================================================
          ' PROCEDURE: WinMain
          ' PURPOSE:   Program entry point, calls initialization function, processes
          '            message loop.
          ' ========================================================================================
          
          FUNCTION WinMain _
            ( _
            BYVAL hInstance     AS DWORD, _       ' handle of current instance
            BYVAL hPrevInstance AS DWORD, _       ' handle of previous instance(not used in Win32)
            BYVAL pszCmdLine    AS ASCIIZ PTR, _  ' address of command line
            BYVAL nCmdShow      AS LONG _         ' show state of window
            ) AS LONG
          
            LOCAL szClassName     AS ASCIIZ * %MAX_PATH       ' class name
            LOCAL twcx            AS WNDCLASSEX               ' class information
            LOCAL tmsg            AS tagMsg                   ' message information
            LOCAL ticc            AS INIT_COMMON_CONTROLSEX   ' specifies common control classes to register
            LOCAL hWnd            AS DWORD                    ' handle of main window
            LOCAL hWndModeless    AS DWORD                    ' handle of the current active window
          
            ' Save the handle of the application instance
            ghInstance = hInstance
          
            ' Register the Form1 window
            szClassName        = "Form1_Class"
            twcx.cbSize        = SIZEOF(twcx)                               ' size of WNDCLASSEX structure
            twcx.style         = %CS_DBLCLKS                                ' class styles
            twcx.lpfnWndProc   = CODEPTR(Form1_WndProc)                     ' address of window procedure used by class
            twcx.cbClsExtra    = 0                                          ' extra class bytes
            twcx.cbWndExtra    = 0                                          ' extra window bytes
            twcx.hInstance     = ghInstance                                 ' instance of the process that is registering the window
            twcx.hIcon         = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)    ' handle of class icon
            twcx.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)        ' handle of class cursor
            twcx.hbrBackground = %COLOR_BTNFACE + 1                         ' brush used to fill background of window's client area
            twcx.lpszMenuName  = %NULL                                      ' resource identifier of the class menu
            twcx.lpszClassName = VARPTR(szClassName)                        ' class name
            twcx.hIconSm       = %NULL                                      ' handle of small icon shown in caption/system Taskbar
            IF ISFALSE RegisterClassEx(twcx) THEN
              FUNCTION = %TRUE
              EXIT FUNCTION
            END IF
          
            ' Load the common controls library and
            ' specify the classes to register.
            ticc.dwSize = SIZEOF(ticc)
            ticc.dwICC  = %ICC_BAR_CLASSES OR %ICC_COOL_CLASSES
            InitCommonControlsEx ticc
          
            ' Register custom messages
            gdwADM_ALIGNCONTROLS = RegisterWindowMessage("ADM_ALIGNCONTROLS")
            gdwADM_REALIGNPARTS  = RegisterWindowMessage("ADM_REALIGNPARTS")
          
            ' Perform extra application initialization
            IF ISTRUE Project1_InitApplication(hInstance, BYVAL pszCmdLine) THEN
              FUNCTION = %FALSE
              EXIT FUNCTION
            END IF
          
            ' Create the Form1 window
            hWnd = CreateWindowEx(%WS_EX_WINDOWEDGE, _                                          ' extended styles
                                  "Form1_Class", _                                              ' class name
                                  "WebBrowser example", _                                       ' caption
                                  %WS_OVERLAPPEDWINDOW OR %WS_VISIBLE, _                        ' window styles
                                  1, 100, _                                                     ' left, top
                                  700, 450, _                                                   ' width, height
                                  %NULL, %NULL, _                                               ' handle of owner, menu handle
                                  ghInstance, BYVAL %NULL)                                      ' handle of instance, creation parameters
            ' If window could not be created, return "failure"
            IF ISFALSE hWnd THEN
              FUNCTION = %FALSE
              EXIT FUNCTION
            END IF
          
            ' Adjust the size of the window so that it conforms
            ' to the specified size of the client area
            phnxAdjustWindowRect hWnd, 700, 450
          
            ' Initialize this instance of the window
            IF ISTRUE Form1_InitWindow(hWnd, BYVAL pszCmdLine) THEN
              SendMessage hWnd, %WM_CLOSE, 0, 0
              FUNCTION = %FALSE
              EXIT FUNCTION
            END IF
          
            ' Center the window relative to the screen
            phnxCenterWindow hWnd, %NULL
            ' Make the window visible; update its client area
            ShowWindow hWnd, nCmdShow
            UpdateWindow hWnd
          
            ' Main message loop of program.
            ' Acquire and dispatch messages until a WM_QUIT message is received.
            WHILE ISTRUE GetMessage(tmsg, BYVAL %NULL, 0, 0)
              IF ISFALSE Form1_TranslateMessage(hWnd, tmsg) THEN
                hWndModeless = phnxGetFormHandle(GetFocus())
                IF (ISFALSE hWndModeless) OR (ISFALSE IsDialogMessage(hWndModeless, tmsg)) THEN
                  TranslateMessage tmsg
                  DispatchMessage tmsg
                END IF
              END IF
            WEND
          
            ' Free memory and unload dlls associated with this instance
            Project1_UnloadInstance hInstance
          
            FUNCTION = tmsg.wParam
          
          END FUNCTION
          
          ' ========================================================================================
          ' PROCEDURE: Form1_WndProc
          ' PURPOSE:   Processes messages for the Form1 window.
          ' ========================================================================================
          
          FUNCTION Form1_WndProc _
            ( _
            BYVAL hWnd    AS DWORD, _ ' window handle
            BYVAL uMsg    AS DWORD, _ ' type of message
            BYVAL wParam  AS DWORD, _ ' first message parameter
            BYVAL lParam  AS LONG _   ' second message parameter
            ) EXPORT AS LONG
          
            LOCAL szItem        AS ASCIIZ * %MAX_PATH   ' working variable
            LOCAL trbi          AS REBARINFO            ' specifies attributes(imagelist) of the rebar control
            LOCAL trbbi         AS REBARBANDINFO        ' specifies or receives the attributes of a rebar band
            LOCAL ttbb          AS TBBUTTON             ' specifies or receives the attributes of a toolbar button
            LOCAL ttbab         AS TBADDBITMAP          ' specifies the images to add to a toolbar
            LOCAL ptnmhdr       AS NMHDR PTR            ' information about a notification message
            LOCAL ptttdi        AS NMTTDISPINFO PTR     ' tooltip notification message information
            LOCAL pttbb         AS TBBUTTON PTR         ' address of array of toolbar button info
            LOCAL plEdge        AS LONG PTR             ' address of array of right edges
            LOCAL hWndChild     AS DWORD                ' handle of child window
            LOCAL hWndRebar     AS DWORD                ' handle of rebar control
            LOCAL hFont         AS DWORD                ' handle of font used by form
            LOCAL lMsgResult    AS LONG                 ' value returned to message after message is processed
          
            SELECT CASE uMsg
              CASE %WM_COMMAND
          
                SELECT CASE LOWRD(wParam)
                  CASE %IDM_GOBACK
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_GoBack(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_GOFORWARD
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_GoForward(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_FIND
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_Find(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_PRINTPREVIEW
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_PrintPreview(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_PAGESETUP
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_PageSetup(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_PRINT
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_Print(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_PROPERTIES
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_Properties(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDM_FILE_SAVE
                    ' If the message was processed
                    IF ISTRUE Form1_Toolbar1_FileSave(hWnd) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
          
                  CASE %IDC_FORM1_EDITURL
          
                    SELECT CASE HIWRD(wParam)
                      CASE %EN_CHANGE
                        ' If the notification was processed
                        IF ISTRUE Form1_EditUrl_Change(hWnd, lParam) THEN
                          FUNCTION = %FALSE
                          EXIT FUNCTION
                        END IF
          
                      CASE %EN_SETFOCUS
                        ' If the notification was processed
                        IF ISTRUE Form1_EditUrl_SetFocus(hWnd, lParam) THEN
                          FUNCTION = %FALSE
                          EXIT FUNCTION
                        END IF
                    END SELECT
          
                  CASE %IDC_FORM1_GOBTN
                    IF HIWRD(wParam) = %BN_CLICKED THEN
                      ' If the notification was processed
                      IF ISTRUE Form1_GoBtn_Clicked(hWnd, lParam) THEN
                        FUNCTION = %FALSE
                        EXIT FUNCTION
                      END IF
                    END IF
          
                  CASE ELSE
                    ' If the message was processed
                    IF ISTRUE Form1_OnCommand(hWnd, LOWRD(wParam), lParam, HIWRD(wParam)) THEN
                      FUNCTION = %FALSE
                      EXIT FUNCTION
                    END IF
                END SELECT
          
              CASE %WM_NOTIFY
                ptnmhdr = lParam
          
                SELECT CASE @ptnmhdr.code
                  CASE %TTN_GETDISPINFO
                    ptttdi        = lParam
                    @ptttdi.hinst = %NULL
          
                    SELECT CASE @ptttdi.hdr.hwndFrom
                      CASE SendMessage(GetDlgItem(GetDlgItem(hWnd, %IDC_FORM1_REBAR1), %IDC_FORM1_TOOLBAR1), %TB_GETTOOLTIPS, 0, 0)
                        SELECT CASE @ptttdi.hdr.idFrom
                           CASE %IDM_GOBACK
                              szItem = "Go Back"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_GOFORWARD
                              szItem = "Go Forward"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_FIND
                              szItem = "Find"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_PRINTPREVIEW
                              szItem = "Print Preview"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_PAGESETUP
                              szItem = "Page Setup"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_PRINT
                              szItem = "Print"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_FILE_SAVE
                              szItem = "Save As"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                           CASE %IDM_PROPERTIES
                              szItem = "Properties"
                              @ptttdi.lpszText = VARPTR(szItem)
                              EXIT FUNCTION
                        END SELECT
                    END SELECT
          
                END SELECT
          
                ' If the message was processed
                IF ISTRUE Form1_OnNotify(hWnd, wParam, lParam, lMsgResult) THEN
                  FUNCTION = lMsgResult
                  EXIT FUNCTION
                END IF
          
              CASE %WM_SYSCOLORCHANGE
                ' Forward this message to common controls so that they will
                ' be properly updated when the user changes the color settings.
                SendMessage GetDlgItem(hWnd, %IDC_FORM1_STATUSBAR1), %WM_SYSCOLORCHANGE, wParam, lParam
                hWndRebar = GetDlgItem(hWnd, %IDC_FORM1_REBAR1)
                SendMessage hWndRebar, %WM_SYSCOLORCHANGE, wParam, lParam
                SendMessage GetDlgItem(hWndRebar, %IDC_FORM1_TOOLBAR1), %WM_SYSCOLORCHANGE, wParam, lParam
          
              CASE %WM_ACTIVATE
                ' If the message was processed
                IF ISTRUE Form1_OnActivate(hWnd, LOWRD(wParam), lParam, HIWRD(wParam)) THEN
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
                FUNCTION = %FALSE
                EXIT FUNCTION
          
              CASE %WM_SETFOCUS
                ' If the message was processed
                IF ISTRUE Form1_OnSetFocus(hWnd, wParam) THEN
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
                ' Set the keyboard focus to the first control that is
                ' visible, not disabled, and has the WS_TABSTOP style
                SetFocus GetNextDlgTabItem(hWnd, %NULL, %FALSE)
          
              CASE %WM_KILLFOCUS
                ' If the message was processed
                IF ISTRUE Form1_OnKillFocus(hWnd, wParam) THEN
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
          
              CASE %WM_CLOSE
                ' If the message was processed
                IF ISTRUE Form1_OnClose(hWnd) THEN
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
          
              CASE %WM_QUERYENDSESSION
                ' If the message was processed
                IF ISTRUE Form1_OnQueryEndSession(hWnd, wParam, lParam, lMsgResult) THEN
                  FUNCTION = lMsgResult
                  EXIT FUNCTION
                END IF
          
              CASE %WM_DESTROY
                Form1_OnDestroy hWnd, lMsgResult
                PostQuitMessage lMsgResult
                FUNCTION = %FALSE
                EXIT FUNCTION
          
              CASE %WM_SIZE
                IF wParam <> %SIZE_MINIMIZED THEN
                  ' Update the size and position of aligned controls
                  SendMessage hWnd, gdwADM_ALIGNCONTROLS, wParam, lParam
                  ' Realign statusbar panels
                  PostMessage hWnd, gdwADM_REALIGNPARTS, hWnd, GetDlgItem(hWnd, %IDC_FORM1_STATUSBAR1)
                  ' If the message was processed
                  IF ISTRUE Form1_OnSize(hWnd, wParam, LOWRD(lParam), HIWRD(lParam)) THEN
                    FUNCTION = %FALSE
                    EXIT FUNCTION
                  END IF
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
          
              CASE gdwADM_ALIGNCONTROLS
                ' Update the size and position of aligned controls
                hWndChild = GetDlgItem(hWnd, %IDC_FORM1_STATUSBAR1)
                SendMessage hWndChild, %WM_SIZE, wParam, lParam
                InvalidateRect hWndChild, BYVAL %NULL, %TRUE
                SendMessage GetDlgItem(hWnd, %IDC_FORM1_REBAR1), %WM_SIZE, wParam, lParam
                FUNCTION = %FALSE
                EXIT FUNCTION
          
              CASE gdwADM_REALIGNPARTS
                ' Realign the panels of statusbars
                RealignStatusPanels wParam, lParam, %TRUE
                InvalidateRect lParam, BYVAL %NULL, %TRUE
                FUNCTION = %FALSE
                EXIT FUNCTION
          
              CASE %WM_PAINT
                ' If the message was processed
                IF ISTRUE Form1_OnPaint(hWnd) THEN
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
          
              CASE %WM_SYSCOMMAND
                ' If the message was processed
                IF ISTRUE Form1_OnSysCommand(hWnd, wParam, LOINT(lParam), HIINT(lParam)) THEN
                  FUNCTION = %FALSE
                  EXIT FUNCTION
                END IF
          
              CASE %WM_CREATE
                ' Create font used by container
                hFont = GetStockObject(%DEFAULT_GUI_FONT)
          
                ' Create the Statusbar1 statusbar control
                hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                                           "msctls_statusbar32", _                              ' class name
                                           "", _                                                ' caption
                                           %WS_CHILD OR %WS_VISIBLE OR _                        ' window styles
                                           %CCS_BOTTOM OR %SBARS_SIZEGRIP, _                    ' class styles
                                           0, 347, _                                            ' left, top
                                           535, 23, _                                           ' width, height
                                           hWnd, %IDC_FORM1_STATUSBAR1, _                       ' handle of parent, control ID
                                           ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
          
                ' Allocate memory for the coordinate of the right edge of each part
                plEdge = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, 1 * 4)
                IF ISTRUE plEdge THEN
                  @plEdge[0] = 96
                  SendMessage hWndChild, %SB_SETPARTS, 1, BYVAL plEdge
                  ' Free memory that was allocated for the edge info
                  HeapFree GetProcessHeap(), 0, BYVAL plEdge
                END IF
                ' Update the size of the statusbar
                SendMessage hWndChild, %WM_SIZE, 0, 0
          
                ' Create the WebBrowser control
                hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                                           "AtlAxWin", _                                        ' class name
                                           "Shell.Explorer", _                                  ' caption
                                           %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR _    ' window styles
                                           %WS_TABSTOP, _
                                           0, 0, _                                              ' left, top
                                           0, 0, _                                              ' width, height
                                           hWnd, %IDC_FORM1_WEBBROWSER1, _                      ' handle of parent, control ID
                                           ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
          
                ' Create the Rebar1 rebar control
                hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                                           "ReBarWindow32", _                                   ' class name
                                           "", _                                                ' caption
                                           %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _          ' window styles
                                           %WS_CLIPCHILDREN OR %WS_CLIPSIBLINGS OR _
                                           %CCS_NOPARENTALIGN OR %CCS_NODIVIDER OR _            ' class styles
                                           %RBS_VARHEIGHT OR %RBS_BANDBORDERS, _
                                           0, 0, _                                              ' left, top
                                           650, 30, _                                           ' width, height
                                           hWnd, %IDC_FORM1_REBAR1, _                           ' handle of parent, control ID
                                           ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
                ' Save the handle of the rebar.  It is used when embedding controls
                hWndRebar = hWndChild
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
          
                ' Create the Toolbar1 toolbar control
                hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                                           "ToolbarWindow32", _                                 ' class name
                                           "", _                                                ' caption
                                           %WS_CHILD OR %WS_VISIBLE OR _                        ' window styles
                                           %CCS_NORESIZE OR %CCS_NODIVIDER OR _                 ' class styles
                                           %TBSTYLE_TOOLTIPS OR %TBSTYLE_FLAT, _
                                           0, 4, _                                              ' left, top
                                           204, 21, _                                           ' width, height
                                           hWnd, %IDC_FORM1_TOOLBAR1, _                         ' handle of parent, control ID
                                           ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
          
                ' Allocate memory for the button info array
                pttbb = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, 8 * SIZEOF(ttbb))
                IF ISTRUE pttbb THEN
                  ' Send the TB_BUTTONSTRUCTSIZE message, for backward compatibility
                  SendMessage hWndChild, %TB_BUTTONSTRUCTSIZE, SIZEOF(ttbb), 0
                  ' Add bitmaps to the internal image list
                  ttbab.hInst = %HINST_COMMCTRL
                  ttbab.nId   = %IDB_STD_SMALL_COLOR
                  SendMessage hWndChild, %TB_ADDBITMAP, 15, BYVAL VARPTR(ttbab)
                  ' Add buttons to the toolbar
                  @pttbb[0].iBitmap   = %STD_UNDO
                  @pttbb[0].idCommand = %IDM_GOBACK
                  @pttbb[0].fsState   = %TBSTATE_ENABLED
                  @pttbb[0].fsStyle   = %BTNS_BUTTON
                  @pttbb[0].dwData    = 0
                  @pttbb[0].iString   = -1
          
                  @pttbb[1].iBitmap   = %STD_REDOW
                  @pttbb[1].idCommand = %IDM_GOFORWARD
                  @pttbb[1].fsState   = %TBSTATE_ENABLED
                  @pttbb[1].fsStyle   = %BTNS_BUTTON
                  @pttbb[1].dwData    = 0
                  @pttbb[1].iString   = -1
          
                  @pttbb[2].iBitmap   = %STD_FIND
                  @pttbb[2].idCommand = %IDM_FIND
                  @pttbb[2].fsState   = %TBSTATE_ENABLED
                  @pttbb[2].fsStyle   = %BTNS_BUTTON
                  @pttbb[2].dwData    = 0
                  @pttbb[2].iString   = -1
          
                  @pttbb[3].iBitmap   = %STD_PRINTPRE
                  @pttbb[3].idCommand = %IDM_PRINTPREVIEW
                  @pttbb[3].fsState   = %TBSTATE_ENABLED
                  @pttbb[3].fsStyle   = %BTNS_BUTTON
                  @pttbb[3].dwData    = 0
                  @pttbb[3].iString   = -1
          
                  @pttbb[4].iBitmap   = %STD_FILENEW
                  @pttbb[4].idCommand = %IDM_PAGESETUP
                  @pttbb[4].fsState   = %TBSTATE_ENABLED
                  @pttbb[4].fsStyle   = %BTNS_BUTTON
                  @pttbb[4].dwData    = 0
                  @pttbb[4].iString   = -1
          
                  @pttbb[5].iBitmap   = %STD_PRINT
                  @pttbb[5].idCommand = %IDM_PRINT
                  @pttbb[5].fsState   = %TBSTATE_ENABLED
                  @pttbb[5].fsStyle   = %BTNS_BUTTON
                  @pttbb[5].dwData    = 0
                  @pttbb[5].iString   = -1
          
                  @pttbb[6].iBitmap   = %STD_PROPERTIES
                  @pttbb[6].idCommand = %IDM_PROPERTIES
                  @pttbb[6].fsState   = %TBSTATE_ENABLED
                  @pttbb[6].fsStyle   = %BTNS_BUTTON
                  @pttbb[6].dwData    = 0
                  @pttbb[6].iString   = -1
          
                  @pttbb[7].iBitmap   = %STD_FILESAVE
                  @pttbb[7].idCommand = %IDM_FILE_SAVE
                  @pttbb[7].fsState   = %TBSTATE_ENABLED
                  @pttbb[7].fsStyle   = %BTNS_BUTTON
                  @pttbb[7].dwData    = 0
                  @pttbb[7].iString   = -1
                  SendMessage hWndChild, %TB_ADDBUTTONS, 8, BYVAL pttbb
                  ' Free memory that was allocated for the button info
                  HeapFree GetProcessHeap(), 0, BYVAL pttbb
                  ' Update the size of the toolbar
                  SendMessage hWndChild, %TB_AUTOSIZE, 0, 0
                END IF
          
                ' Add the band containing the Toolbar1 toolbar control to the rebar
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                                   %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
                trbbi.hwndChild  = hWndChild
                trbbi.cxMinChild = 110
                trbbi.cyMinChild = 21
                trbbi.cx         = 110
                trbbi.wID        = %IDS_STRING0
                trbbi.cxIdeal    = 110
                SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)
          
                ' Create the EditUrl edit control
                hWndChild = CreateWindowEx(%WS_EX_CLIENTEDGE, _                                 ' extended styles
                                           "Edit", _                                            ' class name
                                           "", _                                                ' caption
                                           %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                           %ES_LEFT OR %ES_AUTOHSCROLL, _                       ' class styles
                                           151, 4, _                                            ' left, top
                                           350, 21, _                                           ' width, height
                                           hWnd, %IDC_FORM1_EDITURL, _                          ' handle of parent, control ID
                                           ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
          
                ' Add the band containing the EditUrl edit control to the rebar
                szItem           = "URL"
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_TEXT OR %RBBIM_CHILD OR _
                                   %RBBIM_CHILDSIZE OR %RBBIM_SIZE OR %RBBIM_ID OR _
                                   %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
                trbbi.lpText     = VARPTR(szItem)
                trbbi.hwndChild  = hWndChild
                trbbi.cxMinChild = 350
                trbbi.cyMinChild = 21
                trbbi.cx         = 350
                trbbi.wID        = %IDS_STRING1
                trbbi.cxIdeal    = 350
                SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)
          
                ' Create the GoBtn text button
                hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                                           "Button", _                                          ' class name
                                           "Go", _                                              ' caption
                                           %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _         ' window styles
                                           %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER OR _     ' class styles
                                           %BS_FLAT, _
                                           493, 2, _                                            ' left, top
                                           34, 26, _                                            ' width, height
                                           hWnd, %IDC_FORM1_GOBTN, _                            ' handle of parent, control ID
                                           ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
          
                ' Add the band containing the GoBtn text button to the rebar
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                                   %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_FIXEDSIZE OR %RBBS_CHILDEDGE
                trbbi.hwndChild  = hWndChild
                trbbi.cxMinChild = 34
                trbbi.cyMinChild = 26
                trbbi.cx         = 34
                trbbi.wID        = %IDS_STRING2
                trbbi.cxIdeal    = 34
                SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)
          
                ' If the message was processed
                IF ISTRUE Form1_OnCreate(hWnd, lParam, lMsgResult) THEN
                  FUNCTION = lMsgResult
                  EXIT FUNCTION
                END IF
                FUNCTION = %FALSE
                EXIT FUNCTION
            END SELECT
          
            FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
          
          END FUNCTION
          ' ========================================================================================
          Last edited by José Roca; 30 Aug 2007, 06:39 PM.
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            In the minibrowser example, when you click the save button, the IWebBrowser2_ExecWB method is called. this method always shows the "save as..." dialog. if you want to save the page without showing a dialog you need to use a different technique.

            1. the iwebbrowser2_getdocument wrapper function returns a reference to the IHTMLDocument interface of the loaded page.

            2. IHTMLDocument implements the IPersistFile interface and we can get a reference to it using WBQueryInterface.

            3. using this reference, we will call the save method of the IPersistFile interface to save the page to a file.

            If in the minibrowser example we replace the code in the Form1_Toolbar1_FileSave function for the code below, the page will be saved without promting.

            Code:
            ' ========================================================================================
            ' procedure: form1_toolbar1_filesave
            ' purpose:   toolbar1 idm_file_save notification handler.
            ' return:    true if message was processed, false if it was not.
            ' ========================================================================================
            
            function form1_toolbar1_filesave _
              ( _
              byval hwnd  as dword _  ' handle of window that owns the menu
              ) as long
            
              local hctrl as dword
              local ppvobj as dword
            
              local hr as long
              local ppdoc as dword
              local pppersistfile as dword
              local iid_ipersistfile as guid
            
              ' get the handle of the window that hosts the webbrowser
              hctrl = getdlgitem(hwnd, %idc_form1_webbrowser1)
              if isfalse hctrl then exit function
              ' get the idispatch of the control
              ppvobj = wbgetinterfacepointer(hctrl)
              if isfalse ppvobj then exit function
              
              iid_ipersistfile = guid$("{0000010b-0000-0000-c000-000000000046}")
            
              ' get a reference to the ihtmldocument interface
              ppdoc = iwebbrowser2_getdocument(ppvobj)
              if istrue ppdoc then
                 ' get a reference to the ipersistfile interface
                 pppersistfile = wbqueryinterface(ppdoc, iid_ipersistfile)
                 if istrue pppersistfile then
                    ' save the page calling the save method of the ipersistfile interface
                    hr = ipersistfile_save(pppersistfile, "mysavedfile.htm", %false)
                    if istrue hr then
                       msgbox "error " & hex$(hr) & " saving the page"
                    else
                       msgbox "page saved"
                    end if
                    ' release the ipersistfile interface
                    wbrelease pppersistfile
                 end if
                 ' release the ihtmldocument interface
                 wbrelease ppdoc
              end if
            
              ' release the iwebbrowser2 interface
              wbrelease ppvobj
            
            end function
            This is the wrapper function to call the save method of the IPersistFile interface.

            Code:
            ' ****************************************************************************************
            ' ipersistfile_save method
            ' saves an object to the specified stream.
            ' ****************************************************************************************
            ' hresult ( stdmethodcalltype __rpc_far *save )(
            '     ipersistfile __rpc_far * this,
            '     /* [unique][in] */ lpcolestr pszfilename,
            '     /* [in] */ bool fremember);
            ' ****************************************************************************************
            ' parameters
            ' ****************************************************************************************
            ' pszfilename
            '    [in] points to a zero-terminated string containing the absolute path of the file to
            '    which the object should be saved. if pszfilename is null, the object should save its
            '    data to the current file, if there is one.
            ' fremember
            '    [in] indicates whether the pszfilename parameter is to be used as the current working
            '    file. if true, pszfilename becomes the current file and the object should clear its
            '    dirty flag after the save. if false, this save operation is a "save a copy as ..."
            '    operation. in this case, the current file is unchanged and the object should not
            '    clear its dirty flag. if pszfilename is null, the implementation should ignore the
            '    fremember flag. 
            ' ****************************************************************************************
            ' return values
            ' ****************************************************************************************
            ' %s_ok
            '    the object was successfully saved.
            ' %e_fail
            '    the file was not saved.
            ' ipersistfile::save stg_e_* errors.
            ' %e_pointer
            '    null pointer.
            ' ****************************************************************************************
            declare function proto_ipersistfile_save (byval pthis as dword ptr, byval pszfilename as dword, byval fremember as integer) as long
            ' ****************************************************************************************
            function ipersistfile_save (byval pthis as dword ptr, byval strfilename as string, byval fremember as integer) as long
                local hresult as long
                if isfalse pthis then function = %e_pointer : exit function
                if strfilename = " then
                   call dword @@pthis[6] using proto_ipersistfile_save(pthis, %null, fremember) to hresult
                else
                   strfilename = ucode$(strfilename)
                   call dword @@pthis[6] using proto_ipersistfile_save(pthis, strptr(strfilename), fremember) to hresult
                end if
                function = hresult
            end function
            ' ****************************************************************************************
            P.S. Wrappers for all the other methods of the IPersistFile interface can be found at: http://www.powerbasic.com/support/pbforums/showthread.php?t=24506
            Last edited by José Roca; 30 Aug 2007, 06:43 PM.
            Forum: http://www.jose.it-berater.org/smfforum/index.php

            Comment

            Working...
            X