新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > C++builder串口通信設(shè)計(一)-串口接收數(shù)據(jù)

        C++builder串口通信設(shè)計(一)-串口接收數(shù)據(jù)

        作者: 時間:2016-11-28 來源:網(wǎng)絡(luò) 收藏
        一、安裝mscomm32.ocx控件

        1、復(fù)制mscomm32.ocx到windowssystem32下

        本文引用地址:http://www.104case.com/article/201611/322881.htm

        2、注冊

        二、在c++builder下引入mscomm32.ocx

        選擇菜單component->Import ActiveX Control,




        選擇“Microsoft Comm Control 6.0(Version1.1)”,點擊“install”



        然后可以在ActiveX控件組看到一個像電話的控件。

        三、建立應(yīng)用工程

        1、設(shè)計界面

        引入了mscomm32控件,memo1控件,Button1,Button2,RadioButton1和RadioButton2

        1) 其中memo1用于顯示串口接收內(nèi)容

        2)Button1用于控制串口的開啟和關(guān)閉,Button2用于終止應(yīng)用程序

        3)RadioButton1和RadioButton2用于選擇串口接收方式(類型)

        2、unit1.h內(nèi)容,其中紅色為引入的全局變量

        #include
        #include
        #include "MSCommLib_OCX.h"
        #include
        //---------------------------------------------------------------------------
        class TForm1 : public TForm
        {
        __published: // IDE-managed Components
        TMSComm *MSComm1;
        TMemo *Memo1;
        TButton *Button1;
        TButton *Button2;
        TGroupBox *GroupBox1;
        TRadioButton *RadioButton1;
        TRadioButton *RadioButton2;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall MSComm1Comm(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall RadioButton1Click(TObject *Sender);
        void __fastcall RadioButton2Click(TObject *Sender);
        private: // User declarations
        public: // User declarations
        __fastcall TForm1(TComponent* Owner);
        int type;//0--字符串,1---二進制
        };
        //---------------------------------------------------------------------------
        extern PACKAGE TForm1 *Form1;
        //---------------------------------------------------------------------------
        #endif


        上一頁 1 2 下一頁

        評論


        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 深水埗区| 黑河市| 涟源市| 怀柔区| 朝阳县| 莎车县| 平塘县| 婺源县| 贵阳市| 曲周县| 宁化县| 永胜县| 探索| 建德市| 潜江市| 台湾省| 青海省| 大安市| 乌海市| 融水| 罗甸县| 福贡县| 平乐县| 平阳县| 都安| 始兴县| 永丰县| 卓资县| 清远市| 读书| 平江县| 彭水| 肥东县| 长宁县| 滦南县| 苏尼特右旗| 布尔津县| 江都市| 开阳县| 麻栗坡县| 松桃|