-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmclistview_demo.cpp
89 lines (74 loc) · 2.89 KB
/
mclistview_demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// dui-demo.cpp : main source file
//
#include "stdafx.h"
#include "StudentSmsDlg.h"
//从PE文件加载,注意从文件加载路径位置
#define RES_TYPE 1
//#define RES_TYPE 0 //从文件中加载资源
// #define RES_TYPE 1 //从PE资源中加载UI资源
#ifdef _DEBUG
#define SYS_NAMED_RESOURCE _T("soui-sys-resourced.dll")
#else
#define SYS_NAMED_RESOURCE _T("soui-sys-resource.dll")
#endif
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
{
HRESULT hRes = OleInitialize(NULL);
SASSERT(SUCCEEDED(hRes));
int nRet = 0;
SComMgr *pComMgr = new SComMgr;
//将程序的运行路径修改到项目所在目录所在的目录
TCHAR szCurrentDir[MAX_PATH] = { 0 };
GetModuleFileName(NULL, szCurrentDir, sizeof(szCurrentDir));
LPTSTR lpInsertPos = _tcsrchr(szCurrentDir, _T('\\'));
_tcscpy(lpInsertPos + 1, _T("..\\mclistview_demo"));
SetCurrentDirectory(szCurrentDir);
{
BOOL bLoaded=FALSE;
CAutoRefPtr<SOUI::IImgDecoderFactory> pImgDecoderFactory;
CAutoRefPtr<SOUI::IRenderFactory> pRenderFactory;
bLoaded = pComMgr->CreateRender_Skia((IObjRef**)&pRenderFactory);
SASSERT_FMT(bLoaded,_T("load interface [render] failed!"));
bLoaded=pComMgr->CreateImgDecoder((IObjRef**)&pImgDecoderFactory);
SASSERT_FMT(bLoaded,_T("load interface [%s] failed!"),_T("imgdecoder"));
pRenderFactory->SetImgDecoderFactory(pImgDecoderFactory);
SApplication *theApp = new SApplication(pRenderFactory, hInstance);
theApp->RegisterWindowClass<SSearchDropdownList>();
//从DLL加载系统资源
HMODULE hModSysResource = LoadLibrary(SYS_NAMED_RESOURCE);
if (hModSysResource)
{
CAutoRefPtr<IResProvider> sysResProvider;
CreateResProvider(RES_PE, (IObjRef**)&sysResProvider);
sysResProvider->Init((WPARAM)hModSysResource, 0);
theApp->LoadSystemNamedResource(sysResProvider);
FreeLibrary(hModSysResource);
}else
{
SASSERT(0);
}
CAutoRefPtr<IResProvider> pResProvider;
#if (RES_TYPE == 0)
CreateResProvider(RES_FILE, (IObjRef**)&pResProvider);
if (!pResProvider->Init((LPARAM)_T("uires"), 0))
{
SASSERT(0);
return 1;
}
#else
CreateResProvider(RES_PE, (IObjRef**)&pResProvider);
pResProvider->Init((WPARAM)hInstance, 0);
#endif
theApp->AddResProvider(pResProvider);
theApp->InitXmlNamedID(namedXmlID,ARRAYSIZE(namedXmlID),TRUE);
// BLOCK: Run application
{
CStudentSmsDlg dlgMain;
nRet = dlgMain.DoModal();
}
delete theApp;
}
delete pComMgr;
OleUninitialize();
return nRet;
}