I wanna get a string and put it in EditControl. The Debug Assertion Failed error occurs from the initializing part(SetWindowTextA
), but the cause is unknown. m_ChatWindow
declared CEdit
.
Here is the part of the code:
CMulSenderUIDlg::CMulSenderUIDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_MULSENDERUI_DIALOG, pParent)
{
m_ChatWindow.SetWindowTextA(" ");
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMulSenderUIDlg::DoDataExchange(CDataExchange* pDX)
{
.......
DDX_Control(pDX, IDC_CHATWINDOW, m_ChatWindow);
.......
}
void CMulSenderUIDlg::RecvData(char* buf, int size)
{
char* tempBuffer = new char[BUFFSIZE];
CString currentText;
m_ChatWindow.GetWindowTextA(currentText);
currentText += "\n";
memset(tempBuffer, 0, BUFFSIZE);
memcpy(tempBuffer, currentText.GetBuffer(), currentText.GetLength());
memcpy(tempBuffer + currentText.GetLength(), buf, size);
m_ChatWindow.SetWindowTextA(tempBuffer);
m_ChatWindow.SetWindowTextA("\r\n");
delete[] tempBuffer;
}