一个CChildFrame中有四个View,通过拆分窗口实现的,当然,这个 视图/文档 模板类
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MY3DTYPE,
RUNTIME_CLASS(CMy3DDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMy3DView));
AddDocTemplate(pDocTemplate);
1 为什么CChildFrame,不能接到OnLButtonDown
1 View怎么知道自己是不是活动的呢?
2 怎么通过一个View通知其他的View更新呢?还有问一下,如果要使通过某个CView的OnLButtonDown通知其他CView进行更新的话,下面的这个方法可以么?void CMy3DView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
this->GetDocument()->UpdateAllViews();
CView::OnLButtonDown(nFlags, point);
}
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MY3DTYPE,
RUNTIME_CLASS(CMy3DDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMy3DView));
AddDocTemplate(pDocTemplate);
1 为什么CChildFrame,不能接到OnLButtonDown
1 View怎么知道自己是不是活动的呢?
2 怎么通过一个View通知其他的View更新呢?还有问一下,如果要使通过某个CView的OnLButtonDown通知其他CView进行更新的话,下面的这个方法可以么?void CMy3DView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
this->GetDocument()->UpdateAllViews();
CView::OnLButtonDown(nFlags, point);
}
2.AfxGetMainWnd()->MDIGetActive()->GetActiveView()==this(适用一个DOC只有一个VIEW)
3.需要从Doc Template枚举所有Doc,然后调用每一个Doc的UpdateAllViews
4.这个方法不可以,这个只能更新跟当前Doc相关的所有View.
你说的只有一个View是什么意思呢?我昨天在 OnMouseMove中加了this->GetDocument()->UpdateAllViews(NULL);结果整个屏幕都在更新,刷刷的2
你说的枚举所有的Doc是怎么实现的呢?
2.void GetAllDocs(const CRuntimeClass* pClass,DOCCALLBACK lpfnMethod,DWORD dwData=NULL)
{
POSITION pos = theApp.GetFirstDocTemplatePosition();
CDocTemplate *pDocTemplate;
while (pos)
{
pDocTemplate = theApp.GetNextDocTemplate(pos);
if(pDocTemplate)
{
POSITION pos1 = pDocTemplate->GetFirstDocPosition();
while(pos1)
{
CDocument *pDoc1 = pDocTemplate->GetNextDoc(pos1);
if(pDoc1 && pDoc1->IsKindOf(pClass) && lpfnMethod)
{
if(lpfnMethod(pDoc1,dwData))
return;
}
}
}
}
}BOOL CALLBACK BackgoundChanged(CDocument* pDoc,DWORD dwData)
{
CxxxViewerDoc *pDoc1 = (CxxxViewerDoc*)pDoc;
pDoc1->ReDraw(TRUE);
return FALSE;
}LRESULT CMainFrame::OnBackgroundColorChanged(WPARAM wParam,LPARAM lParam)
{
GetAllDocs(RUNTIME_CLASS(CxxxViewerDoc),BackgoundChanged);
return 0L;
}