0

我想得到一个字符串并将其放入 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;
}
4

0 回答 0