πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1317

Re: How can i disable TCppWebBrowser pop-up menu?

#1317
From: SD
Date: Wed, 23 Mar 2005 07:12
217 lines
5889 bytes
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
Technical Details
Message-ID: <424116df$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42405ace$1@newsgroups.borland.com> <424074bc@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,7582e9bb14d23209
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII
From: "SD" <nospawm@please.it>
Newsgroups: borland.public.cppbuilder.internet.web
References: <42405ace$1@newsgroups.borland.com> <424074bc@newsgroups.borland.com>
Subject: Re: How can i disable TCppWebBrowser pop-up menu? 
Date: Wed, 23 Mar 2005 08:12:29 +0100
Lines: 219
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 217.168.230.137
Message-ID: <424116df$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1111561951 217.168.230.137 (22 Mar 2005 23:12:31 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail