界面处理
两个容器初始化完毕以后,界面可以根据容器的信息生成。
for(CityStationMap::iterator it=cityStationMap.begin();
it!=cityStationMap.end(); ++it)
{
if(city.compare(it->first) != 0)
{
city = it->first;
CString c = city.c_str();
m_wndCity.AddString(c);
}
}
根据配置信息显示城市下拉框,由于multimap不支持直接把所有的key的集合读取出来,所以需要遍历,把不同的城市信息显示到m_wndCity下拉框中。
LRESULT CMobileRadioView::OnComboCityCbnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
CString str;
int sel = m_wndCity.GetCurSel();
m_wndCity.GetLBText(sel, str);
m_wndStation.ResetContent();
std::string city = CT2CA(str);
unsigned int i = 0;
for(CityStationMap::iterator it=cityStationMap.find(city);
it!=cityStationMap.end() && i<cityStationMap.count(city); ++it,++i)
{
CString s = it->second->Name.c_str();
int index = m_wndStation.AddString(s);
m_wndStation.SetItemData(index, it->second->Id);
}
return 0;
}
当城市下拉框的选择发生改变时,根据multimap的信息显示该城市下的电台信息。
LRESULT CMobileRadioView::OnComboStationCbnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
int sel = m_wndStation.GetCurSel();
int id = (int)m_wndStation.GetItemData(sel);
//CString image = (GetCurrentPath() + "Image\\" + stationMap[id]->Image).c_str();
//m_wndPic.SetBitmap(LoadBitmap(NULL, image));
m_spWMPPlayer->put_URL(CComBSTR(stationMap[id]->Stream.c_str()));
return 0;
/Files/procoder/MobileRadio_V3.rar}
当电台下拉框的选择发生改变时,根据map的信息使用Windows Media Player控件播放该电台。
作者:Jake.NET(Jake's Blog on 博客园)
出处:http://procoder.cnblogs.com