Board index » delphi » Finding the mouse position

Finding the mouse position

How do I get the mouse X/Y when clicked, if the componented its
clicking on does'nt support mousedown ?

Craig

 

Re:Finding the mouse position


Quote
Craig Williams wrote:

> How do I get the mouse X/Y when clicked, if the componented its
> clicking on does'nt support mousedown ?

> Craig

I suppose you'll have to use the underlying component. Is your component
on another component, e.g. a Form, which does support the mousedown
event? Use that one and your component's left, right, width and height
properties to check whether or not the mouseposition is in it.

Wouter.

Re:Finding the mouse position


Try using the GetCursorPos function:

var
    Pos: TPoint;
begin
    GetCursorPos(Pos);
    ShowMessage(IntToStr(Pos.X) + ', ' + IntToStr(Pos.Y));
end;

This gives you absolute screen coordinates, so you should adjust it for then
top and left of you forms and controls. To cope with the Non-client area of
forms, you can use the GetClientRect API call, or the GetClientRect method
of  the form.

Hope this helps

                David

Quote
Craig Williams wrote in message <3635ce95.5474...@news.demon.co.uk>...
>How do I get the mouse X/Y when clicked, if the componented its
>clicking on does'nt support mousedown ?

>Craig

Other Threads