简体   繁体   English

WFA任务栏最小化而无边界

[英]WFA taskbar minimize while borderless

I have borderless form window, with custom close/minimize buttons = I have FormBorderStyle:None 我有无边界表单窗口,带有自定义关闭/最小化按钮=我有FormBorderStyle:None

And here is my problem. 这是我的问题。 While using this setting, I cannot minimize my app through an icon in taskbar. 使用此设置时,我无法通过任务栏中的图标最小化我的应用程序。

If I switch to, for example FormBorderStyle:Fixed3D, where are original system buttons present, the task bar icon come back to life and can minimize the app. 如果我切换到FormBorderStyle:Fixed3D之类的原始系统按钮(其中存在原始系统按钮),则任务栏图标将恢复原状,并可以最小化该应用程序。

With restoring the app through taskbar icon, there is no problem. 通过任务栏图标还原应用程序,就没有问题。

So, is it possible to minimize the app through taskbar icon while FormBorderStyle:None ? 因此,是否有可能在FormBorderStyle:None时通过任务栏图标最小化应用程序?

(using .NET 4.5 in MS Visual Studio 2012, Windows Form Application template) (在MS Visual Studio 2012 Windows窗体应用程序模板中使用.NET 4.5)

Thanks in advance 提前致谢

Borderless windows don't have the WS_MINIMIZEBOX window style (because the controlbox is removed when you set FormBorderStyle to None ), so you have to add it yourself by overriding the CreateParams property: 无边界窗口没有WS_MINIMIZEBOX窗口样式(因为将FormBorderStyle设置为None时,控件框已删除),因此您必须通过覆盖CreateParams属性自己添加它:

protected override CreateParams CreateParams {
    get {
        const int WS_MINIMIZEBOX = 0x00020000;
        var cp = base.CreateParams;
        cp.Style |= WS_MINIMIZEBOX;
        return cp;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM