Пример #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;
}
Пример #2
0
void LoadCombo (HWND hComboBox)
{
	DWORD size;
	char *history = LoadFile (GetConfigPath (TC_APPD_FILENAME_HISTORY), &size);
	char *xml = history;
	char volume[MAX_PATH];

	if (xml == NULL) return;

	while (xml = XmlFindElement (xml, "volume"))
	{
		XmlGetNodeText (xml, volume, sizeof (volume));
		AddComboItem (hComboBox, volume, TRUE);
		xml++;
	}

	SendMessage (hComboBox, CB_SETCURSEL, 0, 0);

	free (history);
}