ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:74.89KB ,
资源ID:17714944      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17714944.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(vc++mfc串口通信Word下载.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

vc++mfc串口通信Word下载.docx

1、public: CAboutDlg();/ Dialog Data /AFX_DATA(CAboutDlg) enum IDD = IDD_ABOUTBOX ; /AFX_DATA / ClassWizard generated virtual function overrides /AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support /AFX_VIRTUAL/ Implementationprotected: /AFX_MSG(CAboutDl

2、g) /AFX_MSG DECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD) /AFX_DATA_INIT(CAboutDlg) /AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CAboutDlg) /AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog) /AFX_MSG_MAP(CAboutDlg)

3、/ No message handlers /AFX_MSG_MAPEND_MESSAGE_MAP()/ CSerilDlg dialogCSerilDlg:CSerilDlg(CWnd* pParent /*=NULL*/) : CDialog(CSerilDlg:IDD, pParent) /AFX_DATA_INIT(CSerilDlg) m_strRXData = _T(); m_strTXData = _T( m_TestFlag = _T( / Note that LoadIcon does not require a subsequent DestroyIcon in Win32

4、 m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CSerilDlg: /AFX_DATA_MAP(CSerilDlg) DDX_Control(pDX, IDC_OPENSERIL, m_Opensril); DDX_Control(pDX, IDC_COM, m_serilcom); DDX_Text(pDX, IDC_EDIT_RXDATA, m_strRXData); DDX_Text(pDX, IDC_EDIT_TXDATA, m_strTXData); DDX_Control(pDX, IDC_MSCOMM1, m_ctrlCo

5、mm); DDX_Text(pDX, IDC_TESTFLAG, m_TestFlag);BEGIN_MESSAGE_MAP(CSerilDlg, CDialog) /AFX_MSG_MAP(CSerilDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_CLEAR, OnClear) ON_BN_CLICKED(IDC_CLEARSEND, OnClearsend) ON_CBN_CLOSEUP(IDC_COM, OnCloseupCom) ON_BN_CLICKED(IDC_FASONG

6、, OnFasong) ON_BN_CLICKED(IDC_OPENSERIL, OnOpenseril)/ CSerilDlg message handlersBOOL CSerilDlg:OnInitDialog()OnInitDialog(); / Add About. menu item to system menu. / IDM_ABOUTBOX must be in the system command range. ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX AppendMenu(MF_SE

7、PARATOR);AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); / Set the icon for this dialog. The framework does this automatically / when the applications main window is not a dialog SetIcon(m_hIcon, TRUE); / Set big icon SetIcon(m_hIcon, FALSE); / Set small icon / TODO: Add extra initialization here

8、 return TRUE; / return TRUE unless you set the focus to a controlOnSysCommand(UINT nID, LPARAM lParam) if (nID & 0xFFF0) = IDM_ABOUTBOX) CAboutDlg dlgAbout; dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw

9、 the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.OnPaint() if (IsIconic() CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); / Center icon in client rectangle int cxIcon = Ge

10、tSystemMetrics(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);OnPaint();/ The system calls this to obtain the cursor to display while

11、 the user drags/ the minimized window.HCURSOR CSerilDlg:OnQueryDragIcon() return (HCURSOR) m_hIcon;BEGIN_EVENTSINK_MAP(CSerilDlg, CDialog) /AFX_EVENTSINK_MAP(CSerilDlg) ON_EVENT(CSerilDlg, IDC_MSCOMM1, 1 /* OnComm */, OnComm, VTS_NONE) /AFX_EVENTSINK_MAPEND_EVENTSINK_MAP()OnComm() Add your control n

12、otification handler code here VARIANT variant_inp; COleSafeArray safearray_inp; LONG len,k; BYTE rxdata20480,rxtemp20480=0,top20480,down20480,jm20480,jm120480; /设置BYTE数组 An 8-bit integerthat is not signed. CString strtemp,test,test1; if (m_ctrlComm.GetCommEvent() = 2) /事件值为2表示接收缓冲区内有字符 / CString rw=

13、rw; /以下你可以根据自己的通信协议加入处理代码 variant_inp = m_ctrlComm.GetInput(); /读缓冲区 safearray_inp = variant_inp; /VARIANT型变量转换为ColeSafeArray型变量 len = safearray_inp.GetOneDimSize(); /得到有效数据长度 for(k = 0;k len;k+) safearray_inp.GetElement(&k,rxdata+k);/转换为BYTE型数组 if(rxdata0 = r&rxdata1 = erxdata2 = crxdata3 = irxdata

14、4 = vrxdata5 = ) m_TestFlag = 已被成功接收 else m_ctrlComm.SetOutput(COleVariant(recive); for (k=0;k 1000#pragma once#endif / _MSC_VER class CSerilDlg :/ Construction CSerilDlg(CWnd* pParent = NULL); / standard constructor /AFX_DATA(CSerilDlg) enum IDD = IDD_SERIL_DIALOG ; CButton m_Opensril; CComboBox m_

15、serilcom; CString m_strRXData; CString m_strTXData; CMSComm m_ctrlComm; CString m_TestFlag; /AFX_VIRTUAL(CSerilDlg) HICON m_hIcon; / Generated message map functions /AFX_MSG(CSerilDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HC

16、URSOR OnQueryDragIcon(); afx_msg void OnClear(); afx_msg void OnClearsend(); afx_msg void OnCloseupCom(); afx_msg void OnFasong(); afx_msg void OnComm(); afx_msg void OnOpenseril(); DECLARE_EVENTSINK_MAP()/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_SERILDLG_H_1B

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1