How to create a form (dialog and SDIMDI in DLL)

zhaozj2021-02-08  253

This is an old problem. I briefly wrote a summary, there is deficiencies, please point out, thank you. Call the DLG or SDI / MDI in the DLL, just no longer use the app class because it is inherited from CwinThread, and the internal thread mechanism exports the emergence of problems. (1) For Dialog in the DLL, it is very simple, and the direct call is as: extern "c" void loadDialog () {ctestdlg dlg; if (dlg.domodal == iodk) {// ...}} (2) For the SDI / MDI in the DLL, it is not so straightforward. Need to ensure that the association between Doc / View and MainFrames, therefore reserves the CDOCTemPate class that is originally used in the app and its use to it. To this end, we can build a class such as CSDimain to do the job in the original app (of course, you don't have to use, you will use the problem. After all, create work is on the pile), such as: bool csdimain :: InitInstance () {// create a template if (m_pTemplate == NULL) {m_pTemplate = new CMultiDocTemplate (IDR_MAINFRAME, RUNTIME_CLASS (CSDIForTestDoc), RUNTIME_CLASS (CMainFrame), RUNTIME_CLASS (CSDIForTestView));}

CSDIForTestDoc * pDocument = new CSDIForTestDoc; // Create a new frame CFrameWnd * pFrame = m_pTemplate-> CreateNewFrame (pDocument, NULL); if (NULL == pFrame) {AfxMessageBox ( "Create frame failed"); return FALSE;}

M_PTemplate-> InitialUpdateFrame (Pframe, PDocument);

Return True;}

Yang Xiaoming 2002-5-11

E-mail: brierbird97@mails.tsinghua.edu.cn

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

New Post(0)