I am new to programming C++ with MFC, I do not know, how to get
started.
Here goes...You may have all ready taken some of these measures.
One way to accomplish this is to create a header file that can be used to direct the exporting and importing of your code. For example, in the header file of the dialog class, if you code something like,
#ifdef DllImpExp
#undef DllImpExp
#endif
#ifdef SomeDefineWeWillUseToControlImportExport
#define DllImpExp __declspec( dllexport )
#else
#define DllImpExp __declspec( dllimport )
#endif
the same header can be used to export and import the dialog class. The declaration of your dialog class should then specify “DllImpExp”. For example,
class DllImpExp SomeClass : public SomeBaseClass
In the project that creates the dll, you would add a preprocessor define for “SomeDefineWeWillUseToControlImportExport”. This forces the compiler to export your dialog class code. At this point, your dialog class is ready to be consumed by another object.
Since you’ve exported your class, your dll project has created an import lib with the same name. That lib is used as input into the other projects in which you’d like to use the dialog code. There are several ways to do it, but, simply listing that lib as input to the linker of the project that wants to use it should work. Additionally, you must not define "SomeDefineWeWillUseToControlImportExport" in the project, so that the class will be imported.
As for accessing your dialog resource in the dll, you’ll need to take some special steps. Before you try to display the dialog, you’ll need to point the current resource handle to the dll that contains the resource. Your app uses a single handle to know where to load resources (ie. dialogs). Since you have dialogs in one or more locations, you need to use two functions to manage that. You'll want to use AfxGetResourceHandle to save the current default handle that is used to load resources. Then, look at AfxSetResourceHandle to change the default handle to load from your dll. And, don’t forget to restore the saved handle when you are done working with the dialog from your dll. Failure to do that will likely result in some strange mfc asserts.