protected override void WndProc(ref Message m)
{
FormWindowState previousWindowState = this.WindowState;
base.WndProc(ref m);
FormWindowState currentWindowState = this.WindowState;
if (previousWindowState != currentWindowState && currentWindowState == FormWindowState.Maximized)
{
// TODO: Do something the window has been maximized
}
else if (previousWindowState != currentWindowState && currentWindowState == FormWindowState.Normal)
{
// TODO: Do something the window has been normal
}
else if(....)//minimized
{
}
}
网上有很多的代码都是有问题的,win32接口是老一代接口,针对于c#等代码程序,虽然有时很方便,但是不会给你自检,除非你的win32玩的很溜,尽量不要使用非同种语言的编程融合,因为无法自检,只会给你报个错,检验起来超级麻烦的
本文探讨了在C#中如何监测窗体的状态变化,包括最大化、最小化和恢复正常大小。通过覆写WndProc方法并检查窗体状态,实现特定状态下的响应。
16万+

被折叠的 条评论
为什么被折叠?



