| | |
Disable Close button on form
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 173
Reputation:
Solved Threads: 1
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.
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.
I dont want to use this property because it takes the minimize and maximize button away also.
C++ Syntax (Toggle Plain Text)
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.
Last edited by Lukezzz; May 12th, 2009 at 10:09 pm.
•
•
Join Date: Sep 2008
Posts: 1,568
Reputation:
Solved Threads: 196
[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.
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.
•
•
Join Date: Mar 2008
Posts: 173
Reputation:
Solved Threads: 1
The problem is that I have put "Exit" in the File menu that will be used to close the window and the application like:
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.
C++ Syntax (Toggle Plain Text)
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.
c++ Syntax (Toggle Plain Text)
// 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;
Last edited by cikara21; May 13th, 2009 at 12:46 pm.
•
•
Join Date: Mar 2008
Posts: 173
Reputation:
Solved Threads: 1
It seems to work almost, I have to ask here.
I have succeded to put this as a global variable:
In the closing event of the form, I have put this code:
In the Load event of the form, I have put this code:
But I dont understand where to put this code:
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();
I have succeded to put this as a global variable:
bool can_exit;if(!can_exit)
e->Cancel::set(true);can_exit = false;But I dont understand where to put this code:
// button exit click
can_exit = true;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:
C++ Syntax (Toggle Plain Text)
this->Close();
this->Close();
•
•
•
•
hope that helps..c++ Syntax (Toggle Plain Text)
// 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;
Last edited by Lukezzz; May 13th, 2009 at 3:31 pm.
•
•
Join Date: Mar 2008
Posts: 173
Reputation:
Solved Threads: 1
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...
Many thanks for this help...
C++ Syntax (Toggle Plain Text)
// button exit click can_exit = true;
![]() |
Similar Threads
- How to disable Back button of IE when executing welcome.aspx page? (ASP.NET)
- How to disbale Close(X) button in title bar (JavaScript / DHTML / AJAX)
- Apply code to 'x' button on form (Visual Basic 4 / 5 / 6)
- enable button on other form (C#)
- Borderless MDI form (Visual Basic 4 / 5 / 6)
- Disable MDI child close button (ASP.NET)
- I need to write code for the save and close botton and close button on my form (C#)
Other Threads in the C++ Forum
- Previous Thread: print data from a binary file
- Next Thread: cin.getline() question
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






