Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Disable Close Button from Title bar of a Window

0.00/5 (No votes)
8 Dec 2009 1  
we can also override the CreateParams Code:[I did not write this code, but i found it a while back.]Visual C# .NET-------------------------------------------------#region Disable the 'X'protected override CreateParams CreateParams { get { CreateParams cp =...
we can also override the CreateParams Code:

[I did not write this code, but i found it a while back.]

Visual C# .NET
-------------------------------------------------

#region "Disable the 'X'"
protected override CreateParams CreateParams {
    get {
        CreateParams cp = base.CreateParams;
        const int CS_NOCLOSE = 0x200;
        cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
        return cp;
    }
}
#endregion


Visual Basic .NET
-------------------------------------------------

#Region "Disable the 'X'"
    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            Const CS_NOCLOSE As Integer = &H200
            cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
            Return cp
        End Get
    End Property
#End Region

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here