C#winform窗体如何通过windowApi的FindWindow函数获取窗体句柄
在同一个程序里,传统方式是通过this来设置当前窗体的最大化、最小化等操作,
那么怎样通过窗体句柄来设置窗体的最大化、最小化呢?
1、界面布局
通过this设置窗体最大化: name:btnWindowThis
通过handle设置窗体最大化:name:btnWindowHandle
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY0AAADxCAIAAAC4UnyIAAAgAElEQVR4nO2daXTUVqLn9Wm6p2f6TM88n37v5fSHd5gO3QnkA0smev063R2KbIRAg2kvuAMJCZWw42BWs3VIIAnYGGwnYDAOSdgMIYEE48Is5YV9LWzAJhgwtjGpBDBV2MYUNPNBKi1X0tVVuVwll/+/8z8clXR1daXS/fnqWgDX2to6YMCAhoaG1d95GBPgeUQK+3VDEMRqSm+1/GZECte/f3+Xy7V6l4c9UVeDrWLp0iEIYjXbf7jL9e/fv76+Pq/oLHuirgZbxdKlQxDEagp/aOH69+/f1ta2Zncle6QuammvGAsuAoJEJhub7nL9+/d/9OhRfnEVe6QuammvGAsuAoJEJuuvBz21zlXFHqmLWtorxoKLgCCRydrGoKcK9pxnj9RFLe0VY8FFQJDI5NOGFngqxOAiIEhkAk+FHlyEmMmKwoqJC1e/NuXDCGfiwtUrCivs04bPNu597dlXHXE9IpzXnn31s417KV8QPBV6cBFiJmNnZLnKz1y54YtwXOVnxs7Isk8bhvZ8ek/emruVJyKcPXlrhvZ8mvIFyZ5aX3KBPVIXtbRXjAUXIWYyeupHV274yquaIpwrN3yjp35knzY44nr4Pcd+2LI2wvF7jjnielC+oJXX7jJ5yq1G6qJuKlG//zo18FTM5PXUjy83+UormyKcy02+11M/tk8bHHE9fKeONG1c3bRx9Y1NwWwUI628vmGVkKYNq5o2rLqxabW4i1RS3CSWvLFp9Y2NeTc25skVqmv2nToSNk8pP0pd9NyXjwnxrP93z/p/P772Xw+t+vX+lXHwFNKF8oboiOsRzuUm3xtBR7C0YeHHa+ITnOxZ+PEaS21wxPVoPl5x/fNcMl/kXv9CXF6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LKUb/nKaPjKal/Gv0ijFhv0VPm09Um70+pK9G+8EmsZJ6f0r7kybenp1sYTzGcGuP7U9qxMNAFnrI1YocpVvZnzRs3VeRWVk8FdyS7irieNi/WbGW2Xu7DVt5HV9WpNxLRfSxl/Hszih8AKa1VFp/7GE6N5X30mPoXezoZeAoAYHfgKQCA3YGnAAB2B54CANgdeAoAYHdMPOXyeBEEQWyY359ugKcQBLF14CkEQeweeApBELsHnkIQxO6BpxAEsXvgKQRB7B7RU78/3YAgYQmnJurtQWIjHABh5JGaaDcHxAqtAIQJTs9T0W4U6PKInho3bhz+xJ8d/1PXU1FvFf7s6n9yHPf/AVrnbnXTiBMUAAAAAElFTkSuQmCC" alt="" width="363" height="199" />
2、设置窗体最大化
1)this方式
直接设置当前窗体的状态为最大化就可以了,
/// <summary>
/// 通过this设置方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnWindowThis_Click(object sender, EventArgs e)
{
//通过this.WindowState设置窗体最大化
this.WindowState = FormWindowState.Maximized;
}
2)handle方式
首先获取当前窗体的句柄,通过句柄控制窗体最大化
/// <summary>
/// 通过句柄设置方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnWindowHander_Click(object sender, EventArgs e)
{
// 获取查找窗体句柄(通过窗体标题名)
IntPtr mainHandle = FindWindow(null, "演示窗体");
if (mainHandle != IntPtr.Zero)
{
//通过句柄设置当前窗体最大化(0:隐藏窗体,1:默认窗体,2:最小化窗体,3:最大化窗体,....)
bool result = ShowWindowAsync(mainHandle, );
}
}
Ps: 获取窗体句柄,也可以用C++的Spy++工具查看(获取到的句柄是16进制,而FindWindow()是获取10进制)
3、完整源码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace WindowsForms
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} /// <summary>
/// 获取窗体的句柄函数
/// </summary>
/// <param name="lpClassName">窗口类名</param>
/// <param name="lpWindowName">窗口标题名</param>
/// <returns>返回句柄</returns>
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); /// <summary>
/// 通过句柄,窗体显示函数
/// </summary>
/// <param name="hWnd">窗体句柄</param>
/// <param name="cmdShow">显示方式</param>
/// <returns>返工成功与否</returns>
[DllImport("user32.dll", EntryPoint = "ShowWindowAsync", SetLastError = true)]
public static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); /// <summary>
/// 通过句柄设置方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnWindowHander_Click(object sender, EventArgs e)
{
// 获取查找窗体句柄(通过窗体标题名)
IntPtr mainHandle = FindWindow(null, "演示窗体");
if (mainHandle != IntPtr.Zero)
{
//通过句柄设置当前窗体最大化(0:隐藏窗体,1:默认窗体,2:最小化窗体,3:最大化窗体,....)
bool result = ShowWindowAsync(mainHandle, );
}
} /// <summary>
/// 通过this设置方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnWindowThis_Click(object sender, EventArgs e)
{
//通过this.WindowState设置窗体最大化
this.WindowState = FormWindowState.Maximized;
}
}
}
下一篇,介绍一个程序窗体如何通过句柄控制另一个程序窗体
C#winform窗体如何通过windowApi的FindWindow函数获取窗体句柄的更多相关文章
- FireMonkey下的异形窗体拖动(需要使用FmxHandleToHwnd函数转化一下句柄)
DelphiXE2 Firemoney FMX 的窗体不只是为windows的, 所以很多功能都没有了. 最常见的就是拖拽了 先看 VCL时代 一个经典拖动代码 ReleaseCapture(); S ...
- winform里操作打开在panel里的form窗体,子窗体操作同级子窗体或者父窗体的方法
最近开始了一个winform项目,原先一直都是web项目.遇到个问题,就是在框架内,左侧和中间的main都是用panel来实现的form,就是把form窗体打开到panel里,实现左侧是导航,中间是操 ...
- winform 如何正确的获取窗体的标题栏高度
最近我需要知道鼠标在一个控件里的相对位置,鼠标相对于屏幕的位置我是可以知道的,所以只要得到控件相对于屏幕的位置,就可以算出鼠标相对于控件的位置了 但是发现有误差 后来经过测试是由于窗体的标题栏高度导致 ...
- WinForm中如何实现在容器控件中嵌入form窗体(panel与子窗体)
今天在做项目时候遇到一个问题,窗体分为左右两部分,要求在左边栏点击按钮时,右边动态加载窗体最后想到用panel实现,经历几次失败,并查找资料后,终于搞定 说明:如果多次切换需加入 panel.clea ...
- winform中让显示的图片覆盖到父窗体保持父窗体的不可选中的状态,且任务栏中不会显示子窗体的任务选项
要求:为父窗体添加一个类似于加载等待的功能,当窗体点击备份时弹出且覆盖掉窗体 问题一产生:当为弹窗添加控件时,form.show();导致窗体卡死,控件变得透明化; 问题一分析:当窗体show();之 ...
- winform显示系统托盘,双击图片图表显示窗体,退出窗体是否提示
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { DialogResult result = Messag ...
- VC中获取窗体句柄的各种方法
AfxGetMainWnd AfxGetMainWnd获取自身窗体句柄 HWND hWnd = AfxGetMainWnd()->m_hWnd; GetTopWindow 函数功能:该函数检查与 ...
- JCEF3——谷歌浏览器内核Java版实现(一):使用jawt获取窗体句柄
前言 最近一段时间研究谷歌浏览器内核.谷歌浏览器内核一直开源,并维护更新,它的开源项目中内核更新速度和Chrome浏览器版本更新进度一样!而且它不同于WebKit(值得一题的是谷歌浏览器已不使用Web ...
- C# 子窗体点击按钮产生的新子窗体放在父窗体里
情景展示: 父窗体Form1,左边是按钮,右边是panel(放置子窗体) 父窗体点击按钮,在panel显示第一个子窗体AA, AA有个按钮,点击按钮,是第二个子窗体ZZ, 怎样将AA的子窗体ZZ也显示 ...
随机推荐
- 【angular2+typeScript+ng-zorro】Carousel 走马灯的左右方向控件实现
ng-zorro Carousel 走马灯的左右方向控件实现 ng-zorro框架的走马灯本身还没有左右方向控件的实现,作者只是在文档中(0.6x)中曝出几个方法接口,如图: 实现: 在根compon ...
- 【前端】javascript+jQuery实现360开机时间显示效果
实现效果: 实现原理: 给关闭按钮绑定点击事件,点击以后触发动画效果.利用jQuery的animate方法,先让显示天气的盒子高度变为0,接着让整个包含天气和事件的盒子宽度变为0,最后通过将displ ...
- 常用模块之 time,datetime,random,os,sys
time与datetime模块 先认识几个python中关于时间的名词: 时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量.我们运行“ty ...
- hdu 6168 Numbers
Numbers Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- 处理文字基线 文字对不齐 font-size
这是我无意中发现的,先记录下 比如你在一个h1标签里面添加文字,或者在其他块级标签添加文字,想让他们间隙少一点,(基线影响)可把行高设置为line-height: 1;就达到消除基线的作用. 建议使用 ...
- C#学习笔记(十七):委托、事件、观察者模式、匿名委托和lambert表达式
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- python闭包closure
在讨论闭包之前,先总结一下python的命名空间namespace,一般的语言都是通过namespace来识别名字标识,无论是变量,对象,函数等等.python划分3个名字空间层次,local:局部, ...
- python 加密与解密
加密算法分类 对称加密算法: 对称加密采用了对称密码编码技术,它的特点是文件加密和解密使用相同的密钥 发送方和接收方需要持有同一把密钥,发送消息和接收消息均使用该密钥. 相对于非对称加密,对称加密具有 ...
- DB中字段为null,为空,为空字符串,为空格要怎么过滤取出有效值
比如要求取出微信绑定的,没有解绑的 未绑定,指定字段为null 绑定的,指定字段为某个字符串 解绑的,有的客户用的是更新指定字段为1,有的客户更新指定字段为‘1’ 脏数据的存在,比如该字段为空字符 ...
- 字符集(编码)转换_Qt532_QString
1.网上的资料: 1.1.参考网址:http://blog.csdn.net/changsheng230/article/details/6588447 1.2.网页内容: “ Qt 使用Unicod ...