Able to Update Without AddView ??
Hi
1-) I opened a SDI project:
Code:
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTRYDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTRYView));
2-) Added a view (CLeft) and a Static Splitter:
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);
3-) In CTRYView LBUTTONDOWN handler:
[code]
GetDocument()->m_Point = point;
GetDocument()->UpdateAllViews(NULL);
[code]
4-)In CLeft.h
Code:
#ifndef _DEBUG // debug version in TRYView.cpp
inline CTRYDoc* CTRYView::GetDocument() const
{ return reinterpret_cast<CTRYDoc*>(m_pDocument); }
#endif
and:
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);
}
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.
How is that possible? How does doc knows another view is exist?
Re: Able to Update Without AddView ??
Have a look at CCreateContext structure in MSDN.
Note that you are passing CCreateContext pointer in while creating your Views inside a splitter.
Re: Able to Update Without AddView ??
OK. Thank you.
Understood.