duilib提供了4种加载资源的方式
代码路径:https://download.csdn.net/download/qq_24127015/11002846
1.直接读取xml文件
#include <windows.h>
#include "DuiFrameWnd.h"
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
CPaintManagerUI::SetInstance(hInstance);
CDuiString strPath = CPaintManagerUI::GetInstancePath() + _T("skins");
CPaintManagerUI::SetResourcePath(strPath);
CDuiFrameWnd duiFrame;
duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, 0);
duiFrame.CenterWindow();
duiFrame.ShowModal();
return 0;
}
2.读取zip资源压缩包
#include <windows.h>
#include "DuiFrameWnd.h"
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
CPaintManagerUI::SetInstance(hInstance);
CDuiString strPath = CPaintManagerUI::GetInstancePath() + _T("skinfolder\\");
CPaintManagerUI::SetResourcePath(strPath);
CPaintManagerUI::SetResourceType(UILIB_ZIP);
//CPaintManagerUI::SetResourceZip(L"skins.zip");
CPaintManagerUI::SetResourceZip(L"skins2.zip",true,L"123456");//资源加密
CDuiFrameWnd duiFrame;
duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, 0);
duiFrame.CenterWindow();
duiFrame.ShowModal();
return 0;
}
3.读rc资源
4.读dll中的rc资源
#include <windows.h>
#include "resource.h"
#include "DuiFrameWnd.h"
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
CPaintManagerUI::SetInstance(hInstance);
CPaintManagerUI::SetResourceType(UILIB_ZIPRESOURCE);
//加载资源管理器
HRSRC hResource = ::FindResource(CPaintManagerUI::GetResourceDll(), MAKEINTRESOURCE(IDR_ZIPRES1), _T("ZIPRES"));
if (hResource != NULL)
{
DWORD dwSize = 0;
HGLOBAL hGlobal = ::LoadResource(CPaintManagerUI::GetResourceDll(), hResource);
if (hGlobal != NULL)
{
dwSize = ::SizeofResource(CPaintManagerUI::GetResourceDll(), hResource);
if (dwSize > 0)
{
CPaintManagerUI::SetResourceZip((LPVOID)::LockResource(hGlobal), dwSize);
}
}
::FreeResource(hResource);
}
CDuiFrameWnd duiFrame;
duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, 0);
duiFrame.CenterWindow();
duiFrame.ShowModal();
return 0;
}