I want to mimic sql server 2000 console. It has disabled close button on top
right console root form. How to make it?
Thank you in advance.
Bernie Yaeger - 15 Sep 2004 03:01 GMT
Set a form global variable in the form's declaration section (above the load
event):
Public closetest As Boolean = True
If you have a close button that you want to allow you to get out of the
form, change the status of closetest to false. Then, in the closing event
of the form:
If closetest = True Then
e.Cancel = True
End If
HTH,
Bernie Yaeger
> I want to mimic sql server 2000 console. It has disabled close button on top
> right console root form. How to make it?
>
> Thank you in advance.
Imran Koradia - 15 Sep 2004 05:26 GMT
add this to the form:
Protected Overrides ReadOnly Property CreateParams() _
As System.Windows.Forms.CreateParams
Get
Const CS_NOCLOSE As Integer = &H200
Dim Params As CreateParams = MyBase.CreateParams
Params.ClassStyle = Params.ClassStyle Or CS_NOCLOSE
Return Params
End Get
End Property
CAUTION: You wont be able to close the form from anywhere except the task
manager (or if you are in debug mode, using the stop button in the IDE).
hope that helps..
Imran.
>I want to mimic sql server 2000 console. It has disabled close button on
>top
> right console root form. How to make it?
>
> Thank you in advance.
Herfried K. Wagner [MVP] - 15 Sep 2004 11:48 GMT
* "=?Utf-8?B?RGVhc3k=?=" <Deasy@discussions.microsoft.com> scripsit:
> I want to mimic sql server 2000 console. It has disabled close button on top
> right console root form. How to make it?
Add this to your form:
\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const CS_DBLCLKS As Int32 = &H8
Const CS_NOCLOSE As Int32 = &H200
cp.ClassStyle = CS_DBLCLKS Or CS_NOCLOSE
Return cp
End Get
End Property
///
Alternatively you can remove the according menu items from the system
menu using p/invoke.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/