模态窗口鼠标捕获界限? [英] Modal Window Mouse Capture Outside of Bounds?

查看:69
本文介绍了模态窗口鼠标捕获界限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果Form1以模态方式打开Form2,那么当

Form2打开时,如何捕获Form1上的点击?我想点击Form1并将鼠标坐标

读入Form2。由于Form2是以模态打开的,因此Form1鼠标事件不会发生火灾。 Form2上的哪些事件会触发?

我可以无模式打开Form2,然后在Form1鼠标内处理

事件。还有其他办法吗?


If Form1 opens Form2 modally, how do I capture clicks on Form1 when
Form2 is open? I want to click on Form1 and read the mouse co-ordinates
into Form2. Since Form2 is open modally, Form1 mouse-events do not
fire. What events on Form2 fire?
I could open Form2 modelessly, then process from within Form1 mouse
events. Is there any other way?

推荐答案

On Sun,2007年5月6日20:42:05 -0700,bern11< be **** @ yahoo.comwrote:
On Sun, 06 May 2007 20:42:05 -0700, bern11 <be****@yahoo.comwrote:

如果Form1以模态方式打开Form2,那么当

Form2打开时如何捕获Form1上的点击?
If Form1 opens Form2 modally, how do I capture clicks on Form1 when
Form2 is open?



你不能。这是模态的定义...用户对其他窗口的输入

被禁用。

You can''t. That''s the definition of modal...user input to other windows
is disabled.


[...]

我可以无模式打开Form2,然后在Form1鼠标内处理

事件。还有其他方法吗?
[...]
I could open Form2 modelessly, then process from within Form1 mouse
events. Is there any other way?



编号如果你希望Form1在Form2打开时获得用户输入,那么Form2不能

是模态的。


Pete

No. If you want Form1 to get user input while Form2 is open, Form2 cannot
be modal.

Pete


" Peter Duniho" < Np ********* @nnowslpianmk.com在留言中写道

news:op *************** @ petes-computer.local ...
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...

On Sun,2007年5月6日20:42:05 -0700,bern11< be **** @ yahoo.comwrote:
On Sun, 06 May 2007 20:42:05 -0700, bern11 <be****@yahoo.comwrote:

>如果Form1以模态方式打开Form2,那么当Form2打开时如何捕获Form1上的点击?
>If Form1 opens Form2 modally, how do I capture clicks on Form1 when
Form2 is open?



你不能。这是模态的定义...用户对其他窗口的输入

被禁用。


You can''t. That''s the definition of modal...user input to other windows
is disabled.


> [...]
我可以无模式打开Form2,然后从Form1鼠标
事件中处理。还有其他方法吗?
>[...]
I could open Form2 modelessly, then process from within Form1 mouse
events. Is there any other way?



编号如果你希望Form1在Form2打开时获得用户输入,那么Form2不能

是模态的。


No. If you want Form1 to get user input while Form2 is open, Form2 cannot
be modal.



这取决于你在做什么。模态形式可能是一个下拉菜单,当你在外面点击时,你想要消失的
。为此,我只是重写

WndProc并捕获非客户端鼠标点击。我认为他们从WM_NC开始。

It depends on what you''re doing. The modal form might be a dropdown that you
want to have disappear when the use clicks outside. For this I just override
WndProc and trap the non client mouse clicks. I think they start with WM_NC.


>

Pete
>
Pete



在Sun,2007年5月6日21:36:13 -0700,Michael C< no **** @ nospam.comwrote:
On Sun, 06 May 2007 21:36:13 -0700, Michael C <no****@nospam.comwrote:

>没有。如果您希望Form1在Form2打开时获得用户输入,则Form2
不能是模态的。
>No. If you want Form1 to get user input while Form2 is open, Form2
cannot be modal.



这取决于你在做什么。模态形式可能是一个下拉菜单,当你在外面点击时你想要消失的
。为此,我只是

覆盖WndProc并捕获非客户端鼠标点击。我认为他们用WM_NC开始



It depends on what you''re doing. The modal form might be a dropdown that
you want to have disappear when the use clicks outside. For this I just
override WndProc and trap the non client mouse clicks. I think they start
with WM_NC.



嗯,这是编程。总有办法做你想做的任何事情。

但它经常不值得麻烦,尤其如此

当一个人基本上想要违反标准时UI行为。


但除此之外,.NET并没有提供这样做的方法。你有很多东西可以用来伪造它。


我也会指出你的例子比你的例子简单得多OP

想要,因为在你的情况下,它仍然是你的模态形式点击鼠标即可获得

鼠标。为了解决OP的目标,你必须得到那些点击,

将它们翻译成底层表格,并将它们发布到那个表格'

消息队列。


Pete

Well, it''s programming. There is always a way to do anything you want.
But it is frequently not worth the trouble, and this is especially true
when one is essentially wanting to violate the standard UI behavior.

But beyond any of that, .NET doesn''t provide a way to do this. You have
to go into the guts of things to fake it.

I''ll also point out that your example is a lot simpler than what the OP
wants, since in your case it''s still your "modal form" that is getting the
mouse clicks. To address the OP''s goal, you''d have to get those clicks,
translate them for the underlying form, and post them to that form''s
message queue.

Pete


这篇关于模态窗口鼠标捕获界限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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