Ejemplo n.º 1
0
void QApp::SaveWindowPos()
{
    QConfig *pCfg = QUIGetConfig();
    HWND hWnd = GetMainSafeWnd();
    if (!::IsWindow(hWnd) || (NULL == pCfg))
    {
        ATLASSERT(FALSE);
        return;
    }

    WINDOWPLACEMENT wp = { 0 };
    wp.length = sizeof(WINDOWPLACEMENT);

    // get window position and iconized/maximized status
    ::GetWindowPlacement(hWnd, &wp);

    wp.flags   = 0;
    wp.showCmd = SW_SHOWNORMAL;

    TCHAR tmp[200];
    WTL::SecureHelper::sprintf_x(tmp, 200,_T("%u,%u,%d,%d,%d,%d"),
        wp.flags,
        wp.showCmd,
        wp.rcNormalPosition.left,
        wp.rcNormalPosition.top,
        wp.rcNormalPosition.right,
        wp.rcNormalPosition.bottom);

    // write position to INI file
    pCfg->SetValue(L"app",L"MainWindowPos", tmp);
}
Ejemplo n.º 2
0
BOOL TUIApp::InitRun()
{
	DemoConfig *pCfg = (DemoConfig*)QUIGetConfig();
	
	// 初始化阴影效果组件
	CWndShadow::Initialize(QUIGetInstance());
	SetTopFrameStyle(WS_QEX_ROUNDCONNER|WS_QEX_WNDSHADOW);

	//////////////////////////////////////////////////////////////////////////
	// 登录系统
	LoginDlg().DoModal(NULL, WS_EX_TOOLWINDOW|WS_EX_TOPMOST);

	return FALSE;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
BOOL QApp::RestoreWindowPos()
{
    HWND hWnd = GetMainSafeWnd();
    QConfig *pCfg = QUIGetConfig();
    if (!::IsWindow(hWnd) || (NULL == pCfg))
    {
        ATLASSERT(FALSE);
        return FALSE;
    }
    // read window position from INI file
    // MainWindow format =0,1,395,198,1012,642
    CStdString sPos = pCfg->GetValue(L"app",L"MainWindowPos");
    if (sPos.IsEmpty())
        return FALSE;

    TCHAR tmp[256];
    _tcsncpy_s(tmp, sPos, _countof(tmp)-2);

    // get WINDOWPLACEMENT info
    WINDOWPLACEMENT wp = { 0 };
    wp.length = sizeof(WINDOWPLACEMENT);
    wp.ptMaxPosition = CPoint(-::GetSystemMetrics(SM_CXBORDER), -::GetSystemMetrics(SM_CYBORDER));
    TCHAR *cp = 0;
    wp.rcNormalPosition = CRect(200, 100, 850, 550);
    if ((cp = _tcstok(tmp, _T(",\r\n"))) != NULL)
        wp.flags = _ttoi(cp);
    if ((cp = _tcstok(NULL,  _T(",\r\n"))) != NULL)
        wp.showCmd = _ttoi(cp);
    if ((cp = _tcstok(NULL,  _T(",\r\n"))) != NULL)
        wp.rcNormalPosition.left = _ttoi(cp);
    if ((cp = _tcstok(NULL,  _T(",\r\n"))) != NULL)
        wp.rcNormalPosition.top = _ttoi(cp);
    if ((cp = _tcstok(NULL,  _T(",\r\n"))) != NULL)
        wp.rcNormalPosition.right = _ttoi(cp);
    if ((cp = _tcstok(NULL,  _T(",\r\n"))) != NULL)
        wp.rcNormalPosition.bottom = _ttoi(cp);
    // sets window's position and iconized/maximized status
    ::SetWindowPlacement(hWnd, &wp);

    // 最后给它一个wm_move 消息
    ::SendMessage(hWnd, WM_EXITSIZEMOVE, 0, 0);
    return TRUE;
}