2012-11-10 29 views
0

晚上好。 我明白这个问题可能有点奇怪,所以让我解释一下我的问题:我是从应用程序构建一个Windows,它能够打开多个Child Form,每个包含一个加载Flash动画的WebBrowser组件。PostMessage呼叫窃取重点从兄弟

现在,我需要模拟一个给定的打开窗体上的点击,没有它显示在每一个之上。为了模拟点击,我使用的是神似https://stackoverflow.com/a/11161632/533599代码:我不得不实施2改变

  1. 我必须停下来了“互联网Explorer_Server”,因为我不 有“MacromediaFlashPlayerActiveX”在手柄链中
  2. 对于 点击火,我必须“让它加倍”,也就是鼠标向下,向上,向下。

代码工作得很好,点击被触发,但每次它都会触发,目标表单获得焦点并弹出到他所有的兄弟姐妹之上(但留在我打开的其他窗口之后)。有没有办法来防止这种行为?

+0

嗯,这是非常正常的。就像使用鼠标点击时发生的情况一样,该点击将窗口置于前台。在Flash周围解决这个问题将会非常困难,这是一个完全不同的过程,可以获得点击。最好不要这样做。 –

+0

如果我有这个问题,我应该怎么做? – kaharas

+0

我想通过重写WndProc()来拦截WM_MOUSEACTIVATE消息可能会起作用。不知道,真的。 –

回答

0

目前,我成功地做同样的事情,以我与

[DllImportAttribute("user32.dll", EntryPoint = "SetForegroundWindow")] 
[return: MarshalAsAttribute(UnmanagedType.Bool)] 
public static extern bool SetForegroundWindow([InAttribute()] IntPtr hWnd); 

[DllImportAttribute("user32.dll", EntryPoint = "GetForegroundWindow")] 
public static extern IntPtr GetForegroundWindow(); 

[DllImportAttribute("user32.dll", EntryPoint = "BringWindowToTop")] 
[return: MarshalAsAttribute(UnmanagedType.Bool)] 
public static extern bool BringWindowToTop([InAttribute()] IntPtr hWnd); 

IntPtr old = GetForegroundWindow(); 
LeftClick(hw, x, y); 
SetForegroundWindow(old); 
BringWindowToTop(old); 

缺点是需要,在“点击”的形式还是弹出了第二的graction,给人一种不好的风格效果。任何其他暗示,有助于保持在后台形式是wellcome :)