Expand|Select|Wrap|Line Numbers
- // 12 lines of code to work with windows
- // What I added is in red, the dark red far left
- // is needed the blue is what it wrote
- #pragma once
- namespace WriteRead {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- // I moved what the program wrote over to the left
- // avoid more confusion
- // >>>|
- // <<<what I add is on the right side
- // this is where I put the struct not in the .cpp
- // file
- public value struct Book{
- // I found an example that is using struct at
- // http://www.functionx.com/vccli/applications
- // /carinventory.htm
- // that example is using Visual C++ 2005, I am using
- // Visual C++ 2008 Express Edition
- String ^ tx; // I will trying to do direct access
- // to a text file, to load a page[].tx into textBox2
- // (later)
- // using String pointers? I feel no control and all
- // would be lost if not saved to file
- // char tx[100]; // I would like to do it this way
- // do you have some idea how?
- }; // Will I be able to do direct access in a file
- // using "String ^ tx;" ?
- // If I log the end of the file each time I add a
- // structs, how does it know to only read one back?
- // Using pointers?
- // How does it know the end of one struct?
- // Book page[10]; // I can not used it this way and
- // not needed I will need a array for index location
- /// <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::TextBox^
- textBox1;
- protected:
- private:
- System::Windows::Forms::Button^
- button1;
- private:
- System::Windows::Forms::TextBox^
- textBox2;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container
- ^components;
- private:
- System::Windows::Forms::Button^
- button2;
- private:
- System::Windows::Forms::Label^ label1;
- static array<Book ^> ^ page = gcnew array<Book ^>(10);
- // will need just one // how do you read this?
- // I found in a book they could read this, I will
- // try to post it
- // If I say someting in human language like: "need 10
- // Book struck" the program should ask some questions
- // and refine my word and help me write human language
- // or/and in c++ or c# and it would be teaching me
- // and I am sure it would know about gc in "gcnew".
- #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->textBox1 = (gcnew
- System::Windows::Forms::TextBox());
- this->button1 = (gcnew
- System::Windows::Forms::Button());
- this->textBox2 = (gcnew
- System::Windows::Forms::TextBox());
- this->button2 = (gcnew
- System::Windows::Forms::Button());
- this->label1 = (gcnew
- System::Windows::Forms::Label());
- this->SuspendLayout();
- //
- // textBox1
- //
- this->textBox1->Location =
- System::Drawing::Point(30, 28);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size =
- System::Drawing::Size(100, 20);
- this->textBox1->TabIndex = 0;
- //
- // button1
- //
- this->button1->Location =
- System::Drawing::Point(30, 64);
- this->button1->Name = L"button1";
- this->button1->Size =
- System::Drawing::Size(100, 25);
- this->button1->TabIndex = 1;
- this->button1->Text = L"button1";
- this->button1->UseVisualStyleBackColor
- = true;
- this->button1->Click += gcnew
- System::EventHandler(this,
- &Form1::button1_Click);
- //
- // textBox2
- //
- this->textBox2->Location =
- System::Drawing::Point(30, 108);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size =
- System::Drawing::Size(100, 20);
- this->textBox2->TabIndex = 2;
- this->textBox2->Text =
- this->textBox1->Text;
- //
- // button2
- //
- this->button2->Location =
- System::Drawing::Point(30, 146);
- this->button2->Name = L"button2";
- this->button2->Size =
- System::Drawing::Size(100, 23);
- this->button2->TabIndex = 3;
- this->button2->Text = L"Close";
- this->button2->UseVisualStyleBackColor
- = true;
- this->button2->Click += gcnew
- System::EventHandler(this,
- &Form1::button2_Click);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location =
- System::Drawing::Point(30, 13);
- this->label1->Name = L"label1";
- this->label1->Size =
- System::Drawing::Size(86, 13);
- this->label1->TabIndex = 4;
- this->label1->Text = L"Type in
- textBox1";
- //
- // Form1
- //
- this->AutoScaleDimensions =
- System::Drawing::SizeF(6, 13);
- this->AutoScaleMode =
- System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize =
- System::Drawing::Size(166, 194);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox1);
- this->Name = L"Form1";
- this->Text = L"Form1";
- this->Load += gcnew
- System::EventHandler(this,
- &Form1::Form1_Load);
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void
- Form1_Load(System::Object^ sender,
- System::EventArgs^ e)
- {
- // This is not the way I want to write to the array
- // of structs for a 1000 pages of text
- page[0] = gcnew Book; // all this is to test some ideas
- page[1] = gcnew Book; // later will write to just one
- // struct not 4
- page[2] = gcnew Book; // then save it to file and log
- // location in index array
- page[3] = gcnew Book; // then retrive from text file
- // with direct random access
- }
- private: System::Void
- button1_Click(System::Object^
- sender, System::EventArgs^ e)
- {
- this->page[3]->tx = this->textBox1->Text; // copy
- // textBox1 to struct[3] this works good
- // this->textBox2->Text = this->textBox1->Text;
- // copy box1 to box2, this works good use to help
- // test
- this->textBox1->Text = " "; // clear textBox1 this
- // works good
- this->textBox2->Text = this->page[3]->tx; // From
- // struct to textBox2 ok it is working good
- }
- private: System::Void
- button2_Click(System::Object^ sender,
- System::EventArgs^ e)
- {
- // Close();//or you could say
- Application::Exit();
- }
- };
- }