Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Disable Close Button from Title bar of a Window

, 8 Dec 2009
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

jwalker343

United States United States
No Biography provided

Comments and Discussions

 
GeneralReason for my vote of 1 unable to extend and plug in other o... PinmemberYouzelin4-Jul-11 21:22 
GeneralYa... but how to enable it back again? Pinmembermaxxon1517-Apr-11 5:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 8 Dec 2009
Article Copyright 2009 by jwalker343
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid