Click here to Skip to main content
11,575,635 members (61,878 online)
Click here to Skip to main content

Tagged as

Disable Close Button from Title bar of a Window

, 8 Dec 2009 CPOL 4.2K 2
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)

Share

About the Author

jwalker343
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 1 unable to extend and plug in other o... Pin
Youzelin4-Jul-11 21:22
memberYouzelin4-Jul-11 21:22 
GeneralYa... but how to enable it back again? Pin
maxxon1517-Apr-11 5:35
membermaxxon1517-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 | Terms of Use | Mobile
Web03 | 2.8.150624.2 | Last Updated 8 Dec 2009
Article Copyright 2009 by jwalker343
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid