如何将消息从cleftframe发送到MDI中的子帧 [英] How to send the message from cleftframe to childframe in MDI

查看:66
本文介绍了如何将消息从cleftframe发送到MDI中的子帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从CLeftFrame将消息发送到ChildFrame以显示树控件的数据以及如何在childFrame中调用Switch视图



什么我试过了:



//在FormLeft中

I wanna send the message to the ChildFrame from the CLeftFrame to display the data for tree control and how to call the Switch view in childFrame

What I have tried:

//In FormLeft

void CFormLeft::OnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);

	*pResult = 0;
	m_TreeCtrl->SendMessage(WM_COMMAND, wParam, lParam);
}





//儿童相框





//Child Frame

CView* CSDISplitDoc::SwitchToView ( CView* pNewView )
{

DIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();

    CMDIChildWnd* pChild = (CMDIChildWnd*)pMainWnd->MDIGetActive();

   // Get the active view attached to the active MDI child window.
   CView* pOldActiveView = pChild->GetActiveView();


   CSplitterWnd* pSplitter = (CSplitterWnd *)pOldActiveView->GetParent();
   int row, col;
   ASSERT(pSplitter->IsChildPane(pOldActiveView, row, col));

   // set flag so that document will not be deleted when view is destroyed
   m_bAutoDelete = FALSE;    

   // Dettach existing view
   RemoveView(pOldActiveView);

   // set flag back to default 
   m_bAutoDelete = TRUE;
 
   
   ::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, 0);
   ::SetWindowLong(pNewView->m_hWnd, GWL_ID, pSplitter->IdFromRowCol(row, col));

  
   pNewView->ShowWindow(SW_SHOW);
   pOldActiveView->ShowWindow(SW_HIDE);

     AddView(pNewView);


   pSplitter->GetParentFrame()->SetActiveView(pNewView);
   
   pSplitter->RecalcLayout(); 
   pNewView->SendMessage(WM_PAINT); 

   return pOldActiveView;
}

推荐答案

我们在前两篇文章中告诉过你,左边窗口需要使用SendMessage使用正确的窗口举起活动。
We told you in your previous two posts of this question, that the left Window will need to use SendMessage to raise an event with the right Window.


这篇关于如何将消息从cleftframe发送到MDI中的子帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆