WPF获取窗口句柄
通过WPF的互操作帮助类WindowInteropHelper,相关连接:https://msdn.microsoft.com/zh-cn/library/system.windows.interop.windowinterophelper.aspx
public MainWindow()
{
InitializeComponent();
this.SourceInitialized += MainWindow_SourceInitialized;
}
private void MainWindow_SourceInitialized(object sender, System.EventArgs e)
{
var handle = (new WindowInteropHelper(this)).Handle;
}
可以使用HwndSource.AddHook(HwndSourceHook)加一个事件处理程序接收所有窗口消息,相关连接:https://msdn.microsoft.com/zh-cn/library/system.windows.interop.hwndsource.aspx
private void MainWindow_SourceInitialized(object sender, System.EventArgs e)
{
var handle = (new WindowInteropHelper(this)).Handle;
HwndSource.FromHwnd(handle).AddHook(new HwndSourceHook(WndProc));
}
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
throw new NotImplementedException();
}
WPF获取窗口句柄的更多相关文章
- WPF获取窗口句柄的方法
通过WPF的互操作帮助类WindowInteropHelper,相关连接:https://msdn.microsoft.com/zh-cn/library/system.windows.interop ...
- [WinAPI] 获取窗口句柄的几种方法
1.使用FindWindow函数获取窗口句柄 示例:使用FindWindow函数获取窗口句柄,然后获得窗口大小,并且移动窗口到指定位置. 我们想获得酷我音乐盒的窗口句柄并移动它,该怎么办呢? 首先打开 ...
- WPF 获取程序路径的一些方法,根据程序路径获取程序集信息
一.WPF 获取程序路径的一些方法方式一 应用程序域 //获取基目录即当前工作目录 string str_1 = System.AppDomain.CurrentDomain.BaseDirector ...
- windows获取窗口句柄
1.使用FindWindow函数获取窗口句柄 示例:使用FindWindow函数获取窗口句柄,然后获得窗口大小和标题,并且移动窗口到指定位置. #include <Windows.h> # ...
- WPFの获取任意元素的位置
如果布局在Grid中: 方法一: //_stackPanel为子元素,_grid为父元素 Point point = _stackPanel.TranslatePoint(new Point(0, 0 ...
- c# WPF 获取网络图片,验证码
c# WPF 获取网络图片,验证码 public static BitmapImage getValidCodeBitmap() { string url = "http://my.baaa ...
- WPF 获取应用的所有窗口
原文:WPF 获取应用的所有窗口 本文告诉大家如何获取应用内的所有窗口,无论这些窗口有没显示 在 WPF 可以通过 Application.Current.Windows 列举应用的所有窗口 fore ...
- WPF 获取 ListView DataTemplate 中控件值
原文:WPF 获取 ListView DataTemplate 中控件值 版权声明:本文为博主原创文章,未经博主允许可以随意转载 https://blog.csdn.net/songqingwei19 ...
- WPF 获取鼠标屏幕位置、窗口位置、控件位置
原文:WPF 获取鼠标屏幕位置.窗口位置.控件位置 public struct POINT { public int X; public int Y; public POINT(int x, int ...
随机推荐
- QTP基本方法
1.for循环: m代表间隔循环长度: 如果m>0,则j要大于i: 如果m<0,则i要大于j: for i to j [step m] 语句块 [exit for]//强制退出循环 nex ...
- maven 编译替换占位符
首先开启资源配置的插件,由此插件替换占位符 <plugin> <groupId>org.apache.maven.plugins</groupId> <art ...
- PyTorch Softmax
PyTorch provides 2 kinds of Softmax class. The one is applying softmax along a certain dimension. Th ...
- Android的JNI调用(一)
Android提供NDK开发包来提供Android平台的C++开发,用来扩展Android SDK的功能.主要包括Android NDK构建系统和JNI实现与原生代码通信两部分. 一.Android ...
- Go语言之旅:包
每个 Go 程序都是由一些包组成的. 原文地址:https://golang-book.readthedocs.io 欢迎关注我们的公众号:小菜学编程 (coding-fan) 程序从 main 包开 ...
- 【.net开发者自学java系列】使用Eclipse开发SpringMVC(2)
大概熟悉了 Eclipse. 然后先上Spring MVC 官网看看. 可是英文太差?翻译咯.现在翻译可屌了,真高兴生活在现在科技发达的时代.活着在中国太美好了. 没出过国门就能看懂英文.我都崇拜自己 ...
- 使用DBNEWID Utility 修改oracle数据库的 db name 和 dbid
使用DBNEWID Utility 工具可以同时修改数据库名.DBID,也可以只修改其中一项 官方参考: https://docs.oracle.com/cd/E11882_01/server.112 ...
- 我告诉你 ,一个 window免费系统下载的网站!
一个 window免费系统下载的网站! https://msdn.itellyou.cn/
- MessageBox.Show用法
private void button3_Click(object sender, EventArgs e) { MessageBox.Show(" 1 个参数 "); } ~ ...
- Oracle数据库对表基本的操作--增删查改
--向student表中加入入学时间属性,其数据类型为日期型alter table student add scome date; --删除student表中的入学时间属性alter table st ...