Article View: borland.public.cppbuilder.internet.web
Article #386Re: How to get the "real live" HTML source?
From: Remy Lebeau (TeamB)
Date: Tue, 19 Dec 2006 18:35
Date: Tue, 19 Dec 2006 18:35
64 lines
3477 bytes
3477 bytes
"Enrique" <enridp@yahoo.com.ar> wrote in message
news:4588092d@newsgroups.borland.com...
> And yes, I need more practice with these interfaces, but in C++ it
> seems so complicated... we can see it just viewing the translation to
> C++ of the really simple code in Delphi... why it's so different?
Because the Delphi language has built-in support for interfaces, so it can
handle reference counting, QueryInterface(), and IDispatch::Invoke()
automatically. The C++ language, however, does not natively have such rich
interface support, so you have to write extra code to manage it all
manually.
> MSDN design its interfaces thinking in Object Pascal?
No. On the contrary, just about everything Microsoft does is actually
designed for C++ specifically. What I showed you is similar code to what
VC++ programmers would have to use (just using Microsoft wrappers instead of
Borland wrappers). It is just that Borland designed Delphi to work more
integrated with Microsoft technologies. Delphi code may be cleaner, but the
runtime behavior is still the same either way.
> QueryInterface is like a typecasting?
An interface cannot safely be type-casted from one type to another directly.
QueryInterface() is the only safe way to get one interface type from
another, by actively asking the source interface if it supports a specific
type or not, and if so to then return such a pointer (with proper reference
counting, of course).
> In delhpi we can do this:
The "as" operator in Delphi is just a wrapper for QueryInterface(). If
QueryInterface() returns an error, the "as" operator throws an exception.
> IHTMLElement element;
You have to declare those interfaces as pointers:
IHTMLElement *element;
IHTMLElementCollection *childrenElements;
> childrenElements = (IHTMLElementCollection)element.children;
You cannot type-cast like that. You must use QueryInterface() instead (and
"children" is not a VCL property, so you have to call the get_children()
method instead):
IDispatch *disp;
element->get_children(&disp);
disp->QueryInterface(IID_IHTMLElementCollection,
(LPVOID*)&childrenElements);
disp->Release();
//...
childrenElements->Release();
> childrenElements =
dynamic_cast<IHTMLElementCollection*>(element->children);
You cannot use dynamic_cast on an interface.
Gambit
Technical Details
Message-ID:
<458830cd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4582e657@newsgroups.borland.com> <4582eb35$1@newsgroups.borland.com> <45831d53@newsgroups.borland.com> <4583480c$1@newsgroups.borland.com> <45834aa4$1@newsgroups.borland.com> <4583eee0@newsgroups.borland.com> <4586f05a$1@newsgroups.borland.com> <4588092d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,b54437b3b496861e X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.web References: <4582e657@newsgroups.borland.com> <4582eb35$1@newsgroups.borland.com> <45831d53@newsgroups.borland.com> <4583480c$1@newsgroups.borland.com> <45834aa4$1@newsgroups.borland.com> <4583eee0@newsgroups.borland.com> <4586f05a$1@newsgroups.borland.com> <4588092d@newsgroups.borland.com> Subject: Re: How to get the "real live" HTML source? Date: Tue, 19 Dec 2006 10:35:47 -0800 Lines: 66 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.34.171 Message-ID: <458830cd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1166553293 75.83.34.171 (19 Dec 2006 10:34:53 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail