Jump to content

How to popup a form at postion?


Tokay

Recommended Posts

I know how to popup a context menu:

 if Button = mbRight then
  UniPopupMenu1.Popup(X, Y, Sender);

But how to do it with a Form? How to calculate relative X, Y params to absolute to set Left and Top of the popup Form? ClientToSreen doesn't works. But the Popup Menus can convert X and Y using the Sender.

Link to comment
Share on other sites

32 minutes ago, Tokay said:

In the project exist the main form with TUniEdit on it. When I clcked on the TUniEdit I need to show another form in place where I do click.

Maybe something like this?

procedure TMainForm.UniEdit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  _X, _Y: Integer;
begin
  if Button = mbRight then
  begin
    _X := Self.Left + (Sender as TUniEdit).Left + X;  // +/-
    _Y := Self.Top + (Sender as TUniEdit).Top + Y; // +/-

    with UniForm1 do
    begin
      WebForm.JSInterface.JSAddListener('beforeshow', 'function(){this.setPosition('+_X.ToString()+','+_Y.ToString()+')}');
      ShowModal();
    end;
  end;
end;

 

Link to comment
Share on other sites

11 hours ago, Tokay said:

I understand what happens. Wrong position is obtained only when the TUniEdit is in the container, for example, in the TUniPanel. And this is my case - TUniEdit is the TUniDBGrid column filter.

Try to analyze and use the method that is used here.

 

Link to comment
Share on other sites

Thank you very much! This approach works well. I added

Quote

function mousedown(sender, x, y, eOpts){ajaxRequest(sender, "_mousedown

 as event handler in the TUniEdit, and catch it OnAjaxEvent, and there I get needed coordinates.

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...