Re: _AFX_THREAD_STATE ?
David Ching schrieb:
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:m2j7j4t1ntgf83pkn65671p869ml8bmtf4@4ax.com...
Key here is that if you create code that uses undocumented and
outside-the-scope-of-user-programming techniques, the next release of MFC
could well break
your app, and you will have to figure it out all over again. This is a
dangerous place to be.
That would be true, were MFC still evolving, but the fact is it is as dead
as Latin is, at least regarding implementations for things such as this.
Still, I agree undocumented stuff should be avoid if there is a documented
alternative.
If there *is* a documented alternative, i'd use it. But the key here
is the following:
if you do a..
CMyDialog* pDlg = new CMyDialog;
pDlg->DoModal();
pDlg->Create();
pDlg->Modalize()
with...
void CMyDialog::Modalize()
{
m_nFlags |= WF_CONTINUEMODAL;
if (m_nFlags & WF_CONTINUEMODAL)
{
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
}
it works as expected (displaying the dialog twice in modal mode), and
now i want to get rid of that DoModal(), so i have to somehow
implement the hooking that mfc does in DoModal() without calling
DoModal(). Of cource, this would be much more easier if m$ had decided
to put all the common code of Create() and DoModal() in another
function instead of writing nearly-the-same twice;-/
If i understand what i see, they use the Computer-Based-Training-Hook
(to get *all* messages?) to hook mfc into windows. And they have some
ASSERTS checking if the hwnd in DoModal is null ... but that is pretty
stupid because without checking and instead just loading the resources
if they're not already loaded you just not only get the same
behaviour, you also can "modalize" modeless dialogs. In DoModal, they
create a modeless dialog and make it modal - exactly what i want minus
the fact that i cant overload DoModal() and jump into CDialog::DoModal
()::LineWhatever! (If you jump over some branches with the debugger
you can see this happen). The problem is: those brances nest in some
functions not overloadable or even simply callable.