unitset.cpp

来自「uart串口通信的控件和demo,用API 编写」· C++ 代码 · 共 112 行

CPP
112
字号
//---------------------------------------------------------------------------

#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 + =
减小字号Ctrl + -
显示快捷键?