⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitset.cpp

📁 uart串口通信的控件和demo,用API 编写
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "UnitSet.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormSet *FormSet;
//---------------------------------------------------------------------------
__fastcall TFormSet::TFormSet(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------



void __fastcall TFormSet::BitBtnSureClick(TObject *Sender)
{

        //FlowControlMode
        /*
        int FlowControlMode =  (SendMessage(ComboBoxFlowControl->Handle,
                                                CB_FINDSTRING,0,
                                                long(ComboBoxFlowControl->Text.c_str())));

                                                
        FormPort->CommUart->FlowControl= (TFlowControl)FlowControlMode;
         */
        //DSRSensitivity
        FormPort->CommUart->DSRSensitivity = CheckBoxDSRsen->Checked;

        //XON/XOFF char
        FormPort->CommUart->EventChars->XOffChar = StrToIntDef(LabeledEditXoffchar->Text,19);
        FormPort->CommUart->EventChars->XOnChar = StrToIntDef(LabeledEditXonchar->Text,17);

        //Buffer
        FormPort->CommUart->ReadBufSize = StrToInt(LabeledEditInBuffer->Text);
        FormPort->CommUart->WriteBufSize = StrToInt(LabeledEditOutBuffer->Text);

        //
        //FormPort->CommUart->
        Close();
}
//---------------------------------------------------------------------------


void __fastcall TFormSet::FormCreate(TObject *Sender)
{
        AlphaBlend = FormPort->AlphaBlend;
        AlphaBlendValue = FormPort->AlphaBlendValue;

}
//---------------------------------------------------------------------------


void __fastcall TFormSet::LabeledEditXoffcharKeyPress(TObject *Sender,
      char &Key)
{
        switch(Key)
        {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
        case  9 :           //删除
                break;
        default:
                Key = 0;
                break;
        }
        
}
//---------------------------------------------------------------------------



void __fastcall TFormSet::ComboBoxFlowControlChange(TObject *Sender)
{
        if((SendMessage(ComboBoxFlowControl->Handle,CB_FINDSTRING,0,long(ComboBoxFlowControl->Text.c_str())))==3)
        {
                CheckBoxDSRsen->Enabled = true;
                CheckBoxOutCTSFlow->Enabled = true;
                CheckBoxOutDSRFlow->Enabled = true;
                CheckBoxTxContinueOnXoff->Enabled = true;
                CheckBoxXonXoffIn->Enabled = true;
                CheckBoxXonXoffOut->Enabled = true;
        }
        else
        {
                CheckBoxDSRsen->Enabled = false;
                CheckBoxOutCTSFlow->Enabled = false;
                CheckBoxOutDSRFlow->Enabled = false;
                CheckBoxTxContinueOnXoff->Enabled = false;
                CheckBoxXonXoffIn->Enabled = false;
                CheckBoxXonXoffOut->Enabled = false;


        }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -