StrataFrame Forum

disable/hide close button...

http://forum.strataframe.net/Topic2824.aspx

By StarkMike - 9/14/2006

How do i disable or hide the close button on a windows form? I dont want to hide the minimize and maximize buttons... i want them to stay.



Thanks
By Trent L. Taylor - 9/14/2006

You can't through the standard .NET form designer.  You will have to use a Windows API and hand off the window handle on the form load to hide only the close button Sad  Sorry.
By StarkMike - 9/15/2006

No problem. Thanks for the info. Instead I have a messagebox pop up asking them if they really want to exit. 
By Paul Chase - 9/20/2006

Mike,

You can disable the close button on a form by overriding the createparams property.

Paul

Protected Overrides ReadOnly Property CreateParams() As CreateParams

Get

Dim ClsCp As CreateParams = MyBase.CreateParams

Const CS_NOCLOSE As Integer = &H200

ClsCp.ClassStyle = ClsCp.ClassStyle Or CS_NOCLOSE

Return ClsCp

End Get

End Property