超简:通过onclose事件能使form无法关闭么?(50分)

  • 主题发起人 我爱大富翁
  • 开始时间

我爱大富翁

Unregistered / Unconfirmed
GUEST, unregistred user!
if can ,how?if can't ,how can?(delphi6).thank you.
 
Action:=CaNoNe;
 
sure
onclose event
action:=canone
then
ok
 
//OnCloseQuery
procedure TForm1.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if MessageDlg('Close the form?', mtConfirmation,
[mbOk, mbCancel], 0) = mrCancel then
CanClose := False;
end;
//OnClose
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
 
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if ... then

abort;
end;
 
Action:=CaNone;
 
你要干什么?用closerequest不就可以了?
 
action:=canone是无法关闭
action:=cafree是关闭
 
声明一个全局变量 cc:boolean;
在自己的关闭按钮的Onclick事件中加入:
begin
cc:=true;
close;
end;

在OnCloseQuery中加入:
begin
if cc=false then
canclose:=false;
end;

这样除了你自己的按钮,就再没其它方法关闭啦。
我还没用过Delphi 6 呢,应该也可以的吧。
 
基本同意以上几位的说法
 
大家的回答已经够多了,都可以。wcwcw的回答比较详细。
 
if ... then
Action := caFree
else
Action := caNone;
 
使用了不懂兄的办法,另外每人有参与奖1分
 
难道想做一个监视程序吗?
 
在 CLOSEQUERY 事件中
begin
canclose:=false;
end
 
action:=canone
 
Action:=CaNone;
 
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
 
caFree在MDIChild窗口中不能使用!!!!
要使窗口不关闭用caNone
要关闭 aForm.Free;
aForm := nil;
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
926
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
595
import
I
顶部