Guess I'm lame after all - TIPHTMLPanel woes
lazarus / 13-General
----------------------------------------------------------------------
Caleb · 2008-03-24 19:38
Hi,
I can't seem to find my way out of this: I'm trying to use an
IpHTMLPanel, especially the curElement property, but no matter how I
try, I'm getting a run-time error 219 (Invalid type cast). The code
I've thougth to use is:
Code: [Select]
procedure TForm1.IpHtmlPanel1Click(Sender: TObject);
var s:string;
begin
s:=((IpHtmlPanel1.CurElement^).Owner as TIpHtmlNodeDIV).Id;
showmessage(s);
end;
As stated in the IPRo documentation, curElement gives a pointer, that
should be cast to the specialized tag node type - but no damn way I
can get this work.
Could anybody help me?
----------------------------------------------------------------------
theo · 2008-03-24 21:05
I think you should check what you get before casting:
Code: [Select]procedure TMainForm.IpHtmlPanel1Click(Sender: TObject);
var Obj:TIpHTMLNode;
begin
Obj:=IpHtmlPanel1.CurElement^.Owner;
ShowMessage(Obj.ClassName);
if Obj is TIpHtmlNodeText then
ShowMessage(TIpHtmlNodeText(Obj).ANSIText);
if Obj is TIpHtmlNodeDIV then ShowMessage(TIpHtmlNodeDIV(Obj).Id);
end;
----------------------------------------------------------------------
Caleb · 2008-03-24 21:19
Gosh, I guess I had it all wrong, then. Damn. The title says it all .
Thank you .