Re: Threading problem
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:uftuoyGoGHA.4800@TK2MSFTNGP04.phx.gbl...
Eric Margheim wrote:
What should I intercept to prevent the CFormView from closing as Joe
suggested? I'm already catching OnDestroy but I'm guess that's too
late, or is it?
Sorry I just realized you mentioned the CMainFrame stuff in the other
reply. I'd like to handle this at the form view level for simplicity sake
if possible. If I have to go with the CMainFrame route I'll need to put
in some extra code to recognize the particular view type that needs this
checking. Not that difficult but a little more work and harder for
someone else to troubleshoot.
Instead of recognizing a particular view type, you might consider using
UpdateAllViews. It passes a "hint" value that you can define the meaning
of to every view.
Cool. I am about to test some new code. I was already trapping OnClose in
my CMainFrame class which is a Stingray SECWorkbook derivation.
I'm basically doing the following:
pSheet = (CPrismWorksheet*) GetActiveFrame();
if (pSheet)
{
if (pSheet->GetActiveView()->IsKindOf(RUNTIME_CLASS(CPrismFormView)))
{
CPrismFormView *pView = (CPrismFormView*) pSheet->GetActiveView();
if (pView->GetActiveThreadCount() > 0)
{
if (!pView->IsClosing())
{
pView->SetClosing();
pView->ShowWindow(SW_HIDE);
}
}
else if (pView->IsClosing() && pSheet->GetStyle())
pSheet->GetActiveDocument()->OnCloseDocument();
}
}
In my CFormView I send a message to the parent to close the frame when all
threads are done. Cross fingers... I'm off to debugging.