Hello Judy, yes, thank you for the suggestion. I actually did go that route using the DocTemplate to find all the views that I needed to check before closing. I chose this method because I also have multiple types of documents in the app - here is the code: forgive the mess, I'm self-taught :-O
void CMainFrame::OnClose()
{
#ifdef _USE_CMC6INVOICE_THREAD_
POSITION pos, posView;
pos = theApp.m\_pCmc6InvoiceDocTemplate->GetFirstDocPosition();
while(pos != NULL)
{
CDocument \*pDoc = theApp.m\_pCmc6InvoiceDocTemplate->GetNextDoc(pos);
if(pDoc!= NULL)
{
posView = pDoc->GetFirstViewPosition();
while(posView != NULL)
{
CView \* pView = pDoc->GetNextView(posView);
if(pView->IsKindOf(RUNTIME\_CLASS(CCMC6InvoiceView)))
{
CCMC6InvoiceView \* pInv = (CCMC6InvoiceView \*) pView;
if(pInv->m\_clsInvoice->m\_pThread != NULL)
{
if(pInv->m\_clsInvoice->m\_pThread->GetActivityStatus() == THREAD\_NOTPREPARED\_TO\_TERMINATE)
{
TRACE("Mainframe: OnClose() ->CMC6InvoiceView Thread Busy, Can't close yet...\\n");
Sleep(200);
PostMessage(WM\_CLOSE);
return;
}
}
}
}
}
}
#endif
#ifdef _USE_BACKGROUND_THREAD_
DWORD dwExitCode;
m_pBackThread->Stop(dwExitCode, 0);
if(m_pBackThread->GetActivityStatus() == THREAD_NOTPREPARED_TO_TERMINATE)
{
TRACE("Mainframe: OnClose() ->BackProcess Thread Busy, Can't close yet...\n");
Sleep(200);
PostMessage(WM_CLOSE);
}
else
{
TRACE("Mainframe: OnClose() ->Can close now\n");
m_pBackThread->Stop(dwExitCode);
// Save the current state for tool bars and menus.
SaveCommandBars(\_T("CommandBars"));
// Save the current state for docking panes.
CXTPDockingPaneLayout layoutNormal(&m\_paneManager);
m\_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(\_T("NormalLayout"));
CMDIFrameWnd::OnClose();
}
#else
// Save the current state for tool bars and menus.
SaveCommandBars(_T("CommandBars"));
// Save the current state for docking panes.
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
#endif
}