Board index » cppbuilder » I successed webbrowser coustomization partly.. plz help more..

I successed webbrowser coustomization partly.. plz help more..


2005-03-17 05:38:39 PM
cppbuilder57
I successed webbrowser coustomization partly..
I implemeted below classes
(1) class myIOleClientSite :public IOleClientSite // <--- work good
(2) class myIDocHostShowUI :public IDocHostShowUI // <--- work good
(3) class myIDocHostUIHandler :public IDocHostUIHandler // <--- work
good
(4) class myIDispatch :public IDispatch // <--- NOT WORK!!!!
and below is a part of myIOleClientSite implemetation
class myIOleClientSite :public IOleClientSite
{
.....
virtual HRESULT STDMETHODCALLTYPE QueryInterface( REFIID iid, void
** ppvObject )
{
if (iid == IID_IUnknown) *ppvObject = this->pmyIDispatch;
else if (iid == IID_IDispatch) *ppvObject = this->pmyIDispatch;
else if (iid == IID_IOleClientSite) *ppvObject =
(IOleClientSite*)this;
else if (iid == IID_IDocHostUIHandler) *ppvObject =
this->pmyIDocHostUIHandler;
else if (iid == IID_IDocHostShowUI) *ppvObject =
this->pmyIDocHostShowUI;
else return E_NOINTERFACE;
return S_OK;
}
.....
};
where i mistake...??
below is a part of myIDispatch implemetation
class myIDispatch :public IDispatch
{
.....
virtual HRESULT STDMETHODCALLTYPE Invoke ( DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pDispParams,
VARIANT* pvarResult,
EXCEPINFO* pExcepInfo,
UINT* puArgErr )
{
ShowMessage(dispidMember); // <-- it display just two
messages -5501, -5502
switch (dispidMember)
{
case DISPID_AMBIENT_DLCONTROL:
{
ShowMessage("DISPID_AMBIENT_DLCONTROL"); // <-- never
displayed
pvarResult->vt = VT_I4;
pvarResult->lVal = DLCTL_VIDEOS | DLCTL_NO_SCRIPTS;
//pvarResult->lVal = DLCTL_DLIMAGES | DLCTL_VIDEOS |
DLCTL_NO_SCRIPTS;
}
break;
case DISPID_NEWWINDOW2:
{
ShowMessage("DISPID_NEWWINDOW2"); // <-- never displayed
}
break;
case DISPID_BEFORENAVIGATE2:
{
ShowMessage("DISPID_BEFORENAVIGATE2"); // <-- never
displayed
}
break;
default:
return DISP_E_MEMBERNOTFOUND;
}
return E_NOTIMPL;//S_OK;
}
.....
};
I want customize webbrowser's download and execution.. how to do it??
plz help me..
 
 

Re:I successed webbrowser coustomization partly.. plz help more..

"jini" < XXXX@XXXXX.COM >wrote in message
Quote
(4) class myIDispatch :public IDispatch // <--- NOT WORK!!!!
Why are you implementing IDispatch from scratch? At the very least, you
should use the existing IDispatchImpl class to simplify the work.
Quote
if (iid == IID_IUnknown) *ppvObject = this->pmyIDispatch;
That is not the correct thing to do. You need to return a pointer to the
class that is being queried:
if( iid == IID_IUnknown ) *ppvObject = (IUnknown*)this;
Quote
else if (iid == IID_IOleClientSite) *ppvObject =
(IOleClientSite*)this;
else if (iid == IID_IDocHostUIHandler) *ppvObject =
this->pmyIDocHostUIHandler;
else if (iid == IID_IDocHostShowUI) *ppvObject =
this->pmyIDocHostShowUI;
I would suggest implementing all of the interfaces in the same class, not
separate classes. This you can return 'this' for all of them.
Quote
ShowMessage(dispidMember); // <-- it display just two
messages -5501, -5502
-5501 = DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
-5502 = DISPID_AMBIENT_SILENT
Quote
case DISPID_NEWWINDOW2:
case DISPID_BEFORENAVIGATE2:
To receive those events, you need to attach to the browser's
DWebBrowserEvents2 ConnectionPoint. Query the IWebBrowser2 interface for
IConnectionPointContainer, retreive the IConnectionPoint for
DIID_DWebBrowserEvents2, and add your IDispatch by calling
IConnectionPoint::Advise().
Gambit
 

Re:I successed webbrowser coustomization partly.. plz help more..

Thanks Remy for your kindness..
In spite of youre advise I failed to solve my problems.
I am not good at english. so i did not understand your replies perfectly.
Would you mind make simple example code for me.
I think, I can understand your replies, if i could see example code.
I want to customize webbrowser control, never showmessage never popup right
click menu and
never download exe, zip.. etc files.
Thanks.
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"jini" < XXXX@XXXXX.COM >wrote in message
news:4239501e$ XXXX@XXXXX.COM ...

>(4) class myIDispatch :public IDispatch // <--- NOT WORK!!!!

Why are you implementing IDispatch from scratch? At the very least, you
should use the existing IDispatchImpl class to simplify the work.

>if (iid == IID_IUnknown) *ppvObject = this->pmyIDispatch;

That is not the correct thing to do. You need to return a pointer to the
class that is being queried:

if( iid == IID_IUnknown ) *ppvObject = (IUnknown*)this;

>else if (iid == IID_IOleClientSite) *ppvObject =
>(IOleClientSite*)this;
>else if (iid == IID_IDocHostUIHandler) *ppvObject =
>this->pmyIDocHostUIHandler;
>else if (iid == IID_IDocHostShowUI) *ppvObject =
>this->pmyIDocHostShowUI;

I would suggest implementing all of the interfaces in the same class, not
separate classes. This you can return 'this' for all of them.

>ShowMessage(dispidMember); // <-- it display just two
>messages -5501, -5502

-5501 = DISPID_AMBIENT_OFFLINEIFNOTCONNECTED

-5502 = DISPID_AMBIENT_SILENT

>case DISPID_NEWWINDOW2:
>case DISPID_BEFORENAVIGATE2:

To receive those events, you need to attach to the browser's
DWebBrowserEvents2 ConnectionPoint. Query the IWebBrowser2 interface for
IConnectionPointContainer, retreive the IConnectionPoint for
DIID_DWebBrowserEvents2, and add your IDispatch by calling
IConnectionPoint::Advise().


Gambit


 

{smallsort}