 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Marcelo Mello Guest
|
Posted: Tue Mar 22, 2005 5:51 pm Post subject: How can i disable TCppWebBrowser pop-up menu? |
|
|
How can i disable or change native TCppWebBrowser pop-up menu?
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Tue Mar 22, 2005 7:21 pm Post subject: Re: How can i disable TCppWebBrowser pop-up menu? |
|
|
Marcelo Mello wrote:
| Quote: | How can i disable or change native TCppWebBrowser pop-up menu?
|
Assign an Application OnMessage handler that handles
the WM_RBUTTONDOWN message.
Hans.
|
|
| Back to top |
|
 |
James O'Brien Guest
|
Posted: Tue Mar 22, 2005 7:40 pm Post subject: Re: How can i disable TCppWebBrowser pop-up menu? |
|
|
Hello,
If you simply want to disable the TCppWebBrowser pop-up menu you can use
TApplicationEvents object for the main form
and create an OnMessage event handler to intercept WM_RBUTTONUP messages.
You will need to determine for which window/control the WM_RBUTTONUP is
bound. The class name for TCppWebBrowser control as seen by windows is
"Internet Explorer_Server". If the class name for the window bound to the
WM_RBUTTONUP message matches this, just set the Handled property to true and
the TCppWebBrowser control won't receive the right-mouse click.
//****************************
//OnMessage event handler
//****************************
void __fastcall TMainWnd::Main_AppEventMessage(tagMSG &Msg, bool &Handled)
{
char WndClassName[MAX_PATH+2];
switch(Msg.message){
case WM_RBUTTONUP:
GetClassName(Msg.hwnd, WndClassName, MAX_PATH);
if( !strcmpi(WndClassName, "Internet Explorer_Server") )
Handled = true;
break;
default:
break;
}
return;
}
To be thorough, you would need to check for SHIFT+VK_F10 keyboard sequence
since this will also display pop-up menu for window that has keyboard focus.
If you want to display a custom pop-up menu, you will probably need to know
the context in which the menu is being called. For this you will need to
attach an event sink to the HTML document displayed in the TCppWebBrowser in
order to know what HTML object is firing the event. This can be done by
creating an TEventDispatcher object based on HTMLDocumentEvents or
HTMLDocumentEvents2 event interface. I've done this myself to trap events
other then pop-up menus. If you are interested in this approach let me know
and I'll supply you with some code I've written. Are you at all familar with
MSHTML?
Regards,
James O'Brien
"Marcelo Mello" <mrmello (AT) pop (DOT) com.br> wrote
| Quote: | How can i disable or change native TCppWebBrowser pop-up menu?
|
|
|
| Back to top |
|
 |
SD Guest
|
Posted: Wed Mar 23, 2005 7:12 am Post subject: Re: How can i disable TCppWebBrowser pop-up menu? |
|
|
I've recently implemented with success the IDocHostUIHandler
interface which permit to disable popup menú on right click,
or add your, or do other things....
Good enjoy
Silverio Diquigiovanni
Using mode is:
....
...
..
// navigates to "about:blank" (necessary to obtain a non NULL Browser
IDispatch interface)
WideString Address = "about:blank";
Browser->Navigate(Address);
while(Browser->Busy)
Application->ProcessMessages();
// recovers the Browser IDispatch interface
LPDISPATCH Dispatch = Browser->Document;
// sets new IDocHostUIHandler
FDocHostUIHandler = NULL;
ICustomDoc *CustomDoc = NULL;
Dispatch->QueryInterface(IID_ICustomDoc,(LPVOID *) &CustomDoc);
FDocHostUIHandler = new QDocHostUIHandler();
CustomDoc->SetUIHandler((IDocHostUIHandler * ) FDocHostUIHandler);
CustomDoc->Release();
Dispatch->Release();
// navigates to google home page
Address = "http://www.google.com";
Browser->Navigate(Address);
..
...
....
//--------------------------------------------------------------------------
-
// CLASS: IDocHostUIHandler implementation class
//--------------------------------------------------------------------------
-
class QDocHostUIHandler : public IDocHostUIHandler
{
long refcount;
public:
QDocHostUIHandler() : refcount(1) { }
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID classid, void**
intf)
{
if (classid == IID_IUnknown)
*intf = (IUnknown *) this;
else if (classid == IID_IDocHostUIHandler)
*intf = (IDocHostUIHandler *) this;
else
return E_NOINTERFACE;
return S_OK;
}
virtual ULONG STDMETHODCALLTYPE AddRef()
{
InterlockedIncrement(&refcount);
return refcount;
}
virtual ULONG STDMETHODCALLTYPE Release()
{
InterlockedDecrement(&refcount);
if (refcount == 0)
delete this;
return refcount;
}
// Returning S_OK tells the web browser that it need not display its
// own context menu, presumably because the application hosting it has
// displayed its own menu to replace it.
// Since our host does not display any, no context menu is shown.
virtual HRESULT STDMETHODCALLTYPE ShowContextMenu
(
/* [in] */ DWORD dwID,
/* [in] */ POINT __RPC_FAR *ppt,
/* [in] */ IUnknown __RPC_FAR *pcmdtReserved,
/* [in] */ IDispatch __RPC_FAR *pdispReserved
)
{
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE GetHostInfo
(
/* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE ShowUI
(
/* [in] */ DWORD dwID,
/* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
/* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget,
/* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame,
/* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE HideUI(void)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE UpdateUI(void)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE EnableModeless
(
/* [in] */ BOOL fEnable
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate
(
/* [in] */ BOOL fActivate
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate
(
/* [in] */ BOOL fActivate
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE ResizeBorder
(
/* [in] */ LPCRECT prcBorder,
/* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow,
/* [in] */ BOOL fRameWindow
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator
(
/* [in] */ LPMSG lpMsg,
/* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
/* [in] */ DWORD nCmdID
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath
(
/* [out] */ LPOLESTR __RPC_FAR *pchKey,
/* [in] */ DWORD dw
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetDropTarget
(
/* [in] */ IDropTarget __RPC_FAR *pDropTarget,
/* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetExternal
(
/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE TranslateUrl
(
/* [in] */ DWORD dwTranslate,
/* [in] */ OLECHAR __RPC_FAR *pchURLIn,
/* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut
)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE FilterDataObject
(
/* [in] */ IDataObject __RPC_FAR *pDO,
/* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet
)
{
return E_NOTIMPL;
}
};
//--------------------------------------------------------------------------
-
#endif // QDocHostUIHandlerH
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|