[Lazarus] GetCursorPos

Juha Manninen juha.manninen at phnet.fi
Fri Oct 30 16:18:56 CET 2009


Hi.

> > GetCursorPos is defined in winapih.inc.
> > Does it mean it is Windows only? Is there a cross platform alternative?
> 
> No, it is part of the LCLintf unit:
> http://lazarus-ccr.sourceforge.net/docs/lcl/lclintf/index.html
> 
> Porting Delphi code without having the windows unit is hard, so we made it
>  easier.

Ok, thanks, LCLintf helped.
I am using the function in VirtualTreeView's Plugin.PopupFunc handler like 
this:
  ...
  GetCursorPos(P);
  P := Tree.ScreenToClient(P);
  if PtInRect(Tree.ClientRect, P) then
  begin
    Tree.GetHitTestInfoAt(P.X, P.Y, True, fHitInfo);
    Tree.FocusedColumn := fHitInfo.HitColumn;
    Tree.FocusedNode   := fHitInfo.HitNode;
  end
  ...

It took me a long time in Delphi to find this solution to know on which cell 
the popup menu is opened. Focused cell is easy to get but right-mouse-click 
doesn't focus the cell automatically.
It is possible of course that I missed some easier way of doing it.

Regards,
Juha Manninen




More information about the Lazarus mailing list