How to achieve the conversion of SDI and MDI?

zhaozj2021-02-11  200

How to achieve the conversion of SDI and MDI?

How to achieve the conversion of SDI and MDI? If you want to convert a composed SDI application to MDI, first create a class inherited in cmdichidwnd, assume that CCHLDFRM, as follows 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 (ie CMainFrame) // to your CMDIChildWnd 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; (! pMainFrame-> LoadFrame (IDR_MAINFRAME)) if return FALSE; m_pMainWnd = pMainFrame; .....} after the inheritance from the class CMainFrame CMDIFrameWnd replaced CFramWnd, All classes will inherit from cmdiframe instead of cframeWnd, you will find that the program has changed from SDI to MDI after compiling. Note: The constructor must be changed from private from private to public. Otherwise it will be wrong.

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

New Post(0)