¡¡¡¡procedure TForm1.SetFocusToDoc;
¡¡¡¡begin
¡¡¡¡¡¡if WebBrowser1.Document < > nil then
¡¡¡¡¡¡¡¡with WebBrowser1.Application as IOleobject do
¡¡¡¡¡¡¡¡¡¡DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle,
GetClientRect);
¡¡¡¡end;
¡¡¡¡if WebBrowser1.Document < > nil then
¡¡¡¡¡¡IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).focus
¡¡¡¡if WebBrowser1.Document < > nil then
¡¡¡¡¡¡IHTMLWindow4(WebBrowser1.Document).focus
> Would you tell me how to change to C++ builder?
#include <mshtml.h>
void __fastcall TForm1::SetFocusToDoc()
{
if( WebBrowser1->Document != NULL )
{
DelphiInterface<IOleObject> OleObject =
WebBrowser1->Application;
if( OleObject )
{
DelphiInterface<IOleClientSite> ClientSite = WebBrowser1;
RECT r = ClientRect;
OleObject->DoVerb(OLEIVERB_UIACTIVATE, NULL, ClientSite, 0,
Handle, &r);
}
DelphiInterface<IHTMLDocument2> Doc = WebBrowser1->Document;
DelphiInterface<IHTMLWindow2> Window2 = Doc->ParentWindow;
if( Window2 )
Window2->focus();
DelphiInterface<IHTMLWindow4> Window4 = Doc;
if( Window4 )
Window4->focus();
}
}
> I found that IHTMLWindow4 is not exist now
IHTMLWindow4 is not declared in any version of BCB. Microsoft did not
create IHTMLWindow4 until after BCB6 was released. You will have to define
IHTMLWindow4 manually, ie:
// sorry, I do not know what the actual IID value is,
// it is not documented anywhere, so you will have to
// track it down...
const IID IID_IHTMLWindow4 = {???};
interface IHTMLWindow4 : public IDispatch
{
public:
virtual HRESULT STDMETHODCALLTYPE createPopup(
VARIANT *varArgIn, IDispatch **ppPopup) = 0;
virtual HRESULT STDMETHODCALLTYPE frameElement(
IHTMLFrameBase **p) = 0;
};
Gambit
for
DelphiInterface<IOleClientSite> ClientSite = WebBrowser1;
[C++ Error] unit1.cpp(1181): E2034 Cannot convert 'TCppWebBrowser * const'
to '_di_IOleClientSite'
for
DelphiInterface<IHTMLWindow2> Window2 = Doc->ParentWindow;
[C++ Error] unit1.cpp(1186): E2316 'ParentWindow' is not a member of
'IHTMLDocument2'
Would you help me again?
"Remy Lebeau (TeamB)" <no....@no.spam.com> 写入消息新闻:433c...@newsgroups.borland.com...
> DelphiInterface<IOleClientSite> ClientSite = WebBrowser1;
> [C++ Error] unit1.cpp(1181): E2034 Cannot convert
> 'TCppWebBrowser * const' to '_di_IOleClientSite'
Sorry about that, I posted the code before I was finished translating it.
It should be this instead:
DelphiInterface<IOleClientSite> ClientSite;
OleObject->GetClientSite(&ClientSite);
if( ClientSite )
OleObject->DoVerb(OLEIVERB_UIACTIVATE, NULL, ClientSite, 0, Handle,
&r);
> DelphiInterface<IHTMLWindow2> Window2 = Doc->ParentWindow;
> [C++ Error] unit1.cpp(1186): E2316 'ParentWindow' is not a member of
> 'IHTMLDocument2'
DelphiInterface<IHTMLWindow2> Window2;
Doc->get_parentWindow(Window2);
if( Window2 )
Window2->focus();
Gambit
DelphiInterface<IHTMLWindow2> Window2;
Doc->get_parentWindow(Window2);
for
Doc->get_parentWindow(Window2);
[C++ Error] Unit1.cpp(1197): E2034 Cannot convert
'DelphiInterface<IHTMLWindow2>' to 'IHTMLWindow2 * *'
[C++ Error] Unit1.cpp(1197): E2342 Type mismatch in parameter 'p' (wanted
'IHTMLWindow2 * *', got 'DelphiInterface<IHTMLWindow2>')
would you help me again , thank you
> Doc->get_parentWindow(Window2);
> [C++ Error] Unit1.cpp(1197): E2034 Cannot convert
> 'DelphiInterface<IHTMLWindow2>' to 'IHTMLWindow2 * *'
Doc->get_parentWindow(&Window2);
Gambit
> Can anybody find the defination of IHTMLWindow4 ?
I already gave you the definition of the IHTMLWindow4 interface.
If you are looking for the definition of IID_IHTMLWindow4, on the other
hand, then the only place you're going to find it is by downloading
Microsoft's latest Platform SDK from MSDN and then look in the latest
mshtml.h file (or find someone who already has the latest PSDK). Since it
is not very likely that any Borland user here has the latest PSDK since it
would not work with BCB as-is in the first place, you will likely have to
just download it yourself.
Gambit
> If you are looking for the definition of IID_IHTMLWindow4, on the
> other hand, then the only place you're going to find it is by downloading
> Microsoft's latest Platform SDK from MSDN and then look in the latest
> mshtml.h file (or find someone who already has the latest PSDK). Since
> it is not very likely that any Borland user here has the latest PSDK since
> it would not work with BCB as-is in the first place, you will likely have
> to just download it yourself.
Nevermind. I went ahead and downloaded the PSDK myself for you. The value
of IID_IHTMLWindow4 and IHtmlWindow4 are as follows:
const IID IID_IHTMLWindow4 = {0x3050f6cf, 0x98b5, 0x11cf, {0xbb, 0x82,
0x00, 0xaa, 0x00, 0xbd, 0xce, 0x0b}};
MIDL_INTERFACE("3050f6cf-98b5-11cf-bb82-00aa00bdce0b")
IHTMLWindow4 : public IDispatch
{
public:
virtual HRESULT STDMETHODCALLTYPE createPopup(
VARIANT *varArgIn,
IDispatch **ppPopup) = 0;
virtual HRESULT STDMETHODCALLTYPE get_frameElement(