Hi,
I am creating an sample learning application to create multiple active views at the same time in an SDI. The problem that i am facing is, though i have overridden the OnDraw in my second view class, my call to the SetModifiedFlag(true) and UpdateAllViews(), is not invoking the second views OnDraw(). I debugged into the UpdateAllviews and i could see my second view's OnUpdate is getting called successfully with all parameters 0. What is it that i am missing? please can any one help
Code looks something like this
CMainWnd::CMainWnd()
{
m_pSecondWnd = new CSecondaryWnd();
m_pSecondWnd->Create( 0, L"Second Window", WS_OVERLAPPEDWINDOW );
}
void CMainWnd::CreateNewView( CRuntimeClass* pView, CFrameWnd* pNewWnd, UINT ID)
{
CView* pNewView = NULL;
pNewView = (CView*)pView->CreateObject();
CCreateContext context;
context.m_pCurrentDoc = GetActiveDocument();
pNewView->Create( 0, 0, AFX_WS_DEFAULT_VIEW, rectDefault, pNewWnd, 1 , &context );
pNewView->OnInitialUpdate();
((CSecondaryWnd*)pNewWnd)->ShowWindow( SW_RESTORE );
pNewView->ShowWindow( SW_RESTORE );
pNewWnd->UpdateWindow();
}
void CMainWnd::OnTimer( UINT_PTR nIDEvent )
{
switch(nIDEvent)
{
case ONE_SECOND_TIMER:
{
CSampleDocument* pDoc = (CSampleDocument*)GetActiveDocument();
pDoc->SetModifiedFlag();
pDoc->UpdateAllViews( NULL );
break;
}
}
}
Sample View 2 class:
IMPLEMENT_DYNCREATE( CSampleView2, CView )
BEGIN_MESSAGE_MAP( CSampleView2, CView )
END_MESSAGE_MAP()
CSampleView2::CSampleView2()
{
}
CSampleView2::~CSampleView2()
{
}
void CSampleView2::OnDraw( CDC* pDc )
{
int a = 10;
pDc->TextOut( 100, 100, L"This", 5 );
}
Sample View 1 Class:
IMPLEMENT_DYNCREATE( CSampleView1, CView )
BEGIN_MESSAGE_MAP( CSampleView1, CView )
ON_COMMAND( ID_VIEW_CREATE, OnViewCreate )
END_MESSAGE_MAP()
CSampleView1::CSampleView1()
{
}
CSampleView1::~CSampleView1()
{
}
void CSampleView1::OnDraw( CDC* pDc )
{
pDc->TextOut( 100, 100, L"This", 5 );int a = 10;
}
What I have tried:
Debugged UpdateAllView and i could see while looping through the different views, my second view calss and it OnUpdate is getting called successfully.