📄 unit1.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Comm"
#pragma link "YbCommDevice"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
YbCommDevice1->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
String aa=char(17) ;
YbCommDevice1->Write(aa.c_str(),1) ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
if (ComboBox2->ItemIndex==0)
YbCommDevice1->Baud=TYbCommDevice::br300;
if (ComboBox2->ItemIndex==1)
YbCommDevice1->Baud=TYbCommDevice::br600;
if (ComboBox2->ItemIndex==2)
YbCommDevice1->Baud=TYbCommDevice::br1200;
if (ComboBox2->ItemIndex==3)
YbCommDevice1->Baud=TYbCommDevice::br2400;
if (ComboBox2->ItemIndex==4)
YbCommDevice1->Baud=TYbCommDevice::br4800;
if (ComboBox2->ItemIndex==5)
YbCommDevice1->Baud=TYbCommDevice::br9600;
if (ComboBox2->ItemIndex==6)
YbCommDevice1->Baud=TYbCommDevice::br19200;
if (ComboBox2->ItemIndex==7)
YbCommDevice1->Baud=TYbCommDevice::br38400;
if (ComboBox2->ItemIndex==8)
YbCommDevice1->Baud=TYbCommDevice::br57600;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
String aa=char(19) ;
YbCommDevice1->Write(aa.c_str(),1) ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
String aa=char(17) ;
String bb=char(19) ;
YbCommDevice1->Write(aa.c_str(),1) ;
Sleep(3);
YbCommDevice1->Write(bb.c_str(),1) ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
String aa=char(19) ;
String bb=char(17) ;
YbCommDevice1->Write(aa.c_str(),1) ;
Sleep(1);
YbCommDevice1->Write(bb.c_str(),1) ;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -