完整的代码如下:
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} //禁止窗体移动(此处的Tform1修改成自己的窗体名) 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.