由资源冲突造成的,可以这样解决
在DllMain函数所在的cpp文件中定义一个全局变量
HINSTANCE g_hInstance;
在DllMain函数的
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("DOCUSERTOOLS.DLL Initializing!/n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(DocUserToolsDLL, hInstance))
return 0;
这几句之后加入
g_hInstance = hInstance;
然后在你的DLL导出函数所在的cpp文件中加入如下定义
extern HINSTANCE g_hInstance;
即使用上面所定义的全局变量
然后加入如下宏定义
#define BEGININSTANCE HINSTANCE hOldInstance = ::AfxGetResourceHandle();::AfxSetResourceHandle(g_hInstance);
#define ENDINSTANCE ::AfxSetResourceHandle(hOldInstance);
将这几句
theApp.pMyDlg = new CMyDlg(pParentWnd);
theApp.pMyDlg->Create(IDD_MYDLG,pParentWnd);
theApp.pMyDlg->ShowWindow(SW_SHOW);
改为这样
BEGININSTANCE
theApp.pMyDlg = new CMyDlg(pParentWnd);
theApp.pMyDlg->Create(IDD_MYDLG,pParentWnd);
theApp.pMyDlg->ShowWindow(SW_SHOW);
ENDINSTANCE
dll创建无模式对话框
最新推荐文章于 2021-03-23 20:46:48 发布