c#显示隐藏的窗体和托盘中的程序
来源:互联网 发布:未来城网络黄金裴雷 编辑:程序博客网 时间:2024/06/01 09:09
将程序最小化到托盘已经是最常用的操作,但在C#中凭借 Form1.Visible=true; 抑或是Form1.TopMost=true; 只能将窗体显示在任务栏中,而不能将窗体直接显示给用户,这无疑是糟糕的用户体验。为了实现上述目的,我们需要借助于win32函数:
#region win32函数
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpSpecifiedClassName, string lpWindowName);
[DllImport("user32.dll ", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
[DllImport("user32.dll", EntryPoint = "ShowWindow", CharSet = CharSet.Auto)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
public const int SW_RESTORE = 9;
public static IntPtr formhwnd;
#endregion
IntPtr frm = Form1.Handle; //得到窗体句柄
ShowWindow(frm, 9); //显示窗体
SwitchToThisWindow(frm, true); //切换到窗体
- c#显示隐藏的窗体和托盘中的程序
- C# 托盘程序 实例 双击显示窗体,最小化到托盘
- C# 托盘程序 实例 双击显示窗体,最小化到托盘
- C#程序怎么操作某个进程的窗体显示隐藏
- 浅谈c#实现隐藏任务栏图标的Windows托盘程序
- 浅谈c#实现隐藏任务栏图标的Windows托盘程序
- C#窗体类似于QQ托盘显示
- C# winForm程序开机启动和托盘显示
- C# WF程序 开机启动和托盘显示
- C# winForm程序开机启动和托盘显示
- C# winForm程序开机启动和托盘显示
- C# winForm程序开机启动和托盘显示
- C# winForm程序开机启动和托盘显示
- 启动程序时,不显示窗体,只显示托盘图标的方法
- C#托盘程序的编程
- C#的托盘程序过程
- C# 托盘程序的创建
- C# 托盘程序(自己的)
- LDR指令与LDR伪指令
- Hadoop YARN中web服务的REST API介绍
- jersey 2.6小结
- Android自定义Gallery,实现CoverFlow效果
- windows/linux下创建SVN本地repository
- c#显示隐藏的窗体和托盘中的程序
- (二)uboot移植
- 有关于Nodejs http.get的错误处理
- 图像处理与计算机视觉 基础、经典以及最近发展
- SEO者的痛苦
- Cracking the coding interview--Q12.1
- 【Cocos2d-X(2.x) 游戏开发系列之三】最新版本cocos2d-2.0-x-2.0.2使用资源加载策略
- mysql 优化
- git (版本版本控制工具)