MDI application uses polymorphism to implement the management of subforms

zhaozj2021-02-16  58

One of the most basic problems in the MDI application is the management of subforms.

I encountered a problem when developing an app. Many child forms are similar, but there is a subtle difference. When I use a parent window to manage these child forms, many methods are the same, but the specific implementation may vary. Therefore, it is necessary to implement the management of subforms, and the specific practices are as follows:

1. Write a parent formx, which inherits from the FORM class. It basically doesn't do anything, just write some virtual functions.

2. All sub-forms and MDI form classes are inherited from FormX, and those methods in FormX are overwritten in the sub-form class.

The following is a specific implementation of the parental virtual function

3. When you need to manage the child form, you can use (formx) this.activechild to call the function in the child form, then you don't have to know which form is the current activity, the compiler is automatically Will find the function you need to call.

转载请注明原文地址:https://www.9cbs.com/read-21777.html

New Post(0)