I've been struggling for some time to move a run-time created form to the buttom right corner of the main form.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
// procedure FormClick(Sender: TObject);
private
{ Private declarations }
// procedure WindowPosChanging(var Msg : TMessage); message WM_WINDOWPOSCHANGING;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
F1 : TForm;
begin
F1 := TForm.Create(nil);
F1.Height := 300;
F1.Width :=300;
F1.Position := poDesktopCenter;
F1.Name := 'asdf';
F1.Left:=ClientOrigin.X;//+ ActiveControl.Left+ ClientOrigin.X;
F1.Top:=ClientOrigin.Y;//+ClientOrigin.Y;
F1.Show;
end;
//procedure TForm1.FormClick(Sender: TObject);
//var
// pt : TPoint;
//begin
// pt := mOUse.CursorPos;
// lABEL3.Caption := IntToStr(pt.X);
// label4.Caption := IntToStr(pt.Y);
//end;
//
//procedure TForm1.WindowPosChanging(var Msg: TMessage);
//begin
// Label1.Caption := IntToStr(ClientOrigin.X);
// Label2.Caption := IntToStr(ClientOrigin.Y);
//end;
end.
So we have this example.
F1.Position := poDesktopCenter;
THis command works perfectly if you want to center the form onto the desktop, but what i want to achive is position the F1
form at the buttom corner of the main form. I can't figure out how to do it.
Something like this
Aucun commentaire:
Enregistrer un commentaire