Do not do anything on your behalf.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.