Problems and Solutions in MDI Programming

Source: Internet
Author: User
It may be because of the relationship between the focus of work. I have never used the MDI Interface Programming before. Recently I need to write an MDI Program First, let's take a look at MFC for two days,
From Chapter 8, we can understand the relationship between views and Doc. After a deep understanding of MFC, I found that Microsoft's programming framework has always embodied the concept of induction, reuse, and platform-based Development. The vision is far from average.

Now, I will summarize some of the minor problems and solutions that I have encountered, and the experts will not have to read them.

1. the dialog box resources associated with the cformview class must have the child attribute.

A class derived from cformview can be associated with a dialog box resource. However, in this dialog box, the [child] attribute must be selected for the style in attribute settings. Otherwise,
CodeIt can be compiled, but the debug operation will report an asserted error, trace the code, and assert in:

# Ifdef _ debug

// Dialog template must exist and be invisible with ws_child set
If (! _ Afxcheckdialogtemplate (m_lpsztemplatename, true ))
{
Assert (false); // invalid dialog Template Name
Postncdestroy (); // cleanup if Create fails too soon
Return false;
}

# Endif // _ debug

The comments automatically added by MFC already indicate the cause of the assertion: The ws_child flag is required.

The release operation does not show assertion errors, but the control in the dialog box cannot be displayed.

2. cformview is special. A parent form is nested with a subform. Therefore, the instance of the cformview class does not respond to the wm_close message, but only responds to the wm_destroy message.
In addition, if you want to use code to close the current view, you cannot directly: postmessage (wm_close,);
instead, you must first obtain the pointer to the parent form, then, send the wm_close message to the parent form, as shown in the following figure:
getparent ()-> postmessage (wm_close,);
.
the 8-1 figure in chapter 8 of the in-depth introduction to MFC clearly illustrates this situation. The View window is a subwindow of the cchildframe window.

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.