简体   繁体   中英

WFA taskbar minimize while borderless

I have borderless form window, with custom close/minimize buttons = I have 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.

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 ?

(using .NET 4.5 in MS Visual Studio 2012, Windows Form Application template)

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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