0

我的代码有问题。我需要在文本框中显示存储在变量rawValue中的值。

这是我的代码中对问题很重要的部分:

public ref class Form1 : public System::Windows::Forms::Form
{
public:
    Form1(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::Button^  IniciarCaptura;
private: System::Windows::Forms::DataVisualization::Charting::Chart^  chart1;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::TextBox^  textBoxRAW;
private: System::Windows::Forms::TextBox^  textBoxAtencao;
private: System::Windows::Forms::TextBox^  textBoxMeditacao;



protected: 

private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        System::Windows::Forms::DataVisualization::Charting::ChartArea^  chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
        System::Windows::Forms::DataVisualization::Charting::Legend^  legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
        System::Windows::Forms::DataVisualization::Charting::Series^  series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
        this->IniciarCaptura = (gcnew System::Windows::Forms::Button());
        this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
        this->label1 = (gcnew System::Windows::Forms::Label());
        this->label2 = (gcnew System::Windows::Forms::Label());
        this->label3 = (gcnew System::Windows::Forms::Label());
        this->textBoxRAW = (gcnew System::Windows::Forms::TextBox());
        this->textBoxAtencao = (gcnew System::Windows::Forms::TextBox());
        this->textBoxMeditacao = (gcnew System::Windows::Forms::TextBox());
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->chart1))->BeginInit();
        this->SuspendLayout();
        // 
        // IniciarCaptura
        // 
        this->IniciarCaptura->Location = System::Drawing::Point(15, 443);
        this->IniciarCaptura->Name = L"IniciarCaptura";
        this->IniciarCaptura->Size = System::Drawing::Size(75, 23);
        this->IniciarCaptura->TabIndex = 0;
        this->IniciarCaptura->Text = L"Iniciar";
        this->IniciarCaptura->UseVisualStyleBackColor = true;
        this->IniciarCaptura->Click += gcnew System::EventHandler(this, &Form1::IniciarCaptura_Click);
        // 
        // chart1
        // 
        chartArea1->Name = L"ChartArea1";
        this->chart1->ChartAreas->Add(chartArea1);
        legend1->Name = L"Legend1";
        this->chart1->Legends->Add(legend1);
        this->chart1->Location = System::Drawing::Point(15, 99);
        this->chart1->Name = L"chart1";
        series1->ChartArea = L"ChartArea1";
        series1->Legend = L"Legend1";
        series1->Name = L"Series1";
        this->chart1->Series->Add(series1);
        this->chart1->Size = System::Drawing::Size(300, 300);
        this->chart1->TabIndex = 1;
        this->chart1->Text = L"chart1";
        // 
        // label1
        // 
        this->label1->AutoSize = true;
        this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(0)));
        this->label1->Location = System::Drawing::Point(12, 13);
        this->label1->Name = L"label1";
        this->label1->Size = System::Drawing::Size(36, 13);
        this->label1->TabIndex = 2;
        this->label1->Text = L"RAW";
        // 
        // label2
        // 
        this->label2->AutoSize = true;
        this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(0)));
        this->label2->Location = System::Drawing::Point(12, 40);
        this->label2->Name = L"label2";
        this->label2->Size = System::Drawing::Size(54, 13);
        this->label2->TabIndex = 3;
        this->label2->Text = L"Atenção";
        // 
        // label3
        // 
        this->label3->AutoSize = true;
        this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(0)));
        this->label3->Location = System::Drawing::Point(12, 69);
        this->label3->Name = L"label3";
        this->label3->Size = System::Drawing::Size(66, 13);
        this->label3->TabIndex = 4;
        this->label3->Text = L"Meditação";
        // 
        // textBoxRAW
        // 
        this->textBoxRAW->Location = System::Drawing::Point(78, 5);
        this->textBoxRAW->Name = L"textBoxRAW";
        this->textBoxRAW->Size = System::Drawing::Size(355, 20);
        this->textBoxRAW->TabIndex = 5;
        this->textBoxRAW->TextChanged += gcnew System::EventHandler(this, &Form1::textBoxRAW_TextChanged);
        // 
        // textBoxAtencao
        // 
        this->textBoxAtencao->Location = System::Drawing::Point(78, 33);
        this->textBoxAtencao->Name = L"textBoxAtencao";
        this->textBoxAtencao->Size = System::Drawing::Size(355, 20);
        this->textBoxAtencao->TabIndex = 6;
        // 
        // textBoxMeditacao
        // 
        this->textBoxMeditacao->Location = System::Drawing::Point(78, 62);
        this->textBoxMeditacao->Name = L"textBoxMeditacao";
        this->textBoxMeditacao->Size = System::Drawing::Size(355, 20);
        this->textBoxMeditacao->TabIndex = 7;
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(448, 484);
        this->Controls->Add(this->textBoxMeditacao);
        this->Controls->Add(this->textBoxAtencao);
        this->Controls->Add(this->textBoxRAW);
        this->Controls->Add(this->label3);
        this->Controls->Add(this->label2);
        this->Controls->Add(this->label1);
        this->Controls->Add(this->chart1);
        this->Controls->Add(this->IniciarCaptura);
        this->Name = L"Form1";
        this->Text = L"Form1";
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->chart1))->EndInit();
        this->ResumeLayout(false);
        this->PerformLayout();

    }
#pragma endregion
static void handleDataValueFunc(unsigned char extendedCodeLevel, unsigned char code,
    unsigned char valueLength, const unsigned char *value, void *customData)
{
    /*FILE *arq1;
    FILE *arq2;
    FILE *arq3;
        arq1 = fopen("raw.txt","a");
        arq2 = fopen("atencao.txt","a");
        arq3 = fopen("meditacao.txt","a");*/

    if (extendedCodeLevel == 0 && code == RAW_WAVE_CODE)
    {
        short rawValue = ((value[0] << 8) & 0xff00) | (0x00ff & value[1]);
        /*printf("%d\n", rawValue);
        fprintf(arq1,"%d\n",rawValue);*/

        textBoxRAW.SetWindowText(textBoxRAW.text + "" + rawValue + " ");
    }    

我收到以下错误:

error C2228: left of '.Text' must have class/struct/union

这是错误所在的行:

textBoxRAW.SetWindowText(textBoxRAW.text + "" + rawValue + " ");

我怎么解决这个问题?我见过一些代码示例,人们会简单地编写“TextBox->Text”之类的内容,但它不适用于我的代码。

4

1 回答 1

1

从您的帖子中,我认为您倾向于忽略大小写。C++ 区分大小写;因此,文本和文本是不同的。您必须使用 -> 范围运算符进行引用。正确的语法:

    textBoxRAW->Text  = textBoxRAW->Text  + " " + rawValue + " ";
于 2012-09-20T03:19:21.283 回答