c++ - MFC SetWindowTextA 错误。我怎么解决这个问题
问题描述
我想得到一个字符串并将其放入 EditControl。Debug Assertion Failed 错误发生在初始化部分( SetWindowTextA
) 中,但原因未知。m_ChatWindow
宣布CEdit
。
这是代码的一部分:
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;
}
解决方案
推荐阅读
- excel - Power Query 空问题
- javascript - 自动关闭模态弹出窗口,而不是使用按钮/单击
- mysql - 平等在MySQL中真的意味着平等吗?
- reactjs - 我正在用 react 和 flask 构建一个不和谐的 oauth2 应用程序。这是正确的方法吗?
- java - 一个线程池Java的多个CompletionService
- c++ - Cap'n'proto过早破坏接口?
- google-apps-script - Google Apps 脚本对 GmailApp 的限制
- couchdb - 如何在 Couchdb/Couchbase 中为帖子实现喜欢和不喜欢计数
- django - 使用 Django m2m_changed 信号,有没有办法知道删除了哪个关系?
- python - youtube-dl 下载无法播放的音频文件