Click here to Skip to main content
15,919,479 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionmoving a mfc app into a dll Pin
DevMentor.org21-Jul-07 23:11
DevMentor.org21-Jul-07 23:11 
AnswerRe: moving a mfc app into a dll Pin
#realJSOP22-Jul-07 0:16
professional#realJSOP22-Jul-07 0:16 
GeneralRe: moving a mfc app into a dll Pin
DevMentor.org22-Jul-07 8:32
DevMentor.org22-Jul-07 8:32 
AnswerRe: moving a mfc app into a dll Pin
Mark Salsbery22-Jul-07 9:15
Mark Salsbery22-Jul-07 9:15 
GeneralRe: moving a mfc app into a dll Pin
DevMentor.org22-Jul-07 9:35
DevMentor.org22-Jul-07 9:35 
GeneralRe: moving a mfc app into a dll Pin
Mark Salsbery22-Jul-07 9:39
Mark Salsbery22-Jul-07 9:39 
GeneralRe: moving a mfc app into a dll Pin
DevMentor.org22-Jul-07 9:55
DevMentor.org22-Jul-07 9:55 
GeneralRe: moving a mfc app into a dll Pin
Mark Salsbery22-Jul-07 10:05
Mark Salsbery22-Jul-07 10:05 
I'll rip the relevent portions for you:

"A regular DLL, statically linked to MFC, has the following requirements:
This type of DLL must instantiate a class derived from CWinApp.
This type of DLL uses the DllMain provided by MFC. Place all DLL-specific initialization code in
the InitInstance member function and termination code in ExitInstance as in a normal MFC
application.
Even though the term USRDLL is obsolete, you must still define "_USRDLL" on the compiler command
line. This definition determines which declarations is pulled in from the MFC header files
"

"Regular DLLs must have a CWinApp-derived class and a single object of that application class, as
does an MFC application. However, the CWinApp object of the DLL does not have a main message
pump, as does the CWinApp object of an application.

Note that the CWinApp::Run mechanism does not apply to a DLL, because the application owns the
main message pump. If the DLL opens modeless dialogs or has a main frame window of its own, the
application's main message pump must call a routine exported by the DLL that in turn calls the
CWinApp::PreTranslateMessage member function of the DLL's application object.
"


"A regular DLL, dynamically linked to MFC has the following requirements:
These DLLs are compiled with _AFXDLL defined, just like an executable that is dynamically linked
to the MFC DLL. But _USRDLL is also defined, just like a regular DLL that is statically linked to
MFC.

This type of DLL must instantiate a CWinApp-derived class.
This type of DLL uses the DllMain provided by MFC. Place all DLL-specific initialization code in
the InitInstance member function and termination code in ExitInstance as in a normal MFC
application.

Because this kind of DLL uses the dynamic-link library version of MFC, you must explicitly set
the current module state to the one for the DLL. To do this, use the AFX_MANAGE_STATE macro at
the beginning of every function exported from the DLL.

Regular DLLs must have a CWinApp-derived class and a single object of that application class, as
does an MFC application. However, the CWinApp object of the DLL does not have a main message
pump, as does the CWinApp object of an application.

Note that the CWinApp::Run mechanism does not apply to a DLL, because the application owns the
main message pump. If your DLL brings up modeless dialogs or has a main frame window of its own,
your application's main message pump must call a DLL-exported routine that calls
CWinApp::PreTranslateMessage.

Place all DLL-specific initialization in the CWinApp::InitInstance member function as in a normal
MFC application. The CWinApp::ExitInstance member function of your CWinApp derived class is
called from the MFC provided DllMain function before the DLL is unloaded.
"

Is that better? Poke tongue | ;-P

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: moving a mfc app into a dll Pin
DevMentor.org22-Jul-07 10:17
DevMentor.org22-Jul-07 10:17 
AnswerRe: moving a mfc app into a dll Pin
DevMentor.org23-Jul-07 10:39
DevMentor.org23-Jul-07 10:39 
Questionhow to get Cwnd object Pin
Max++21-Jul-07 21:46
Max++21-Jul-07 21:46 
AnswerRe: how to get Cwnd object Pin
#realJSOP22-Jul-07 0:27
professional#realJSOP22-Jul-07 0:27 
AnswerRe: how to get Cwnd object Pin
ThatsAlok22-Jul-07 17:56
ThatsAlok22-Jul-07 17:56 
AnswerRe: how to get Cwnd object Pin
Hamid_RT31-Jul-07 19:48
Hamid_RT31-Jul-07 19:48 
Questionerror C2061: syntax error : identifier 'search' Pin
jt900021-Jul-07 18:31
jt900021-Jul-07 18:31 
AnswerRe: error C2061: syntax error : identifier 'search' Pin
Abhijeet Pathak22-Jul-07 4:41
Abhijeet Pathak22-Jul-07 4:41 
QuestionHow to get all the export functions of a dll Pin
kcynic21-Jul-07 17:37
kcynic21-Jul-07 17:37 
AnswerRe: How to get all the export functions of a dll Pin
Michael Dunn21-Jul-07 18:00
sitebuilderMichael Dunn21-Jul-07 18:00 
GeneralRe: How to get all the export functions of a dll Pin
kcynic21-Jul-07 18:53
kcynic21-Jul-07 18:53 
AnswerRe: How to get all the export functions of a dll Pin
DevMentor.org21-Jul-07 23:48
DevMentor.org21-Jul-07 23:48 
AnswerRe: How to get all the export functions of a dll Pin
ThatsAlok22-Jul-07 17:56
ThatsAlok22-Jul-07 17:56 
AnswerRe: How to get all the export functions of a dll Pin
kcynic22-Jul-07 18:23
kcynic22-Jul-07 18:23 
QuestionDon't understand what's required in order to use unmgd c++ class in c# app - help? Pin
sherifffruitfly21-Jul-07 10:32
sherifffruitfly21-Jul-07 10:32 
AnswerRe: Don't understand what's required in order to use unmgd c++ class in c# app - help? Pin
Mark Salsbery21-Jul-07 10:51
Mark Salsbery21-Jul-07 10:51 
GeneralRe: Don't understand what's required in order to use unmgd c++ class in c# app - help? Pin
sherifffruitfly21-Jul-07 11:17
sherifffruitfly21-Jul-07 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.