-
June 12th, 2014, 05:45 AM
#1
Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditions)
Hello !
I'm pretty much newbie in creating a succesful GUI in C++.
Although, i managed to create 4 buttons that should show a certain form.
Lets say, Form1 is my main form, therefore - Button 1 will open Form2, and Button 2 will open Form3.....
But the conditions is - If there is a form that is already open, clicking again on the Button that should open it, will Close it, but all the forms (form1,2,3,4,5) can be enabled together.
Also, a very important note is that whenever i close a form, in any way of closing it (Not the main form) It will "save" the changes i made (Such as ticking checkboxes and so..) and won't reopen it, it will just use "Visible" i guess ?
I couldn't get it on google, really =/
Please help me out !
Notes :
If i use Form2 ^form2show = gcnew Form2;
and then Form2->Show();
I will be able to simply ATTACK the button and open Billions of form2 ^_^
Although, when i use Form2->ShowDialog();
It won't let me open the form3,4,5.
Which isn't so bad, but when i exit from the form2, it won't save my changes (Such as checkboxes..)
Plaese, HELP ME =/
I'm stucked so hard on this sht...
-
June 12th, 2014, 06:40 AM
#2
Re: Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditio
Make Form2 ^form2show class member in the main form. When it is null, create and show it. If not null, do something else, for example, hide/show it.
Then you need to override FormClosing event in Form2. If closing reason is user interaction, hide the form instead of closing it.
Last edited by Alex F; June 12th, 2014 at 07:04 AM.
-
June 12th, 2014, 07:05 AM
#3
Re: Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditio
Originally Posted by Alex F
Make Form2 ^form2show class member in the main form. When it is null, create and show it. If not null, do something else, for example, hide/show it.
so, my code will be :
Form2 ^form2show= gcnew form2;
if(form2show = NULL)
{
form2show->Show();
}
else
{
form2show->Hide();
}
In the first button.
But it says it cannot convert int to Duffyduck::Form2 ^ with the operator '='...
Also, i assume (without building the project) that whenever i'll press the ('X') button in the form2, it will exit and won't recover it well..
-
June 12th, 2014, 07:08 AM
#4
Re: Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditio
Originally Posted by Alex F
Then you need to override FormClosing event in Form2. If closing reason is user interaction, hide the form instead of closing it.
To be honest, i already tried the FormClosing event...
Never got it to work,
If you have time to make a source with a button that does the conditions, it will really be greatful !
And really thanks for helping me !
-
June 12th, 2014, 07:18 AM
#5
Re: Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditio
Please read my post again: Make Form2 ^form2show class member in the main form
-
June 12th, 2014, 07:37 AM
#6
Re: Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditio
Originally Posted by Alex F
Please read my post again: Make Form2 ^form2show class member in the main form
Alright, now i understood it better,
Although, still can't understand a certain thing - How can i check if its null? or if the closing reason is actually a user interaction ? (To be honest, it doesnt matter for me, just need to hide it)..
-
June 13th, 2014, 01:56 PM
#7
Re: Really need help with Opening Form2,3,4,5 with buttons from Form 1 (With conditio
Originally Posted by Duffyduck
How can i check if its null?
The correct expresion to check for that condition is form2show == nullptr instead of form2show = NULL. The NULL macro is intended for use with native pointers, as opposed to the managed tracking handles used in .NET, and the single = operator is an assignment (i.e. it modifies the object at its left-hand side) rather than the equality test you want.
or if the closing reason is actually a user interaction ?
The event args parameter passed to your FormClosing event handler has a CloseReason property that indicates just what its name suggests: the reason why the form is about to be closed. One of its possible values is CloseReason::UserClosing. You then may set the event args object's Cancel property to true to prevent the form from actually being closed, if your checks indicate that it's appropriate.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|