πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
4 messages
4 total messages Started by Marcelo Mello Tue, 22 Mar 2005 17:51
How can i disable TCppWebBrowser pop-up menu?
#1314
Author: Marcelo Mello
Date: Tue, 22 Mar 2005 17:51
1 lines
971 bytes
How can i disable or change native TCppWebBrowser pop-up menu?
Re: How can i disable TCppWebBrowser pop-up menu?
#1316
Author: Hans Galema
Date: Tue, 22 Mar 2005 19:21
7 lines
1177 bytes
Marcelo Mello wrote:
> How can i disable or change native TCppWebBrowser pop-up menu?

Assign an Application OnMessage handler that handles
the WM_RBUTTONDOWN message.

Hans.
Re: How can i disable TCppWebBrowser pop-up menu?
#1315
Author: James O'Brien
Date: Tue, 22 Mar 2005 19:40
52 lines
2983 bytes
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@pop.com.br> wrote in message 
news:42405ace$1@newsgroups.borland.com...
> How can i disable or change native TCppWebBrowser pop-up menu? 
Re: How can i disable TCppWebBrowser pop-up menu?
#1317
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads