HELP! MFC DLL can't do messages.....
David Little -- dlittle@communique.net
Saturday, September 28, 1996
Environment: Win95, VC++ 4.1, PS4.0
I am writing a DLL using MFC, and plan to call it from PS FORTRAN. I =
exported this function from the DLL:
BOOL __stdcall DISPLAYABOUTDIALOG(int* Parent)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
HWND hWndParent =3D (HWND)(*Parent);
TRY
{
CAboutDlg dlg(CWnd::FromHandle(hWndParent));
if (dlg.DoModal() !=3D IDOK)
return FALSE;
}
CATCH_ALL(e)
{
// a failure caused an exception.
return FALSE;
}
END_CATCH_ALL
return TRUE;
}
The CAboutDlg is generated by the ClassWizard, with no changes. When I =
call this function, the about box paints, then I get an assert here:
// phase2: pump messages while available
do
{
ASSERT(ContinueModal());
// pump message, but quit on WM_QUIT
if (!AfxGetThread()->PumpMessage()) <=3D=3D=3D ASSERT HERE..
{
AfxPostQuitMessage(0);
return -1;
}
because AfxGetThread() returns a null, and therefore can't handle =
messages...
HELP!
Thanks!
David
Shanku Niyogi -- shanku@accent.net
Monday, September 30, 1996
>From: David Little
>To: 'mfc-l@netcom.com'
>Subject: HELP! MFC DLL can't do messages.....
>Date: Saturday, September 28, 1996 10:05 PM
>
>
>Environment: Win95, VC++ 4.1, PS4.0
>
>I am writing a DLL using MFC, and plan to call it from PS FORTRAN. I
>exported this function from the DLL:
>
>....
>
>
>because AfxGetThread() returns a null, and therefore can't handle
messages...
David, the main problem is that MFC has not initialized a CWinApp-type
object in the DLL. To do this, you need to compile the DLL to statically
link MFC - the _USRDLL define, and include a CWinApp derived object
in your app.
This would not have been a problem in MFC 2.0, but MFC 4.0 implements
all modal dialogs as modeless dialogs with its own message loop.
For details see MFC Technical Note 11.
Regards,
Shanku.
=======================================================================
Shanku S. Niyogi
shanku@accent.net
Etobicoke, Ontario, Canada
David Little -- dlittle@communique.net
Thursday, October 03, 1996
>David, the main problem is that MFC has not initialized a CWinApp-type
>object in the DLL. To do this, you need to compile the DLL to =
statically
>link MFC - the _USRDLL define, and include a CWinApp derived object
>in your app.
>
>This would not have been a problem in MFC 2.0, but MFC 4.0 implements
>all modal dialogs as modeless dialogs with its own message loop.=20
>
>For details see MFC Technical Note 11.
I do have a CWinApp derived object in my DLL, and I read TN11. I also =
have read through DLLTRACE and DLLHUSK, neither of which really helps =
much. DLLTRACE is the closest that I can come to what I want, but it =
forces the calling app (.EXE) to call PreTranslateMessage and OnIdle in =
the DLL. I don't even have a message loop (at least easily) in my =
FORTRAN QuickWin app. I made my modal dialogs work using the =
old-fashioned way of DialogBox(....) and my own message loop, but that =
doesn't help the modeless ones...
Still looking for ideas! Thanks!
David
----------
From: Shanku Niyogi[SMTP:shanku@accent.net]
Sent: Monday, September 30, 1996 10:27 AM
To: mfc-l@netcom.com
Subject: Re: HELP! MFC DLL can't do messages.....
>From: David Little
>To: 'mfc-l@netcom.com'
>Subject: HELP! MFC DLL can't do messages.....
>Date: Saturday, September 28, 1996 10:05 PM
>
>
>Environment: Win95, VC++ 4.1, PS4.0
>
>I am writing a DLL using MFC, and plan to call it from PS FORTRAN. I
>exported this function from the DLL:
>
>....
>
>
>because AfxGetThread() returns a null, and therefore can't handle
messages...
David, the main problem is that MFC has not initialized a CWinApp-type
object in the DLL. To do this, you need to compile the DLL to statically
link MFC - the _USRDLL define, and include a CWinApp derived object
in your app.
This would not have been a problem in MFC 2.0, but MFC 4.0 implements
all modal dialogs as modeless dialogs with its own message loop.=20
For details see MFC Technical Note 11.
Regards,
Shanku.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Shanku S. Niyogi =20
shanku@accent.net
Etobicoke, Ontario, Canada
| Вернуться в корень Архива
|