using MFC/calling an MFC dll- in a Win32 project
Posted on 1997-06-09
Can I use MFC without the Application framework.
I have an MFC ODBC DLL that exports some C-Style APIs that expects MFC objects (specifically, CTypedPtrArray<CObArray, CMyNonODBCClass* and CString) as its parameters.
But now the catch is that the application that will be using this DLL is a Win32 Non-MFC Application, built with the same version of Visual C++ (5.0).
Three solutions come to my mind.
1. Changing some settings in the Non-MFC Application to make it use MFC.
2. Porting the Application to MFC. It would require significant effort.
3. Changing my DLL to only export APIs that do not require any MFC stuff.
Although this requires some effort, it would be much less than #2.
I found out that option 1 is in fact quite trivial.
In the non-MFC Win32 application, I included <afx.h and <afxtempl.h and
then linked to MFC42D.lib
However, I'm still stuck trying to get rid of these warnings.
blah.h(51) : warning C4275: non dll-interface class 'CObject' used as base for dll-interface class 'CBlah'
blah.h(61) : warning C4251: 'm_LastName' : class 'CString' needs to have dll-interface to be used by clients of class 'CBlah'
CBlah is my class derived from CObject and defined in the DLL. I built the DLL project as an MFC project, dynamically linked to MFC, withDatabase support.
Can someone please comment on this, and suggest the best way to approach