首页 > 代码库 > 同步窗体移动
同步窗体移动
方法2
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormShow(Sender: TObject);
private
procedure WMMOVE(var Msg: TMessage); message WM_MOVE;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.FormShow(Sender: TObject);
begin
Form2.Visible := true;
end;
procedure TForm1.WMMOVE(var Msg: TMessage);
begin
inherited;
try
Form2.Parent:=Panel1;
Form2.Left:=0;
Form2.Top:=0;
Form2.Align:=alClient;
except
end;
end;
end.
方法1
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
private
procedure WMMOVE(var Msg: TMessage); message WM_MOVE;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.WMMOVE(var Msg: TMessage);
begin
inherited;
try
form2.Width := Panel1.Width;
form2.Height := Panel1.Height;
form2.left := Form1.left + Panel1.Left;
form2.Top := Form1.Top + Panel1.Top;
except
end;
end;
end.
来自为知笔记(Wiz)
附件列表
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。