91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 39.06MB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-06-30
  • 語言: C/C++
  • 標簽: 即時通訊??

資源簡介

c++ tcp udp通訊 文件操作 容器操作 mysql操作 mfc界面等等 另外的服務器代碼通過博客查找網(wǎng)頁地址:http://blog.csdn.net/perfectguyipeng/article/details/71698826

資源截圖

代碼片段和文件信息

//?Chat.cpp?:?實現(xiàn)文件
//

#include?“stdafx.h“
#include?“MyChattingroom_client.h“
#include?“Chat.h“
#include?“afxdialogex.h“

struct?apple?
{
char?mymesssage[1024]?;
};

apple?myapple?;
//?CChat?對話框

IMPLEMENT_DYNAMIC(CChat?CDialogEx)

CChat::CChat(CWnd*?pParent?/*=NULL*/)
:?CDialogEx(CChat::IDD?pParent)
?m_recmessage(_T(““))
?m_sendmsg(_T(““))
{

}

CChat::~CChat()
{
}

void?CChat::DoDataExchange(CDataExchange*?pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX?IDC_recmessage?m_recmsgctr);
DDX_Text(pDX?IDC_recmessage?m_recmessage);
DDX_Text(pDX?IDC_sendmsg?m_sendmsg);
}


BEGIN_MESSAGE_MAP(CChat?CDialogEx)
ON_BN_CLICKED(IDC_send?&CChat::OnBnClickedsend)
ON_BN_CLICKED(IDC_BUTTON2?&CChat::OnBnClickedButton2)
ON_WM_CLOSE()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_file?&CChat::OnBnClickedfile)
ON_BN_CLICKED(IDC_chatting?&CChat::OnBnClickedchatting)
END_MESSAGE_MAP()


//?CChat?消息處理程序


void?CChat::OnBnClickedsend()
{
//?TODO:?在此添加控件通知處理程序代碼
CTime?time;
time?=?CTime::GetCurrentTime();??//獲取現(xiàn)在時間

CString?strTime?=?time.Format(“%Y-%m-%d?%H:%M:%S??“);
theApp.head.type?=?3;
UpdateData(true);
m_recmessage?+=?strTime?+?(CString)“(“?+?theApp.m_userid?+?(CString)“)?“?+?theApp.m_username?+?(CString)“\r\n????“?+?m_sendmsg?+?(CString)“\r\n“;
CHead?Msg;
Msg.type?=?3;

strcpy_s(Msg.fromID(CStringA)theApp.m_userid);
strcpy_s(Msg.nicname(CStringA)theApp.m_username);
strcpy(Msg.id(CStringA)theApp.m_userid);
strcpy(Msg.toID(CStringA)mytoid);
strcpy_s(Msg.IPtheApp.head.IP);
strcpy_s(Msg.message(CStringA)m_sendmsg);
m_sendmsg?=?““;
UpdateData(false);
m_recmsgctr.LineScroll(m_recmsgctr.GetLineCount()-1);
theApp.mytcp->Send(&Msgsizeof(Msg));

//打開文件
CString?mm?=?(CString)“10000“?;
ofstream?outfile;
char?messsage[1024]?;
char?repair[200];
if(mytoid?==?mm)?//群聊記錄
{
//打開文件
strcpy_s(myapple.mymesssage(CStringA)m_recmessage)?;??//消息
strcpy(repair“討論群的聊天記錄.txt“);
}
else?//私聊記錄
{
char?tempname[100];
char?tempother[100]?;
strcpy_s(tempname(CStringA)theApp.m_username)?;?//我的昵稱
strcpy_s(myapple.mymesssage(CStringA)m_recmessage)?;??//消息
strcpy_s(tempother(CStringA)theApp.m_client[(CString)Msg.toID])?;??
sprintf(repair“%s和%s的聊天記錄.txt“tempnametempother);
}
outfile.open(repairios::binary?|?ios::app);
outfile.write((char*)&myapplesizeof(myapple));
outfile.close();

}


BOOL?CChat::OnInitDialog()
{
CDialogEx::OnInitDialog();

//?TODO:??在此添加額外的初始化

mycaption?=(CString)“正與(“?+??mytoid?+?(CString)“)?“?+?othername?+?(CString)“?聊天中“;
SetWindowTextW(mycaption);//設置對話框標題
theApp.friendid?=?mytoid?;
theApp.friendname?=?theApp.m_client[mytoid]?;
CImage?m_image;
CString?strPath?=?TEXT(“D:/Pic/b.png“);
if(m_image.Load((LPCTSTR)strPath)?!=?S_OK)?//根據(jù)圖片路徑加載圖片?
{
AfxMessageBox(TEXT(“Load?Error!“));
return?FALSE;
}
CRect?rect;//定義矩形類??

int?cx?=?m_image.GetWidth();//

評論

共有 條評論