GameServer.ccp
Code:
//buscar
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) // OK
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
//en esta parte agregar esto de aquí
case IDM_IPMANAGER:
DialogBox(hInst,(LPCTSTR)IDD_BANNED,hWnd,(DLGPROC)IPBanned);
break;
//hasta quí
default:
return DefWindowProc(hWnd,message,wParam,lParam);
}
}
//agregar la función en gameserver.h
std::map<std::string,IP_ADDRESS_INFO>::iterator it;
std::map<std::string,IP_ADDRESS_INFO>::iterator buscador;
LRESULT CALLBACK IPBanned(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) // OK
{
switch(message)
{
case WM_INITDIALOG:
hWndComboBox1 = GetDlgItem(hDlg, IDC_LIST2);
if( !hWndComboBox1 )
{
MessageBox(hDlg,
"Could not create the combo box",
"Failed Control Creation",
MB_OK);
return FALSE;
}
for ( it = gIpManager.m_IpAddressInfo.begin(); it != gIpManager.m_IpAddressInfo.end(); it++ )
{
if(it->second.IpBlocked == 1){
char fulltext[16];
wsprintf(fulltext,"%s",it->second.IpAddress);
intindex = SendMessage(hWndComboBox1, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)fulltext));
SendMessage(hWndComboBox1, LB_SETITEMDATA, (WPARAM) index, (LPARAM) it->second.IpAddress);
}
}
return1;
case WM_COMMAND:
if(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg,LOWORD(wParam));
return1;
}
elseif(LOWORD(wParam) == IDC_DISBAND)
{
int itemIndex = (int) SendMessage(hWndComboBox1, LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
if (itemIndex == LB_ERR)
{
return0;
}
// Getdata
char* s = (char*) SendMessage(hWndComboBox1, LB_GETITEMDATA, itemIndex, 0);
for ( buscador = gIpManager.m_IpAddressInfo.begin(); buscador != gIpManager.m_IpAddressInfo.end(); buscador++ )
{
if(buscador->second.IpAddress == s){
buscador->second.IpBlocked = 0;
char fulltext[16];
wsprintf(fulltext,"%s",buscador->second.IpAddress);
MessageBox(hDlg, fulltext, "Confirm", MB_OK);
}
}
}
break;
}
return0;
}
create a dialog with the following
identifier for the Dialog: IDD_BANNED
Identifier for the Listbox : IDC_LIST2
Identifier for the Button: IDC_DISBAND
[IMG]
[/IMG]