查找WPF窗口的句柄 [英] Finding the handle to a WPF window
本文介绍了查找WPF窗口的句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Windows窗体具有属性win1.Handle,如果我记得,它会返回主窗口句柄的句柄?
Windows forms had a property win1.Handle which, if I recall, returns the handle of the main window handle?
是否有等效的方法来获取WPF窗口的句柄?
Is there an equivalent way to get the handle of a WPF Window?
我在线找到了以下代码,
I found the following code online,
IntPtr windowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
但是我认为这不会帮助我,因为我的应用程序有多个窗口.
but I don't think that will help me because my application has multiple windows.
谢谢!
推荐答案
好吧,不用传递Application.Current.MainWindow
,只需将引用传递给您想要的任何窗口即可:new WindowInteropHelper(this).Handle
,依此类推.
Well, instead of passing Application.Current.MainWindow
, just pass a reference to whichever window it is you want: new WindowInteropHelper(this).Handle
and so on.
这篇关于查找WPF窗口的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文