Link to home
Start Free TrialLog in
Avatar of fidel83
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?
ASKER CERTIFIED SOLUTION
Avatar of MrJul
MrJul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MrJul
MrJul

PS: you have to put MSHTML in your uses clause.
Avatar of fidel83

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?
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(IWebBrowser2(VarData^.VDispatch), X, Y);
Avatar of fidel83

ASKER

thanks MrJul,
I ended up changing my code to use IHTMLDocument2