How to Implement the conversion between SDI and MDI?
Source: Internet
Author: User
How to Implement the conversion between SDI and MDI?
If you want to write a compiled SDI application Program To convert to MDI, you must first create a class that inherits cmdichidwnd. Assume It is cchldfrm and make the following changes in cwinapp.
Initinstance ()
{
....
// Instead of adding csingledoctemplate
// Add cmultidoctemplate.
Pdoctemplate = new cmultidoctemplate (
Idr_mainframe,
Runtime_class (csdidoc ),
Runtime_class (cchldfrm ),
// For main MDI frame change this frame window from
// Cframewnd derivative (I. e. cmainframe)
// To your ichildwnd derived cchldfrm.
Runtime_class (csdiview ));
/// After this it is required to create the main frame window
// Which will contain all the child windows. Now this window is
// What was initially frame window for SDI.
Cmainframe * pmainframe = new cmainframe;
If (! Pmainframe-> loadframe (idr_mainframe ))
Return false;
M_pmainwnd = pmainframe;
.....
}
After cmainframe of the class inherited from cmdiframewnd replaces cframwnd, all classes will be inherited from cmdiframe instead of cframewnd. After compilation and running, you will find that the program has been transformed from SDI to MDI.
Note: In cmainfram, you must change the constructor from private to public. Otherwise, an error occurs.
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.