Zorak
Zorak

Reputation: 709

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

Upvotes: 0

Views: 507

Answers (1)

Jyrka98
Jyrka98

Reputation: 530

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;
    }
}

Upvotes: 1

Related Questions