首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

哪位高手有Visual C++ 2005 关于SerialPort 串口通讯例子

2012-02-04 
谁有Visual C++ 2005 关于SerialPort 串口通讯例子如题[解决办法]转一段代码给你看看using Systemusing S

谁有Visual C++ 2005 关于SerialPort 串口通讯例子
如题

[解决办法]
转一段代码给你看看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;

namespace TestSerialPort
{
public partial class frmTESTSerialPort : Form
{
public frmTESTSerialPort()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
}

private Button button1;
private TextBox txtSend;
private TextBox txtReceive;
private Label label1;
private Label label2;

/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name= "disposing "> 如果应释放托管资源,为 true;否则为 false。 </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.txtSend = new System.Windows.Forms.TextBox();
this.txtReceive = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(440, 379);
this.button1.Name = "button1 ";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "发送 ";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtSend
//
this.txtSend.Location = new System.Drawing.Point(59, 12);
this.txtSend.Multiline = true;
this.txtSend.Name = "txtSend ";
this.txtSend.Size = new System.Drawing.Size(456, 164);
this.txtSend.TabIndex = 2;
//
// txtReceive
//
this.txtReceive.Location = new System.Drawing.Point(59, 200);
this.txtReceive.Multiline = true;
this.txtReceive.Name = "txtReceive ";
this.txtReceive.Size = new System.Drawing.Size(456, 164);
this.txtReceive.TabIndex = 2;
//
// label1
//
this.label1.Location = new System.Drawing.Point(13, 15);
this.label1.Name = "label1 ";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "发送 ";
//
// label2
//


this.label2.Location = new System.Drawing.Point(13, 213);
this.label2.Name = "label2 ";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 0;
this.label2.Text = "接收 ";
//
// frmTESTSerialPort
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(546, 434);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtReceive);
this.Controls.Add(this.txtSend);
this.Controls.Add(this.button1);
this.Name = "frmTESTSerialPort ";
this.Text = "串口试验 ";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

热点排行