建立基于CFormView的单文档程序,向COM口以敲入字符的方式发命令,接收到后,如何显示在View中呢?显示时,如何实现换行呢?
BOOL CMy1View::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN)
{ i++;
char *command;
text+=pMsg->wParam;
command=text.GetBuffer(10);
if (!m_com.ComWrite(comnum,command,1))
{
::MessageBox(NULL,"Can not write to com!",
"Error",MB_OK|MB_ICONERROR);
return FALSE;
}
char data[100];
if (!m_com.ComRead(comnum,data,1))
{
::MessageBox(NULL,"Can not read from com!",
"Error",MB_OK|MB_ICONERROR);
return FALSE;
}
pMsg->wParam= ? (如何把读出的字符转变给pMsg->wParam)
}
return CFormView::PreTranslateMessage(pMsg);
}
BOOL CMy1View::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN)
{ i++;
char *command;
text+=pMsg->wParam;
command=text.GetBuffer(10);
if (!m_com.ComWrite(comnum,command,1))
{
::MessageBox(NULL,"Can not write to com!",
"Error",MB_OK|MB_ICONERROR);
return FALSE;
}
char data[100];
if (!m_com.ComRead(comnum,data,1))
{
::MessageBox(NULL,"Can not read from com!",
"Error",MB_OK|MB_ICONERROR);
return FALSE;
}
pMsg->wParam= ? (如何把读出的字符转变给pMsg->wParam)
}
return CFormView::PreTranslateMessage(pMsg);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货