怎么控制关闭按钮

tigerlhp 2011-04-08 10:47:34
窗体右上的关闭按钮按下时,希望将窗体隐藏而不关闭
然后可以随时再显示出来,不知道怎么做。
...全文
60 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tigerlhp 2011-04-10
  • 打赏
  • 举报
回复
我的窗体是主窗体,试了下你们的方法,直接关闭了
而 FormCloseQuery 方法的能隐藏第一次,第二次再让他隐藏它就不甩我了
牧牛童子 2011-04-09
  • 打赏
  • 举报
回复
在窗体的OnCloseQuery事件里,
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
CanClose=false; //不退出
this->Visible =false; //隐藏窗体。
}

但是要再让它显示出来,得有个地方将该窗体Visible=true;
我不懂电脑 2011-04-09
  • 打赏
  • 举报
回复
Action: 的取值有
Value Meaning
caNone
The form is not allowed to close, so nothing happens.

caHide
The form is not closed, but just hidden. Your application can still access a hidden form.

caFree
The form is closed and all allocated memory for the form is freed.

caMinimize
The form is minimized, rather than closed. This is the default action for MDI child forms.

我不懂电脑 2011-04-09
  • 打赏
  • 举报
回复
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
if (MessageDlg("Close application ?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo,0) == mrYes)
Action = caFree;
else
Action = caMinimize;
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧