MFC分视图操作

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
 BOOL bResult=m_wndSplitterV.CreateStatic(this,1,2);
 ASSERT(bResult);
 m_wndSplitterH.CreateStatic(&m_wndSplitterV,3,1,WS_CHILD | WS_VISIBLE,m_wndSplitterV.IdFromRowCol(0,1));

 RECT clientRect;
 GetClientRect(&clientRect);
 int width=clientRect.right-clientRect.left;
 int height=clientRect.bottom-clientRect.top;

 m_wndSplitterV.CreateView(0,0,RUNTIME_CLASS(CClientView),CSize(g_ScreenX,g_ScreenY),pContext);
 m_wndSplitterH.CreateView(0,0,RUNTIME_CLASS(CWebView),CSize(200,200),pContext);
 m_wndSplitterH.CreateView(1,0,RUNTIME_CLASS(CWebView2),CSize(200,200),pContext);
 m_wndSplitterH.CreateView(2,0,RUNTIME_CLASS(CWebView),CSize(200,200),pContext);

 g_Viewhwnd=m_wndSplitterV.GetPane(0,0)->GetSafeHwnd();
 g_pWnd=m_wndSplitterV.GetPane(0,0);


 m_wndSplitterV.SetOwner(this);
//  //设置窗格的初始化的大小
  m_wndSplitterV.SetColumnInfo(0,width*3/4,10);
 m_wndSplitterH.SetRowInfo(0,height/3,10);
 m_wndSplitterH.SetRowInfo(1,height/3,10);
 m_wndSplitterH.SetRowInfo(2,height/3,10);

 //((CWebView*)m_wndSplitterH.GetPane(0,0));  
 //激活sceneview使得其可以接受命令消息
 m_wndSplitterV.SetActivePane(0,0,g_pWnd);
 m_bCreateSplitter = TRUE;

 return bResult;

 

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
 CFrameWnd::OnSize(nType,cx,cy);
 
 if(m_bCreateSplitter)
 {
  m_wndSplitterV.SetColumnInfo(0,cx*3/4,10);
  m_wndSplitterV.SetColumnInfo(1,cx*1/4,10);
  m_wndSplitterV.SetRowInfo(0,cy,10);
  m_wndSplitterH.SetRowInfo(0,cy/3,10);
  m_wndSplitterH.SetRowInfo(1,cy/3,10);
  m_wndSplitterH.SetRowInfo(2,cy/3,10);
  m_wndSplitterH.RecalcLayout();
  m_wndSplitterV.RecalcLayout();
  ::UpdateWindow(g_hwnd);
  ::SetFocus(g_Viewhwnd); 
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值