Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLLs & Dialogs

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I’m trying to learn more about creating & using DLLs. I’ve been doing okay but have now hit a problem;
I’ve inserted a dialog into my DLL project and created a class to handle it via Class Wiz in the same way that I’ve done successfully a number of times when creating a simple .exe. The class itself is created without a problem and I’m able to access it from my app. however, when I execute DoModal nothing happens. I would expect the dialog to appear, but it doesn’t. I’ve spent a while now trying to guess what step I’m missing out but have gotten nowhere.
I’d be very grateful for any ideas anyone might have.
Cheers.
 
If it's the problem i thought, it is quite trichy.
Just test that:
In the function of your DLL where you want to display the dialog:

//Get DLL Handle
HMODULE hDLL = GetModuleHandle("MyDLL.dll");

// Get handle of the caller
HINSTANCE hEXE = AfxGetResourceHandle();

// Set that we use the dll resource for the rest of this code
AfxSetResourceHandle((HINSTANCE) hDLL);

CMyDlg dlg;
if( dlg.DoModal() != IDOK)
{
return;
}
// Set back resources on the caller
AfxSetResourceHandle(hEXE);

The problem as you see is that the dll use by default the exe resource and we have to tell that the resources to use is the dll ones.
 
Fantastic!!!
Got it working.
This has been bugging me for a week.
Thanks very much indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top