码迷,mamicode.com
首页 > Windows程序 > 详细

Get the Handle Of the Main Window in WPF

时间:2016-06-04 14:49:12      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

  WinForm中获取窗体句柄用this.Handle就行了。

   但WPF中有点麻烦,需要先引用命名空间:

1 using System.Windows.Interop;

  然后调用方法:

1 IntPtr Handle = new WindowInteropHelper(this).Handle;

  其中this指的是要获取的Window的实例,方法返回后,Handle正是Window的句柄。

Get the Handle Of the Main Window in WPF

标签:

原文地址:http://www.cnblogs.com/Bita/p/5558706.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!