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 90 91 92 93 94 95 96 97 98
| #include "stdafx.h"
#include "resource.h"
#include "MainDlg.h" #include "DuiSystem.h" #include "DuiDefaultLogger.h"
CAppModule _Module;
int RunUI() { int nRet = 0; CMainDlg dlgMain; nRet = dlgMain.DoModal();
return nRet; }
int RunDuiEngine(HRESULT hRes, HINSTANCE hInstance) { DUIASSERT(SUCCEEDED(hRes));
TCHAR szCurrentDir[MAX_PATH + 1] = {0}; memset( szCurrentDir, 0, sizeof(szCurrentDir) ); GetModuleFileName( NULL, szCurrentDir, MAX_PATH ); LPTSTR lpInsertPos = _tcsrchr( szCurrentDir, _T('\\') ); *lpInsertPos = _T('\0');
DuiSystem duiSystem(hInstance);
DefaultLogger loger; loger.setLogFilename(CDuiStringT(szCurrentDir) + _T("\\duiengine.log")); duiSystem.SetLogger(&loger); duiSystem.logEvent(_T("demo started"));
duiSystem.InitName2ID(IDR_NAME2ID,_T("XML2"));
#ifdef __DUIFILE_RC _tcscat( szCurrentDir, _T("\\..\\..\\..\\..\\coding\\demo\\WTLDemo\\skin") ); DuiResProviderFiles *pResFiles=new DuiResProviderFiles; if(!pResFiles->Init(szCurrentDir)) { DUIASSERT(0); return 1; } duiSystem.SetResProvider(pResFiles); #else duiSystem.SetResProvider(new DuiResProviderPE(hInstance)); #endif BOOL result = duiSystem.Init(IDR_DUI_INIT); duiSystem.SetMsgBoxTemplate(IDR_DUI_MSGBOX); int uiResult = 0; if (result) { uiResult = RunUI(); }
duiSystem.logEvent(_T("demo end")); delete duiSystem.GetResProvider();
return uiResult; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR , int ) { HRESULT hRes = ::CoInitialize(NULL);
ATLASSERT(SUCCEEDED(hRes));
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_BAR_CLASSES);
hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes));
AtlAxWinInit();
int nRet = RunDuiEngine(hRes, hInstance);
_Module.Term(); ::CoUninitialize();
return nRet; }
|