c# 重载WndProc,实现重写“最小化”的实现方法
时间:2022-10-22 10:16:13
code #1
private void Form1_SizeChanged(object sender, EventArgs e) //最小化隐藏窗体
{
if (this.WindowState == FormWindowState.Minimized)//窗体状态为最小化
{
StopRectTimer.Enabled = false;
this.Visible = false;
this.notifyIcon1.Visible = true; //显示系统托盘图标
this.notifyIcon1.Text = this.Text; //设置图标显示的文本
this.ShowInTaskbar = false; //窗体在任务标中隐藏
reghotkey();
打开OToolStripMenuItem.Text = "打开(&O)";
}
}
很显然,如果打开歌词状态话的话,怎样才能最小化而不改变窗体的大小呢?我想到了重载“最小化”,但是怎么重载呢?这里给出一种重载WndProc的方案:
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SYSCOMMAND)
{
if (m.WParam.ToInt32() == SC_MINIMIZE)
{
this.Visible = false;
return;
}
}
base.WndProc(ref m);
}
标签:c#,WndProc,最小化
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
maven打包如何指定jdk的版本
2022-12-21 20:59:20
![](https://img.aspxhome.com/file/2023/3/67683_0s.png)
SpringMVC Restful api接口实现的代码
2023-11-29 12:34:27
![](https://img.aspxhome.com/file/2023/8/60528_0s.jpg)
Spring Security内置过滤器的维护方法
2022-07-30 18:10:16
![](https://img.aspxhome.com/file/2023/5/61285_0s.jpg)
Android使用vitamio插件实现视频播放器
2022-09-23 02:40:55
![](https://img.aspxhome.com/file/2023/1/137421_0s.gif)
解决Android平台中应用程序OOM异常的方法
2023-07-29 09:45:17
Java 通过API操作GraphQL
2021-12-24 03:21:49
Java设计模式之命令模式(Command模式)介绍
2021-12-02 01:01:02
Java详细分析梳理垃圾回收机制
2023-10-30 04:02:33
![](https://img.aspxhome.com/file/2023/5/62765_0s.png)
基于Spring整合mybatis的mapper生成过程
2022-01-11 03:49:26
![](https://img.aspxhome.com/file/2023/9/61129_0s.png)
java实现简单学生成绩管理系统
2023-08-15 18:38:57
![](https://img.aspxhome.com/file/2023/8/98708_0s.jpg)
C#实现影院售票系统
2021-12-27 00:53:26
![](https://img.aspxhome.com/file/2023/3/108733_0s.png)
使用Jacoco获取 Java 程序的代码执行覆盖率的步骤详解
2022-07-22 00:25:13
![](https://img.aspxhome.com/file/2023/5/64805_0s.png)
java使用Dijkstra算法实现单源最短路径
2022-02-16 23:13:26
![](https://img.aspxhome.com/file/2023/4/96134_0s.jpg)
java.lang.StackOverflowError出现的原因及解决
2022-03-21 08:12:21
![](https://img.aspxhome.com/file/2023/8/77148_0s.jpg)
SpringBoot一个非常蛋疼的无法启动的问题解决
2023-12-12 15:24:36
Java(TM) Platform SE binary 打开jar文件的操作
2021-10-02 00:08:12
![](https://img.aspxhome.com/file/2023/4/62534_0s.jpg)
C# 语音功能的实现方法
2023-03-15 13:40:51
Android开发之针对联系人的封装
2023-12-24 05:56:25
![](https://img.aspxhome.com/file/2023/6/137506_0s.png)
使用SpringBoot实现微服务超时重试模式的示例
2021-12-28 13:58:45
![](https://img.aspxhome.com/file/2023/6/86826_0s.png)
java 引用类型的数据传递的是内存地址实例
2023-11-29 15:13:53
![](https://img.aspxhome.com/file/2023/7/60557_0s.png)