如何强制AfxMessageBox中心在大型机上,而不是当前有焦点的任何子窗口 [英] How to force AfxMessageBox to center on mainframe and not whatever child window that currently has focus

查看:147
本文介绍了如何强制AfxMessageBox中心在大型机上,而不是当前有焦点的任何子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个MDI应用程序,主文档在MDI框架中最大化。我创建一个非模态对话框弹出窗口,以便在用户在主窗口中工作时向其显示辅助信息。然而,当用户移动弹出窗口时,它需要预期的焦点。当此窗口具有焦点并且在大型机中发生生成AfxMessageBox的事件时,会出现问题。我会期望AfxMessageBox弹出在大型机的中心。目前,它弹出以非模态对话框弹出窗口为中心,这是偶然的时候有焦点。

I'm developing an MDI application, the primary document is maximized in the MDI frame. I create a non-modal dialog pop-up to display secondary information to the user while they work in the main window. However, when the user moves the pop-up it takes focus which is expected. The problem occurs when this window has focus and an event which generates an AfxMessageBox occurs in the mainframe. I would expect the AfxMessageBox to pop-up centered on the mainframe. Currently, it pops up centered on the non-modal dialog pop-up window which, by chance, had focus at that time.

有一种方法强制AfxMessageBox总是弹出中心在大型机?或者至少强迫它弹出在它被调用的窗口的中心。例如,如果在我的非模态对话框中发生错误,我会希望AfxMessageBox出现在该对话框的中心,因为它是直观的,错误发生在那里。或者,如果我使用非模态对话框,并在大型机或文档中发生错误,那么我想AfxMessageBox出现在它的视图/框架的中心,尽管事实上,我目前使用子窗口。

Is there a way to force AfxMessageBox to always pop-up centered on the mainframe? Or at least force it to pop-up centered on the window in which it was called. For example, if in my non-modal dialog an error occurs, i would want the AfxMessageBox to appear centered on that dialog because it's intuitive that the error occurred there. Alternatively, if I'm working with the non-modal dialog and an error occurs in the mainframe or document then I would like the AfxMessageBox to appear centered on it's view/frame despite the fact that I'm currently working with the child window.

我希望很清楚。

推荐答案

c $ c> AfxMessageBox 但重写 DoMessageBox 的CWinApp子类。在你的覆盖中做任何你想使用 :: MessageBox()显示一个消息框,甚至显示一个自定义对话框。这可以节省您在源代码文件中替换 AfxMessageBox 的调用。

Keep using AfxMessageBox but override DoMessageBox of your CWinApp subclass. In your override do whatever you want to display a message box to the user using ::MessageBox() or even displaying a custom dialog box. This saves you from replacing calls to AfxMessageBox across your source code files.

这篇关于如何强制AfxMessageBox中心在大型机上,而不是当前有焦点的任何子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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