加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 如何在Delphi中隐藏MDI子窗体?

发布时间:2020-12-13 20:29:20 所属栏目:Windows 来源:网络整理
导读:如何在Delphi中隐藏MDIChild窗口? 我在我的MDI子项的FormClose()事件中使用此代码,但它似乎不起作用: procedure TfrmInstrument.FormClose(Sender: TObject; var Action: TCloseAction);begin Action := caNone; ShowWindow(Handle,SW_HIDE); frmMainForm.
如何在Delphi中隐藏MDIChild窗口?

我在我的MDI子项的FormClose()事件中使用此代码,但它似乎不起作用:

procedure TfrmInstrument.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caNone;
  ShowWindow(Handle,SW_HIDE);
  frmMainForm.MDIChildClosed(Handle);
end;

我的子窗口被最小化而不是被隐藏.

TCustomForm中有一个受保护的过程定义为:
procedure TCustomForm.VisibleChanging;
begin
  if (FormStyle = fsMDIChild) and Visible and (Parent = nil) then
    raise EInvalidOperation.Create(SMDIChildNotVisible);
end;

在您的MDI子窗口中覆盖它:

procedure TMDIChildForm.VisibleChanging;
begin
  // :-P
end;

Here’s a simple example

在阅读了Jeroen的评论后,我尝试了另一种解决方案,但也有一点点闪烁:

procedure TMDIChildForm.VisibleChanging;
begin
  if Visible then
    FormStyle := fsNormal
  else
    FormStyle := fsMDIChild;
end;

也许这适用于所有Windows版本.

PS:我没有发现Windows 2k3SP2 x86和Windows 7 Ultimate x86上的第一个解决方案有任何问题

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读