프로그래밍/C#
Minimize a form without border using the taskbar
bluecandyg
2022. 8. 17. 14:19
By default borderless forms are not designed to be minimized,
which means when the form’s FormBorderStyle property is set to None you will notice that clicking the application box in taskbar does not minimize the form.
This can be fixed by overriding CreateParams and adding the WS_MINIMIZEBOX style to the Window and CS_DBLCLKS to the Window class styles.
Simply place the following code inside your Form’s class which you want to enable the minimize functionality using the taskbar.
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;
}
}