3个回答
展开全部
通过下述代码可以完成两个分割窗口视图间的消息传递,其中CLeft为左侧视图,CSplitView为右侧视图。
void CLeft::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame* MainFrame = (CMainFrame*)AfxGetMainWnd();
CSplitView* FindView=(CSplitView*)MainFrame->m_wndSplitter.GetPane(0,1);
//FindView->point=point;
FindView->DrawPoint(point);
CView::OnLButtonDown(nFlags, point);
}
DrawPoint函数为画点函数,如下:
void CSplitView::DrawPoint(CPoint Point)
{
HDC hDC=::GetDC(m_hWnd);
SetPixel(hDC,Point.x,Point.y,RGB(255,0,0));
}
CMainFrame类中的OnCreateClient函数代码如下:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// CG: The following block was added by the Splitter Bar component.
{
m_wndSplitter.CreateStatic(this,1,2);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeft),CSize(200,600),pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CSplitView),CSize(100,0),pContext);
return true;
}
}
我这有源代码,可以加我qq:113035171
void CLeft::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame* MainFrame = (CMainFrame*)AfxGetMainWnd();
CSplitView* FindView=(CSplitView*)MainFrame->m_wndSplitter.GetPane(0,1);
//FindView->point=point;
FindView->DrawPoint(point);
CView::OnLButtonDown(nFlags, point);
}
DrawPoint函数为画点函数,如下:
void CSplitView::DrawPoint(CPoint Point)
{
HDC hDC=::GetDC(m_hWnd);
SetPixel(hDC,Point.x,Point.y,RGB(255,0,0));
}
CMainFrame类中的OnCreateClient函数代码如下:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// CG: The following block was added by the Splitter Bar component.
{
m_wndSplitter.CreateStatic(this,1,2);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeft),CSize(200,600),pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CSplitView),CSize(100,0),pContext);
return true;
}
}
我这有源代码,可以加我qq:113035171
展开全部
可以试试通过文档通信
CRightView* CXXDoc::GetView()
{
// find the first view - if there are no views
// we must return NULL
POSITION pos = GetFirstViewPosition();
if (pos == NULL)
return NULL;
// find the first view that is a CRichEditView
CView* pView;
while (pos != NULL)
{
pView = GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CRightView)))
return (CRightView*) pView;
}
// can't find one--return NULL
return NULL;
}
CRightView* CXXDoc::GetView()
{
// find the first view - if there are no views
// we must return NULL
POSITION pos = GetFirstViewPosition();
if (pos == NULL)
return NULL;
// find the first view that is a CRichEditView
CView* pView;
while (pos != NULL)
{
pView = GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CRightView)))
return (CRightView*) pView;
}
// can't find one--return NULL
return NULL;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询