⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msg.cpp

📁 用Visual C++实现的网络聊天室
💻 CPP
字号:
#include "stdafx.h"
#include "Msg.h"

CMsg::CMsg(CString& preMsg)
{
	m_strText=preMsg;
	Init();

}
CMsg::CMsg()
{
	m_strText=_T("");
	Init();
}

void CMsg::Init()
{
	m_strText=_T("");
    m_nomalMsg.who=m_nomalMsg.toWho=m_nomalMsg.msgItem=_T("");
	m_systemMsg.msgItem=m_systemMsg.type=_T("");
//	m_loadMsg.name=m_loadMsg.password=_T("");

}


CString CMsg::WhatType()
{
	CString preType("NULLMSG");
	int begin=0;
	int end=0;
	end=m_strText.Find("_");
    preType=m_strText.Mid(begin,end-begin);
	if(preType!="NOMALMSG"&&
		preType!="SYSTEMMSG"&&
		preType!="LOADMSG")
	{
		preType="ERRORMSG";
	}
		return preType;
}

void CMsg::BuildNomal()
{
	int begin=0;
	int end=0;
	end=m_strText.Find("_");
	begin=end+1;
	end=m_strText.Find("_",begin);
	
	m_nomalMsg.who=m_strText.Mid(begin,end-begin);//提取是谁发的消息
	

	begin=end+1;
	end=m_strText.Find("_",begin);
	m_nomalMsg.toWho=m_strText.Mid(begin,end-begin);//提取发给谁

    m_nomalMsg.msgItem=m_strText.Mid(end+1);//消息体




}
void CMsg::BuildLoad()
{
	int begin=0;
	int end=0;
	end=m_strText.Find("_");

	begin=end+1;
	end=m_strText.Find("_",begin);
    m_loadMsg.name=m_strText.Mid(begin,end-begin);//提取是谁发的消息

	begin=end+1;
    m_loadMsg.password=m_strText.Mid(begin);//消息体

}


void CMsg::BuileSystem()
{
	int begin=0;
	int end=0;
	end=m_strText.Find("_");//SYSTEMMSG

	begin=end+1;
	end=m_strText.Find("_",begin);
	m_systemMsg.type=m_strText.Mid(begin,end-begin);//CLOSE

	begin=end+1;
	end=m_strText.Find("_",begin);
	m_systemMsg.name=m_strText.Mid(begin,end-begin);//NAME

	begin=end+1;
	end=m_strText.Find("_",begin);
	m_systemMsg.msgItem=m_strText.Mid(begin);

}

	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -