0

How would it be possible to disable the closebutton(X) in the upper right corner of the form.
I dont want to use this property because it takes the minimize and maximize button away also.

ControlBox = false;

The only thing I will need on the form is the minimizebutton.
I can find separate properties for the minimizebutton and maximizebutton but not for the (X) button.

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by Lukezzz
0

[Warning: This is coming from a Java programmer with no C++ experience]

Assuming that clicking 'X' generates an event, and C++ has method overriding - override the method that closes the window when the user clicks 'X', and do nothing in that method. That way, nothing will happen when the 'X' is clicked.

0

The problem is that I have put "Exit" in the File menu that will be used to close the window and the application like:

this->Close();

So I cant if that is possible to not close the form in that event.

I still need to disable or remove the close(X) from the form in somehow.

[Warning: This is coming from a Java programmer with no C++ experience]

Assuming that clicking 'X' generates an event, and C++ has method overriding - override the method that closes the window when the user clicks 'X', and do nothing in that method. That way, nothing will happen when the 'X' is clicked.

0

Yes ofcourse, I forgot to tell this.

I use Visual C++ 2008 Express Edition. I am googling around but I have problem to find a direct solution for this.

Give us a little chance and tell us what GUI you are using?

0
// extra variable
Boolean can_exit;

// form closing
if(!can_exit)
   e->Cancel::set(true);

// button exit click
can_exit = true;

this->Close();

// form load
can_exit = false;

hope that helps..

0

It seems to work almost, I have to ask here.
I have succeded to put this as a global variable:

[B]bool can_exit;[/B]

In the closing event of the form, I have put this code:

[B]if(!can_exit)
   e->Cancel::set(true);[/B]

In the Load event of the form, I have put this code:

[B]can_exit = false;[/B]

But I dont understand where to put this code:

[I]// button exit click
can_exit = true;[/I]

I have never found an event for the close(x) button but perheps there is one ? I wonder if that code will be put in that event in that case.

However if I put the other code in place, nothing happens when I click the close(X) button wich is perfect.
However when I press a button on the form that tries to close the form(below code), nothing happens but perheps that has to do with the code that I wonder where to put:

this->Close();

this->Close();

// extra variable
Boolean can_exit;

// form closing
if(!can_exit)
   e->Cancel::set(true);

// button exit click
can_exit = true;

this->Close();

// form load
can_exit = false;

hope that helps..

0

I just understood that I will put that code in the event for the button that will close the form:

Many thanks for this help...

// button exit click
can_exit = true;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.