Click here to Skip to main content
15,894,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Load Dialog From a Resource DLL Pin
goldenrose911-Jan-11 4:49
goldenrose911-Jan-11 4:49 
AnswerRe: Load Dialog From a Resource DLL Pin
Andrew Brock11-Jan-11 5:09
Andrew Brock11-Jan-11 5:09 
Firstly you need a message handler, essentialy the same as your main message handler, usually WndProc
BOOL CALLBACK DlgProc(HWND hDlg, UINT nMessage, WPARAM wParam, LPARAM lParam) {
	switch (nMessage) { 
		case WM_INITDIALOG: 
			//This is where you do all your initialisation. This is the first place after all the controls have been created, so you can use GetDlgItem()
			return TRUE; 
 
		case WM_COMMAND:
			//This is the same as it is in the WndProc, handle button clicks, etc...
			switch (LOWORD(wParam)) {
				case IDOK: //This is usually the OK or Done button
					return TRUE; 
 
				case IDCANCEL: //This is usually the Close or Cancel button
					DestroyWindow(hDlg); //close the dialog
					return TRUE;
			}
			break;
            } 
    } 
    return FALSE; 
} 


Then you just need to use that as the "procedure function"
void DisplayDynamicDialog(HWND hParent) {
	HMODULE hModule = LoadLibrary("Resources.dll");
	if(hModule != NULL) {
		hDialog = CreateDialog(hModule, MAKEINTRESOURCE(ID_DIALOG), hParent, (DLGPROC)DlgProc); 
		ShowWindow(hDialog, SW_SHOW);
		FreeLibrary(hModule); //This might need to be called later, after the dialog has been closed since it is modeless
	}
}


Finally, just to reiterate what Thaddeus Jones said, the ID you supply needs to be the ID defined in the DLL, not the ID defined in the exe, hence the resource.h that you include needs to be from the dll. To avoid confusion, I recommend using quoted string names instead.
GeneralRe: Load Dialog From a Resource DLL Pin
goldenrose911-Jan-11 19:53
goldenrose911-Jan-11 19:53 
AnswerRe: Load Dialog From a Resource DLL Pin
Abhi Lahare11-Jan-11 5:19
Abhi Lahare11-Jan-11 5:19 
AnswerRe: Load Dialog From a Resource DLL Pin
Richard MacCutchan11-Jan-11 5:58
mveRichard MacCutchan11-Jan-11 5:58 
GeneralRe: Load Dialog From a Resource DLL Pin
goldenrose911-Jan-11 16:40
goldenrose911-Jan-11 16:40 
GeneralRe: Load Dialog From a Resource DLL Pin
Richard MacCutchan11-Jan-11 21:13
mveRichard MacCutchan11-Jan-11 21:13 
GeneralRe: Load Dialog From a Resource DLL Pin
goldenrose912-Jan-11 4:27
goldenrose912-Jan-11 4:27 
QuestionActivex control in linux Pin
Sakhalean11-Jan-11 2:42
Sakhalean11-Jan-11 2:42 
AnswerRe: Activex control in linux Pin
CPallini11-Jan-11 2:49
mveCPallini11-Jan-11 2:49 
GeneralRe: Activex control in linux Pin
Sakhalean11-Jan-11 3:01
Sakhalean11-Jan-11 3:01 
AnswerRe: Activex control in linux Pin
Cool_Dev11-Jan-11 2:50
Cool_Dev11-Jan-11 2:50 
QuestionListing Unused Variables Pin
softwaremonkey11-Jan-11 2:31
softwaremonkey11-Jan-11 2:31 
AnswerRe: Listing Unused Variables Pin
Maximilien11-Jan-11 2:41
Maximilien11-Jan-11 2:41 
GeneralRe: Listing Unused Variables Pin
Luc Pattyn11-Jan-11 3:12
sitebuilderLuc Pattyn11-Jan-11 3:12 
GeneralRe: Listing Unused Variables Pin
Maximilien11-Jan-11 6:34
Maximilien11-Jan-11 6:34 
GeneralRe: Listing Unused Variables Pin
Luc Pattyn11-Jan-11 6:46
sitebuilderLuc Pattyn11-Jan-11 6:46 
AnswerRe: Listing Unused Variables Pin
Cool_Dev11-Jan-11 2:47
Cool_Dev11-Jan-11 2:47 
GeneralRe: Listing Unused Variables Pin
softwaremonkey11-Jan-11 3:04
softwaremonkey11-Jan-11 3:04 

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.