프로그래밍/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;
    }
}

'프로그래밍 > C#' 카테고리의 다른 글

Get Client IP Address in C#  (0) 2022.08.17
Create Folder on FTP Server in C#  (0) 2022.08.17
C# RabbitMQ Client  (0) 2021.06.30
HttpUtility.HtmlDecode  (0) 2021.06.22
Windows Installer 에서 특정파일 자동복구 기능 중지  (0) 2021.04.01