完整的代码如下:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) lbl1: TLabel; private procedure WMSYSCOMMAND(var msg:TMessage);message WM_SYSCOMMAND; { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.WMSYSCOMMAND(var msg: TMessage); begin if msg.WParam=SC_CLOSE then Close; if msg.WParam=SC_MOVE then msg.WParam:=0; end; end.