Ir ao conteúdo
  • Cadastre-se

Ajuda com Strings em Visual C++ (Solucionado!)


Pulllga

Posts recomendados

Olá, sou o Pulllga,

Estou desenvolvendo um software que se comunica pela porta serial com um no-break, o problema é quando recebo os dados, eu preciso de duas variáveis do tipo string.

Eu uso o Visual Studio 2005 e estou programando em Visual C++.

Já tentei com o #include <string> como li aqui no fórum, mas não deu certo, o VS continua dando erro.

Alguém sabe como declarar variáveis string no Visual Studio 2005 C++???

Agradeço desde já, t+ :D:D:D

Link para o comentário
Compartilhar em outros sites

Tio Patinhas,

Prefiro, usar string, se eu usar o char, eu vou ter que fazer muitas conversões durante o programa e com o tipo string iria funciona muito mais tranquilo!

E quando eu uso char, eu preciso converter as strings para char, mas quando uso Convert::ToChar, ele diz que não pode converter para w_char!!!

Alguém sabe exatamente como usar o tipo String???

T+ :D:D:D

Link para o comentário
Compartilhar em outros sites

Eu uso o componente de comunicação serial que vem com o VS, o serialPort, ele recebe as informações da comunicação na propriedade ReadLine, que é do tipo String, e ai tenho que converter pra char pra colocar em variáveis char, mas ai ele fala que não dá pra converter, tem que converter para w_char!!!

Depois vou ter que quebrar essa string em outras e lançar cada uma em uma TextBox ou Label, ai, se usar char, vou ter que converter tudo de char para string quando eu for lançar esses dados nos componentes!!!

Além de não conseguir converter estes dados, a meu ver é mais fácil usar string do que ficar convertendo seguido!!!

Se alguém ainda souber me ajudar...

T+ valeu :D:D:D

Link para o comentário
Compartilhar em outros sites

Olá,

Ainda assim não dá certo!!!

Declarei no stdafx.h:

#include <string>

E declarei as variáveis:

string tempBuf, defBuff;

Mas não funciona, fica dando os erros:

"missing ';' before identifier 'tempBuff'"

"missing type specifier - int assumed. Note C++ does not support default-int"

O que eu faço???

Lembrando que uso o Visual C++

valeu :D:D:D

Link para o comentário
Compartilhar em outros sites

Quer ver o código?

Lá vai...

A parte marcada de vermelho é onde recebo a string da porta serial, eu concateno ela, se seu usar char, não conseguirei concatenar tudo, são mais de 1500 caracteres!

E mesmo se eu conseguisse, toda vez que eu fosse exibir os dados ou grava-los no arquivo de log, ia ter que fazer mais converssões!!!

Por isso quero usar strings, converto só uma vez, poupo linhas, tempo e trabalho!!!

Ah, aqui eu retirei o #include <string>, é nesse arquivo que coloco?

Eu já tentei mas não deu!!!

#pragma once

namespace LightUPS {

int Btn;

int xPos,yPos,marCon;

int val1, val2, val3, val4;

string tempBuff, defBuff;

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

/// <summary>

/// Summary for Form1

///

/// WARNING: If you change the name of this class, you will need to change the

/// 'Resource File Name' property for the managed resource compiler tool

/// associated with all .resx files this class depends on. Otherwise,

/// the designers will not be able to interact properly with localized

/// resources associated with this form.

/// </summary>

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::PictureBox^ picFun;

protected:

private: System::Windows::Forms::PictureBox^ picFec;

private: System::Windows::Forms::PictureBox^ picHel;

private: System::Windows::Forms::PictureBox^ picCon;

private: System::Windows::Forms::PictureBox^ picMax;

private: System::Windows::Forms::PictureBox^ picMed;

private: System::Windows::Forms::PictureBox^ picMin;

private: System::Windows::Forms::PictureBox^ picSet;

private: System::Windows::Forms::ToolTip^ tipPri;

private: System::Windows::Forms::Label^ lblNom;

private: System::Windows::Forms::Label^ lblHF;

private: System::Windows::Forms::Label^ lblLog;

private: System::Windows::Forms::Label^ lblDis;

private: System::Windows::Forms::Label^ lblTen;

private: System::Windows::Forms::Label^ lblCor;

private: System::Windows::Forms::Label^ lblFre;

private: System::Windows::Forms::Label^ lblCar;

private: System::Windows::Forms::ProgressBar^ barCar;

private: System::Windows::Forms::Label^ lblVal1;

private: System::Windows::Forms::Label^ lblVal2;

private: System::Windows::Forms::Label^ lblVal3;

private: System::Windows::Forms::Label^ lblVal4;

private: System::Windows::Forms::PictureBox^ pictureBox1;

private: System::Windows::Forms::PictureBox^ pictureBox2;

private: System::Windows::Forms::Timer^ timLet;

private: System::IO::Ports::SerialPort^ serPri;

private: System::Windows::Forms::Timer^ timCom;

private: System::Windows::Forms::TextBox^ txtTmp;

private: System::Windows::Forms::TextBox^ txtBuf;

private: System::ComponentModel::IContainer^ components;

protected:

private:

/// <summary>

/// Required designer variable.

/// </summary>

#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)

{

this->components = (gcnew System::ComponentModel::Container());

System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));

this->picFun = (gcnew System::Windows::Forms::PictureBox());

this->picFec = (gcnew System::Windows::Forms::PictureBox());

this->picHel = (gcnew System::Windows::Forms::PictureBox());

this->picCon = (gcnew System::Windows::Forms::PictureBox());

this->picMax = (gcnew System::Windows::Forms::PictureBox());

this->picMed = (gcnew System::Windows::Forms::PictureBox());

this->picMin = (gcnew System::Windows::Forms::PictureBox());

this->picSet = (gcnew System::Windows::Forms::PictureBox());

this->tipPri = (gcnew System::Windows::Forms::ToolTip(this->components));

this->lblNom = (gcnew System::Windows::Forms::Label());

this->lblHF = (gcnew System::Windows::Forms::Label());

this->lblLog = (gcnew System::Windows::Forms::Label());

this->lblDis = (gcnew System::Windows::Forms::Label());

this->lblTen = (gcnew System::Windows::Forms::Label());

this->lblCor = (gcnew System::Windows::Forms::Label());

this->lblFre = (gcnew System::Windows::Forms::Label());

this->lblCar = (gcnew System::Windows::Forms::Label());

this->barCar = (gcnew System::Windows::Forms::ProgressBar());

this->lblVal1 = (gcnew System::Windows::Forms::Label());

this->lblVal2 = (gcnew System::Windows::Forms::Label());

this->lblVal3 = (gcnew System::Windows::Forms::Label());

this->lblVal4 = (gcnew System::Windows::Forms::Label());

this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());

this->timLet = (gcnew System::Windows::Forms::Timer(this->components));

this->serPri = (gcnew System::IO::Ports::SerialPort(this->components));

this->timCom = (gcnew System::Windows::Forms::Timer(this->components));

this->txtTmp = (gcnew System::Windows::Forms::TextBox());

this->txtBuf = (gcnew System::Windows::Forms::TextBox());

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picFun))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picFec))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picHel))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picCon))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picMax))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picMed))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picMin))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picSet))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox2))->BeginInit();

this->SuspendLayout();

//

// picFun

//

this->picFun->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picFun.Image")));

this->picFun->Location = System::Drawing::Point(0, 70);

this->picFun->Name = L"picFun";

this->picFun->Size = System::Drawing::Size(238, 11);

this->picFun->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picFun->TabIndex = 0;

this->picFun->TabStop = false;

//

// picFec

//

this->picFec->AccessibleDescription = L"Fechar";

this->picFec->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picFec.Image")));

this->picFec->Location = System::Drawing::Point(209, 5);

this->picFec->Name = L"picFec";

this->picFec->Size = System::Drawing::Size(24, 24);

this->picFec->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picFec->TabIndex = 1;

this->picFec->TabStop = false;

this->tipPri->SetToolTip(this->picFec, L"Fechar");

this->picFec->Click += gcnew System::EventHandler(this, &Form1::picFec_Click);

//

// picHel

//

this->picHel->AccessibleDescription = L"Ajuda";

this->picHel->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picHel.Image")));

this->picHel->Location = System::Drawing::Point(179, 5);

this->picHel->Name = L"picHel";

this->picHel->Size = System::Drawing::Size(24, 24);

this->picHel->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picHel->TabIndex = 2;

this->picHel->TabStop = false;

this->tipPri->SetToolTip(this->picHel, L"Ajuda");

//

// picCon

//

this->picCon->AccessibleDescription = L"Configurações";

this->picCon->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picCon.Image")));

this->picCon->Location = System::Drawing::Point(149, 5);

this->picCon->Name = L"picCon";

this->picCon->Size = System::Drawing::Size(24, 24);

this->picCon->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picCon->TabIndex = 3;

this->picCon->TabStop = false;

this->tipPri->SetToolTip(this->picCon, L"Configurar");

//

// picMax

//

this->picMax->AccessibleDescription = L"Máximo";

this->picMax->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picMax.Image")));

this->picMax->Location = System::Drawing::Point(119, 5);

this->picMax->Name = L"picMax";

this->picMax->Size = System::Drawing::Size(24, 24);

this->picMax->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picMax->TabIndex = 4;

this->picMax->TabStop = false;

this->tipPri->SetToolTip(this->picMax, L"Completo");

this->picMax->Click += gcnew System::EventHandler(this, &Form1::picMax_Click);

//

// picMed

//

this->picMed->AccessibleDescription = L"Médio";

this->picMed->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picMed.Image")));

this->picMed->Location = System::Drawing::Point(89, 5);

this->picMed->Name = L"picMed";

this->picMed->Size = System::Drawing::Size(24, 24);

this->picMed->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picMed->TabIndex = 5;

this->picMed->TabStop = false;

this->tipPri->SetToolTip(this->picMed, L"Minimo");

this->picMed->Click += gcnew System::EventHandler(this, &Form1::picMed_Click);

//

// picMin

//

this->picMin->AccessibleDescription = L"Mínimo";

this->picMin->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picMin.Image")));

this->picMin->Location = System::Drawing::Point(59, 5);

this->picMin->Name = L"picMin";

this->picMin->Size = System::Drawing::Size(24, 24);

this->picMin->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picMin->TabIndex = 6;

this->picMin->TabStop = false;

this->tipPri->SetToolTip(this->picMin, L"Oculto");

this->picMin->Click += gcnew System::EventHandler(this, &Form1::picMin_Click);

//

// picSet

//

this->picSet->AccessibleDescription = L"Próxima tela...";

this->picSet->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"picSet.Image")));

this->picSet->Location = System::Drawing::Point(208, 61);

this->picSet->Name = L"picSet";

this->picSet->Size = System::Drawing::Size(24, 24);

this->picSet->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->picSet->TabIndex = 7;

this->picSet->TabStop = false;

this->tipPri->SetToolTip(this->picSet, L"Próxima tela...");

this->picSet->Visible = false;

//

// tipPri

//

this->tipPri->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(0)),

static_cast<System::Int32>(static_cast<System::Byte>(192)));

this->tipPri->ForeColor = System::Drawing::Color::White;

this->tipPri->IsBalloon = true;

//

// lblNom

//

this->lblNom->AutoSize = true;

this->lblNom->BackColor = System::Drawing::Color::Transparent;

this->lblNom->Font = (gcnew System::Drawing::Font(L"Courier New", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblNom->ForeColor = System::Drawing::Color::White;

this->lblNom->Location = System::Drawing::Point(5, 35);

this->lblNom->Name = L"lblNom";

this->lblNom->Size = System::Drawing::Size(80, 16);

this->lblNom->TabIndex = 8;

this->lblNom->Text = L"Light UPS";

//

// lblHF

//

this->lblHF->AutoSize = true;

this->lblHF->BackColor = System::Drawing::Color::Transparent;

this->lblHF->Font = (gcnew System::Drawing::Font(L"Courier New", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblHF->ForeColor = System::Drawing::Color::White;

this->lblHF->Location = System::Drawing::Point(86, 35);

this->lblHF->Name = L"lblHF";

this->lblHF->Size = System::Drawing::Size(40, 16);

this->lblHF->TabIndex = 9;

this->lblHF->Text = L"(HF)";

//

// lblLog

//

this->lblLog->AutoSize = true;

this->lblLog->BackColor = System::Drawing::Color::Transparent;

this->lblLog->Font = (gcnew System::Drawing::Font(L"Courier New", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblLog->ForeColor = System::Drawing::Color::White;

this->lblLog->Location = System::Drawing::Point(153, 35);

this->lblLog->Name = L"lblLog";

this->lblLog->Size = System::Drawing::Size(80, 16);

this->lblLog->TabIndex = 10;

this->lblLog->Text = L"LOGMASTER";

//

// lblDis

//

this->lblDis->AutoSize = true;

this->lblDis->BackColor = System::Drawing::Color::Transparent;

this->lblDis->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblDis->Location = System::Drawing::Point(12, 61);

this->lblDis->Name = L"lblDis";

this->lblDis->Size = System::Drawing::Size(63, 14);

this->lblDis->TabIndex = 11;

this->lblDis->Text = L"Bateria:";

this->lblDis->Visible = false;

//

// lblTen

//

this->lblTen->AutoSize = true;

this->lblTen->BackColor = System::Drawing::Color::Transparent;

this->lblTen->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblTen->Location = System::Drawing::Point(12, 83);

this->lblTen->Name = L"lblTen";

this->lblTen->Size = System::Drawing::Size(56, 14);

this->lblTen->TabIndex = 12;

this->lblTen->Text = L"Tensão:";

this->lblTen->Visible = false;

//

// lblCor

//

this->lblCor->AutoSize = true;

this->lblCor->BackColor = System::Drawing::Color::Transparent;

this->lblCor->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblCor->Location = System::Drawing::Point(12, 98);

this->lblCor->Name = L"lblCor";

this->lblCor->Size = System::Drawing::Size(63, 14);

this->lblCor->TabIndex = 13;

this->lblCor->Text = L"Corrente";

this->lblCor->Visible = false;

//

// lblFre

//

this->lblFre->AutoSize = true;

this->lblFre->BackColor = System::Drawing::Color::Transparent;

this->lblFre->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblFre->Location = System::Drawing::Point(12, 113);

this->lblFre->Name = L"lblFre";

this->lblFre->Size = System::Drawing::Size(84, 14);

this->lblFre->TabIndex = 14;

this->lblFre->Text = L"Frequência:";

this->lblFre->Visible = false;

//

// lblCar

//

this->lblCar->AutoSize = true;

this->lblCar->BackColor = System::Drawing::Color::Transparent;

this->lblCar->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblCar->Location = System::Drawing::Point(146, 96);

this->lblCar->Name = L"lblCar";

this->lblCar->Size = System::Drawing::Size(49, 14);

this->lblCar->TabIndex = 17;

this->lblCar->Text = L"Carga:";

this->lblCar->Visible = false;

//

// barCar

//

this->barCar->Location = System::Drawing::Point(149, 113);

this->barCar->Name = L"barCar";

this->barCar->Size = System::Drawing::Size(77, 13);

this->barCar->TabIndex = 18;

this->barCar->Visible = false;

//

// lblVal1

//

this->lblVal1->AutoSize = true;

this->lblVal1->BackColor = System::Drawing::Color::Transparent;

this->lblVal1->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblVal1->Location = System::Drawing::Point(2, 61);

this->lblVal1->Name = L"lblVal1";

this->lblVal1->Size = System::Drawing::Size(49, 14);

this->lblVal1->TabIndex = 19;

this->lblVal1->Text = L"Valor1";

//

// lblVal2

//

this->lblVal2->AutoSize = true;

this->lblVal2->BackColor = System::Drawing::Color::Transparent;

this->lblVal2->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblVal2->Location = System::Drawing::Point(56, 61);

this->lblVal2->Name = L"lblVal2";

this->lblVal2->Size = System::Drawing::Size(49, 14);

this->lblVal2->TabIndex = 20;

this->lblVal2->Text = L"Valor2";

//

// lblVal3

//

this->lblVal3->AutoSize = true;

this->lblVal3->BackColor = System::Drawing::Color::Transparent;

this->lblVal3->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblVal3->Location = System::Drawing::Point(108, 61);

this->lblVal3->Name = L"lblVal3";

this->lblVal3->Size = System::Drawing::Size(49, 14);

this->lblVal3->TabIndex = 21;

this->lblVal3->Text = L"Valor3";

//

// lblVal4

//

this->lblVal4->AutoSize = true;

this->lblVal4->BackColor = System::Drawing::Color::Transparent;

this->lblVal4->Font = (gcnew System::Drawing::Font(L"Courier New", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->lblVal4->Location = System::Drawing::Point(162, 61);

this->lblVal4->Name = L"lblVal4";

this->lblVal4->Size = System::Drawing::Size(49, 14);

this->lblVal4->TabIndex = 22;

this->lblVal4->Text = L"Valor4";

//

// pictureBox1

//

this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));

this->pictureBox1->Location = System::Drawing::Point(0, 57);

this->pictureBox1->Name = L"pictureBox1";

this->pictureBox1->Size = System::Drawing::Size(4, 19);

this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->pictureBox1->TabIndex = 23;

this->pictureBox1->TabStop = false;

//

// pictureBox2

//

this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox2.Image")));

this->pictureBox2->Location = System::Drawing::Point(234, 57);

this->pictureBox2->Name = L"pictureBox2";

this->pictureBox2->Size = System::Drawing::Size(4, 19);

this->pictureBox2->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;

this->pictureBox2->TabIndex = 24;

this->pictureBox2->TabStop = false;

//

// timLet

//

this->timLet->Enabled = true;

this->timLet->Tick += gcnew System::EventHandler(this, &Form1::timLet_Tick);

//

// serPri

//

this->serPri->BaudRate = 4800;

this->serPri->DataReceived += gcnew System::IO::Ports::SerialDataReceivedEventHandler(this, &Form1::serPri_DataReceived);

//

// timCom

//

this->timCom->Enabled = true;

this->timCom->Tick += gcnew System::EventHandler(this, &Form1::timCom_Tick);

//

// txtTmp

//

this->txtTmp->Location = System::Drawing::Point(8, 130);

this->txtTmp->Name = L"txtTmp";

this->txtTmp->Size = System::Drawing::Size(107, 20);

this->txtTmp->TabIndex = 25;

//

// txtBuf

//

this->txtBuf->Location = System::Drawing::Point(8, 156);

this->txtBuf->Name = L"txtBuf";

this->txtBuf->Size = System::Drawing::Size(107, 20);

this->txtBuf->TabIndex = 26;

//

// Form1

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));

this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;

this->ClientSize = System::Drawing::Size(238, 81);

this->ControlBox = false;

this->Controls->Add(this->picSet);

this->Controls->Add(this->txtBuf);

this->Controls->Add(this->txtTmp);

this->Controls->Add(this->pictureBox2);

this->Controls->Add(this->pictureBox1);

this->Controls->Add(this->lblVal4);

this->Controls->Add(this->lblVal3);

this->Controls->Add(this->lblVal2);

this->Controls->Add(this->lblVal1);

this->Controls->Add(this->barCar);

this->Controls->Add(this->lblCar);

this->Controls->Add(this->lblFre);

this->Controls->Add(this->lblCor);

this->Controls->Add(this->lblTen);

this->Controls->Add(this->lblDis);

this->Controls->Add(this->lblLog);

this->Controls->Add(this->lblHF);

this->Controls->Add(this->lblNom);

this->Controls->Add(this->picMin);

this->Controls->Add(this->picMed);

this->Controls->Add(this->picMax);

this->Controls->Add(this->picCon);

this->Controls->Add(this->picHel);

this->Controls->Add(this->picFec);

this->Controls->Add(this->picFun);

this->Cursor = System::Windows::Forms::Cursors::Default;

this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;

this->Name = L"Form1";

this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;

this->Text = L"Form1";

this->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseUp);

this->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseMove);

this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseDown);

this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picFun))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picFec))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picHel))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picCon))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picMax))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picMed))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picMin))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picSet))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox2))->EndInit();

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

private: System::Void picFec_Click(System::Object^ sender, System::EventArgs^ e) {

Form1::Close();

}

private: System::Void picMin_Click(System::Object^ sender, System::EventArgs^ e) {

WindowState = System::Windows::Forms::FormWindowState::Minimized;

}

private: System::Void picMax_Click(System::Object^ sender, System::EventArgs^ e) {

Form1::Size = System::Drawing::Size(238, 137);

picFun->Location = System::Drawing::Point(0, 126);

lblDis->Visible = true;

lblTen->Visible = true;

lblCor->Visible = true;

lblFre->Visible = true;

lblCar->Visible = true;

barCar->Visible = true;

picSet->Visible = true;

lblVal1->Visible = false;

lblVal2->Visible = false;

lblVal3->Visible = false;

lblVal4->Visible = false;

timLet->Enabled = false;

}

private: System::Void picMed_Click(System::Object^ sender, System::EventArgs^ e) {

Form1::Size = System::Drawing::Size(238, 81);

picFun->Location = System::Drawing::Point(0, 70);

lblDis->Visible = false;

lblTen->Visible = false;

lblCor->Visible = false;

lblFre->Visible = false;

lblCar->Visible = false;

barCar->Visible = false;

picSet->Visible = false;

lblVal1->Visible = true;

lblVal2->Visible = true;

lblVal3->Visible = true;

lblVal4->Visible = true;

timLet->Enabled = true;

}

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

val1 = lblVal1->Left;

val2 = lblVal1->Left + lblVal1->Width + 5;

val3 = lblVal2->Left + lblVal2->Width + 5;

val4 = lblVal3->Left + lblVal3->Width + 5;

}

private: System::Void Form1_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {

xPos = e->X;

yPos = e->Y;

if(Btn == 1){

Form1::Left = xPos + Form1::Left;

Form1::Top = yPos + Form1::Top;

}

}

private: System::Void timLet_Tick(System::Object^ sender, System::EventArgs^ e) {

val1 = val1 - 1;

val2 = val2 - 1;

val3 = val3 - 1;

val4 = val4 - 1;

if(lblVal1->Left + lblVal1->Width == 0){

val1 = 238;

}

if(lblVal2->Left + lblVal2->Width == 0){

val2 = 238;

}

if(lblVal3->Left + lblVal3->Width == 0){

val3 = 238;

}

if(lblVal4->Left + lblVal4->Width == 0){

val4 = 238;

}

lblVal1->Left = val1;

lblVal2->Left = val2;

lblVal3->Left = val3;

lblVal4->Left = val4;

}

private: System::Void timCom_Tick(System::Object^ sender, System::EventArgs^ e) {

if(serPri->IsOpen && marCon == 1){

serPri->Close();

}

else{

serPri->Open();

}

if(serPri->IsOpen){

serPri->WriteLine("log1" + Convert::ToChar(13));

txtTmp->Text=Convert::ToString("log1" + Convert::ToChar(13));

marCon = 1;

}

}

private: System::Void Form1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {

if(Convert::ToString(e->Button) == "Left"){

Btn = 1;

Form1::Cursor = System::Windows::Forms::Cursors::NoMove2D;

}

}

private: System::Void Form1_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {

if(Convert::ToString(e->Button) == "Left"){

Btn = 0;

Form1::Cursor = System::Windows::Forms::Cursors::Default;

}

}

private: System::Void serPri_DataReceived(System::Object^ sender, System::IO::Ports::SerialDataReceivedEventArgs^ e) {

tempBuff = serPri->ReadLine();

defBuff = defBuff + tempBuff;

}

};

}

valeu pela força :D:D:D

Link para o comentário
Compartilhar em outros sites

  • 2 semanas depois...

Caros amigos espinhentos, como se consideram programadores se desconhecem algo tão simples? Desculpem-me se estou sendo arrogante, mas esta questão é trivial. string não é um tipo comum da linguagem como bol, char, double e int. Ele é definido no header strings, da STL. Portanto, o modo para se inicializar uma string é:

#include <iostream>;

#include <string>;

int main() {

std::string s;

return 0;

}

Para facilitar, pode se declarar o namespace:

#include <iostream>;

#include <string>;

using namespace std;

int main() {

string s;

return 0;

}

Cheers!

Link para o comentário
Compartilhar em outros sites

  • Membro VIP

Hoje tomei vergonha na cara e resolvi ler o código do Pullga...

Pelo que percebi ele não esta usando o C++ tradicional, mas sim o C++ gerenciado (C++/CLI), ai "string" não existe mesmo, mas "String" (sim, é só a primeira letra que muda) existe e é esse o tipo que você precisa.

Link para o comentário
Compartilhar em outros sites

Caros amigos espinhentos, como se consideram programadores se desconhecem algo tão simples? Desculpem-me se estou sendo arrogante, mas esta questão é trivial. string não é um tipo comum da linguagem como bol, char, double e int. Ele é definido no header strings, da STL. Portanto, o modo para se inicializar uma string é:

#include <iostream>;

#include <string>;

int main() {

std::string s;

return 0;

}

Para facilitar, pode se declarar o namespace:

#include <iostream>;

#include <string>;

using namespace std;

int main() {

string s;

return 0;

}

Cheers!

pois é caro amigo programador veterano que se acha o cara....

se você tivesse o trabalho de ter lido as respostas antes de ter postado não teria feito esse infeliz comentário

Link para o comentário
Compartilhar em outros sites

  • Membro VIP
Caros amigos espinhentos, como se consideram programadores se desconhecem algo tão simples? Desculpem-me se estou sendo arrogante...

Forums existem para ajudar aqueles que tem dúvida, e para aprimoramento dos que já tem certa experiência em determinado assunto.

Como pretende participar deste Forum, se desconhece algo tão simples?

Este tipo de comportamento não é bem-vindo nem dos veteranos, imagine então vindo de alguém que se registrou ontem...

Link para o comentário
Compartilhar em outros sites

Olá,

Acho que vocês não estão me compreendendo direito.

Eu já captei a parte das strings, mas não consegui testar ainda!!!

É que eu sei programar um pouco em C, e estou migrando para Visual C++, só que no C, a gente tem basicamente só um arquivo, e no topo dele a gente coloca os #includes e #defines, logo abaixo do main(), a gente põe as variáveis, etc...

Mas e no Visual C++???

Onde ponho os includes???

Existem vários arquivos, em qual arquivo eu coloco os #includes e #defines???

Onde coloco as declarações de variáveis???

Quanto a Strings eu já entendi, mas quanto onde coloco tudo, isso eu ainda não sei!!!

Please, help me!

falou :D:D:D

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...