代碼如下:
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判斷就發生窗體不能使用鼠標拖動了,望指教!==}

解决方案 »

  1.   

    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;
          
      end;
      //要放在这里。
      inherited;
    end;
      

  2.   

    这样试试!!
    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;
      

  3.   

    lili1(离奇) 的通過, juliens(星星球) 的不行。謝謝進來頂的朋友!都有分