Re: How to display Cdialog-derived control in MFC extension DLL
On Oct 8, 11:36 pm, "Scott McPhillips [MVP]" <org-dot-mvps-at-
scottmcp> wrote:
Look up AFX_MANAGE_STATE.
"ThirstyForKnowledge" <thirstyforknowle...@live.com> wrote in message
news:333594cd-e768-4fc4-b142-040124500434@8g2000hse.googlegroups.com...
Hi All,
This post follows another post which I have posted before in another
group without arriving at a suitable solution. The problem which I'm
about to write about and for which I seek your help really has to do
with something that I have experienced with respect to xll. Yet here
I won't dexcribe the problem in terms of the original xll project that
I built. Rather, I chose to create a mini-version of the that proble=
m
in terms of MFC extension dll --- that makes things simpler and devoid
of all the "extra noise" accompanied when creating an xll project.
Moreover, the one who finds the answer to the problem I'm about to
specify, would surely help me find a solution for the original
problem.
HERE IS THE PROBLEM:
I've created an MFC extnsion DLL project with the the "MFC
AppWizrd(dll)" in VC++ . In that project, I added a dialog through the
insert option in ResourceView, and following that I cretaed with the
Class Wizard a CDialog-based class that is realted to the just
mentioned added Dialog. The following is the declartion of the class
and its methods:
// MyDialog dialog
class MyDialog : public CDialog
{
// Construction
public:
MyDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(MyDialog)
enum { IDD = IDD_DIALOG1 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(MyDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV
support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(MyDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
When I cretae a function to display the dialog like the one just
below, I get an error message:
void DialogInterface()
{
DLG=new MyDialog();
DLG->DoModal();
}
The error message I'm prompted with takes place upon the code trying
to execute the DoModal() method. It is a Debug Assertion type of
error specifying line 22 in afxwin1.inl
Pleasse note that line 22 in afxwin1.inl is the middle line of th=
e
following function:
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
{ ASSERT(afxCurrentResourceHandle != NULL); //this is the line whe=
re
code fails
return afxCurrentResourceHandle; }
Also note that that function immediately above is called from within
the DoModal Method and the particular line that makes that call is:
HINSTANCE hInst = AfxGetResourceHandle();
IS THERE ANY VC++ GURU WHO CAN FIGURE OUT WHY DO I GET THE ASSERTION
ERROR WITHOUT GETTING THE DIALOG TO BE DISPLAYED. ANY HELP WILL BE
APPRECIATED.
THANKS
--
Scott McPhillips [VC++ MVP]- Hide quoted text -
- Show quoted text -
Thanks for your input. I considered using that macro in the past, but
I did not use it in the past because I had the impression that the
AFX_MANAGE_STATE is used only in regular dll, whereas I use the MFC
extension dll. I even read that Article ID: Q161589 of microsoft says
that that macro should not be used in MFC extension dlls.
At anyrate, I tried to create the following function:
extern "C" void PASCAL EXPORT DisplayDialog()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
MyDialog dialog;
dialog.DoModal();
}
After trying to compile I got a linking error (below). Any idea what
did I do wrong?
Many Thanks
mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already
defined in MFC_Dll_withDialog_model.obj
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined
in MFC_Dll_withDialog_model.obj
mfcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already
defined in MFC_Dll_withDialog_model.obj
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already
defined in MFC_Dll_withDialog_model.obj; second definition ignored
mfcs42d.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already
defined in MFC_Dll_withDialog_model.obj; second definition ignored
Creating library Debug/MFC_Dll_withDialog_model.lib and object
Debug/MFC_Dll_withDialog_model.exp
Debug/MFC_Dll_withDialog_model.dll : fatal error LNK1169: one or more
multiply defined symbols found