Jump to content

How to know the position relative to the form ?


FFREDIANELLI

Recommended Posts

Please how can I know the position of a button created dinamicaly inside a panel, that is inside other panel, and scrollbox,  all of them created dinamicaly ? I need to open an options form closer to the button, so I think that i need the x,y position of the form, because the left and right position of the button is relative to the panel, that is inside a scroll box so i can not calculate the position based in summing the position of the parent components...

If its not possible i will create in the center... not so profissional... but will work..

Link to comment
Share on other sites

None..., but there is no other way to create a similar funcionality of the site monday.com, i'm almost there... but for some interface things i dont know how to do it...  as you can see in the image i can not use unidbgrid becase the kind of components that can compose a pulse are variable project by project, and board by board. So, for example the user will click on the panel red status and i whant to present the possible status 'near' this panel... just this. each line is a panel with componets created dinamicaly .

and why not pay monday.com, because it will not integrate with out industrial cost system and production system, (ERP).

image.thumb.png.a238f803a2d595b08867fe0eb121139f.png

Link to comment
Share on other sites

4 hours ago, FFREDIANELLI said:

Please how can I know the position of a button created dinamicaly inside a panel, that is inside other panel, and scrollbox,  all of them created dinamicaly ? I need to open an options form closer to the button, so I think that i need the x,y position of the form, because the left and right position of the button is relative to the panel, that is inside a scroll box so i can not calculate the position based in summing the position of the parent components...

If its not possible i will create in the center... not so profissional... but will work..

Hi,

Can you explain in more details what you wanted to implement?

Make a simple testcase for this if possible

Link to comment
Share on other sites

37 minutes ago, FFREDIANELLI said:

Here is the testcase Sherzod, thanks for any help.

You can try something like this:

foptions -> Position -> poDefault

procedure pAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);

procedure TMainForm.pAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  p: TUniPanel;
  x, y: Integer;
begin
  if EventName = '_mousedown' then
  begin
    x := Params.Values['x'].ToInteger();
    y := Params.Values['y'].ToInteger();

    p := findcomponent((Sender as TComponent).Name) as TUniPanel;
    foptions.unilabel2.Caption := p.Caption;
    foptions.Top := y;
    foptions.Left := x;
    foptions.ShowModal();
  end;
end;

procedure TMainForm.UniPanel1Click(Sender: TObject);
var
  i: integer;
begin
  for i := 1 to 25 do
  begin
    pStatus := TUniPanel.Create(MainForm);
    with pStatus do
    begin
      Name := 'Option_' + inttostr(i);
      caption := name;
      Parent := sb;
      Top := i * 41;
      Height := 40;
      align := altop;
      color := RGB(Random(255), Random(255), Random(255));
      //onclick := pstatusClick;
      OnAjaxEvent := pAjaxEvent;
      ClientEvents.ExtEvents.Values['mousedown'] := 'function mousedown(sender, x, y, eOpts){ajaxRequest(sender, "_mousedown", ["x="+parseInt(x+sender.getX()), "y="+parseInt(y+sender.getY())])}';
    end;
  end;
end;
    

 

  • Like 1
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...