I've heared that its very easy to add c++ code to c++/cli project (net.framework @ Visual Studio 2010)
Unfortunatelly I cant do that.
I was seraching all over the internet and I cant find any decent examples.
All I want to do is to make a function that will read all options sfrom config/config.txt file, and to show them in the checkbox item....
my previous program was written in pure c++ and i made function which read all option sfrom the text file...and it was sth like this:
void system_load()
{
int counter=0;
int counter1=0;
string filename,filename1,line;
filename="CONFIG//systems.txt";
ifstream plik_wejsciowy (filename.c_str());
if (plik_wejsciowy.is_open())
while (! plik_wejsciowy.eof() )
{
counter++;
getline (plik_wejsciowy,line);
if (line == "") continue;
comboBox1->Items->Add(line);
}
//---------------------------------------
filename1="CONFIG//affected.txt";
ifstream plik_wejsciowy1 (filename1.c_str());
if (plik_wejsciowy1.is_open())
while (! plik_wejsciowy1.eof() )
{
counter1++;
getline (plik_wejsciowy1,line);
if (line == "") continue;
comboBox2->Items->Add(line);
}
}
I have tried to rewrite it to load options from text file into the ComboBox1 but without result...when i add that void to the code below (form1.h) I recive thousands of errors...as if it was not written in c++..
I added new namesapce std etd...it didnt help..ofcourse I added also all "includes" to the code, but it generated some linker errors..thats all.
code of my menu:
#pragma once
namespace Templater {
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
/// </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::MenuStrip^ menuStrip1;
protected:
private: System::Windows::Forms::ToolStripMenuItem^ typeToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ availabilityToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ unavailabilityToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ degradationToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::DateTimePicker^ dateTimePicker1;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ button1;
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::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->typeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->availabilityToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->unavailabilityToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->degradationToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->label1 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
this->label4 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// menuStrip1
//
resources->ApplyResources(this->menuStrip1, L"menuStrip1");
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->typeToolStripMenuItem,
this->aboutToolStripMenuItem});
this->menuStrip1->Name = L"menuStrip1";
//
// typeToolStripMenuItem
//
resources->ApplyResources(this->typeToolStripMenuItem, L"typeToolStripMenuItem");
this->typeToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->availabilityToolStripMenuItem,
this->unavailabilityToolStripMenuItem, this->degradationToolStripMenuItem});
this->typeToolStripMenuItem->Name = L"typeToolStripMenuItem";
//
// availabilityToolStripMenuItem
//
resources->ApplyResources(this->availabilityToolStripMenuItem, L"availabilityToolStripMenuItem");
this->availabilityToolStripMenuItem->Name = L"availabilityToolStripMenuItem";
this->availabilityToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::availabilityToolStripMenuItem_Click);
//
// unavailabilityToolStripMenuItem
//
resources->ApplyResources(this->unavailabilityToolStripMenuItem, L"unavailabilityToolStripMenuItem");
this->unavailabilityToolStripMenuItem->Name = L"unavailabilityToolStripMenuItem";
this->unavailabilityToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::unavailabilityToolStripMenuItem_Click);
//
// degradationToolStripMenuItem
//
resources->ApplyResources(this->degradationToolStripMenuItem, L"degradationToolStripMenuItem");
this->degradationToolStripMenuItem->Name = L"degradationToolStripMenuItem";
this->degradationToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::degradationToolStripMenuItem_Click);
//
// aboutToolStripMenuItem
//
resources->ApplyResources(this->aboutToolStripMenuItem, L"aboutToolStripMenuItem");
this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
this->aboutToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::aboutToolStripMenuItem_Click);
//
// label1
//
resources->ApplyResources(this->label1, L"label1");
this->label1->Name = L"label1";
this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
//
// comboBox1
//
resources->ApplyResources(this->comboBox1, L"comboBox1");
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(3) {resources->GetString(L"comboBox1.Items"), resources->GetString(L"comboBox1.Items1"),
resources->GetString(L"comboBox1.Items2")});
this->comboBox1->Name = L"comboBox1";
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
//
// textBox1
//
resources->ApplyResources(this->textBox1, L"textBox1");
this->textBox1->Name = L"textBox1";
//
// label2
//
resources->ApplyResources(this->label2, L"label2");
this->label2->Name = L"label2";
//
// textBox2
//
resources->ApplyResources(this->textBox2, L"textBox2");
this->textBox2->Name = L"textBox2";
//
// label3
//
resources->ApplyResources(this->label3, L"label3");
this->label3->Name = L"label3";
//
// dateTimePicker1
//
resources->ApplyResources(this->dateTimePicker1, L"dateTimePicker1");
this->dateTimePicker1->Format = System::Windows::Forms::DateTimePickerFormat::Short;
this->dateTimePicker1->Name = L"dateTimePicker1";
//
// label4
//
resources->ApplyResources(this->label4, L"label4");
this->label4->Name = L"label4";
//
// button1
//
resources->ApplyResources(this->button1, L"button1");
this->button1->Name = L"button1";
this->button1->UseVisualStyleBackColor = true;
//
// Form1
//
resources->ApplyResources(this, L"$this");
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->Controls->Add(this->button1);
this->Controls->Add(this->label4);
this->Controls->Add(this->dateTimePicker1);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label1);
this->Controls->Add(this->menuStrip1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void availabilityToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Text="Notifier 1.0 - Availability";
}
private: System::Void unavailabilityToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Text="Notifier 1.0 - Unvailability";
}
private: System::Void degradationToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Text="Notifier 1.0 - Degradation";
}
private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Notifier 1.0 by Kolendo, Michal","About",MessageBoxButtons::OK,MessageBoxIcon::Information);
}
};
}