Re: Problem displaying data in a Editbox
I have attached my callback function and com select dialog function
for the main dialogue. This is just a rip off from the serial MFC
demo. I have added a breakpoint and it does get into this function. I
have added a watch on szData and it does store the whole string from
the embedded board but when I try to display on an edit box or a rich
edit box it does not display the full string. I have also tested the
setWindowtext function by printing a text and that works fine. I have
also use unicode in my project option as the serial MFC demo also use
unicode settings but I still experience the same problem. The serial
class MFC demo from Codeproject works fine as it display the captured
string continuously.
LRESULT CMyTabExampleDlg::OnSerialMsg (WPARAM wParam, LPARAM /
*lParam*/)
{
CSerial::EEvent eEvent = CSerial::EEvent(LOWORD(wParam));
CSerial::EError eError = CSerial::EError(HIWORD(wParam));
if (eEvent & CSerial::EEventRecv)
{
// Create a clean buffer
DWORD dwRead;
char szData[101];
const int nBuflen = sizeof(szData)-1;
// Obtain the data from the serial port
do
{
m_serial.Read(szData,nBuflen,&dwRead);
szData[dwRead] = '\0';
// Scan the string for unwanted characters
for (DWORD dwChar=0; dwChar<dwRead; dwChar++)
{
if (!isprint(szData[dwChar]) && !isspace(szData[dwChar]))
{
szData[dwChar] = '.';
}
}
} while (dwRead == nBuflen);
m_disp_log.SetWindowTextA(szData);
}
}
void CMyTabExampleDlg::OnComOpen()
{
// TODO: Add your command handler code here
// Obtain the requested COM port
CComSelectDlg dlgComSelect(this);
dlgComSelect.DoModal();
// Open the serial port
if (m_serial.Open(dlgComSelect.m_strComPort,this) != ERROR_SUCCESS)
{
AfxMessageBox(_T("Unable to open COM-port"),MB_ICONSTOP|MB_OK);
GetParent()->PostMessage(WM_CLOSE);
}
m_serial.Setup
(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
}