コード例 #1
0
ファイル: QApp.cpp プロジェクト: qiuchengw/qui
BOOL QApp::Run( HINSTANCE hInstance )
{
    SetAppName(NULL);

    // 设置工作目录
    SetCurrentDirectory(quibase::GetModulePath());

	// 配置应用程序
    QConfig *pCfg = QUIGetConfig();
	if ((NULL == pCfg) || !(pCfg->SetConfigPath(GetConfigPath())))
	{
        // 这个时候还没有加载UI,不能使用QUI里面的MessageBox
        ::MessageBox(NULL,L"读取配置文件失败!", L"错误", MB_OK);
        ATLASSERT(FALSE);
        return FALSE;
	}
	// 配置UI管理器
	if (!QUIMgr::GetInstance()->Startup())
	{
        ::MessageBox(NULL,L"UI管理器启动失败!", L"错误", MB_OK);
		ATLASSERT(FALSE);
		return FALSE;
	}

	// 默认开启窗口的圆角和阴影效果
	CWndShadow::Initialize(hInstance);
	SetTopFrameStyle(WS_QEX_ROUNDCONNER|WS_QEX_WNDSHADOW);

	// 主界面线程循环
	QMessageLoop loop;
	AddMessageLoop(&loop);

	// 启动主界面
	if (!InitRun() || (m_pMainWnd == NULL))
	{
		return FALSE;
	}

	loop.Run();
	RemoveMessageLoop();

    UnInit();

    QUIGetMainWnd();

	return TRUE;
}
コード例 #2
0
int CGtserviceModule::Run(int nShowCmd )
{
	CMessageLoop theLoop;
	AddMessageLoop(&theLoop);

	CMainDlg dlgMain;
	if(dlgMain.Create(NULL) == NULL)
	{
		ATLTRACE(_T("Main dialog creation failed!\n"));
		return 0;
	}
	m_pdlgMain = &dlgMain;
	dlgMain.ShowWindow(nShowCmd);

	
	StartWork();
	
	int nRet = theLoop.Run();
	_Module.RemoveMessageLoop();
	return nRet;
}