The problem of closing a form in C, how to close all sub forms in C

Updated on technology 2024-05-20
8 answers
  1. Anonymous users2024-02-11

    The overall idea is to set both the A and B forms as global variables, so that they can access each other.

    For the specific method, you open it first and change the things in the prgram class to something like this.

    public static form1 form1;

    public static form2 form2;

    static void main();

    form1 = new form1();

    Of course, you can't run two forms in one program, and the other one needs to be showdialog.

  2. Anonymous users2024-02-10

    It's easy to do. You can do this.

    Declare an instance of form B in form A.

    Then when you show out form B, call its show method directly, don't use showdialog (or you won't be able to click the button on form A).

    Calling the close method of the instance of b in the event of a button... Well.

  3. Anonymous users2024-02-09

    Then you need to get a reference to form b in form a, which is the thing before the new formb() thing, e.g. formb fb=new formb();

    If Form B is created in A, it's simple and straightforward;

    If not, you have to pass the reference with an argument and then execute close

  4. Anonymous users2024-02-08

    LZ wants to close Form B during the button click event of Form A, is there still a button to open Form B?

    This is because the program entry cannot allow two forms to be displayed at the same time.

  5. Anonymous users2024-02-07

    Change the two forms to public so that it is convenient to use, hehe. But the security is a little worse.。。

  6. Anonymous users2024-02-06

    Whichever form you want to close, use a new object and call its close() method with that object.

  7. Anonymous users2024-02-05

    Then in form A, a new instance of form b is written, and in window A, it is written;

  8. Anonymous users2024-02-04

    1. First of all, we open the properties of the sub-window, click on the "lightning icon (framed in the picture below)" to find the formclosing (or formclosed) event, and double-click.

    2. In the gameui formclosing event**.

    <>4、;If you just close the current window, you can't exit the program if it's not the main form, and if you have a managed thread (not the main thread), you can't exit cleanly.

    5、;Force all messages to abort and exit all forms, but if there is a managed thread (not the main thread), it will not be able to exit cleanly.

    6、;Forcibly aborting all messages on the calling thread also faces the problem that other threads cannot exit correctly.

    7、;This is the most thorough way to exit, no matter what thread is forced to quit, and the program ends cleanly.

Related questions
13 answers2024-05-20

I don't know if net has this kind of control or has the function itself, if you want to write it yourself, it is to detect whether the program form is outside the screen, that is, whether the y coordinate is less than 0 and so on; It will be displayed if the mouse cursor is moving over it.

4 answers2024-05-20

Your form2 constructor should be overloaded once: it should pass the textbox as an argument and it becomes: >>>More

29 answers2024-05-20

Check this out. <>

You can also knock ** yourself. >>>More

7 answers2024-05-20

clrscr is a standard library function for C, not a standard library function for C++. >>>More

11 answers2024-05-20

It's textbox, right? textbook?

double somedouble; >>>More