Delphi - 如何防止表单/消息框在先前的表单下移动? [英] Delphi - How to prevent Forms/MsgBoxes to move under prior form?

查看:21
本文介绍了Delphi - 如何防止表单/消息框在先前的表单下移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 98 时代之后,我们多次经历过一些对话框失去了它们的 Z-Order 并返回到以前的形式.

Many times after the Windows 98 era we have experienced that some dialogs lose their Z-Order and move back to the prior form.

例如:

Dialog1.ShowModal;

Dialog1.OnClickButton() : ShowMessage('anything');

MessageBox 出现时,有时没有焦点,被移到Dialog1 下.用户对此感到困惑,他们说:我的应用程序冻结了!!!但如果他们使用 Alt+Tab 移动到另一个应用程序并返回,焦点将返回到 MessageBox,它将成为前台窗口.

When MessageBox appears, it sometimes doesn't have focus and is moved under Dialog1. The users are confused about it, they say: My application froze!!! But if they use Alt+Tab to move to another app and back, the focus returns to the MessageBox and it will be the foreground window.

我们已经在 ShowMessage、MessageBox、普通表单和 QuickReport 表单中体验过这一点.

We have experienced this with ShowMessage, MessageBox, normal forms, and also QuickReport forms.

有人知道吗?它是Windows错误吗?你怎么能防止它?如何抓住这个?

Does anyone know about this? Is it a Windows bug? How can you prevent it? How to catch this?

感谢您的帮助:dd

我真的说过Win98之后,所以所有操作系统(Win7也是)都受到这个问题的影响.我们使用的是 Delphi 6 Prof,因此这些属性不适用于默认表单.

I really said that AFTER Win98, so all OSs (Win7 also) are affected by this problem. We used Delphi 6 Prof, so the properties are not working with Default forms.

有人说消息对话框可以用 MessageBox + MB_APPLMODAL 来控制.这是个好消息,但我们有许多旧表单和组件以及第三方工具.

Somebody said that message dialogs are controllable with MessageBox + MB_APPLMODAL. This is good news, but we have many old forms and components, third party tools.

因此,通过替换表单来制作一个全新的应用程序是一项艰巨的工作.

So it is hard work to make a completely new application with substitution of the forms.

但我们会尝试这样做.

我认为答案是一半是应用程序问题,一半是 Windows 问题.如果 Windows 有时会处理这个问题,有时不会 - 这似乎是一个 Windows 错误.但是如果我们可以强制制作好的模态窗口,那就是一个编程错误.

I think the answer is this is a half application problem and half a Windows problem. If Windows sometimes handles this, and sometimes doesn't - that seems to be a Windows bug. But if we can force good modal window making then it is a programming bug.

有人可以向我解释一下 WS_POPUP 标志的含义是什么吗?有没有副作用?

Can somebody explain to me what is the meaning of the WS_POPUP flag? Does it have some side effect or not?

谢谢:dd

推荐答案

这就是 PopupModePopupParent 属性 用于.

That's what the PopupMode and PopupParent properties are for.

例如,你可以这样做:

Dialog1.PopupMode := pmExplicit;
Dialog1.PopupParent := self;
Dialog1.ShowModal;

这告诉 Windows 正确的 Z 顺序.

This tells Windows the correct Z-order.

这篇关于Delphi - 如何防止表单/消息框在先前的表单下移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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