Link to home
Start Free TrialLog in
Avatar of imarshad
imarshadFlag for Pakistan

asked on

How to disable the Close Button at Runtime.......??

Hi all,
         I want to disable the Close button of my form during some function call in my code......
Something like this.....

call DisableCloseButton
call MyFunction
call EnableCloseButton

I have tried to use the enable property but it freezes the whole form which is not desireable.........

Imran Arshad
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Try with:

yourform.Controlbox=true
Last example is to enable. To disable

yourform.Controlbox=false
Hi,

Here is a code sample from MS which allows you to disable the close button during runtime:

How To Disable the Close Option on Control Menu of a VB Form
http://support.microsoft.com/support/kb/articles/Q184/6/86.asp

Hope it helps!
Avatar of imarshad

ASKER

Compilation Error.....
Function or interface marked as restricted, or the function uses an automation type not supported in VB....
You cannot set the ControlBox property of a form in code.  This is only available in design time.
Erick37,
            What you have supplied is exactly what I want........Isn't there a simple way of doing it ? If none then I will give the points to you...........I am trying to write the DisableCloseButton and EnableCloseButton from the code you have suggested.....
I will ideally like to have these functions in a Module.......Can you help me in this regard ? My main form is Form1......

Imran Arshad
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help......

Imran Arshad