- 博客(0)
- 资源 (3)
- 收藏
- 关注
局域网内聊天 vc源码
//************************* 增加在Clinet list中****************//
BOOL CWChatDlg::ClientListCtrl()
{
/*********************************************************/
/*****************返回 Ture 表示还要对数据进行处理********/
/******************返回 FLASE 表示处理完了****************/
/*********************************************************/
int iCout;
char cTemp;
CString strTemp;
strTemp.Format( g_recvClientMsg.m_pEnd->info.userIP ); //从m_revClientMsg 表尾开始处理数据
if(0==strcmp(g_recvClientMsg.m_pEnd->info.messageType, g_leave))
{
iCout = m_ClientIP.GetCount();
while(iCout>=0)
{
char str[sizeof( g_recvClientMsg.m_pEnd->info.userIP )];
memset(str,0,sizeof(g_recvClientMsg.m_pEnd->info.userIP));
m_ClientList.GetItemText(iCout, 3, str, strlen(g_recvClientMsg.m_pEnd->info.userIP)+1);
if(0==strcmp(str,g_recvClientMsg.m_pEnd->info.userIP))
{
strTemp.Format(g_recvClientMsg.m_pEnd->info.userIP);
m_ClientIP.RemoveAt( m_ClientIP.Find(strTemp) );// 从容器中删除
m_ClientList.DeleteItem(iCout); //从列表中删除
itoa(iCout,&cTemp,10);
SetDlgItemText(IDC_CCout, &cTemp); //更新在线人数
break;
}
iCout--;
}
return TRUE;
}
// 上线(g_coming)或在线(g_onlineMsg)消息且不在容器中
if (NULL == m_ClientIP.Find( strTemp ))
{
iCout = m_ClientIP.GetCount(); //统计在线人数
itoa(iCout+1,&cTemp,10);
SetDlgItemText(IDC_CCout, &cTemp); //显示在线人数
m_ClientIP.AddTail(strTemp); //加到容器中方便计算和查找
m_ClientList.InsertItem( iCout, g_recvClientMsg.m_pEnd->info.userName );
m_ClientList.SetItemText( iCout, 2, g_recvClientMsg.m_pEnd->info.hostName);
m_ClientList.SetItemText( iCout, 3, g_recvClientMsg.m_pEnd->info.userIP );
}
else
{
g_recvClientMsg.DeleteUserInfo();
// if(0 != g_recvClientMsg.m_count)
// SysMsgRemind(WM_MYMSG_SYSREMIND, WM_MYMSG_CREATEREMIND);
return FALSE;
}
if(0 == strcmp(g_recvClientMsg.m_pEnd->info.messageType, g_onlineMsg)) //在线回复的不用提醒,加在用户列表
{
g_recvClientMsg.DeleteUserInfo();
return FALSE;
}
return TRUE;
}
2011-08-13
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人