you may add command function in your left view class
just like this
BOOL CLeftView::OnCommand(WPARAM wParam, LPARAM lParam)
{
TRACE("%d, %d/r/n", (int)wParam, (int)lParam);
CMainFrame* pMainFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
VERIFY(NULL != pMainFrame);
if (NULL != pMainFrame->m_pSplitterWnd)
{
pMainFrame->m_pSplitterWnd->SendSplitterMessage(1, 2, wParam, lParam);
}
else
{
CRfxBaseView::OnCommand(wParam, lParam);
}
return TRUE
}
SendSplitterMessage just like this
void ST_SplitterWnd::SendSplitterMessage(int nSide,int nViewIX /* = -1 */, WPARAM wParam, LPARAM lParam)
{
// if the View is -1 then just use the next view...
if (nViewIX == -1) {
nViewIX = m_nCurrentView[nSide] + 1;
if (nViewIX >= (int)m_views[nSide].size()) nViewIX = 0; // rollover to first view
}
CWnd* pWnd = m_views[nSide][nViewIX];
pWnd->PostMessage(WM_COMMAND, wParam, lParam);
}
mainframe
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_pSplitterWnd = new ST_SplitterWnd();
m_pSplitterWnd->Create(this,NULL,NULL,pContext,true);
m_nViewNo[0] = m_pSplitterWnd->AddView(LEFT_SIDE,RUNTIME_CLASS(CViewLeft1),pContext);
m_nViewNo[1] = m_pSplitterWnd->AddView(RIGHT_SIDE,RUNTIME_CLASS(CViewRight1),pContext);
m_nViewNo[2] = m_pSplitterWnd->AddView(RIGHT_SIDE,RUNTIME_CLASS(CViewRight2),pContext);
m_nViewNo[3] = m_pSplitterWnd->AddView(RIGHT_SIDE,RUNTIME_CLASS(CViewRight3),pContext);
return TRUE;
}
CViewRight3 message Handling
BEGIN_MESSAGE_MAP(CViewRight3, CView)
ON_COMMAND(ID_VIEW_CHANGE, OnViewChange)
ON_BN_CLICKED(IDC_BTN_1, OnBtnClick1)
ON_BN_CLICKED(IDC_BTN_2, OnBtnClick2)
ON_BN_CLICKED(IDC_BTN_3, OnBtnClick3)
END_MESSAGE_MAP()
and functions
enjoy it
just like this
BOOL CLeftView::OnCommand(WPARAM wParam, LPARAM lParam)
{
TRACE("%d, %d/r/n", (int)wParam, (int)lParam);
CMainFrame* pMainFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
VERIFY(NULL != pMainFrame);
if (NULL != pMainFrame->m_pSplitterWnd)
{
pMainFrame->m_pSplitterWnd->SendSplitterMessage(1, 2, wParam, lParam);
}
else
{
CRfxBaseView::OnCommand(wParam, lParam);
}
return TRUE
}
SendSplitterMessage just like this
void ST_SplitterWnd::SendSplitterMessage(int nSide,int nViewIX /* = -1 */, WPARAM wParam, LPARAM lParam)
{
// if the View is -1 then just use the next view...
if (nViewIX == -1) {
nViewIX = m_nCurrentView[nSide] + 1;
if (nViewIX >= (int)m_views[nSide].size()) nViewIX = 0; // rollover to first view
}
CWnd* pWnd = m_views[nSide][nViewIX];
pWnd->PostMessage(WM_COMMAND, wParam, lParam);
}
mainframe
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_pSplitterWnd = new ST_SplitterWnd();
m_pSplitterWnd->Create(this,NULL,NULL,pContext,true);
m_nViewNo[0] = m_pSplitterWnd->AddView(LEFT_SIDE,RUNTIME_CLASS(CViewLeft1),pContext);
m_nViewNo[1] = m_pSplitterWnd->AddView(RIGHT_SIDE,RUNTIME_CLASS(CViewRight1),pContext);
m_nViewNo[2] = m_pSplitterWnd->AddView(RIGHT_SIDE,RUNTIME_CLASS(CViewRight2),pContext);
m_nViewNo[3] = m_pSplitterWnd->AddView(RIGHT_SIDE,RUNTIME_CLASS(CViewRight3),pContext);
return TRUE;
}
CViewRight3 message Handling
BEGIN_MESSAGE_MAP(CViewRight3, CView)
ON_COMMAND(ID_VIEW_CHANGE, OnViewChange)
ON_BN_CLICKED(IDC_BTN_1, OnBtnClick1)
ON_BN_CLICKED(IDC_BTN_2, OnBtnClick2)
ON_BN_CLICKED(IDC_BTN_3, OnBtnClick3)
END_MESSAGE_MAP()
and functions
enjoy it