void CSbmfcsampleDlg::OnColumnclickServerlist(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // track ascending/descending static bool ascending = false; ascending = !ascending; //figure out which column they clicked switch(pNMListView->iSubItem) { case COL_SERVERNAME: ServerBrowserSort(m_serverBrowser, (SBBool)ascending, "hostname", sbcm_stricase); break; case COL_PING: ServerBrowserSort(m_serverBrowser, (SBBool)ascending, "ping", sbcm_int); break; case COL_PLAYERS: ServerBrowserSort(m_serverBrowser, (SBBool)ascending, "numplayers", sbcm_int); break; case COL_MAPNAME: ServerBrowserSort(m_serverBrowser, (SBBool)ascending, "mapname", sbcm_stricase); break; case COL_GAMETYPE: ServerBrowserSort(m_serverBrowser, (SBBool)ascending, "gametype", sbcm_stricase); break; } // we don't want the server list to redraw every time we insert a server! m_serverList.SetRedraw(false); // clear the server list m_serverList.DeleteAllItems(); // clear the server count m_serverCount = 0; m_servers.SetWindowText("0"); // go through the list of servers for(int i = 0; i < ServerBrowserCount(m_serverBrowser) ; i++) { // if we got basic info for it, put it back in the list SBServer server = ServerBrowserGetServer(m_serverBrowser, i); if(SBServerHasBasicKeys(server)) AddServer(server, FALSE); } // let the server list redraw itself now that we're done updating m_serverList.SetRedraw(true); *pResult = 0; }
void CClientDlg::OnLvnColumnclickServerslist(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); // TODO: Add your control notification handler code here // track ascending/descending static bool ascending = false; ascending = !ascending; switch(pNMLV->iSubItem) { case COL_SERVERNAME : { ServerBrowserSort(m_serverBrowser, (SBBool)ascending, (char*)qr2_registered_key_list[HOSTNAME_KEY], sbcm_stricase); }break; case COL_MAPNAME : { ServerBrowserSort(m_serverBrowser, (SBBool)ascending, (char*)qr2_registered_key_list[MAPNAME_KEY], sbcm_stricase); }break; case COL_GAMETYPE : { ServerBrowserSort(m_serverBrowser, (SBBool)ascending, (char*)qr2_registered_key_list[GAMETYPE_KEY], sbcm_stricase); }break; case COL_PLAYERS : { ServerBrowserSort(m_serverBrowser, (SBBool)ascending, (char*)qr2_registered_key_list[NUMPLAYERS_KEY], sbcm_int); }break; case COL_PING : { ServerBrowserSort(m_serverBrowser, (SBBool)ascending, "ping", sbcm_int); }break; } RefillServersList (); *pResult = 0; }