串口

来源:互联网 发布:图像算法专业 编辑:程序博客网 时间:2024/05/17 03:52

 }
 else
 {
  CDialog::OnSysCommand(nID, lParam);
 }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSCOMMDlg::OnPaint()
{
 if (IsIconic())
 {
  CPaintDC dc(this); // device context for painting

  SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

  // Center icon in client rectangle
  int cxIcon = GetSystemMetrics(SM_CXICON);
  int cyIcon = GetSystemMetrics(SM_CYICON);
  CRect rect;
  GetClientRect(&rect);
  int x = (rect.Width() - cxIcon + 1) / 2;
  int y = (rect.Height() - cyIcon + 1) / 2;

  // Draw the icon
  dc.DrawIcon(x, y, m_hIcon);
 }
 else
 {
  CDialog::OnPaint();
 }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSCOMMDlg::OnQueryDragIcon()
{
 return (HCURSOR) m_hIcon;
}
static long rxdatacount=0;  //该变量用于接收字符计数
LONG CSCOMMDlg::OnCommunication(WPARAM ch, LPARAM port)
{
 if (port <= 0 || port > 4)
  return -1;
 rxdatacount++;   //接收的字节计数
 CString strTemp;
 strTemp.Format("%ld",rxdatacount);
 strTemp="RX:"+strTemp;
 m_ctrlRXCOUNT.SetWindowText(strTemp);  //显示接收计数
 
 
 //如果选择了"十六进制显示",则显示十六进制值
 CString str;

    str.Format("%02X ",ch);