Code to fix borderless form minimize from taskbar

Discussion in 'Mixed Languages' started by QuantumBug, Feb 8, 2013.

  1. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,485
    1,321
    60
    #1 QuantumBug, Feb 8, 2013
    Last edited by a moderator: Apr 20, 2017
    Since I managed to resolve this issue I thought I'd explain it and share the code with you.

    The issue:

    When a form has no border (FormBorderStyle = None) you cannot minimize via clicking the taskbar icon.

    The fix:


    C# .NET

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

    VB.NET


    Code:
        Const WS_MINIMIZEBOX As Integer = &H20000
        Const CS_DBLCLKS As Integer = &H8
        Protected Overrides ReadOnly Property CreateParams() As CreateParams
            Get
                Dim cp As CreateParams = MyBase.CreateParams
                cp.Style = cp.Style Or WS_MINIMIZEBOX
                cp.ClassStyle = cp.ClassStyle Or CS_DBLCLKS
                Return cp
            End Get
        End Property


    You can just copy and paste. Enjoy.
     
  2. PAYMYRENT

    PAYMYRENT MDL Developer

    Jul 28, 2009
    1,462
    419
    60