I have been thinking about how to use it more efficiently.CodeWhen creating interfaces, you often want to reuse a dialog box class. Because the dialog box categories are special, they are generally tailored to specific requirements. There are several edit boxes, several combo boxes, several buttons, and check boxes, which are different, it is difficult to reuse the dialog box.
Occasionally, some windows can be reused. For example, a dialog box is used to receive the input of a record. This dialog box can be reused when such a record needs to be added in multiple places.
However, do not update the control status of the parent window in the Child Window. For example, the parent window has a list control that displays records in a database, when the "add record" dialog box is displayed as if a record is successfully inserted in the database, you need to update the list of records displayed in the parent window. This operation cannot be completed in the subwindow, in this way, the window must call the function of the parent window, or even directly use the resources of the parent window. In this case, the parent window is unique. When the parent window changes, the Child Window cannot be reused.
The method is to send a message to the parent window in the subwindow. The parent window can update its own list in the message processing function, and even do other things. When the parent window changes, you only need the new parent window to process the message, and do not need to change the child window, so that the child window can be reused to a certain extent.
This is the so-called "who does what they do, don't do it on behalf of others ". Updating the list is a task of the parent window. Therefore, the parent window is implemented by itself in the message processing function, and the Child Window only serves to notify the parent window to do this.