15 June 2009

How to disable close button of form

In a Form, you can enable/disable miximize/minimize button control easily by FormObject.MaximizeButton or FormObject.MinimizeButton property. But unfortunately, there is no such property for close button. You can disable the close button by overriding a property in your form class like below.

private const int CP_NOCLOSE_BUTTON = 0x200;

protected override CreateParams CreateParams




CreateParams myCp = base.CreateParams;

myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;

return myCp;



Note: This procedure works for disabling the close button at the time of form loading, not after loading the form.



© 2007 t!ps n tr!cks: How to disable close button of form

Template unik dari rohman

---[[ Skip to top ]]---