16,748
社区成员
发帖
与我相关
我的任务
分享
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
procedure WndProc(var message:TMessage);override;
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.WndProc(var message: TMessage);
begin
if message.Msg =WM_MOVE then
begin
Label1.Caption := IntToStr(self.Left);
if self.Left< Form1.Left then
self.Left := form1.Left;
if Self.Top < form1.Top then
self.Top := form1.Top;
if self.Top > form1.Top + form1.Height - Form2.Height then
self.Top := form1.Top + form1.Height - Form2.Height;
if self.Left > form1.Left + form1.Width - form2.Width then
self.Left := form1.Left + form1.Width - form2.Width;
end;
inherited WndProc(message);
end;
end.