本文介绍了知道CChildFrame何时与另一个切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。有没有人知道一条消息或一个处理程序告诉我何时用户在MFC MDI应用程序中切换了另一个CChildFrame?子框架是MDI选项卡:
int CMainFrame :: OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CMDIFrameWndEx :: OnCreate(lpCreateStruct)= = -1)
返回-1;
BOOL bNameValid;
//基于持久值设置可视化管理器和样式
OnApplicationLook(theApp.m_nAppLook);
EnableMDITabs(
TRUE,
TRUE,
CMFCBaseTabCtrl :: LOCATION_TOP,
TRUE,
CMFCTabCtrl :: STYLE_3D_SCROLLED,
FALSE,
FALSE);
CMFCTabCtrl& MFCTabCtrl = GetMDITabs();
MFCTabCtrl.SetTabBorderSize(0);
MFCTabCtrl.SetFlatFrame(TRUE);
MFCTabCtrl.EnableTabSwap(TRUE);
MFCTabCtrl.EnableTabDocumentsMenu(TRUE);
MFCTabCtrl.EnableAutoColor(TRUE);
if(!m_wndMenuBar.Create(this))
{
TRACE0("无法创建menubar \ n");
返回-1; //无法创建
}
当然,我尝试过这样的事情:
void CChildFrame :: OnActivate(UINT nState,CWnd * pWndOther,BOOL bMinimized)
{
CMDIChildWndEx :: OnActivate(nState,pWndOther,bMinimized);
// TODO:在此处添加您的消息处理程序代码
TRACE(">>>>>>>>>> %d |%p \ n",nState,pWndOther);
}
和
BEGIN_MESSAGE_MAP(CChildFrame,CMDIChildWndEx)
ON_WM_ACTIVATE()
END_MESSAGE_MAP()
但不会在子帧切换时触发......
此外,我已尝试过:
void CJoint8View :: OnActivate(UINT nState,CWnd * pWndOther,BOOL bMimimized)
{
CView :: OnActivate(nState,pWndOther,bMinimized);
// TODO:在此处添加您的消息处理程序代码
TRACE(" +>>>>>>>>>> ;%d |%p \ n",nState,pWndOther);
}
也没有解雇......为什么?
解决方案
Hi all of you. Does anyone know a message, or a handler that tell me when an user has switch a CChildFrame with another one, in an MFC MDI app ? The childframes are MDI tabs:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; BOOL bNameValid; // set the visual manager and style based on persisted value OnApplicationLook(theApp.m_nAppLook); EnableMDITabs( TRUE, TRUE, CMFCBaseTabCtrl::LOCATION_TOP, TRUE, CMFCTabCtrl::STYLE_3D_SCROLLED, FALSE, FALSE); CMFCTabCtrl& MFCTabCtrl = GetMDITabs(); MFCTabCtrl.SetTabBorderSize(0); MFCTabCtrl.SetFlatFrame(TRUE); MFCTabCtrl.EnableTabSwap(TRUE); MFCTabCtrl.EnableTabDocumentsMenu(TRUE); MFCTabCtrl.EnableAutoColor(TRUE); if (!m_wndMenuBar.Create(this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create }
Of course, I have tried something like this:
void CChildFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { CMDIChildWndEx::OnActivate(nState, pWndOther, bMinimized); // TODO: Add your message handler code here TRACE(">>>>>>>>>>%d|%p\n", nState, pWndOther); }
and
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) ON_WM_ACTIVATE() END_MESSAGE_MAP()
but it isn't fired on childframes switching ...
Also, I I have tried:
void CJoint8View::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { CView::OnActivate(nState, pWndOther, bMinimized); // TODO: Add your message handler code here TRACE("+>>>>>>>>>>%d|%p\n", nState, pWndOther); }
No fired also ... why ?
解决方案
这篇关于知道CChildFrame何时与另一个切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!