代碼如下:
type
...
private
Procedure MyMessage(var Msg: TWMSysCommand); message WM_SYSCOMMAND;...
implementation{$R *.dfm}procedure TForm1.myMessage(var Msg: TWMSysCommand);
begin
if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) then
begin
if Application.MessageBox('are you sure?','confirm',Mb_YesNo)=Id_No then
Exit;
inherited;
end
end;
{==奇怪就是,如果單獨判斷一個(Msg.CmdType = SC_MINIMIZE)或者(Msg.CmdType = SC_MAXIMIZE),卻完全沒問題,如果使用OR判斷就發生窗體不能使用鼠標拖動了,望指教!==}
type
...
private
Procedure MyMessage(var Msg: TWMSysCommand); message WM_SYSCOMMAND;...
implementation{$R *.dfm}procedure TForm1.myMessage(var Msg: TWMSysCommand);
begin
if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) then
begin
if Application.MessageBox('are you sure?','confirm',Mb_YesNo)=Id_No then
Exit;
inherited;
end
end;
{==奇怪就是,如果單獨判斷一個(Msg.CmdType = SC_MINIMIZE)或者(Msg.CmdType = SC_MAXIMIZE),卻完全沒問題,如果使用OR判斷就發生窗體不能使用鼠標拖動了,望指教!==}
begin
if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) then
begin
if Application.MessageBox('are you sure?','confirm',Mb_YesNo)=Id_No then
Exit;
end;
//要放在这里。
inherited;
end;
procedure TForm1.myMessage(var Msg: TWMSysCommand);
begin
if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) then
begin
if Application.MessageBox('are you sure?','confirm',Mb_YesNo)=Id_No then
Abort
else
inherited;
end;
end;