mngdlg.cpp
来自「本系统所完成功能如下:  即时消息:用户之间发送即时消息。 」· C++ 代码 · 共 151 行
CPP
151 行
// MngDlg.cpp : implementation file
//
#include "stdafx.h"
#include "IM.h"
#include "MngDlg.h"
#include "AddgrpDlg.h"
#include "DelgrpDlg.h"
#include "MovgrpDlg.h"
extern int m_uid,total;
extern struct user
{
int uid;
CString fipport;
CString fnicheng;
BOOL fonline;
BOOL fvip;
}fuser[100];
extern CString CRdir;
extern SOCKET TCPsocket;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// MngDlg dialog
MngDlg::MngDlg(CWnd* pParent /*=NULL*/)
: CDialog(MngDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(MngDlg)
m_nOnline = -1;
m_nDeID = 0;
//}}AFX_DATA_INIT
}
void MngDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(MngDlg)
DDX_Radio(pDX, IDC_RADIO1, m_nOnline);
DDX_Text(pDX, IDC_EDIT1, m_nDeID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(MngDlg, CDialog)
//{{AFX_MSG_MAP(MngDlg)
ON_BN_CLICKED(IDC_BTNADDGRP, OnBtnaddgrp)
ON_BN_CLICKED(IDC_BTNDELGRP, OnBtndelgrp)
ON_BN_CLICKED(IDC_BTNMVGRP, OnBtnmvgrp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// MngDlg message handlers
void MngDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if(m_nDeID!=0)
{
//删除好友
CString str;
for(int i=1;i<=total;i++)
if(fuser[i].uid==m_nDeID)break;
if(i>total)
MessageBox("您所输用户不是您的好友!");
else
{
//C类服务 删除好友请求
str.Format("c%d#%d",m_uid,m_nDeID);
::send(TCPsocket,str,str.GetLength()+1,0);
DelFriend(m_nDeID);
str.Format("%s\\%d.ini",CRdir,m_nDeID);
FILE *De=fopen(str,"w+");
fclose(De);
}
}
CDialog::OnOK();
}
void MngDlg::OnBtnaddgrp()
{
// TODO: Add your control notification handler code here
AddgrpDlg agd;
agd.DoModal();
}
void MngDlg::OnBtndelgrp()
{
// TODO: Add your control notification handler code here
DelgrpDlg dgd;
dgd.DoModal();
}
void MngDlg::OnBtnmvgrp()
{
// TODO: Add your control notification handler code here
MovgrpDlg mgd;
mgd.DoModal();
}
void MngDlg::DelFriend(int uid)
{
//删除好友的本地文件处理 纯修改分组文件
int friendnum,k=1,nextuid;
CString str,s;
BOOL find=FALSE;
char buf[20][16];
int grpnum=GetPrivateProfileInt("FriendGroup","Groupnum",0,CRdir+"\\fenzu.ini");
for(int i=1;i<=grpnum;i++)
{
str.Format("Groupname%d",i);
GetPrivateProfileString("FriendGroup",str,NULL,buf[i],16,CRdir+"\\fenzu.ini");
friendnum=GetPrivateProfileInt(buf[i],"Friendnum",0,CRdir+"\\fenzu.ini");
for(k=1;k<=friendnum;k++)
{
str.Format("Friend%d",k);
nextuid=(int)GetPrivateProfileInt(buf[i],str,0,CRdir+"\\fenzu.ini");
if(uid==nextuid)
find=TRUE;
else if(find)
{
str.Format("Friend%d",k-1);
s.Format("%d",nextuid);
WritePrivateProfileString(buf[i],str,s,CRdir+"\\fenzu.ini");
}
}
if(find)
{
s.Format("%d",friendnum-1);
WritePrivateProfileString(buf[i],"Friendnum",s,CRdir+"\\fenzu.ini");
s.Format("Friend%d",friendnum);
WritePrivateProfileString(buf[i],s,NULL,CRdir+"\\fenzu.ini");
break;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?