NO

Author Topic: [SOLVED] Casting IHTMLElement to IHTMLDOMNode and Reinterpret Cast  (Read 8037 times)

Tino

  • Guest
Hello Forum,

I often read the term "reinterpret cast",
how to do that in PellesC ?

I want to access an IHTMLDOMNode
but the only thing i have is a IHTMLElement ..

.. i read that it should be the same..
.. but casting doesn´t work ...

IHTMLDOMNode = (IHTMLDOMNode) IHTMLElement;

Thanks
Tino
« Last Edit: May 28, 2008, 07:35:02 AM by Tino »

severach

  • Guest
Re: Casting IHTMLElement to IHTMLDOMNode (Reinterpret Cast)
« Reply #1 on: May 22, 2008, 06:40:57 AM »
Pelles is a C only compiler. I Googled "reinterpret cast" and found this in the first result.

Reinterpret-cast Typecast
Quote
Reinterpret casts are only available in C++

Checking into mshtml.dll those things are part of a C++ class and not exported as C functions. Your program requires C++.
« Last Edit: May 22, 2008, 06:52:02 AM by severach »

Tino

  • Guest
Re: Casting IHTMLElement to IHTMLDOMNode (Reinterpret Cast)
« Reply #2 on: May 22, 2008, 10:29:08 PM »
Hello severach,

Thanks for your answer.

I came to that conclusion too,
but under the hood it´s all COM, structures and pointers
defined as i see in mshtmlc.h..
( C and C++ Style )

Another Source told me "reinterpret cast is only formal as hint for the programmer/compiler"..
Not secure, not type safe.



Must be possible somehow to get to an ITHMLDOMNode via IHTMLElement.
Once i had a demo but can´t find it again.

I tried workaround using IHTMLCollection, Markup, Persistent and many different other ways,
didn´t crash,
but didn´t lead to ouput.



Any help would be most welcome,
Thanks,
Tino

Tino

  • Guest
[SOLVED]
« Reply #3 on: May 28, 2008, 07:34:16 AM »
Hello,

i solved it.
The hint is HTMLDOMNode is HTMLElement as written in another forum.

No conversion needed,
just query´ing leads to result.


IHTMLElement *pElement;
IHTMLDOMNode *pNode = NULL;

pElement->lpVtbl->QueryInterface(
                              pElement,
                              &IID_IHTMLDOMNode,
                              (LPVOID *) &pNode);

Thanks,
Tino