Jump to content

Mouse coordinates are not getting correctly.


abhimanyu

Recommended Posts

Hi,

 

I have panel in main form when I click in the region of panel at position I need to open the popupmenu but it open at different position not that current position.

 

procedure TMainForm.UniPanel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  pt: TPoint;
begin
  pt := Mouse.CursorPos;
  pt := ScreenToClient(pt);
  if Button = mbLeft then
  begin
    UniPopupMenu1.Popup(pt.x, pt.y);
  end;
end;
Link to comment
Share on other sites

Hi,

 

You can use just like this:

procedure TMainForm.UniPanel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = mbLeft then
  begin
    UniPopupMenu1.Popup(X, Y, Sender);
  end;
end;

Best regards.

Link to comment
Share on other sites

  • 1 year later...

it's relative to the panel, If you want the absolute location you have to add the panel's offset (x,y)

Hello there !

 

How may I achieve something like that if my panel Align prop is set to alRight (and so panel's offset is (0,0)) ?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...