Thread View: borland.public.cppbuilder.internet.web
8 messages
8 total messages
Started by jini
Tue, 08 Mar 2005 12:38
About WebBrowser Customization.. Please Help me..
Author: jini
Date: Tue, 08 Mar 2005 12:38
Date: Tue, 08 Mar 2005 12:38
93 lines
3642 bytes
3642 bytes
How use IDocHostUIHandler, IDocHostUIHander2, IDocHostShowUI, and ICustomDoc
Etc..
i coded like below..
//--------------------------------------------------------------------------
----
void __fastcall TMainForm::get_I (IHTMLDocument2 *HTMLDoc)
{
Mshtml_tlb::IHTMLWindow2 *HTMLWindow = NULL;
HTMLDoc->get_parentWindow(&HTMLWindow);
IOleObject *pOleObject = NULL;
IOleClientSite *pOleClientSite = NULL;
IOleDocumentSite *pOleDocumentSite= NULL;
IDocHostUIHandler *pHostUIHandler = NULL;
IDocHostShowUI *pHostShowUI = NULL;
ICustomDoc *pCustomDoc = NULL;
//HTMLWindow->navigate((WideString)"http://www.yahoo.co.kr"); <-- it
works good.
//HTMLWindow->alert((WideString)"test message"); <-- it works good.
if ( SUCCEEDED( HTMLWindow->QueryInterface(IID_IOleObject,
(LPVOID*)&pOleObject )) )
{
ShowMessage("OK-0"); // <-- not visible
}
if ( SUCCEEDED( HTMLWindow->QueryInterface(IID_IOleDocumentSite,
(LPVOID*)&pOleDocumentSite )) )
{
ShowMessage("OK-a"); // <-- not visible
}
if ( SUCCEEDED( HTMLWindow->QueryInterface(IID_IOleClientSite,
(LPVOID*)&pOleClientSite )) )
{
ShowMessage("OK-1"); // <-- not visible
}
if ( SUCCEEDED( HTMLWindow->QueryInterface(IID_IDocHostUIHandler,
(LPVOID*)&pHostUIHandler )) )
{
ShowMessage("OK-2"); // <-- not visible
}
if ( SUCCEEDED( HTMLWindow->QueryInterface(IID_IDocHostShowUI,
(LPVOID*)&pHostShowUI )) )
{
ShowMessage("OK-3"); // <-- not visible
}
if ( SUCCEEDED( HTMLWindow->QueryInterface(IID_ICustomDoc,
(LPVOID*)&pCustomDoc )) )
{
ShowMessage("OK-4"); // <-- not visible
}
ShowMessage("DONE!");
}
//--------------------------------------------------------------------------
----
How get pOleObject, pOleDocumentSite, pOleClientSite, pCustomDoc,
pHostUIHandler, pHostShowUI, pCustomDoc.. Etc ??
MSDN say < The mechanism for WebBrowser Control customization is designed to
be automated when a container provides support for ActiveX controls.
Whenever the WebBrowser Control is instantiated, it attempts to find
IDocHostUIHandler, IDocHostUIHandler2 and IDocHostShowUI implementations
from the host, if they are available. The WebBrowser Control does this by a
QueryInterface call on the host's IOleClientSite interface.>
I guss if sucess to get IOleClientSite or IOleObject then it is possible to
get IDocHostUIHandler, IDocHostUIHandler2, IDocHostShowUI...
like this
if ( SUCCEEDED( pOleObject ->QueryInterface(IID_ICustomDoc,
(LPVOID*)&pCustomDoc )) )
{
// to do...
}
Please help me..................... thanks.
Re: About WebBrowser Customization.. Please Help me..
Author: Remy Lebeau (TeamB)
Date: Tue, 08 Mar 2005 18:06
Date: Tue, 08 Mar 2005 18:06
33 lines
2430 bytes
2430 bytes
"jini" <fseconds@hotmail.com> wrote in message
news:422d9caa@newsgroups.borland.com...
> How get pOleObject, pOleDocumentSite, pOleClientSite, pCustomDoc,
> pHostUIHandler, pHostShowUI, pCustomDoc.. Etc ??
You are querying the interfaces from the wrong place. IDocHostUIHandler,
etc, are not implemented in IHTMLWindow2. In fact, you probably did not
carefully read what Microsoft was actually saying about IDocHostUIHandler.
You are supposed to implement **YOUR OWN** custom IDocHostUIHandler-derived
class and then give it to the browser for use. You are not supposed to be
querying it from the browser. Please re-read the "WebBrowser Customization"
article again. It specifically says as much:
"These are interfaces that you implement in your application when you
want to modify the WebBrowser Control."
That means, you have to provide your own class(es) that are derived from
IOleClientSite, IDocHostUIHandler, etc. You obtain the browser's
IWebBrowser2 interface, not IHTMLWindow2, and then query it for IOleObject.
From there, you use IOleObject::SetClientSite() to pass the browser your own
IOleClientSite. The browser queries the other interfaces from your own
IOleClientSite.
In the case of ICustomDoc, the browser does provide that, but again not from
IHTMLWindow2. Using ICustomDoc, you can then pass your custom
IDocHostUIHandler-derived class to the browser via the
ICustomDoc::SetUIHandler() method. Using IOleObject and IOleClientSite is
more flexible than using ICustomDoc, though.
Gambit
Re: Thanks Remy and I have other question.. help me agin.
Author: jini
Date: Thu, 10 Mar 2005 02:53
Date: Thu, 10 Mar 2005 02:53
4 lines
1043 bytes
1043 bytes
Thanks Remy. Your advise is good help for me!!! ^_^
I successed to get pOleObject and set pmyIOleClientSite.. how
Author: jini
Date: Thu, 10 Mar 2005 04:08
Date: Thu, 10 Mar 2005 04:08
67 lines
2975 bytes
2975 bytes
I successed to get pOleObject and set pmyIOleClientSite..
but i don't know how use pmyIDocHostShowUI, pmyIDocHostUIHandlerr.. etc.
i coded like below...
//--------------------------------------------------------------------------
-
class myIOleClientSite :public IOleClientSite
{
...
};
class myIDocHostShowUI :public IDocHostShowUI
{
...
}
class myIDocHostUIHandler :public IDocHostUIHandler
{
...
}
pmyIOleClientSite = new myIOleClientSite;
pmyIDocHostUIHandler = new myIDocHostUIHandler;
pmyIDocHostShowUI = new myIDocHostShowUI;
IServiceProvider *pServiceProvider = NULL;
if (
SUCCEEDED(Web->Document->QueryInterface(IID_IServiceProvider,(LPVOID*)&pServ
iceProvider)) )
{
IWebBrowser2 *pWebBrowser = NULL;
if ( SUCCEEDED(pServiceProvider->QueryService(IID_IWebBrowserApp,
IID_IWebBrowser2, (LPVOID*)&pWebBrowser)) )
{
IOleObject *pOleObject = NULL;
if (
SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject,(LPVOID*)&pOleObject))
)
{
pOleObject->SetClientSite(pmyIOleClientSite); // <---
SUCCESS..!!
//
// ????????????????????????????????????????????????
// how to use pmyIDocHostShowUI,
// pmyIDocHostUIHandlerr etc.. that implemented by me
// ????????????????????????????????????????????????
//
}
pWebBrowser->Release();
}
pServiceProvider->Release();
}
//--------------------------------------------------------------------------
-
i know how to use myIDocHostUIHandler by ICustomDoc.
ICustomDoc *pCustomDoc;
Web->Document->QueryInterface(&pCustomDoc);
if (pCustomDoc) pCustomDoc->SetUIHandler(pmyIDocHostUIHandler);
but this solution cannot use myIDocHostShowUI.
and you said to me "Using IOleObject and IOleClientSite is more flexible
than using ICustomDoc, though."
so i want use IOleClientSite..
please help me!!
Thanks...
Re: I successed to get pOleObject and set pmyIOleClientSite.. how
Author: Remy Lebeau (TeamB)
Date: Thu, 10 Mar 2005 16:59
Date: Thu, 10 Mar 2005 16:59
18 lines
1641 bytes
1641 bytes
"jini" <fseconds@hotmail.com> wrote in message news:422fc828$1@newsgroups.borland.com... > I successed to get pOleObject and set pmyIOleClientSite.. > but i don't know how use pmyIDocHostShowUI, > pmyIDocHostUIHandlerr.. etc. Your IOleClientSite is supposed to return them from its QueryInterface() method. > IServiceProvider *pServiceProvider = NULL; You don't need that. Use the WebBrowser's ControlInterface property instead. It is a direct pointer to the IWebBrowser2 interface. Gambit
I successed webbrowser coustomization partly.. plz help more..
Author: jini
Date: Thu, 17 Mar 2005 09:38
Date: Thu, 17 Mar 2005 09:38
85 lines
3990 bytes
3990 bytes
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..
Author: Remy Lebeau (TeamB)
Date: Thu, 17 Mar 2005 18:17
Date: Thu, 17 Mar 2005 18:17
44 lines
2786 bytes
2786 bytes
"jini" <fseconds@hotmail.com> wrote in message
news:4239501e$1@newsgroups.borland.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
Re: I successed webbrowser coustomization partly.. plz help more..
Author: jini
Date: Mon, 21 Mar 2005 15:31
Date: Mon, 21 Mar 2005 15:31
62 lines
3266 bytes
3266 bytes
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)" <no.spam@no.spam.com> wrote in message news:4239c9a1$1@newsgroups.borland.com... > > "jini" <fseconds@hotmail.com> wrote in message > news:4239501e$1@newsgroups.borland.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 > >
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