Hi
1-) I opened a SDI project:
2-) Added a view (CLeft) and a Static Splitter:Code:pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CTRYDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CTRYView));
3-) In CTRYView LBUTTONDOWN handler:Code:m_wndSpliiter.CreateStatic(this, 2, 1); m_wndSpliiter.CreateView(0, 0, RUNTIME_CLASS(CLeft), CSize(100, 100), pContext); m_wndSpliiter.CreateView(1, 0, RUNTIME_CLASS(CTRYView), CSize(100, 100), pContext);
[code]
GetDocument()->m_Point = point;
GetDocument()->UpdateAllViews(NULL);
[code]
4-)In CLeft.h
and:Code:#ifndef _DEBUG // debug version in TRYView.cpp inline CTRYDoc* CTRYView::GetDocument() const { return reinterpret_cast<CTRYDoc*>(m_pDocument); } #endif
I didn't call AddView for CLeft, but when i clicked on CTRYView and as seemed, it calls UpdateAllView(NULL) and it updates CLeftView too. But there is no connection.Code:void CLeft::OnDraw(CDC* pDC) { CDocument* pDoc = this->GetDocument(); // TODO: add draw code here pDC->Ellipse( GetDocument()->m_Point.x - 10, GetDocument()->m_Point.y - 10, GetDocument()->m_Point.x + 10, GetDocument()->m_Point.y + 10); }
How is that possible? How does doc knows another view is exist?


Reply With Quote
Victor Nijegorodov 