This is a migrated thread and some comments may be shown as answers.

How To Disable R.A.D Form 's close button

4 Answers 784 Views
Form
This is a migrated thread and some comments may be shown as answers.
Daniel Kuo
Top achievements
Rank 1
Daniel Kuo asked on 25 Aug 2009, 07:58 AM
Hi:

I found a way to disable wimform's close button on codeproject

http://www.codeproject.com/KB/cs/DisableClose.aspx

but it's not working  on R.A.D form (Q1 2009 SP1)  with vista theme.

can you provide a way to disable close button of R.A.D form?

thanks.

4 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 25 Aug 2009, 01:29 PM
Hello Daniel,

You can use the following approach to disable the Close button of a RadForm component:

public RadFormTestForm() 
        { 
            InitializeComponent(); 
            this.FormElement.TitleBar.CloseButton.Enabled = false
        } 
 
        private const int CP_NOCLOSE_BUTTON = 0x200; 
        protected override CreateParams CreateParams 
        { 
            get 
            { 
                CreateParams myCp = base.CreateParams; 
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON; 
                return myCp; 
            } 
        } 

Basically, the CreateParams property removes the style that shows a close button in the system menu and in the title bar of a standard windows form. However, since RadForm customizes the standard non-client area of a Windows Form, you will have to additionally disable the Close button in our Title Bar and also apply the style that removes it from the system menu (so that the user will not be able to still close the form from the system menu) .

I hope this is helpful.

Kind regards,
Deyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Daniel Kuo
Top achievements
Rank 1
answered on 26 Aug 2009, 03:18 AM
Hi :

thanks, it works

regards,

Lu
0
Holger Boskugel
Top achievements
Rank 2
answered on 05 Jun 2012, 05:10 PM
Hello,

There is no (longer) need to override CreateParams. Only the settings for CloseButton in constructor are relevant. There you can also remove the CloseButton by Visibility = Hidden.


Regards from Leipzig

Holger
0
Ivan Petrov
Telerik team
answered on 08 Jun 2012, 12:51 PM
Hello guys,

Thank you all for writing.

There are several properties which control the visibility of the minimize, maximize and close buttons. You can use RadForm properties MinimizeBox, MaximizeBox and ControlBox. Or you can directly access the buttons elements:
this.FormElement.TitleBar.MinimizeButton
this.FormElement.TitleBar.MaximizeButton
this.FormElement.TitleBar.CloseButton

You can then use the Visibility property to show/hide these button elements.

I hope this will be useful. Should you have further questions, feel free to write back.

Greetings,
Ivan Petrov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Form
Asked by
Daniel Kuo
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Daniel Kuo
Top achievements
Rank 1
Holger Boskugel
Top achievements
Rank 2
Ivan Petrov
Telerik team
Share this question
or