As already noted by _Superman_, use
GetDocument()
to get the data from your document class.
OnDraw()
of views is rather seldom used. If your view is derived from a Windows control or contains multiple controls, call the control specific update functions like
SetWindowText()
,
SetItem()
from the
OnUpdate()
function of your view. Use
OnInitialUpdate()
to initiliaze the controls after the view has been created like
OnInitDialog()
with dialogs.
A simple example:
void CMyView::OnInitialUpdate()
{
m_editText1.SetLimitText(255);
CView::OnInitialUpdate();
}
void CMyView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
m_editText1.SetWindowText(GetDocument()->GetText1());
}
The
lParam
and
pHint
parameters can be used to update only specific parts of your view. To trigger an update, use
CDocument::UpdateAllViews()
.