fidel83
asked on
HTML element position
Hi,
I'm using 'elementFromPoint' to return me an html 'element' object. this works fine. I would like to know the element's left and top coordinates.
Any ideas?
I'm using 'elementFromPoint' to return me an html 'element' object. this works fine. I would like to know the element's left and top coordinates.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PS: you have to put MSHTML in your uses clause.
ASKER
hey MrJul,
I'm using 'variant' for the internet explorer object. is there a way to convert your code so that it works with this?
I'm using 'variant' for the internet explorer object. is there a way to convert your code so that it works with this?
It depends of what is stored in your Variant.
If it is a IWebBrowser2 interface as I suspect, do the following :
Replace
function GetElemCoordsFromPoint(WB: TWebBrowser; X, Y: Integer): TPoint;
By
function GetElemCoordsFromPoint(WB: IWebBrowser2; X, Y: Integer): TPoint;
Then use the following code to call the function :
(V is assumed to be your Variant)
var
Pt: TPoint;
VarData: PVarData;
begin
VarData := FindVarData(V);
GetElemCoordsFromPoint(IWe bBrowser2( VarData^.V Dispatch), X, Y);
If it is a IWebBrowser2 interface as I suspect, do the following :
Replace
function GetElemCoordsFromPoint(WB:
By
function GetElemCoordsFromPoint(WB:
Then use the following code to call the function :
(V is assumed to be your Variant)
var
Pt: TPoint;
VarData: PVarData;
begin
VarData := FindVarData(V);
GetElemCoordsFromPoint(IWe
ASKER
thanks MrJul,
I ended up changing my code to use IHTMLDocument2
I ended up changing my code to use IHTMLDocument2