CppWebBrowser - Rmouse menu

0

Czesc,

Mam pytanie odnosnie BCB, komponent CppWebBrowser.

Chodzi o zlikwidowanie wyskakujacego menu po klikniejcu Rmouse na otwartej stronie www (to menu z "wstecz, dalej, pokaz zrodlo....).

Czy zna ktos moze sposob, jakas gotowa funkcja mile widziana.

Pozdrawiam

0

Zrób swoje OnKeyDown (??) OnMouse... (??) w którym nie będziesz w ogóle obsługiwał prawego klawisza.

0

Problem w tym ze tam <ort>w ogóle</ort> nie ma takiego zdarzenia dostepnego :/, nie ma nic OnMouse...

Wiem ze da sie to zrobic bo np. gadu-gadu jest tak zrobione, ale JAK to zrobic :), heh...

0

Może nie jest to dokładnie to damo, a na dodatek w Delphi, ale jednak myślę, że może ci w czymś pomóc:
http://4programmers.net/Forum/viewtopic.php?id=44281

0

tak się składa ze ostatnio równierz szukałem sposobu, oto co znalazłem:

// File: Unit1.h
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include 
#include 
#include 
#include 
#include "mshtmhst.h"
#include "SHDocVw_OCX.h"
#include 
//---------------------------------------------------------------------------

// Simple implementation for IDocHostUIHandler and IUnknown interfaces
// Implementation returns E_NOTIMPL for all IDocHostUIHandler methods except
// ShowContextMenu. See comment block preceeding that ShowContxtMenu for 
// further information.
class MyDocHandler :public IDocHostUIHandler
{
  long refcount;
public:

  MyDocHandler() :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;
    }
};

//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


Modifications to Unit1.cpp are listed below: 

//File: Unit1.cpp
//---------------------------------------------------------------------------

#include 
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SHDocVw_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------

// The constructor for TForm1 navigates the web browser to www.hotmail.com,
// and waits for the page to completely load before passing a pointer to 
// MyDocHandler to the browser via SetUIHandler.

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner) {
    dochandler = new MyDocHandler;
    CppWebBrowser1->Navigate(WideString(L"www.hotmail.com"));
    while(CppWebBrowser1->Busy)
      Application->ProcessMessages();

    ICustomDoc *custdoc;
    CppWebBrowser1->Document->QueryInterface(&custdoc);
    if (custdoc)
      custdoc->SetUIHandler(dochandler);
}
//---------------------------------------------------------------------------
__fastcall TForm1::~TForm1() {
  dochandler->Release();
}

//---------------------------------------------------------------------------


Pozostaje jedynie gdziekolwiek zadeklarować zmienną MyDocHandler *dochandler; Działa na 100%

1 użytkowników online, w tym zalogowanych: 0, gości: 1