• Doc的窗口就创建一个,如果已经存在就激活那个窗口,不存在就建立Doc(转自CSDN)


    CDocument* CMyApp::CreateOrShow(CMultiDocTemplate*   pDocTemplate) 

    POSITION   posDoc=pDocTemplate-> GetFirstDocPosition(); 
    CDocument*   pDocument   =NULL; 
    if(posDoc!=NULL){ 
    pDocument   =pDocTemplate-> GetNextDoc(posDoc); 
    //To   get   the   first   view   in   the   list   of   views: 

    POSITION   posView   =   pDocument   -> GetFirstViewPosition(); 
    CView*   pFirstView   =   pDocument   -> GetNextView(posView); 
    ASSERT(pFirstView   !=NULL); 
    pFirstView   -> GetParentFrame()-> GetLastActivePopup()-> BringWindowToTop(); 
    return pDocument; 

    else{ 
    pDocument   =pDocTemplate-> CreateNewDocument(); 
    if   (pDocument   ==   NULL) 

    TRACE0( "CDocTemplate::CreateNewDocument   returned   NULL.\n "); 
    AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC); 
    return   NULL; 

    ASSERT_VALID(pDocument); 
    CString strTitle; 
    pDocTemplate-> GetDocString(strTitle,CDocTemplate::windowTitle); 
    pDocument-> SetTitle(strTitle); 
    BOOL   bAutoDelete   =   pDocument-> m_bAutoDelete; 
    pDocument-> m_bAutoDelete   =   FALSE;       //   don 't   destroy   if   something   goes   wrong 
    CFrameWnd*   pFrame   =   pDocTemplate-> CreateNewFrame(pDocument,   NULL); 
    pDocument-> m_bAutoDelete   =   bAutoDelete; 
    if   (pFrame   ==   NULL) 

    AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC); 
    delete   pDocument;               //   explicit   delete   on   error 
    return   NULL; 

    ASSERT_VALID(pFrame); 
    pDocTemplate-> InitialUpdateFrame(pFrame   ,pDocument,TRUE); 
    pFrame-> ShowWindow(SW_SHOWMAXIMIZED); 

    return pDocument   ; 

    ==================================================================================

    ==================================================================================

    BOOL   CMainFrame::FntCreateOrShow(CMultiDocTemplate*   pDocTemplate) 

    POSITION   posDoc=pDocTemplate-> GetFirstDocPosition(); 
    CDocument*   pDocument   =NULL; 
    if   (posDoc!=NULL) 

    pDocument   =pDocTemplate-> GetNextDoc(posDoc); 
    POSITION   posView   =   pDocument   -> GetFirstViewPosition(); 
    CView*   pFirstView   =   pDocument   -> GetNextView(posView); 
    ASSERT(pFirstView   !=NULL); 
    pFirstView-> GetParentFrame()-> GetLastActivePopup()-> BringWindowToTop();//激活视图 
    return   TRUE; 

    else 

    pDocTemplate-> OpenDocumentFile(NULL); 

    return   FALSE; 
    }

  • 相关阅读:
    一个长串由一个字串循环构成
    区间边界 张贴海报的可见性
    summary
    分区本质 从磁盘物理层面优化查询 分区操作的锁表
    全局变量在反汇编中是怎么体现的
    MathType怎么打定积分竖线
    定积分换元法洛必达法则求极限
    静态链表的插入和删除
    Git恢复之前版本的两种方法reset、revert
    服务去耦合
  • 原文地址:https://www.cnblogs.com/zlintokyo/p/2178465.html
Copyright © 2020-2023  润新知