加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

visual-c – 将资源构建到DLL中以供重用,MFC / VC

发布时间:2020-12-16 09:23:38 所属栏目:百科 来源:网络整理
导读:例如,我想构建一个DLL,导出一个名为ShowDialog的函数,该函数显示一个对话框并更改其中一个对话框按钮中的文本.对话框和所有其他资源应捆绑在DLL中. 我做了一个快速测试,当DLL尝试使用某个控件ID的GetDlgItem()时,它会返回一个空指针.我假设在这种情况下需要
例如,我想构建一个DLL,导出一个名为ShowDialog的函数,该函数显示一个对话框并更改其中一个对话框按钮中的文本.对话框和所有其他资源应捆绑在DLL中.

我做了一个快速测试,当DLL尝试使用某个控件ID的GetDlgItem()时,它会返回一个空指针.我假设在这种情况下需要更多步骤来正确处理资源.

解决方法

从 MSDN开始:

By default,MFC uses the resource
handle of the main application to load
the resource template. If you have an
exported function in a DLL,such as
one that launches a dialog box in the
DLL,this template is actually stored
in the DLL module. You need to switch
the module state for the correct
handle to be used. You can do this by
adding the following code to the
beginning of the function:

AFX_MANAGE_STATE(AfxGetStaticModuleState());

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读