当前位置:网站首页>MFC implementation resources are implemented separately by DLL
MFC implementation resources are implemented separately by DLL
2022-04-23 05:19:00 【houxian1103】
summary
We are developing MFC In the project , If it's a project, it's ok , If we divide into different projects , And each project as Dll Provide , In this way, resources may be stored in each dynamic library , Very bad for management , So we think of resources as a single Dll Library provides .
resources Dll The implementation of the
Create resources Dll
Compile after creation , After compiling , It means that our project is OK , There is also a link option to set
Now we can add our own resources 、 Edit resource .
The call of the main program sets the resource dynamic library .
// CMultilingualDemoApp initialization
BOOL CMultilingualDemoApp::InitInstance()
{
// If one runs on Windows XP The application manifest on specifies to
// Use ComCtl32.dll edition 6 Or later to enable visualization ,
// You need to InitCommonControlsEx(). otherwise , Windows will not be created .
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set it to include all of the
// Common control classes .
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
m_hLangDLL = NULL;
AfxEnableControlContainer();
// establish shell Manager , In case the dialog box contains
// whatever shell Tree view control or shell List view control .
CShellManager *pShellManager = new CShellManager;
// Activate “Windows Native” Vision Manager , In order to be in MFC Control
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// Standard initialization
// If you don't use these features and want to reduce
// The size of the final executable , The following should be removed
// Specific initialization routines not required
// Change the registry key used to store settings
// TODO: The string should be modified appropriately ,
// For example, change it to company or organization name
SetRegistryKey(_T(" Local applications generated by the application wizard "));
HINSTANCE m_hLangDLL = ::LoadLibrary(_T("Resource_zh.dll"));
if(m_hLangDLL != NULL)
{
AfxSetResourceHandle(m_hLangDLL);
}
else
{
AfxMessageBox(_T(" resources DLL File load failed !"));
exit(1);
}
In fact, the implementation of resource independent dynamic library is realized .
Digression :
Resources are used alone as Dll Can succeed , So if we are multilingual , Each language can be a separate Dll, In this way, the use of Dll Multi language support .
The following is the code for dynamically loading resources :
BOOL CMultilingualDemoDlg::ResetDialog()
{
//TODO: Process additional resources that may have been added
AfxOleTerm(FALSE);
if(m_hLangDLL)
{
FreeLibrary(m_hLangDLL);
}
STARTUPINFO StartupInfo={
0};
PROCESS_INFORMATION ProcessInfo;
StartupInfo.cb=sizeof(STARTUPINFO);
char Path[256];
GetModuleFileName(NULL,(LPSTR)(LPCTSTR)Path,255);
CreateProcess(NULL,(LPSTR)(LPCTSTR)Path,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo);
return TRUE;
}
版权声明
本文为[houxian1103]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230516141963.html
边栏推荐
- 7-4 is it too fat (10 points) PTA
- Source code analysis of how to use jump table in redis
- 4 个最常见的自动化测试挑战及应对措施
- 看板快速启动指南
- QPushButton slot function is triggered multiple times
- Basic theory of Flink
- JSP-----JSP简介
- Luogu p2731 horse riding fence repair
- Study notes: unity customsrp-13-colorgrading
- Project manager's thinking mode worth trying: project success equation
猜你喜欢
《2021年IT行业项目管理调查报告》重磅发布!
JSP-----JSP简介
#define 定义常量和宏,指针和结构体
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
Cross border e-commerce | Facebook and instagram: which social media is more suitable for you?
Publish your own wheel - pypi packaging upload practice
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
何时适合进行自动化测试?(下)
Unique primary key ID of tidb sub table -- solution to failure of sequence and Gorm to obtain primary key
Where, on when MySQL external connection is used
随机推荐
Musk and twitter storm drama
Where, on when MySQL external connection is used
Good simple recursive problem, string recursive training
Uglifyjs compress JS
Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
Summary of MySQL knowledge points
Cross border e-commerce | Facebook and instagram: which social media is more suitable for you?
This call when the transaction does not take effect
MySQL external connection, internal connection, self connection, natural connection, cross connection
Source code analysis of how to use jump table in redis
Redis data type usage scenario
Five key technologies to improve the devsecops framework
TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
#define 定义常量和宏,指针和结构体
What role do tools play in digital transformation?
Deep learning notes - data expansion
何时适合进行自动化测试?(下)
即将毕业的大学生找技术开发工作的焦虑根源
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
Unique primary key ID of tidb sub table -- solution to failure of sequence and Gorm to obtain primary key