我用MFC做的聊天软件刚刚点击完发送就弹出每个MFC都会弹出的普通窗口,然后聊天的对话框就不见了,求解释??
我是照着书上做的,我在创建服务器后会有个对话框,然后有发送按钮,预想点击发送后是会像聊天窗口一样的显示,但是实际上却是:
关闭了对话框,然后打开MFC最开始的基本窗口;
我的
窗口函数在这里,然后OnSend是处理“发送”按钮的
// CChat 消息处理程序
#include"NetControl.h"
extern NetControl netcontrol;
void CChat::OnSend()
{
// TODO: 在此添加控件通知处理程序代码
/*
netcontrol.m_pSocket = new(CNet);
netcontrol.SendMsg(netcontrol.m_pSocket, "Hello World");
delete netcontrol.m_pSocket;
*/
UpdateData();
if (m_Puts == "") {
MessageBox("Empty Input", "Warning");
return;
}
netcontrol.m_pSocket = new(CNet);
char st[1000] = "";
UpdateData();
CTime time = CTime::GetCurrentTime();
sprintf_s(st, "%d:%d:%d\r\n%s", time.GetHour(), time.GetMinute(), time.GetSecond(), m_Puts);
netcontrol.SendMsg(netcontrol.m_pSocket, st);
CString tem;
if (m_Gets != "")
m_Gets.Format("%s\r\n Send \t%s", st, tem);
else
m_Gets.Format("Send \t%s", st);
m_Puts = "";
UpdateData(false);
delete netcontrol.m_pSocket;
}