• 在Dialog中嵌入View的方法


     

    在dialog中嵌入view也没有想象到的那么复杂,遵循如下步骤即可。

    1. Create 一个 child类型的CFrameWnd,摆正位置。

    2. 正确设置CCreateContext

    3. Create 出View与CFrameWnd关联4. Show it!

    看代码:

        CWnd* pPosWnd = GetDlgItem(IDC_VIEW_POSITON);
       CRect rect;
       pPosWnd->GetWindowRect(&rect);
       CRect rectView = rect;
       ScreenToClient(&rect);

       m_pFrame = new CFrameWnd();
       m_pFrame->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this);

       m_pFrame->ScreenToClient(&rectView);

       m_pDoc = static_cast<CDlgViewDoc*>(RUNTIME_CLASS(CDlgViewDoc)->CreateObject());

       CCreateContext context;
       context.m_pNewViewClass = RUNTIME_CLASS(CDlgViewView);
       context.m_pCurrentDoc = m_pDoc;
       context.m_pNewDocTemplate = NULL;
       context.m_pLastView = NULL;
       context.m_pCurrentFrame = m_pFrame;

       CView* pView = static_cast<CView*>(RUNTIME_CLASS(CDlgViewView)->CreateObject() );
       if( !pView )
          return FALSE;
       if( !pView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW, rectView, m_pFrame, AFX_IDW_PANE_FIRST,&context) )
          return FALSE;
       pView->ShowWindow(SW_SHOW);
       pView->OnInitialUpdate();

  • 相关阅读:
    python-configparser模块,xml.etree模块
    Ubuntu16.04环境下Vim 配置 for HTML,CSS,JAVASCRIPT(1)
    Windows 命令行及Git操作
    Ubuntu16.04 无任务栏问题
    ubuntu16.04安装中文输入法
    本地Web服务器搭建
    爬虫(1)
    Python(四):数字连珠2
    python学习(四)五数连珠
    Openjudge 百练第4109题
  • 原文地址:https://www.cnblogs.com/aiwz/p/6333136.html
Copyright © 2020-2023  润新知