www.pudn.com > 图形界面聊天软件.rar > pictalkDlg.cpp
#include "stdafx.h"
#include "pictalk.h"
#include "pictalkDlg.h"
#include "ConnectDialog.h"
#include "SetDialog.h"
#include "MyEdit.h"
#include "SetDlg.h"
#include "ShowSen.h"
#include "ShowInfo.h"
//#include "TransparentWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPictalkDlg dialog
CPictalkDlg::CPictalkDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPictalkDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPictalkDlg)
m_Sendinfo = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pNet=NULL;
}
void CPictalkDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPictalkDlg)
DDX_Text(pDX, IDC_TALK, m_Sendinfo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPictalkDlg, CDialog)
//{{AFX_MSG_MAP(CPictalkDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_INFO_SEND, OnInfoSend)
ON_COMMAND(ID_MENU_LINK, OnMenuLink)
ON_COMMAND(ID_MENU_STOP, OnMenuStop)
ON_COMMAND(ID_MENU_SERVER, OnMenuServer)
ON_WM_TIMER()
ON_COMMAND(ID_BK_COLOR, OnBkColor)
ON_COMMAND(ID_FONT_COLOR, OnFontColor)
ON_BN_CLICKED(IDC_BUTTON_ANGRY, OnButtonAngry)
ON_BN_CLICKED(IDC_BUTTON_CRY, OnButtonCry)
ON_BN_CLICKED(IDC_BUTTON_SIT, OnButtonSit)
ON_THREAD_MESSAGE(ID_ACCEPT_MESSAGE,OnAcceptMessage)
ON_BN_CLICKED(IDC_BUTTON_SMILE, OnButtonSmile)
ON_BN_CLICKED(IDC_BUTTON_HELLO, OnButtonHello)
ON_BN_CLICKED(IDC_BUTTON_SEN, OnButtonSen)
ON_MESSAGE(WM_SENDLGCLOSE,OnDlgSenClose)
ON_MESSAGE(WM_SHOWINFOCLOSE,OnDlgInfoClose)
ON_EN_CHANGE(IDC_TALK, OnChangeTalk)
ON_BN_CLICKED(IDC_BUTTON_SHOWINFO, OnButtonShowinfo)
ON_WM_MOUSEMOVE()
ON_THREAD_MESSAGE(ID_CONNECTOVER,OnConnectOver)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPictalkDlg message handlers
BOOL CPictalkDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_pMyEdit=new CMyEdit(this);
m_pMyEdit->SubclassDlgItem(IDC_TALK,this);
m_bConnected=FALSE;
m_pUserList.RemoveAll();
m_pShowSen=NULL;
m_pShowInfo=NULL;
m_UserCount=0;
m_pPW=&((CPictalkApp *)AfxGetApp())->pw;
m_pPW->Create(this,&m_pUserList);
CSetDlg dlg;
dlg.SetBMP(&(m_pPW->m_bm));
if(dlg.DoModal()==IDOK){
}
m_pUser=new CUserInfo(this);
m_pUser->m_Name=dlg.m_Name;
m_pUser->m_pic=dlg.m_PicID;
m_pUser->m_nAge=dlg.m_nAge;
m_pUser->m_Sex=dlg.m_Sex;
m_pUser->m_ICQ.Format("%s:%u",dlg.m_IcqType,dlg.m_IcqNum);
m_pUser->m_Job=dlg.m_Job;
m_pUser->m_Address=dlg.m_Address;
m_pUser->m_pPW=m_pPW;
m_bSendOut=TRUE;
{
WORD wversionrequested;
WSADATA wsadata;
CString str;
char name[255];
PHOSTENT hostinfo;
wversionrequested = MAKEWORD( 2, 0 );
if ( WSAStartup( wversionrequested, &wsadata ) == 0 ){
if( gethostname ( name, sizeof(name)) == 0){
if((hostinfo = gethostbyname(name)) != NULL){
str = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
}
WSACleanup( );
}
m_pUser->m_IP=str;
}
m_MainUser=0;
return TRUE; // return TRUE unless you set the focus to a control
}
void CPictalkDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPictalkDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CEdit * pEdit=(CEdit *)GetDlgItem(IDC_TALK);
if(pEdit)
pEdit->SetFocus();
CDialog::OnPaint();
CClientDC dc(this);
m_pPW->paint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPictalkDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPictalkDlg::OnInfoSend()
{
// TODO: Add your control notification handler code here
if(m_bConnected)
{
UpdateData(TRUE);
if(m_Sendinfo.IsEmpty())
return;
mpack Msgpack;
Msgpack.m_MsgID=MID_PUBLICMSG;
Msgpack.m_ComID=MID_SENTENCE;
Msgpack.m_ID=m_pUser->m_ID;
Msgpack.m_state=m_pUser->m_state;
Msgpack.m_x=m_pUser->m_x;
Msgpack.m_y=m_pUser->m_y;
Msgpack.m_bSit=m_pUser->m_bSit;
Msgpack.m_Sen=m_Sendinfo;
SendMsg(Msgpack);
m_pUser->m_ComArray.Add(Msgpack);
m_Sendinfo="";
UpdateData(FALSE);
}
else
MessageBox("尚未连接","MB_OK");
}
void CPictalkDlg::ShowMsg(mcom &Msgcom)
{
CUserInfo * tempUser;
if(!m_MapUser.Lookup(Msgcom.m_ID,tempUser))
return;
tempUser->m_ComArray.Add(Msgcom);
}
void CPictalkDlg::OnMenuLink()
{
// TODO: Add your command handler code here
if(m_bConnected){
MessageBox("已建立连接!","警告信息",MB_OK);
return;
}
CConnectDialog m_Dlg1;
if(m_Dlg1.DoModal()==IDOK)
{
m_pNet=new CNet(this,m_Dlg1.m_ServerName,m_Dlg1.m_PortAddress);
m_pUserList.AddTail(m_pUser);
m_pUser->ShowUser();
m_bConnected=TRUE;
SetTimer(2,5000,NULL);
// if(((CCliNet *)m_pNet)->m_pSocket)
// {
// m_SenList.RemoveAll();
// m_bConnected=TRUE;
// OnButtonShowinfo();
// SendUser();
// m_time=SetTimer(1,500,NULL);
// m_contype=2;
// AfxBeginThread(AcceptWinInetThreadProc, GetSafeHwnd(), THREAD_PRIORITY_NORMAL);
// }
}
}
void CPictalkDlg::OnMenuStop()
{
// TODO: Add your command handler code here
if(m_bConnected)
{
if(m_bSendOut)
SendOut();
KillTimer(1);
StopLink();
}
else
MessageBox("未连接到任何服务器!","警告信息",MB_OK);
}
void CPictalkDlg::OnMenuServer()
{
// TODO: Add your command handler code here
CSetDialog m_Dlg1;
if(m_Dlg1.DoModal()==IDOK)
{
m_pNet=new CNet(this,m_Dlg1.m_PortAddress);
mpack::m_OldID=1;
if(m_pNet->m_pListeningSocket)
{
m_UserCount=1;
m_pUser->m_ID=m_UserCount;
m_SenList.RemoveAll();
m_bConnected=TRUE;
m_MapUser.SetAt(m_pUser->m_ID,m_pUser);
m_RoomName=m_Dlg1.m_RoomName;
m_pUserList.AddTail(m_pUser);
SetTimer(2,5000,NULL);
OnButtonShowinfo();
// m_time=SetTimer(1,500,NULL);
m_pUser->ShowUser();
m_contype=1;
m_MainUser=1;
if(m_Dlg1.m_bShowWeb)
{
roomid=0;
m_PortAddress=m_Dlg1.m_PortAddress;
m_time=SetTimer(1,5000,NULL);
g_strShowInfo.Format("port=%d&name=%s",m_Dlg1.m_PortAddress,m_RoomName);
AfxBeginThread(ShowWinInetThreadProc,GetSafeHwnd(),THREAD_PRIORITY_NORMAL);
}
}
}
}
void CPictalkDlg::CheckMsg(mpack & Msgpack)
{
switch(Msgpack.m_MsgID)
{
case MID_PUBLICMSG:
ShowMsg(Msgpack);
break;
case MID_ADDUSER:
AddUser(Msgpack);
break;
case MID_USERID:
GetID(Msgpack);
break;
case MID_DELUSER:
DelUser(Msgpack);
break;
default:
break;
}
}
void CPictalkDlg::AddUser(mcom &Msgcom)
{
CUserInfo * tempUser;
if(m_MapUser.Lookup(Msgcom.m_ID,tempUser))
return;
CUserInfo *pNewUser=new CUserInfo(this);
pNewUser->m_pic=Msgcom.m_pic;
pNewUser->m_ID=Msgcom.m_ID;
pNewUser->m_x=Msgcom.m_x;
pNewUser->m_y=Msgcom.m_y;
pNewUser->m_bSit=Msgcom.m_bSit;
pNewUser->m_state=Msgcom.m_state;
pNewUser->m_pPW=m_pPW;
pNewUser->m_IP=Msgcom.m_IP;
pNewUser->m_Name=Msgcom.m_Name;
pNewUser->m_nAge=Msgcom.m_nAge;
pNewUser->m_Sex=Msgcom.m_Sex;
pNewUser->m_ICQ=Msgcom.m_ICQ;
pNewUser->m_Job=Msgcom.m_Job;
pNewUser->m_Address=Msgcom.m_Address;
pNewUser->m_nPort=Msgcom.m_nPort;
m_MapUser.SetAt(pNewUser->m_ID,pNewUser);
m_pUserList.AddTail(pNewUser);
pNewUser->ShowUser();
}
void CPictalkDlg::SendUser()
{
mpack Msgpack;
Msgpack.m_MsgID=MID_ADDUSER;
Msgpack.m_ID=m_pUser->m_ID;
Msgpack.m_state=m_pUser->m_state;
Msgpack.m_x=m_pUser->m_x;
Msgpack.m_y=m_pUser->m_y;
Msgpack.m_Name=m_pUser->m_Name;
Msgpack.m_bSit=m_pUser->m_bSit;
Msgpack.m_pic=m_pUser->m_pic;
Msgpack.m_IP=m_pUser->m_IP;
Msgpack.m_Name=m_pUser->m_Name;
Msgpack.m_nAge=m_pUser->m_nAge;
Msgpack.m_Sex=m_pUser->m_Sex;
Msgpack.m_ICQ=m_pUser->m_ICQ;
Msgpack.m_Job=m_pUser->m_Job;
Msgpack.m_Address=m_pUser->m_Address;
Msgpack.m_nPort=m_pUser->m_nPort;
SendMsg(Msgpack);
}
POSITION CPictalkDlg::UserInfo(mpack &Msgpack, POSITION pos)
{
CUserInfo *tempUser;
UINT uID;
m_MapUser.GetNextAssoc(pos,uID,tempUser);
Msgpack.create();
Msgpack.m_MsgID=MID_ADDUSER;
Msgpack.m_ID=tempUser->m_ID;
Msgpack.m_state=tempUser->m_state;
Msgpack.m_x=tempUser->m_x;
Msgpack.m_y=tempUser->m_y;
Msgpack.m_IP=tempUser->m_IP;
Msgpack.m_Name=tempUser->m_Name;
Msgpack.m_bSit=tempUser->m_bSit;
Msgpack.m_pic=tempUser->m_pic;
Msgpack.m_nAge=tempUser->m_nAge;
Msgpack.m_Sex=tempUser->m_Sex;
Msgpack.m_ICQ=tempUser->m_ICQ;
Msgpack.m_Job=tempUser->m_Job;
Msgpack.m_Address=tempUser->m_Address;
Msgpack.m_nPort=tempUser->m_nPort;
return pos;
}
void CPictalkDlg::GetID(mcom &Msgcom)
{
m_pUser->m_ID=Msgcom.m_ID;
mpack::m_OldID=m_pUser->m_ID;
m_MapUser.SetAt(m_pUser->m_ID,m_pUser);
// m_pUser->ShowUser();
}
void CPictalkDlg::SendOut()
{
mpack Msgpack;
Msgpack.create();
Msgpack.m_MsgID=MID_DELUSER;
Msgpack.m_ID=m_pUser->m_ID;
if(m_bConnected)
m_pNet->SendMsg(Msgpack,NULL);
}
void CPictalkDlg::DelUser(mcom &Msgcom)
{
POSITION pos,prvepos;
CUserInfo *tempUser;
for( pos = m_pUserList.GetHeadPosition(); pos != NULL; )
{
prvepos=pos;
tempUser=(CUserInfo *)m_pUserList.GetNext(pos);
if(tempUser->m_ID==Msgcom.m_ID)
{
// m_pUserList.RemoveAt(prvepos);
// delete tempUser;
break;
}
};
m_pUserList.RemoveAt(prvepos);
m_MapUser.RemoveKey(tempUser->m_ID);
delete tempUser;
}
void CPictalkDlg::SendMsg(mpack &Msgpack)
{
CEdit * pEdit=(CEdit *)GetDlgItem(IDC_TALK);
pEdit->SetFocus();
Msgpack.create();
m_pNet->SendMsg(Msgpack,NULL);
}
void CPictalkDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent==1)
{
if(roomid){
g_strShowInfo.Format("id=%d&port=%d&name=%s",roomid,m_PortAddress,m_RoomName);
AfxBeginThread(ShowWinInetThreadProc,THREAD_PRIORITY_NORMAL);
}
}
if(nIDEvent==2){
mpack Msgpack;
Msgpack.create();
Msgpack.m_MsgID=MID_VISIT;
SendMsg(Msgpack);
POSITION pos,pos2;
for( pos = m_pUserList.GetHeadPosition(); pos != NULL; )
{
pos2=pos;
CUserInfo *tempUser=(CUserInfo *)m_pUserList.GetNext(pos);
if(tempUser->m_ID!=m_pUser->m_ID){
tempUser->m_Visit++;
if(tempUser->m_Visit>3){
m_pUserList.RemoveAt(pos2);
m_MapUser.RemoveKey(tempUser->m_ID);
delete tempUser;
}
}
}
}
CDialog::OnTimer(nIDEvent);
}
void CPictalkDlg::Move(UINT dir)
{
if(m_bConnected)
{
m_cs.Lock();
if(m_pUser->m_MsgCount)
return;
m_pUser->m_MsgCount++;
m_cs.Unlock();
if(m_pUser->m_bSit)
{
m_pUser->m_MsgCount--;
return;
}
mpack Msgpack;
Msgpack.m_MsgID=MID_PUBLICMSG;
if(dir!=m_pUser->m_state)
Msgpack.m_ComID=MID_TURN;
else
Msgpack.m_ComID=MID_MOVE;
Msgpack.m_ID=m_pUser->m_ID;
Msgpack.m_state=dir;
Msgpack.m_x=m_pUser->m_x;
Msgpack.m_y=m_pUser->m_y;
Msgpack.m_bSit=m_pUser->m_bSit;
SendMsg(Msgpack);
m_pUser->m_ComArray.Add(Msgpack);
return;
}
}
void CPictalkDlg::OnBkColor()
{
// TODO: Add your command handler code here
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
m_pPW->m_BKColor=dlg.GetColor();
}
void CPictalkDlg::OnFontColor()
{
// TODO: Add your command handler code here
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
m_pPW->m_FontColor=dlg.GetColor();
}
void CPictalkDlg::OnButtonAngry()
{
// TODO: Add your control notification handler code here
SingleMsg(MID_ANGRY);
}
void CPictalkDlg::OnButtonCry()
{
// TODO: Add your control notification handler code here
SingleMsg(MID_CRY);
}
void CPictalkDlg::OnButtonSit()
{
// TODO: Add your control notification handler code here
if(m_bConnected){
if(m_pUser->m_bSit){
SingleMsg(MID_STAND);
GetDlgItem(IDC_BUTTON_SIT)->SetWindowText("坐下");
}
else{
SingleMsg(MID_SIT);
GetDlgItem(IDC_BUTTON_SIT)->SetWindowText("站起");
}
}
}
void CPictalkDlg::OnButtonSmile()
{
// TODO: Add your control notification handler code here
SingleMsg(MID_SMILE);
}
void CPictalkDlg::SingleMsg(int nCom)
{
CEdit * pEdit=(CEdit *)GetDlgItem(IDC_TALK);
pEdit->SetFocus();
if(m_bConnected){
if(m_pUser->m_MsgCount==1)
return;
m_pUser->m_MsgCount++;
mpack Msgpack;
Msgpack.m_MsgID=MID_PUBLICMSG;
Msgpack.m_ComID=nCom;
Msgpack.m_ID=m_pUser->m_ID;
Msgpack.m_state=m_pUser->m_state;
Msgpack.m_x=m_pUser->m_x;
Msgpack.m_y=m_pUser->m_y;
Msgpack.m_bSit=m_pUser->m_bSit;
SendMsg(Msgpack);
m_pUser->m_ComArray.Add(Msgpack);
}
}
void CPictalkDlg::OnButtonHello()
{
// TODO: Add your control notification handler code here
SingleMsg(MID_HELLO);
}
void CPictalkDlg::StopLink()
{
delete m_pNet;
m_bConnected=FALSE;
POSITION pos,prvepos;
for( pos = m_pUserList.GetHeadPosition(); pos != NULL; )
{
prvepos=pos;
CUserInfo *tempUser=(CUserInfo *)m_pUserList.GetNext(pos);
m_pUserList.RemoveAt(prvepos);
delete tempUser;
}
// m_ShowName.ResetContent();
}
void CPictalkDlg::OnAcceptMessage(UINT nID, LPARAM param)
{
/* m_cs.Lock();
int i,j;
j=MsgArray.GetSize();
for(i=0;iCreate(IDD_DIALOG_SENTEN,this);
int i;
for(i=0;im_ListSen.InsertString(-1,m_SenList[i]);
m_pShowSen->ShowWindow(SW_SHOW);
}
else{
delete m_pShowSen;
m_pShowSen=NULL;
}
/* CEdit * pEdit=(CEdit *)GetDlgItem(IDC_TALK);
if(pEdit)
pEdit->SetFocus();*/
}
LRESULT CPictalkDlg::OnDlgSenClose(WPARAM wParam,LPARAM param)
{
m_pShowSen->UpdateData();
if(m_pShowSen->m_Sen!=""){
m_Sendinfo=m_pShowSen->m_Sen;
UpdateData(FALSE);
OnInfoSend();
}
else{
m_pShowSen->DestroyWindow();
m_pShowSen=NULL;
}
return 0L;
}
void CPictalkDlg::AddSenten(CString &str)
{
m_SenList.Add(str);
if(m_pShowSen!=NULL){
m_pShowSen->m_ListSen.InsertString(-1,str);
m_pShowSen->UpdateData(FALSE);
m_pShowSen->m_ListSen.SetCurSel(m_pShowSen->m_ListSen.GetCount()-1);
m_pShowSen->AddSen();
}
if(m_SenList.GetSize()>50){
m_SenList.RemoveAt(0);
if(m_pShowSen!=NULL){
m_pShowSen->m_ListSen.DeleteString(0);
m_pShowSen->UpdateData(FALSE);
}
}
}
void CPictalkDlg::OnChangeTalk()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData();
if(m_Sendinfo.GetLength()>48){
if(m_pShowSen==NULL){
m_pShowSen=new CShowSen(this);
m_pShowSen->Create(IDD_DIALOG_SENTEN,this);
int i;
for(i=0;im_ListSen.InsertString(-1,m_SenList[i]);
m_pShowSen->ShowWindow(SW_SHOW);
}
m_pShowSen->SetFocus();
m_pShowSen->UpdateData();
m_pShowSen->m_SenCtrl.SetSel(0,-1);
m_pShowSen->m_SenCtrl.ReplaceSel(m_Sendinfo);
}
}
void CPictalkDlg::OnButtonShowinfo()
{
// TODO: Add your control notification handler code here
if(m_pShowInfo==NULL){
m_pShowInfo=new CShowInfo(this);
m_pShowInfo->Create(IDD_USERINFO,this);
m_pShowInfo->ShowWindow(SW_SHOW);
}
else{
m_pShowInfo->DestroyWindow();
delete m_pShowInfo;
m_pShowInfo=NULL;
}
SetFocus();
}
LRESULT CPictalkDlg::OnDlgInfoClose(WPARAM wParam,LPARAM param)
{
m_pShowInfo->DestroyWindow();
delete m_pShowInfo;
m_pShowInfo=NULL;
return 0L;
}
void CPictalkDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect ret;
POSITION pos;
if(m_pShowInfo){
for( pos = m_pUserList.GetHeadPosition(); pos != NULL; )
{
CUserInfo *tempUser=(CUserInfo *)m_pUserList.GetNext(pos);
ret=tempUser->m_Place;
ret.left+=12;
ret.right+=12;
if(ret.PtInRect(point))
{
m_pShowInfo->m_Name="昵称:"+tempUser->m_Name;
m_pShowInfo->m_IP=tempUser->m_IP;
m_pShowInfo->m_nAge=tempUser->m_nAge;
m_pShowInfo->m_Sex=tempUser->m_Sex;
m_pShowInfo->m_IcqNum=tempUser->m_ICQ;
m_pShowInfo->m_Job=tempUser->m_Job;
m_pShowInfo->m_Address=tempUser->m_Address;
m_pShowInfo->FindIP(tempUser->m_IP);
m_pShowInfo->UpdateData(FALSE);
}
}
}
CDialog::OnMouseMove(nFlags, point);
}
void CPictalkDlg::Connected()
{
OnButtonShowinfo();
SendUser();
}
void CPictalkDlg::OnConnectOver(UINT nID, LPARAM param)
{
m_pNet->ConnectOver();
}
void CPictalkDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
SendOut();
POSITION pos,pos2;
for( pos = m_pUserList.GetHeadPosition(); pos != NULL; )
{
pos2=pos;
CUserInfo *tempUser=(CUserInfo *)m_pUserList.GetNext(pos);
delete tempUser;
m_pUserList.RemoveAt(pos2);
}
}
BOOL CPictalkDlg::IsUser(UINT uID)
{
CUserInfo * tempUser;
return m_MapUser.Lookup(uID,tempUser);
}