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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...