Delphi MainFormOnTaskBar模态Windows错误 [英] Delphi MainFormOnTaskBar Modal windows bug

查看:121
本文介绍了Delphi MainFormOnTaskBar模态Windows错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我正在使用Delphi 2007,并将MainFormOnTaskBar属性设置为true。

I'm using Delphi 2007 and have set the MainFormOnTaskBar property to true.

如果您从主窗体中打开一个子窗口,然后从刚打开的子窗口中显示一个消息对话框。当您关闭消息对话框,然后关闭子窗口时,主窗体将发送到屏幕上其他任何应用程序的背面。

If you open a child window from the main form and then you show a message dialog from the child window you just opened. When you close the message dialog and then close the child window, the main form will be sent to the back of any other application you have on the screen.

Windows Vista和Windows7。有人知道为什么会发生这种情况吗,我该如何解决?

This happens under windows Vista and Windows 7. Does anyone know why this is happens and how can I fix it?

推荐答案

我已解决此问题有两种方式。

I've fixed this in two ways.

首先,如Andreas Hausladen所述,在Forms.pas中的DoFindWindow的末尾添加stdcall。

Firstly by adding stdcall to the end of DoFindWindow in Forms.pas as described by Andreas Hausladen. This handles when a child form is hidden (CloseAction = caHide) instead of released when closing the form.

第二个-从TCustomForm.CMShowingChanged复制了代码,该代码调用FindTopMostWindow,然后处理该问题。激活返回到TCustomForm.CMRelease的窗口。

Secondly - copied the code from TCustomForm.CMShowingChanged that calls FindTopMostWindow and then activates the window that was returned into TCustomForm.CMRelease.

(编辑:代码块需要缩进4个空格)

procedure TCustomForm.CMRelease;
var
  NewActiveWindow: LongInt;
begin
  if Application.MainFormOnTaskbar then
  begin
    NewActiveWindow := 0;

    if (GetActiveWindow = Handle) and not IsIconic(Handle) then
    begin
      NewActiveWindow := FindTopMostWindow(Handle);
    end;

    if NewActiveWindow <> 0 then
    begin
      SetActiveWindow(NewActiveWindow);
    end;
  end;

  Free;
end;

这似乎已经完成,我将继续测试以确保结果。

This seems to have done it, I'll continue testing to make sure.

这篇关于Delphi MainFormOnTaskBar模态Windows错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆