在Window上找到MessageBox [英] Locate MessageBox over Window

查看:92
本文介绍了在Window上找到MessageBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



消息框对象的一个​​选项表明它可以放在

选定窗口上,而不是只显示在桌面上居中。

函数是Overloads Public Shared Function Show(IWin32Window,String)As

DialogResult


我尝试失败:

///

Dim winhandle as string

Dim rtn as DialogResult

winHandle = Me.Handle。 ToString()

rtn = MessageBox.Show(winhandle,我的消息)

\\\


不幸的是,winhandle成为我的消息的内容,作为

标题和桌面中心的方框,而不是形式1。

感谢一些帮助。 />

Ed


One option of the messagebox object indicates it can be placed over a
selected window rather than just appearing centered on the desktop. The
function is "Overloads Public Shared Function Show(IWin32Window, String) As
DialogResult"

I have unsuccessfully tried:
///
Dim winhandle as string
Dim rtn as DialogResult
winHandle = Me.Handle.ToString()
rtn = MessageBox.Show(winhandle, "My message")
\\\

Unfortunately the winhandle becomes the content with the My message as the
title and the box in the center of the desktop, not over form1.
Appreciate some help.

Ed

推荐答案

" Ed Bitzer" < ED ****** @ yahoo.com> schrieb:
"Ed Bitzer" <ed******@yahoo.com> schrieb:
消息框对象的一个​​选项表明它可以放在一个选定的窗口上,而不是只显示在桌面的中心。
One option of the messagebox object indicates it can be placed over a
selected window rather than just appearing centered on the desktop.




您可以使用钩子定位消息框窗口。可以在这里找到一个可以转换为VB.NET的VB6样本:


< URL:http://dotnet.mvps.org/ vb / samples / misc / DialogPosition.zip>


-

MS Herfried K. Wagner

MVP< URL: http://dotnet.mvps.org/>

VB< URL:http://classicvb.org/petition/>



You can position a messagebox window by using a hook. A VB6 sample which
can be converted to VB.NET can be found here:

<URL:http://dotnet.mvps.org/vb/samples/misc/DialogPosition.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>




" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

新闻:eB ************** @ TK2MSFTNGP15.phx.gbl ...

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eB**************@TK2MSFTNGP15.phx.gbl...
你可以使用钩子定位消息框窗口。可以在此处找到可以转换为VB.NET的VB6示例:

< URL:http://dotnet.mvps.org/vb/samples/misc/DialogPosition。 zip>
You can position a messagebox window by using a hook. A VB6 sample which
can be converted to VB.NET can be found here:

<URL:http://dotnet.mvps.org/vb/samples/misc/DialogPosition.zip>




Herfried,

我感谢你,但转换代码是我的头脑。 vb.net

消息框对象似乎具有该功能并且只是执行但是我不知道窗口识别语法。


Ed



Herfried,
I do thank you but converting that code is over my head. The vb.net
messagebox object appears to have the capability and simply executed but I
do not understand the window identification syntax.

Ed


MessageBox.Show()方法的''owner''参数类型为

IWin32Window。它不代表窗口句柄,而是代表一个

窗口。所以在你的情况下它应该是:rtn = MessageBox.Show(我,我的

消息)。


当你了解更大的一点阅读文档是你

可以使用owner参数来指定一个特定的对象,它实现了IWin32Window接口的
,将消息框放在前面。 " ;.注意

使用前面的短语''。这意味着对话框的位置在

的z顺序,而不是屏幕上对话框的位置。


我从来没有理解过这个参数很有用。因为对话框对应用程序是模态的,所以我无法看到在可能位于当前窗口后面的窗口前面显示对话框的任何一点。人们不得不

移动当前窗口才能看到它,但对话框是模态的,所以你不能。

Ed Bitzer < ED ****** @ yahoo.com>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...
The ''owner'' parameter to the MessageBox.Show() method is of type
IWin32Window. It does not represent a window handle, rather it represents a
window. so in your case it should be: rtn = MessageBox.Show(Me, "My
message").

The bigger point to understand when you read the documentation is that "You
can use the owner parameter to specify a particular object, which implements
the IWin32Window interface, to place the message box in front of.". Note the
use of the phrase ''in front of''. This means the position of the dialog in
the z-order, not the location of the dialog on the screen.

I have never understood how this parameter is useful. Because the dialog is
modal to the application, I can''t see any point in displaying the dialog in
front of a window that might be behind the current window. One would have to
move the current window to see it but the dialog is modal so you can''t.
"Ed Bitzer" <ed******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
功能是Overloads Public Shared Function Show(IWin32Window,String)
As DialogResult

我没有成功尝试过:
///
Dim winrtle as string
Dim rtn as DialogResult
winHandle = Me.Handle.ToString()
rtn = MessageBox.Show(winhandle,我的消息)
\\\ \\\

不幸的是,winhandle成为了我的消息的内容,作为
标题和桌面中心的框,而不是形式1。
感谢一些帮助。

Ed

One option of the messagebox object indicates it can be placed over a
selected window rather than just appearing centered on the desktop. The
function is "Overloads Public Shared Function Show(IWin32Window, String)
As DialogResult"

I have unsuccessfully tried:
///
Dim winhandle as string
Dim rtn as DialogResult
winHandle = Me.Handle.ToString()
rtn = MessageBox.Show(winhandle, "My message")
\\\

Unfortunately the winhandle becomes the content with the My message as the
title and the box in the center of the desktop, not over form1.
Appreciate some help.

Ed



这篇关于在Window上找到MessageBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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