I've just extended the dialog callback function. It now also selects the server the player is playing on when you click on a result:
//Edit by Richard
//Message handler for Player Search Dialog
static LRESULT CALLBACK SearchPlayerDlg (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_SP_EDIT, EN_CHANGE), (LPARAM) GetDlgItem(hDlg, IDC_SP_EDIT));
return TRUE;
case WM_COMMAND:
static std::vector <std::pair<std::string, int> > vFound;
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if ((LOWORD(wParam) == IDC_SP_EDIT) and (HIWORD(wParam) == EN_CHANGE))
{
std::string sContentBuffer;
char szNameBuffer[GetWindowTextLength(GetDlgItem(hDlg, IDC_SP_EDIT)) + 1];
SendMessage(GetDlgItem(hDlg, IDC_SP_LIST), LB_RESETCONTENT, 0, 0);
GetWindowText(GetDlgItem(hDlg, IDC_SP_EDIT), szNameBuffer,
sizeof(szNameBuffer) / sizeof (szNameBuffer[0]));
SearchPlayer(szNameBuffer, &vFound);
for (int i = 0; i < vFound.size(); i++)
{
sContentBuffer.assign(g_mServers[vFound[i].first].vPlayers[vFound[i].second].sName);
sContentBuffer.append (" on ");
sContentBuffer.append (g_mServers[vFound[i].first].sHostName);
int index = SendMessage(GetDlgItem(hDlg, IDC_SP_LIST), LB_ADDSTRING,
0, (LPARAM) sContentBuffer.c_str());
SendMessage(GetDlgItem(hDlg, IDC_SP_LIST), LB_SETITEMDATA, index, i);
}
}
if (HIWORD(wParam) == LBN_SELCHANGE and LOWORD(wParam) == IDC_SP_LIST)
{
int iFoundIndex;
int iListId;
iFoundIndex = SendMessage(GetDlgItem(hDlg, IDC_SP_LIST),
LB_GETITEMDATA,
SendMessage (GetDlgItem(hDlg, IDC_SP_LIST), LB_GETCURSEL, 0, 0),
0);
iListId = GetListIDFromAddress(vFound[iFoundIndex].first.c_str());
if (iListId >= 0)
{
SetFocus(g_hServerList);
ListView_SetItemState(g_hServerList, -1, 0, 0x000F);
ListView_SetItemState(g_hServerList, iListId, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
UpdateInfoLists(iListId, false);
//TODO: set scrollbar position
}
return TRUE;
}
break;
}
return FALSE;
}
I'll add source, the executable and a cvs patch containing all changes.