在父窗体中居中 MessageBox [英] center MessageBox in parent form
问题描述
在 .net 2.0 中是否有一种简单的方法可以将 MessageBox 以父窗体居中
Is there a easy way to center MessageBox in parent form in .net 2.0
推荐答案
来自对 乔尔·斯波尔斯基的博客:
消息框始终位于屏幕中央.您可以提供所有者,但这仅适用于 Z 顺序,而不是居中.唯一的方法是使用 Win32 钩子并自己居中.如果你搜索它,你可以在网上找到这样做的代码.
A Messagebox is always centered on the screen. You can provide an owner, but that is just for Z-order, not centering. The only way is to use Win32 hooks and center it yourself. You can find code doing that online if you search for it.
编写您自己的消息框类并添加居中功能要容易得多.然后您还可以添加默认字幕,不再显示 - 复选框并使它们无模式.
Much easier is to just write your own message box class and add centering functionality. Then you can also add default captioning, Do not show again-checkbox and making them modeless.
Win32 钩子"可能是指使用 SetWindowsHookEx
如这个例子所示.
"Win32 hooks" probably refers to using SetWindowsHookEx
as shown in this example.
这篇关于在父窗体中居中 MessageBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!