Click here to Skip to main content
15,904,287 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Measure CRichEditCtrl height Pin
User 742933811-Jan-11 10:14
professionalUser 742933811-Jan-11 10:14 
GeneralRe: Measure CRichEditCtrl height Pin
Pavel Sokolov11-Jan-11 10:43
Pavel Sokolov11-Jan-11 10:43 
QuestionRe: Measure CRichEditCtrl height Pin
User 742933811-Jan-11 10:45
professionalUser 742933811-Jan-11 10:45 
AnswerRe: Measure CRichEditCtrl height Pin
Pavel Sokolov11-Jan-11 11:02
Pavel Sokolov11-Jan-11 11:02 
AnswerRe: Measure CRichEditCtrl height Pin
Pavel Sokolov11-Jan-11 11:39
Pavel Sokolov11-Jan-11 11:39 
QuestionRe: Measure CRichEditCtrl height Pin
David Crow11-Jan-11 9:08
David Crow11-Jan-11 9:08 
AnswerRe: Measure CRichEditCtrl height Pin
Pavel Sokolov11-Jan-11 10:07
Pavel Sokolov11-Jan-11 10:07 
GeneralRe: Measure CRichEditCtrl height Pin
Nikolay Denisov18-Feb-11 22:27
Nikolay Denisov18-Feb-11 22:27 
GeneralRe: Measure CRichEditCtrl height Pin
Pavel Sokolov18-Feb-11 22:41
Pavel Sokolov18-Feb-11 22:41 
GeneralRe: Measure CRichEditCtrl height Pin
Nikolay Denisov18-Feb-11 23:02
Nikolay Denisov18-Feb-11 23:02 
QuestionError concatinating file path and file name.... Pin
AmbiguousName11-Jan-11 4:27
AmbiguousName11-Jan-11 4:27 
AnswerRe: Error concatinating file path and file name.... Pin
Cedric Moonen11-Jan-11 4:42
Cedric Moonen11-Jan-11 4:42 
AnswerRe: Error concatinating file path and file name.... Pin
Luc Pattyn11-Jan-11 4:43
sitebuilderLuc Pattyn11-Jan-11 4:43 
AnswerRe: Error concatinating file path and file name.... Pin
Richard MacCutchan11-Jan-11 6:02
mveRichard MacCutchan11-Jan-11 6:02 
AnswerRe: Error concatinating file path and file name.... Pin
User 742933811-Jan-11 6:41
professionalUser 742933811-Jan-11 6:41 
GeneralRe: Error concatinating file path and file name.... Pin
XTAL25611-Jan-11 13:38
XTAL25611-Jan-11 13:38 
AnswerRe: Error concatinating file path and file name.... Pin
«_Superman_»11-Jan-11 6:44
professional«_Superman_»11-Jan-11 6:44 
QuestionLoad Dialog From a Resource DLL Pin
goldenrose911-Jan-11 3:31
goldenrose911-Jan-11 3:31 
QuestionRe: Load Dialog From a Resource DLL Pin
Cool_Dev11-Jan-11 3:49
Cool_Dev11-Jan-11 3:49 
AnswerRe: Load Dialog From a Resource DLL Pin
goldenrose911-Jan-11 4:46
goldenrose911-Jan-11 4:46 
GeneralRe: Load Dialog From a Resource DLL Pin
Cool_Dev11-Jan-11 16:23
Cool_Dev11-Jan-11 16:23 
GeneralRe: Load Dialog From a Resource DLL Pin
goldenrose911-Jan-11 16:43
goldenrose911-Jan-11 16:43 
AnswerRe: Load Dialog From a Resource DLL Pin
User 742933811-Jan-11 3:54
professionalUser 742933811-Jan-11 3:54 
GeneralRe: Load Dialog From a Resource DLL Pin
goldenrose911-Jan-11 4:53
goldenrose911-Jan-11 4:53 
GeneralRe: Load Dialog From a Resource DLL Pin
Andrew Brock11-Jan-11 4:46
Andrew Brock11-Jan-11 4:46 
If you are using MFC you can create an instance of the dialog class from the DLL. Be sure to use MFC with dynamic linking in both the exe and dll.
The way I did this in my project was:
In the DLL have
class MyDialog : public CDialog {
	//program this class as if it was part of the exe
}


Then an exported function to create and destroy the instance.
Because in C++ the return type and parameters make up the function name, we should use C for exporting functions, however we cannot create classes in C.
Any memory allocated from within a DLL should be deleted from within the DLL too, so we need a create and destroy function
The following will create an instance of the class and return it through a C function and delete it when you are finished with it.
//This function name is ?InternalGetDialog@@YAPEAXXZ if it was exported. Which is why we don't.
void *InternalGetDialog() {
	return new MyDialog();
}

//This function name is ?InternalDeleteDialog@@YAXPEAVCDialog@@@Z if it was exported. Which is why we don't.
//This is a generic function that will destroy any dialog created from this dll
void InternalDeleteDialog(void *pDlg) {
	CDialog *pDialog = (CDialog *)pDialog; //cast so that we call the destructor
	delete pDialog;
}

extern "C" {
	//This function name is GetDialog when importing
	__declspec(dllexport) void *GetDialog() {
		return InternalGetDialog();
	}
	//This function name is DeleteDialog when importing
	__declspec(dllexport) void DeleteDialog(void *pDialog) {
		InternalDeleteDialog(pDialog);
	}
}


Then in the exe that displays the dialog
typedef CDialog *(*GetDialogFunc)();
typedef CDialog *(*DeleteDialogFunc)();

void DisplayDynamicDialog() {
	HMODULE hModule = LoadLibrary("Resources.dll");
	if (hModule != NULL) {
		GetDialogFunc pGetDialogFunc = (GetDialogFunc)GetProcAddress(hModule, "GetDialog");
		DeleteDialogFunc pDeleteDialogFunc = (DeleteDialogFunc)GetProcAddress(hModule, "DeleteDialog");
		CDialog *pDialog = pGetDialogFunc();
		INT_PTR nRes = pDialog->DoModal();
		//check nRes, process what is on the dialog, ...
		pDeleteDialogFunc(pDialog);
		FreeLibrary(hModule);
	}
}

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.