
Problem using MFC modal dialog with long animation refresh
Hi,
I'm using OpenGL, a SetTimer call and OnTimer method to control an
animation in a MFC MDI program. It all seems to work great until the
size of the models I am displaying cause the refresh rate to exceed
the interval between the OnTimer calls. I don't mind if the animation
slows down at that point (which it does) since this is an engineering
application. The problem is that when I try to bring up a modal
window with a CDialog::DoModal() call while it is animating, the
dialog never appears but the dialog handler thread continues to
execute and wait for input. My animation contiues to run but I can no
longer get the focus back from the dialog and can't interact with the
UI.
I suspect the problem is that my OnTimer routine issues redraw events
rather than actually redrawing the program. If this is the case, can
someone suggest a better way to handle the animation timing in a MDI
program where all of the views and models animate together?
Here is some of my code:
void CMainFrame::OnTimer(UINT nIDEvent)
{ CObList docList;
CNomadDoc *doc;
POSITION pos;
theApp.GetDocumentList(&docList);
if (!docList.IsEmpty())
{
doc=(CNomadDoc *)docList.GetHead();
pos=docList.GetHeadPosition();
while(pos)
{
doc->AdvanceOneFrame(m_viewDialog.m_fAmplitude,
DEFAULT_FPS/m_viewDialog.m_fPrefOscilationTime);
doc->UpdateAllViews(NULL);
doc=(CNomadDoc *)docList.GetNext(pos);
}
}
CMDIFrameWnd::OnTimer(nIDEvent);
Quote:
}
// this routine is called from the user menu
void CMainFrame::OnViewOptions()
{ int createVal;
createVal=m_viewDialog.DoModal(); // hangs in this call
if(createVal==IDOK)
{
renderSettings.bAntialiasing=m_viewDialog.m_bLineSmoothing;
renderSettings.m_fLineWidth=m_viewDialog.m_fLineWidth;
CNomadDoc *doc=(CNomadDoc *)GetMDIActiveDocument();
if (doc!=NULL)
doc->UpdateAllViews(NULL);
}
Quote:
}