Example #1
0
int     CZiMainFrame::OnReturnSearch(TNotifyUI & msg)
{
	CEditUI  * pSearchEdit  = DuiControl(CEditUI,  _T("SearchEdit"));
	CComboUI * pSearchCombo = DuiControl(CComboUI, _T("SearchCombo"));

	Assert(pSearchEdit && pSearchCombo);

	LPCTSTR    ptsItemName = pSearchEdit->GetText().GetData();
	if(!ptsItemName) return 0;

	if (wcscmp(ptsItemName, m_itemSelfInfo.tstrNickName.c_str()) == 0) {
		return 0;
	}

	// 增加 pSearchCombo 列表并显示. 
	// 测试代码 ***
	//AddComboItem(_T("111111"));
	//return 0;

	ImcNodeList_t nodeList;
	int size = pSearchCombo->GetCount();
	ClearComboItem();
	m_searchNodes.clear();
	SearchFriendsNode(ptsItemName, m_searchNodes);

	for(ImcNodeList_t::iterator it = m_searchNodes.begin(); 
		it != m_searchNodes.end(); it++)
	{
		ItemNodeInfo_t & itemInfo = (*it)->GetNodeData();
		if(itemInfo.Type() == Type_ImcFriend || 
			itemInfo.Type() == Type_ImcFriendX)
		{
			Assert(!itemInfo.IsInvalid());
			if(::_tcsstr(itemInfo.tstrNickName.c_str(), ptsItemName))
			{
				AddComboItem(itemInfo.tstrNickName.c_str());
			}
		}
	}

	// 不能够显示出来 list 的内容来, 不知道为什么 ?
	// HWND hF = ::GetFocus();
	::SendMessage(::GetFocus(), WM_KILLFOCUS, 0, 0);
	pSearchCombo->SetFocus();
	pSearchCombo->Activate();
	return 0;
}
Example #2
0
void RedisConfigUI::DoFillData()
{
    CEditUI exampleEditUI;
    CComboUI exampleComboUI;

    RedisClient::TDicConfig::const_iterator it = m_dicConfig.begin();
    RedisClient::TDicConfig::const_iterator itend = m_dicConfig.end();

    for ( ; it!=itend; ++it)
    {
        CDuiString name = _T("redisconfig_");
        CDuiString key = Base::CharacterSet::ANSIToUnicode(it->first).c_str();
        CDuiString val = Base::CharacterSet::ANSIToUnicode(it->second).c_str();
        name.Append(key);
        CControlUI* pCtl = GetPaintMgr()->FindControl(name);

        /// xml中未配置该项
        if (pCtl == NULL) continue;

        if (pCtl->GetClass() == exampleEditUI.GetClass())
        {
            CEditUI* pEdit = static_cast<CEditUI*> (pCtl);
            pEdit->SetText(val);
        }
        else if (pCtl->GetClass() == exampleComboUI.GetClass())
        {
            CComboUI* pCombo = static_cast<CComboUI*> (pCtl);
            int idx = 0;
            if (val == _T("yes")) idx = 0;
            else if (val == _T("no")) idx = 1;
            else if (it->first == "loglevel")
            {
                string loglevel = it->second;
                if (loglevel == "debug") idx = 0;
                else if (loglevel == "verbose") idx = 1;
                else if (loglevel == "notice") idx = 2;
                else if (loglevel == "warning") idx = 3;
            }
            pCombo->SetInternVisible(true);
            pCombo->SelectItem(idx);
            pCombo->SetFocus();
        }
    }
}