comset.cpp
来自「spcomm串口控件及例子,如何进行十六进制到ASCII码的转换」· C++ 代码 · 共 43 行
CPP
43 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ComSet.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TSetCom *SetCom;
//---------------------------------------------------------------------------
__fastcall TSetCom::TSetCom(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TSetCom::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TSetCom::Button1Click(TObject *Sender)
{
MainForm->Comm->StopComm();
MainForm->Comm->CommName=ComName->Text;
MainForm->Comm->BaudRate=BaudRate->Text.ToIntDef(9600);
MainForm->Comm->ByteSize=ByteSize->Text.ToIntDef(_8);
MainForm->Comm->StopBits=StopBits->Text.ToIntDef(_1);
try
{
MainForm->Comm->StartComm();
Close();
}
catch(...)
{
Application->MessageBoxA("串口通信参数设置错误!\n现在串口停止工作。","串口错误",0);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?