Reactivate form to closure of other

Asked

Viewed 112 times

0

I have a form main and from this form I click on a button and open another form, So when I open this other form I disable the main one, so that’s okay, so I wanted when the user closes the second one form, the main one back to work normally. I would like to do this using the event FormClosed in the second form, then how will I reactivate the first form in the code of the second?

This is the part of the code that opens the form

if (numbersandletter->IsMatch(txta->Text) && (Convert::ToDouble(a) * letra) > 0){

                Mat::Mat1^ mat1 = gcnew Mat1();
                mat1->Show();
                this->Enabled = false;

    }

I open the form secondary and inattentive the main.

  • You are the first person I see using Winforms c/C++ :)

  • It’s Normal to Use What ?

  • C# and very eventually VB.Net.

  • WHAT IS THE ADVANTAGE ?

  • They are much easier languages and with more support from Microsoft at least for this technology (although the technology is already almost abandoned too).

  • Well I Prefer Performance Over An Easy Language, One Opinion Only, And As To That of Microsoft, It Really Is Very Boring.

  • How are you using . Net the performance of C++ isn’t all this. And performance for GUI application? Any GUI is so slow, but so slow that it can choose any language, it won’t matter. What people do is they take the excerpts that really need performance and optimize, eventually even in another, faster language. But for most things you won’t find much more performance in C++/CLI than in C#. You are looking for the performance without a justification for it. I believe you are still novice.

  • Add your relevant code to the question to try to help you.

Show 3 more comments

2 answers

1

You can do the same code in the secondary form, but I don’t think you can do it directly in formClosed, but in Formclosing, because this event is triggered before the form closes.

The difference between one code and the other is that instead of using

mat1->show();
this->Enabled = False;

You’d have to use a command like:

form1->show();
form1->Enabled = True;
this->Enabled = False;

Following the sequence of opening and activation of the forms.

Another way, which would involve a little more work, is to create a "Register" of global variables indicating status, a global array [form,status] to be verified at each form start, where only forms would change the value "Status" of the respective "Form".

Anyway I believe that both solutions are valid.

1


Try this code:

if (numbersandletter->IsMatch(txta->Text) && (Convert::ToDouble(a) * letra) > 0){
            Mat::Mat1^ mat1 = gcnew Mat1();
            this->Enabled = false;  // Desnecessário
            mat1->ShowDialog(this); // O ShowDialog ficara aguardando o fechamento do form
            this->Enabled = true;   // Esta linha será executada após o fechamento do form
            this->Focus();       

}
  • 1

    Excellent, I had already thought about Dialog but I do not know why :/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.