Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

How to disable close button in top-right form?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deasy - 15 Sep 2004 02:13 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.