I've recently came across a DLL (github) that uses MFC dialogs (it imports "afxdlg.h" and calls CFileDialog, for example) and appears to statically link to MFC, but doesn't have a class based on CWinApp. I'm somewhat confused: is it a MFC DLL or not? How come it doesn't have CWinApp?
Rephrased: In a Win32 DLL I use some MFC classes (e.g. I include "afxdlgs.h" and use CFileDialog) and link MFC statically. There's no DllMain. Will the final DLL have DllMain from Win32 or from MFC?
If it picks the MFC version, then another question: What is the simplest way to make a Win32 DLL with DllMain (no threads) to use MFC DllMain? Is the following correct?
#include "afx.h" /* correct? */
class MyDll: public CWinApp
{
public:
/* do I need constructor and destructor here? */
virtual BOOL InitInstance();
virtual BOOL ExitInstance();
} theDll;
BOOL
MyDLL::InitInstance()
{
CWinApp::InitInstance();
/* code from old DllMain, DLL_PROCESS_ATTACH.
For hInst use theDll.m_hInstance */
return TRUE;
}
BOOL
MyDLL::ExitInstance()
{
/* code from old DllMain, DLL_PROCESS_DETACH */
return CWinApp::ExitInstance();
}