数据库开发之窗体编程,数据库开发之窗体编程
【 tulaoshi.com - C语言心得技巧 】
数据库开发之窗体编程
作者:李强
public: CMultiDocTemplate* pDoctemp1; CMultiDocTemplate* pDoctemp2;
三、修改InitInstance()中将如下代码:
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_MDISDITYPE, RUNTIME_CLASS(CMdisdiDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CMdisdiView)); AddDocTemplate(pDocTemplate);改为:
//CMultiDocTemplate* pDocTemplate;//删除 pDoctemp1 = new CMultiDocTemplate( IDR_MDISDITYPE, RUNTIME_CLASS(CMdisdiDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CMdisdiView)); AddDocTemplate(pDoctemp1);
四、加入新类CDoc2,基类为CDocument(利用菜单Insert-New Class…让其自动生成即可);加入新框架类CChildFrame2,基类为CMDIChildWnd;
加入新视类,这里新加CView2基类为CFormView类(Insert-New Form…),注意在添加对话框中将Document选为CDoc2;
五、同(三)将如下代码:
CMultiDocTemplate* pNewDocTemplate = new CMultiDocTemplate( IDR_VIEW2_TMPL, RUNTIME_CLASS(CDoc2), // document class RUNTIME_CLASS(CMDIChildWnd), // frame class RUNTIME_CLASS(CView2)); // view class AddDocTemplate(pNewDocTemplate);
改为:
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)pDoctemp2 = new CMultiDocTemplate( IDR_VIEW2_TMPL, RUNTIME_CLASS(CDoc2), // document class RUNTIME_CLASS(CChildFrame2), // frame class RUNTIME_CLASS(CView2)); // view class AddDocTemplate(pDoctemp2);并在mdisdi.cpp头部添加:
#include "Doc2.h"六、修改IDR_MAINFRAME菜单,新添一菜单“功能”,其子菜单为窗口1和窗口2.用ctrl+c复制,ctrl+v粘贴,产生二个新菜单IDR_MAINFRAME1和IDR_MAINFRAME2,再将其更名为IDR_MDISDITYPE,IDR_VIEW2_TMPL.
#include "mdisdiDoc.h" #include "Doc2.h"并在类中添加:
public: CMdisdiDoc * pDoc1; CDoc2 * pDoc2;在MainFrm.cpp增加代码如下:
void CMainFrame::OnMenuitem32771() { // TODO: Add your command handler code here if(pDoc1==NULL) { CMdisdiApp * pmdisdiapp =(CMdisdiApp *)AfxGetApp(); pDoc1=(CMdisdiDoc *) pmdisdiapp-pDoctemp1-OpenDocumentFile(NULL); } else { POSITION pos; pos=pDoc1-GetFirstViewPosition(); CView * pView; pView=pDoc1-GetNextView(pos); pView-GetParentFrame()-ActivateFrame(); } } void CMainFrame::OnMenuitem32772() { if(pDoc2==NULL) { CMdisdiApp * pmdisdiapp =(CMdisdiApp *)AfxGetApp(); pDoc2=(CDoc2 *) pmdisdiapp-pDoctemp2-OpenDocumentFile(N
来源:http://www.tulaoshi.com/n/20160129/1484014.html