Displaying a dialog resource from a different DLL

2019-09-21 19:57发布

问题:

I have a Win32 resource DLL (No MFC), which has a dialog in it.

I can load the Win32 dll using LoadLibrary from the MFC application.

After loading the DLL, how do I bring up the dialog to show it to the user?

I Would appreciate if someone can share the code to do this.

I remember using AfxGetResourceHandle to do this kind of stuff, but don't remember it now.

回答1:

The basic steps are:

  1. LoadLibrary (as you have done)
  2. FindResource (gives you an HRSRC)
  3. LoadResource (gives you an HGLOBAL)
  4. LockResource (gives you an LPVOID which you can cast to LPCDLGTEMPLATE)
  5. CreateDialogIndirectParam (creates the dialog)