MFC Dialog in Static Library
-
Hi, I have a MFC dialog that I want to be in a static library. When it is in the static library and I call DoModal on it, the FindResource comes back with 0.
if (m_lpszTemplateName != NULL) { hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG); // Works HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG); // Fails hDialogTemplate = LoadResource(hInst, hResource); // Obviously fails... }
Is it possible to have a dialog defined in static library with MFC support? I should point out that made sure that all the resource identifiers are out of the range of all other identifiers in the program (ie, 5000+) Sincerly, Clint Singer -
Hi, I have a MFC dialog that I want to be in a static library. When it is in the static library and I call DoModal on it, the FindResource comes back with 0.
if (m_lpszTemplateName != NULL) { hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG); // Works HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG); // Fails hDialogTemplate = LoadResource(hInst, hResource); // Obviously fails... }
Is it possible to have a dialog defined in static library with MFC support? I should point out that made sure that all the resource identifiers are out of the range of all other identifiers in the program (ie, 5000+) Sincerly, Clint Singerclintsinger wrote:
Is it possible to have a dialog defined in static library with MFC support?
Yes. But since you can't link resource templates into static libraries, you'll need to remember to do so in the app that uses them. For instance:
- Clint.exe links with ClintLib.lib, and has resources specified in Clint.rc
- ClintLib.lib contains class for dialog, template for dialog is defined in ClintLib.rc
- Clint.rc must
#include
ClintLib.rc in order for those resources to be available at runtime.
-
clintsinger wrote:
Is it possible to have a dialog defined in static library with MFC support?
Yes. But since you can't link resource templates into static libraries, you'll need to remember to do so in the app that uses them. For instance:
- Clint.exe links with ClintLib.lib, and has resources specified in Clint.rc
- ClintLib.lib contains class for dialog, template for dialog is defined in ClintLib.rc
- Clint.rc must
#include
ClintLib.rc in order for those resources to be available at runtime.
Thank you. It worked! Cheers, Clint