www.pudn.com > TestIPMSG.rar > FastTransmit.cpp
// FastTransmit.cpp : implementation file // #include "stdafx.h" #include "TestIPMSG.h" #include "FastTransmit.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFastTransmit dialog extern vectorg_AcceptClient; //全局变量,用来管理客户端信息 CFastTransmit::CFastTransmit(CWnd* pParent /*=NULL*/) : CDialog(CFastTransmit::IDD, pParent), iChatDlgNum(0) { //{{AFX_DATA_INIT(CFastTransmit) m_sMsg = _T(""); //}}AFX_DATA_INIT } void CFastTransmit::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFastTransmit) DDX_Control(pDX, IDC_LIST2, m_ClientInfoList); DDX_Text(pDX, IDC_EDIT3, m_sMsg); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFastTransmit, CDialog) //{{AFX_MSG_MAP(CFastTransmit) ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2) ON_BN_CLICKED(IDOK, OnChatOK) ON_BN_CLICKED(IDC_BUTTON2, OnUpdateClient) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFastTransmit message handlers void CFastTransmit::AddAllClientInfo() { vector ::iterator ts; m_ClientInfoList.DeleteAllItems(); int i = 0; for( ts = g_AcceptClient.begin();ts != g_AcceptClient.end();ts ++ ) { m_ClientInfoList.InsertItem(i,ts->m_loginName); m_ClientInfoList.SetItemText(i,1,ts->m_groupName); m_ClientInfoList.SetItemText(i,2,ts->m_ComputerName); m_ClientInfoList.SetItemText(i,3,ts->m_ClientIPAddr); i++; } } BOOL CFastTransmit::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_ClientInfoList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_TRACKSELECT | 1); m_ClientInfoList.InsertColumn(0,"用户名",0,100); m_ClientInfoList.InsertColumn(1,"组名",0,100); m_ClientInfoList.InsertColumn(2,"计算机名",0,100); m_ClientInfoList.InsertColumn(3,"IP地址",0,100); AddAllClientInfo(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CFastTransmit::SendDataToClient() { } void CFastTransmit::RecvDataFromClient() { } void CFastTransmit::SendQueryChatCommand() { } BOOL CFastTransmit::InitChatServerSocket() { return TRUE; } void CFastTransmit::GetHostIP(DWORD &dwLocalIP) { } void CFastTransmit::StartChatServerThread() { } void CFastTransmit::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here int iSel = m_ClientInfoList.GetSelectionMark(); char curSelUserName[80]; CTestIPMSGApp * TestIPMSG =(CTestIPMSGApp * ) AfxGetApp(); m_ClientInfoList.GetItemText(iSel,0,(LPTSTR)curSelUserName,sizeof(curSelUserName)); if ( iChatDlgNum > 10 ) return ; if ( curSelUserName != NULL ) TestIPMSG->m_chatWindowDlg[iChatDlgNum].GetChatObj(curSelUserName); TestIPMSG->m_chatWindowDlg[iChatDlgNum].Create(IDD_DIG_CHATWINDOW,NULL); TestIPMSG->m_chatWindowDlg[iChatDlgNum].ShowWindow(SW_SHOW); iChatDlgNum++; *pResult = 0; } void CFastTransmit::OnChatOK() { // TODO: Add your control notification handler code here int iSel = -1; iSel = m_ClientInfoList.GetSelectionMark(); CTestIPMSGApp * TestIPMSG =(CTestIPMSGApp * ) AfxGetApp(); if ( iSel != -1 ) { char curUserName[80]; m_ClientInfoList.GetItemText(iSel,0,(LPTSTR)curUserName,sizeof(curUserName)); GetDlgItem(IDC_EDIT3)->GetWindowText(m_sMsg); int iMsgLen = m_sMsg.GetLength(); if ( iChatDlgNum > 10 ) return; if ( curUserName != NULL ) TestIPMSG->m_chatWindowDlg[iChatDlgNum].GetChatObjAndContent(curUserName,m_sMsg.GetBuffer(iMsgLen)); GetDlgItem(IDC_EDIT3)->SetWindowText(""); TestIPMSG->m_chatWindowDlg[iChatDlgNum].Create(IDD_DIG_CHATWINDOW,NULL); TestIPMSG->m_chatWindowDlg[iChatDlgNum].ShowWindow(SW_SHOW); iChatDlgNum++; } } void CFastTransmit::OnUpdateClient() { // TODO: Add your control notification handler code here CTestIPMSGApp * testApp = ( CTestIPMSGApp *)AfxGetApp(); testApp->m_AcceptClient.SendToClient(); Sleep(200); AddAllClientInfo(); }