April 18, 2024, 04:54:17 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


@GETNAVURL suggestion

Started by ZeroDog, April 24, 2012, 12:38:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZeroDog

Currently in IWB2, when you use the @GETNAVURL in your embedded browser, it often returns the URL of something other than the actual URL of the page you are on.  Sometimes it returns the URL of the last loaded advert, or the URL of an IFrame.

In order to resolve this issue, I have had to make use of some code supplied by Sapero (thanks again!):


typedef HRESULT int
typedef ULONG int
typedef LCID int
typedef BOOL int
typedef VARIANT_BOOL word
typedef BSTR pointer
extern _IID_IWebBrowser2 as GUID
declare import, SysFreeString(BSTR b)
declare import, SysStringLen(BSTR b),UINT
declare import, GetProp alias GetPropA(UINT hWnd, pointer lpString),int
declare import,WideCharToMultiByte(UINT CodePage,UINT dwFlags,pointer lpWideCharStr,int cchWideChar,pointer lpMultiByteStr,int cbMultiByte,pointer lpDefaultChar,pointer lpUsedDefaultChar),int

interface IWebBrowser2 ' IWebBrowserApp
stdmethod QueryInterface(pointer riid,pointer ppvObject),HRESULT
stdmethod AddRef(),ULONG
stdmethod Release(),ULONG
'IDispatch
stdmethod GetTypeInfoCount(pointer pctinfo),HRESULT
stdmethod GetTypeInfo(UINT iTInfo,LCID lcid,pointer ppTInfo),HRESULT
stdmethod GetIDsOfNames(pointer riid,pointer rgszNames,UINT cNames,LCID lcid,pointer rgDispId),HRESULT
stdmethod Invoke(DISPID dispIdMember,pointer riid,LCID lcid,word wFlags,pointer pDispParams,pointer pVarResult,pointer pExcepInfo,pointer puArgErr),HRESULT
'IWebBrowser
stdmethod GoBack(),HRESULT
stdmethod GoForward(),HRESULT
stdmethod GoHome(),HRESULT
stdmethod GoSearch(),HRESULT
stdmethod Navigate(pointer URL,pointer Flags,pointer TargetFrameName,pointer PostData,pointer Headers),HRESULT
stdmethod Refresh(),HRESULT
stdmethod Refresh2(pointer Level),HRESULT
stdmethod _Stop(),HRESULT
stdmethod get_Application(pointer ppDisp),HRESULT
stdmethod get_Parent(pointer ppDisp),HRESULT
stdmethod get_Container(pointer ppDisp),HRESULT
stdmethod get_Document(pointer ppDisp),HRESULT
stdmethod get_TopLevelContainer(pointer pBool),HRESULT
stdmethod get_Type(pointer _Type),HRESULT
stdmethod get_Left(pointer pl),HRESULT
stdmethod put_Left(int Left),HRESULT
stdmethod get_Top(pointer pl),HRESULT
stdmethod put_Top(int Top),HRESULT
stdmethod get_Width(pointer pl),HRESULT
stdmethod put_Width(int Width),HRESULT
stdmethod get_Height(pointer pl),HRESULT
stdmethod put_Height(int Height),HRESULT
stdmethod get_LocationName(pointer LocationName),HRESULT
stdmethod get_LocationURL(pointer LocationURL),HRESULT
stdmethod get_Busy(pointer pBool),HRESULT
'IWebBrowserApp
stdmethod Quit(),HRESULT
stdmethod ClientToWindow(pointer pcx,pointer pcy),HRESULT
stdmethod PutProperty(pointer Property, VARIANT vtValue byval),HRESULT
stdmethod GetProperty(pointer Property,pointer pvtValue),HRESULT
stdmethod get_Name(pointer Name),HRESULT
stdmethod get_HWND(pointer pHWND),HRESULT
stdmethod get_FullName(pointer FullName),HRESULT
stdmethod get_Path(pointer Path),HRESULT
stdmethod get_Visible(pointer pBool),HRESULT
stdmethod put_Visible(VARIANT_BOOL Value),HRESULT
stdmethod get_StatusBar(pointer pBool),HRESULT
stdmethod put_StatusBar(VARIANT_BOOL Value),HRESULT
stdmethod get_StatusText(pointer StatusText),HRESULT
stdmethod put_StatusText(pointer StatusText),HRESULT
stdmethod get_ToolBar(pointer Value),HRESULT
stdmethod put_ToolBar(int Value),HRESULT
stdmethod get_MenuBar(pointer Value),HRESULT
stdmethod put_MenuBar(VARIANT_BOOL Value),HRESULT
stdmethod get_FullScreen(pointer pbFullScreen),HRESULT
stdmethod put_FullScreen(VARIANT_BOOL bFullScreen),HRESULT
'IWebBrowser2
stdmethod Navigate2(pointer URL,pointer Flags,pointer TargetFrameName,pointer PostData,pointer Headers),HRESULT
stdmethod QueryStatusWB(OLECMDID cmdID,pointer pcmdf),HRESULT
stdmethod ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt,pointer pvaIn, pointer pvaOut),HRESULT
stdmethod ShowBrowserBar(pointer pvaClsid,pointer pvarShow,pointer pvarSize),HRESULT
stdmethod get_ReadyState(pointer plReadyState),HRESULT
stdmethod get_Offline(pointer pbOffline),HRESULT
stdmethod put_Offline(VARIANT_BOOL bOffline),HRESULT
stdmethod get_Silent(pointer pbSilent),HRESULT
stdmethod put_Silent(VARIANT_BOOL bSilent),HRESULT
stdmethod get_RegisterAsBrowser(pointer pbRegister),HRESULT
stdmethod put_RegisterAsBrowser(VARIANT_BOOL bRegister),HRESULT
stdmethod get_RegisterAsDropTarget(pointer pbRegister),HRESULT
stdmethod put_RegisterAsDropTarget(VARIANT_BOOL bRegister),HRESULT
stdmethod get_TheaterMode(pointer pbRegister),HRESULT
stdmethod put_TheaterMode(VARIANT_BOOL bRegister),HRESULT
stdmethod get_AddressBar(pointer Value),HRESULT
stdmethod put_AddressBar(VARIANT_BOOL Value),HRESULT
stdmethod get_Resizable(pointer Value),HRESULT
stdmethod put_Resizable(VARIANT_BOOL Value),HRESULT
endinterface

BSTR bstrUrl


sub BrowserGetUrl(WINDOW w, string szUrl, int size_of_url),int :' BOOL
IWebBrowser2 browser
szUrl[0] = 0
if (BrowserFromWindow(w, &browser))
if (!browser->get_LocationURL(&bstrUrl) and bstrUrl)
WideCharToMultiByte(0, 0, bstrUrl, -1, szUrl, size_of_url, 0, 0)
SysFreeString(bstrUrl)
endif
browser->Release()
endif
return szUrl[0]
endsub


sub BrowserFromWindow(WINDOW w, pointer ppBrowser),BOOL
$ifdef UNICODE
pointer p = GetProp(w.hWnd, L"BROWSER")
$else
pointer p = GetProp(w.hWnd, "BROWSER")
$endif
BOOL success = FALSE
*<int>ppBrowser = 0
if (p)
IDispatch unk = *<comref>p
if (unk <> 0)
success = (unk->QueryInterface(_IID_IWebBrowser2, ppBrowser) = 0)
endif
endif
return success
endsub


Would it be possible to make use of this to update the @GETNAVURL in IWB3?  Maybe add @GETNAVURLEX, in case the old method is needed?