[英]How to minimize and maximize winform from taskbar?
I have a Winforms application, which I'm able to minimize by clicking on the corresponding button on the top right of the window; 我有一个Winforms应用程序,可以通过单击窗口右上方的相应按钮来最小化它。 I can then maximize it by clicking on this application's taskbar icon. 然后,我可以通过单击此应用程序的任务栏图标来最大化它。
My problem is that if the window is maximized, it should be minimized when I click on the taskbar icon again, and it's currently not happening. 我的问题是,如果窗口已最大化,则当我再次单击任务栏图标时应将其最小化 ,但目前没有发生。
How can I make this behavior happen? 如何使这种行为发生? I don't want to have to use NotifyIcon or system tray. 我不想使用NotifyIcon或系统托盘。
const int WS_MINIMIZEBOX = 0x20000;
const int CS_DBLCLKS = 0x8;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= WS_MINIMIZEBOX;
cp.ClassStyle |= CS_DBLCLKS;
return cp;
}
}
您也可以做到无国界..需要额外的编码
Try to check what's going on in LocationChanged
, Move
, RegionChanged
, Resize
, ResizeBegin
, ResizeEnd
, SizeChanged
events. 尝试检查LocationChanged
, Move
, RegionChanged
, Resize
, ResizeBegin
, ResizeEnd
, SizeChanged
事件中发生了什么。 Could be that some code in any of these events is blocking the behavior you described. 可能是这些事件中的某些代码阻止了您描述的行为。
I am not seeing the described problem on a new empty form. 我没有在新的空白表格上看到所描述的问题。
Update: I am using Window 7 Pro. 更新:我正在使用Window 7 Pro。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.