Exemple #1
0
void CNotice::TypeInit(TNotifyUI& msg)
{
	CPaintManagerUI* pPaintMgrUI = GetPaintMgr();
	ASSERT(pPaintMgrUI);
	
	CTextUI* pLabel = static_cast<CTextUI*>(pPaintMgrUI->FindControl(noticeView::kUser));
	if(pLabel){ 		
		pLabel->SetText(m_strText);
	}
	int iWidth = GetSystemMetrics(SM_CXSCREEN);
	int iHeight = GetSystemMetrics(SM_CYSCREEN);//计算的屏幕客户工作区域
	MONITORINFO oMonitor = {};
	oMonitor.cbSize = sizeof(oMonitor);
	::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
	CDuiRect rcWork = oMonitor.rcWork;
	RECT rcWnd;
	SIZE szInit = GetPaintMgr()->GetInitSize();

	rcWnd.right = rcWork.right-1;
	rcWnd.left = rcWnd.right-szInit.cx;
	rcWnd.bottom = rcWork.bottom -1;
	rcWnd.top = rcWnd.bottom-szInit.cy;

//	MoveWindow(&rcWnd);
	HWND hWnd = GetForegroundWindow();
	SetWindowPos(HWND_TOPMOST,&rcWnd,SWP_NOACTIVATE);
	SetForegroundWindow(hWnd);
	/* 设置初始皮肤 */
}
Exemple #2
0
//聊天框信息已准备好
void CRightFrame::OnTalkBufferReady(BzDui::CStdString strBuf,int iTextHeight)
{
	if (strBuf.GetLength() == 0)
	{
		return;
	}

	CTextUI* pText = new CTextUI();
	pText->SetFloat(false);
	pText->SetShowHtml(true);
	pText->SetText(strBuf);

	CListContainerElementUI* pCtn = new CListContainerElementUI();
	pCtn->SetFixedHeight(iTextHeight);
	pCtn->Add(pText);

	m_pTalkBoxList->Add(pCtn);

	return;
}
LRESULT RedisInfoUI::OnInfoRefresh( HWND hwnd, WPARAM wParam, LPARAM lParam )
{
    std::string* pInfo = (std::string*)wParam;
    std::string& info = *pInfo;
    std::istringstream istr(info);
    std::string line;
    while (getline(istr, line))
    {
        int pos = line.find(":");
        if (pos == std::string::npos) continue;
        string key = line.substr(0, pos);
        string value = line.substr(pos+1, line.length()-pos);
        std::wstring controlName = Base::CharacterSet::ANSIToUnicode(key);
        std::wstring ControlText = Base::CharacterSet::ANSIToUnicode(value);
        CTextUI* p = static_cast<CTextUI*> (GetPaintMgr()->FindControl(controlName.c_str()));
        if (p)
        {
            p->SetText(ControlText.c_str());
            p->NeedUpdate();
        }
    }
    delete pInfo;
    return TRUE;
}
Exemple #4
0
void CQuizWnd::InitWindow()
{
	assert(m_songInfo);
	CenterWindow();
	auto& quizInfo = m_songInfo->GetQuizInfo();

	// show title
	CTextUI* title = static_cast<CTextUI*>(m_PaintManager.FindControl(L"title"));
	if (!title) return;
	title->SetText(quizInfo.get_title().c_str());
	
	// show questoins button
	CHorizontalLayoutUI* questions_btn = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(L"questions_btn"));
	if (!questions_btn) return;
	wchar_t ndx[3] = L"1";
	auto cnt = quizInfo.get_quiz_count();
	static const int FIXED_LENGTH = 64;
	SIZE sz = { 1,1 };
	for (auto i = 0; i < cnt; i++) {
		CButtonUI* btn = new CButtonUI();
		btn->SetName(((wstring)BTN_QUESTION_PREFIX + ndx).c_str());
		btn->SetFloat();
		btn->SetFixedXY(sz);
		btn->SetFixedHeight(FIXED_LENGTH);
		btn->SetFixedWidth(FIXED_LENGTH);
		btn->SetNormalImage(((wstring)NORMAL_PREFIX + ndx + POSTFIX_PNG).c_str());
		btn->SetFocusedImage(((wstring)NORMAL_PREFIX + ndx + POSTFIX_PNG).c_str());
		btn->SetHotImage(((wstring)HOT_PREFIX + ndx + POSTFIX_PNG).c_str());
		btn->SetPushedImage(((wstring)HOT_PREFIX + ndx + POSTFIX_PNG).c_str());
		questions_btn->Add(btn);
		ndx[0]++;
		sz.cx += FIXED_LENGTH + 1;
		if (ndx[0] == 58) {
			ndx[0] = L'1';
			ndx[1] = L'0';
		}
	}

	// show doen button
	if (cnt > 0) {
		CButtonUI* btn = new CButtonUI();
		btn->SetName(((wstring)BTN_QUESTION_PREFIX + DONE).c_str());
		btn->SetFloat();
		btn->SetFixedXY(sz);
		btn->SetFixedHeight(FIXED_LENGTH);
		btn->SetFixedWidth(FIXED_LENGTH);
		btn->SetNormalImage(((wstring)NORMAL_PREFIX + DONE + POSTFIX_PNG).c_str());
		btn->SetFocusedImage(((wstring)NORMAL_PREFIX + DONE + POSTFIX_PNG).c_str());
		btn->SetHotImage(((wstring)HOT_PREFIX + DONE + POSTFIX_PNG).c_str());
		btn->SetPushedImage(((wstring)HOT_PREFIX + DONE + POSTFIX_PNG).c_str());
		questions_btn->Add(btn);

	}

	// init question container
	CActiveXUI* question = static_cast<CActiveXUI*>(m_PaintManager.FindControl(_T("question")));
	if (!question) return;
	question->SetDelayCreate(false);              // 相当于界面设计器里的DelayCreate属性改为FALSE,在duilib自带的FlashDemo里可以看到此属性为TRUE             
	question->CreateControl(CLSID_WebBrowser);    // 相当于界面设计器里的Clsid属性里填入{8856F961-340A-11D0-A96B-00C04FD705A2},建议用CLSID_WebBrowser,如果想看相应的值,请见<ExDisp.h>
	question->GetControl(IID_IWebBrowser2, (void**)&m_question);
	assert(m_question);

	// show 1st question
	ShowQuiz(1);
}
Exemple #5
0
		int ShowMsgBox(HWND hwnd,
			LPCTSTR lpszText,
			LPCTSTR lpszCaption,
			UINT nType)
		{
			if(!IsWindow())
			{
				//	this->Create(hwnd,lpszCaption,UI_WNDSTYLE_DIALOG,UI_WNDSTYLE_EX_DIALOG);
				this->Create(hwnd,lpszCaption,UI_WNDSTYLE_DIALOG,0);
			}

			CenterWindow();

			CTextUI* pTitle       = static_cast<CTextUI*>(GetPaintMgr()->FindControl(_T("title")));
			CTextUI* pMsg         = static_cast<CTextUI*>(GetPaintMgr()->FindControl(_T("msg")));
			CButtonUI* pCancelBtn = static_cast<CButtonUI*>(GetPaintMgr()->FindControl(_T("cancel")));
			CButtonUI* pOkBtn     = static_cast<CButtonUI*>(GetPaintMgr()->FindControl(_T("yes")));
			CTabLayoutUI* pTable  = static_cast<CTabLayoutUI*>(GetPaintMgr()->FindControl(_T("icon")));
			CCheckBoxUI* pCheckBox= static_cast<CCheckBoxUI*>(GetPaintMgr()->FindControl(_T("checkbox")));

			ASSERT(pTitle);
			ASSERT(pMsg);
			ASSERT(pCancelBtn);
			ASSERT(pOkBtn);
			ASSERT(pTable);
			ASSERT(pCheckBox);

			if(pTitle) pTitle->SetText((lpszCaption ? lpszCaption : _T("")));
			if(pMsg)   pMsg->SetText((lpszText ? lpszText : _T("")));
			if(pCancelBtn) pCancelBtn->SetFocus();

			if(pTable)
			{
				if(nType & MBT_INFO)
					pTable->SelectItem(0);
				else if(nType & MBT_OK)
					pTable->SelectItem(1);
				else if(nType & MBT_WARN)
					pTable->SelectItem(2);
			}

			const bool isShowCancel   = (pCancelBtn && ((nType & MBBT_CANCEL) > 0));
			const bool isShowOk       = (pOkBtn && ((nType & MBBT_OK) > 0));
			const bool isShowCheckBox = (pCheckBox &&((nType & MBBT_CHECKBOX) > 0));
			const bool isShake = ((nType & MBT_SHAKE) > 0);
			_bShakeWindow = isShake;

			pCancelBtn->SetVisible(isShowCancel);
			pOkBtn->SetVisible(isShowOk);
			pCheckBox->SetVisible((/*isShowOk && */isShowCheckBox));
		
			if(!isShowCancel && isShowOk)
			{
				pCancelBtn->SetVisible(true);
				pOkBtn->SetVisible(false);
				pCancelBtn->SetName(pOkBtn->GetName());
				pCancelBtn->SetText(pOkBtn->GetText());
				pCancelBtn->SetToolTip(pOkBtn->GetToolTip());
				pCancelBtn->SetFocus();
			}
			return ShowModal();
		}