WPF 精修篇 调用Win32Api

栗子是 调用WIn32API 让窗口最前
后台代码
-
[DllImport("user32.dll")]
-
private static extern bool SetForegroundWindow(IntPtr hWnd);
-
-
//
-
Process process = null;
-
private void OPenButton_Click(object sender, RoutedEventArgs e)
-
{
-
process = new Process();
-
process.StartInfo.FileName = "iexplore.exe";
-
process.StartInfo.Arguments = Text_Path.Text;
-
process.Start();
-
}
-
-
private void TOPButton_Click(object sender, RoutedEventArgs e)
-
{
-
if (process != null)
-
{
-
var ptr = process.MainWindowHandle;
-
SetForegroundWindow(ptr);
-
}
-
}
-
-
private void FlushButton_Click(object sender, RoutedEventArgs e)
-
{
-
if (process != null)
-
{
-
var ptr = process.MainWindowHandle;
-
SetForegroundWindow(ptr);
-
SendKeys.SendWait("{F5}");
-
}
-
}
前台
-
<Grid>
-
<TextBox x:Name="Text_Path" HorizontalAlignment="Left" Height="25" Margin="0,34,0,0" TextWrapping="Wrap" Text="https://www.baidu.com" VerticalAlignment="Top" Width="251" />
-
<Button x:Name="OPenButton" Content="打开" HorizontalAlignment="Left" Margin="10,86,0,0" VerticalAlignment="Top" Width="75" Click="OPenButton_Click"/>
-
<Button x:Name="TOPButton" Content="前台" HorizontalAlignment="Left" Margin="10,123,0,0" VerticalAlignment="Top" Width="75" Click="TOPButton_Click"/>
-
<Button x:Name="FlushButton" Content="刷新" HorizontalAlignment="Left" Margin="10,160,0,0" VerticalAlignment="Top" Width="75" Click="FlushButton_Click"/>
-
-
</Grid>
SendKeys.SendWait("{F5}"); 需要引用System.Windows.Forms.dll
WPF 精修篇 调用Win32Api的更多相关文章
- WPF 精修篇 数据触发器
原文:WPF 精修篇 数据触发器 数据触发器 可以使用Binding 来绑定控件 或者数据源 来触发相关动作 举栗子 <Window.Resources> <Style Target ...
- WPF 精修篇 属性触发器
原文:WPF 精修篇 属性触发器 属性触发器是通过 某个条件触发改变属性 通过无代码实现功能 <Style TargetType="{x:Type Label}"> ...
- WPF 精修篇 样式继承
原文:WPF 精修篇 样式继承 这个 是新知识 样式可以继承 <Style x:Key="TextBlockStyleBase" TargetType="{x:Ty ...
- WPF 精修篇 自定义控件
原文:WPF 精修篇 自定义控件 自定义控件 因为没有办法对界面可视化编辑 所以用来很少 现在实现的是 自定义控件的 自定义属性 和自定义方法 用VS 创建自定义控件后 会自动创建 Themes 文件 ...
- WPF 精修篇 用户控件
原文:WPF 精修篇 用户控件 增加用户控件 数据绑定还是用依赖属性 使用的事件 就委托注册一下 public delegate void ButtonClick(object b,EventArgs ...
- WPF 精修篇 DataGrid 筛选
原文:WPF 精修篇 DataGrid 筛选 DataGrid也可以分组 但是用的地方不多 就没写 筛选还是可以的 比如Datagrid数据量比较大 要做数据筛选 贴码 <DataGrid x: ...
- WPF 精修篇 DataGrid 数据源排序
原文:WPF 精修篇 DataGrid 数据源排序 效果 <DataGrid x:Name="datagrid" ItemsSource="{Binding Ele ...
- WPF 精修篇 数据绑定到对象
原文:WPF 精修篇 数据绑定到对象 数据绑定到对象 首先 我们需要一个对象 public class Preson { private string name; public string Name ...
- WPF 精修篇 数据绑定 更新通知
原文:WPF 精修篇 数据绑定 更新通知 开始更新一点有意思的了 首先 数据绑定 其中之一 Element 绑定 看例子 <Window x:Class="WpfApplicatio ...
随机推荐
- Lodash 严重安全漏洞背后 你不得不知道的 JavaScript 知识
摘要: 详解原型污染. 原文:Lodash 严重安全漏洞背后 你不得不知道的 JavaScript 知识 作者:Lucas HC Fundebug经授权转载,版权归原作者所有. 可能有信息敏感的同学已 ...
- 获取mac地址和扫描端口
获取IP mac地址 arp -a 10.0.0.34 扫描指定IP 1到30000端口 nmap -p1-30000 10.0.0.36
- 【分布式搜索引擎】Elasticsearch之安装Elasticsearch可视化平台Kibana
一.Kibana简单介绍 Kibana 是为 Elasticsearch设计的开源分析和可视化平台.你可以使用 Kibana 来搜索,查看存储在 Elasticsearch 索引中的数据并与之交互.你 ...
- openstack 创建实例报错 **aborted: Failed to allocate the network(s), not rescheduling
消息 Build of instance 6320b5f2-edc2-4e8e-b07c-0047f7ed8f6a aborted: Failed to allocate the network(s) ...
- vue-router路由传参之query和params
首先简单来说明一下$router和$route的区别 //$router : 是路由操作对象,只写对象 //$route : 路由信息对象,只读对象 //操作 路由跳转 this.$router.pu ...
- 在浏览器输入URL回车之后发生了什么?(超详细版)
前言 这个问题已经是老生常谈了,更是经常被作为面试的压轴题出现,网上也有很多文章,但最近闲的无聊,然后就自己做了一篇笔记,感觉比之前理解更透彻了. 这篇笔记是我这两天看了数十篇文章总结出来的,所以相对 ...
- 201871010126 王亚涛 《面向对象程序设计(Java)》第八周实验总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...
- 搭建Dubbo Admin(五)
Dubbo Admin下载地址(2019年9月8日):https://github.com/apache/dubbo-admin 注意:JDK要求1.8以上 1. 进入到模块 dubbo-admin- ...
- Java编译期与运行期
编译期:是指把源码交给编译器编译成计算机可以执行的文件的过程.在Java中也就是把Java代码编成class文件的过程.编译期只是做了一些翻译功能,并没有把代码放在内存中运行起来,而只是把代码当成文本 ...
- hdu1247-Hat’s Words-(字典树)
http://acm.hdu.edu.cn/showproblem.php?pid=1247 题意:给出一堆单词,求哪些单词是其中某两个单词拼接起来的. 题解:用字典树存储所有的单词,标记结束点,再次 ...