CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2014
    Location
    North Dakota, USA
    Posts
    4

    Help with a really simple program

    This is what i need(I made a short video):
    http://screencast.com/t/UsPjDW4Y

    Heres the details:


    You enter text in "TextBox3" and "TextBox4" and Click on "Button1"

    After "Button1" is clicked it needs to make a file called "Start.txt" in the folder the program is in and put this in it:

    Set EnDe="" (If button one is flicked it needs to put a 0 between the "" )

    Set TranCode="" (It needs to paste the text that was entered into "TextBox3" between the "" )

    Set Text="" (It needs to paste the text from "TextBox4" between the "" )
    So if you did this:
    Attachment 33153

    And clicked "Button1"


    The the text file would say this:

    Start.txt
    Set EnDe="0"

    Set TranCode="PieIsAwesome"

    Set Text="Pandas are even more awesome"
    Then it needs to start "Fireware.bat" and wait for it to close. Then, it needs to copy the text out of a file called "Finish.txt" and paste it into "TextBox1". And then after the text is in "TextBox1" it needs to delete the files called "Start.txt" and "Finish.txt" and/or simply remove all text from them so that there empty.



    Now the other half of the program works similar, but...



    In the "Set EnDe="0" " There needs to be a 1 instead of a 0 if "Button2" is pressed. And in the "Set Text="" " needs to be the text from "TextBox5"

    Example:
    Attachment 33155

    And the Text file will say:

    Start.txt
    Set EnDe="1"

    Set TranCode="PieIsAwesome"

    Set Text="5J-KK-82-K6-LP-VV-10-45-9G-"
    And then it needs to start "Fireware.bat" wait for it to close. And then copy the text out of "Finish.txt" and put it into "TextBox2" And then delete, and/or clear the text from "Start.txt" and "Finish.txt"
    I'm a total noob, and i have no idea what to do when it comes to Cpp, any help would be greatly appreciated.





    Code:
    #pragma once
    
    namespace FirewareEvolution {
    
    	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::Label^  label1;
    	protected: 
    	private: System::Windows::Forms::Label^  label2;
    	private: System::Windows::Forms::Button^  button1;
    	private: System::Windows::Forms::Button^  button2;
    	private: System::Windows::Forms::Label^  label3;
    	private: System::Windows::Forms::TextBox^  textBox1;
    	private: System::Windows::Forms::TextBox^  textBox2;
    	private: System::Windows::Forms::TextBox^  textBox3;
    	private: System::Windows::Forms::TextBox^  textBox4;
    	private: System::Windows::Forms::TextBox^  textBox5;
    
    
    
    
    
    
    
    
    
    	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::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->button1 = (gcnew System::Windows::Forms::Button());
    			this->button2 = (gcnew System::Windows::Forms::Button());
    			this->label3 = (gcnew System::Windows::Forms::Label());
    			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox4 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox5 = (gcnew System::Windows::Forms::TextBox());
    			this->SuspendLayout();
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(691, 89);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(53, 13);
    			this->label1->TabIndex = 0;
    			this->label1->Text = L"Decryptor";
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(335, 16);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(87, 13);
    			this->label2->TabIndex = 1;
    			this->label2->Text = L"Translation Code";
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(167, 84);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(75, 23);
    			this->button1->TabIndex = 2;
    			this->button1->Text = L"Encrypt";
    			this->button1->UseVisualStyleBackColor = true;
    			// 
    			// button2
    			// 
    			this->button2->Location = System::Drawing::Point(511, 84);
    			this->button2->Name = L"button2";
    			this->button2->Size = System::Drawing::Size(75, 23);
    			this->button2->TabIndex = 3;
    			this->button2->Text = L"Decrypt";
    			this->button2->UseVisualStyleBackColor = true;
    			// 
    			// label3
    			// 
    			this->label3->AutoSize = true;
    			this->label3->Location = System::Drawing::Point(12, 89);
    			this->label3->Name = L"label3";
    			this->label3->Size = System::Drawing::Size(52, 13);
    			this->label3->TabIndex = 4;
    			this->label3->Text = L"Encryptor";
    			// 
    			// textBox1
    			// 
    			this->textBox1->Location = System::Drawing::Point(12, 241);
    			this->textBox1->MaxLength = 400;
    			this->textBox1->Multiline = true;
    			this->textBox1->Name = L"textBox1";
    			this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
    			this->textBox1->Size = System::Drawing::Size(266, 130);
    			this->textBox1->TabIndex = 5;
    			// 
    			// textBox2
    			// 
    			this->textBox2->Location = System::Drawing::Point(478, 241);
    			this->textBox2->MaxLength = 400;
    			this->textBox2->Multiline = true;
    			this->textBox2->Name = L"textBox2";
    			this->textBox2->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
    			this->textBox2->Size = System::Drawing::Size(266, 130);
    			this->textBox2->TabIndex = 6;
    			// 
    			// textBox3
    			// 
    			this->textBox3->Location = System::Drawing::Point(278, 32);
    			this->textBox3->MaxLength = 25;
    			this->textBox3->Name = L"textBox3";
    			this->textBox3->Size = System::Drawing::Size(200, 20);
    			this->textBox3->TabIndex = 7;
    			this->textBox3->UseSystemPasswordChar = true;
    			// 
    			// textBox4
    			// 
    			this->textBox4->Location = System::Drawing::Point(12, 113);
    			this->textBox4->MaxLength = 400;
    			this->textBox4->Multiline = true;
    			this->textBox4->Name = L"textBox4";
    			this->textBox4->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
    			this->textBox4->Size = System::Drawing::Size(266, 122);
    			this->textBox4->TabIndex = 8;
    			// 
    			// textBox5
    			// 
    			this->textBox5->Location = System::Drawing::Point(478, 113);
    			this->textBox5->MaxLength = 400;
    			this->textBox5->Multiline = true;
    			this->textBox5->Name = L"textBox5";
    			this->textBox5->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
    			this->textBox5->Size = System::Drawing::Size(266, 122);
    			this->textBox5->TabIndex = 9;
    			this->textBox5->TextChanged += gcnew System::EventHandler(this, &Form1::textBox5_TextChanged);
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(756, 383);
    			this->Controls->Add(this->textBox5);
    			this->Controls->Add(this->textBox4);
    			this->Controls->Add(this->textBox3);
    			this->Controls->Add(this->textBox2);
    			this->Controls->Add(this->textBox1);
    			this->Controls->Add(this->label3);
    			this->Controls->Add(this->button2);
    			this->Controls->Add(this->button1);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->label1);
    			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
    			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
    			this->MaximizeBox = false;
    			this->Name = L"Form1";
    			this->Text = L"Fireware";
    			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) {
    			 }
    private: System::Void textBox5_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    		 }
    };
    }
    Last edited by GameRunnerHD; November 23rd, 2014 at 10:40 PM. Reason: Needed to add more info.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Help with a really simple program

    Most users offering assistance here are reluctant to following off-site links to obscure videos and stuff, so please explain your intentions (perhaps using screen shots you upload directly to the CodeGuru site) rather than posting such links.

    From the code you posted, it's hard to guess what you're actually trying to do, since that code literally doesn't do anything at all by now. It seems, however, that it has somthing to do with encryption and decryption, so, meanwhile, here's an extensive thread dealing with the .NET Crypgographic Services, including some sample code, that may already answer some of your questions: http://forums.codeguru.com/showthrea...encrypt-a-file It will probably leave some open questions, though, since, for instance, all the code samples there are console-based rather than Windows-Forms-based. But in fact that only concerns the user interface, not the crypto code itself.

    HTH
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Nov 2014
    Location
    North Dakota, USA
    Posts
    4

    Re: Help with a really simple program

    Thats not what i need, i know nothing about Cpp so i simply want it to make a simple .txt file then to type a small amount of Batch Code in the file and then run a .bat file, wait for it to end, then display text from another .txt file in one of the boxes on screen, then delete both .txt files. The reason for this is so i can do all the complex code in a .bat file so that i know what i'm doing.

    Heres the details:


    You enter text in "TextBox3" and "TextBox4" and Click on "Button1"

    After "Button1" is clicked it needs to make a file called "Start.txt" in the folder the program is in and put this in it:

    Set EnDe="" (If Button1 is clicked it needs to put a 0 between the "" )

    Set TranCode="" (It needs to paste the text that was entered into "TextBox3" between the "" )

    Set Text="" (It needs to paste the text from "TextBox4" between the "" )
    So if you did this:
    Attachment 33153

    And clicked "Button1"


    The the text file would say this:

    Start.txt
    Set EnDe="0"

    Set TranCode="PieIsAwesome"

    Set Text="Pandas are even more awesome"
    Then it needs to start "Fireware.bat" and wait for it to close. Then, it needs to copy the text out of a file called "Finish.txt" and paste it into "TextBox1". And then after the text is in "TextBox1" it needs to delete the files called "Start.txt" and "Finish.txt" and/or simply remove all text from them so that there empty.



    Now the other half of the program works similar, but...



    In the "Set EnDe="0" " There needs to be a 1 instead of a 0 if "Button2" is pressed. And in the "Set Text="" " needs to be the text from "TextBox5"

    Example:
    Attachment 33155

    And the Text file will say:

    Start.txt
    Set EnDe="1"

    Set TranCode="PieIsAwesome"

    Set Text="5J-KK-82-K6-LP-VV-10-45-9G-"
    And then it needs to start "Fireware.bat" wait for it to close. And then copy the text out of "Finish.txt" and put it into "TextBox2" And then delete, and/or clear the text from "Start.txt" and "Finish.txt"
    Last edited by GameRunnerHD; November 23rd, 2014 at 10:31 PM.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Help with a really simple program

    Quote Originally Posted by GameRunnerHD View Post
    Thats not what i need, i know nothing about Cpp so i simply want it to make a simple .txt file then to type a small amount of Batch Code in the file and then run a .bat file, wait for it to end, then display text from another .txt file in one of the boxes on screen, then delete bxt files. The reason for this is so i can do all the complex code in a .bat file so that i know what i'm doing.
    Hmmm, well... Your approach looks pretty paradox, even starting with its fundamental concept: The DOS/Windows batch file language is, by its very concept, inclined towards the primitive/trivial kind of tasks, whereas C++/CLI (or practically any other high level language, for that matter) is better suited for the comparatively more complex tasks. You seem to be trying to put things upside down!

    If what you want is nothing more than scripting (which is the category that batch file languages belong to) with optional graphical user interface capabilities, then why not simply have a closer look at PowerShell? (I admit, while conceptually PoweShell seems to be a good candidate for what you're going to write, I, personally, did not really get familiar with it yet; it's language concept, though certainly thought out well by its developers, seems to tend to obscure things, that I'd like to have availabale right at my fingertips. Again, PowerShell probably is quite cool once you found your way of using it effective- and efficiently, just I haven't found that for me yet.

    And if you really insist in .NET high level language as front end comvined with a batch-based back end, why then not use one of the simpler (compared to C++/CLI, and that's practically all others) .NET HLLs? C++/CLI may give you a small advantage if you already have a C++ background (and even that is highly arguable), but as I understand you, you don,t have douch a background.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Nov 2014
    Location
    North Dakota, USA
    Posts
    4

    Re: Help with a really simple program

    I just want a program that looks like the pics i posted and does what i said i wanted it to do. And because i know what it would do, this would help me learn Cpp because i could review the code and learn what everything does. Also i'm taking college classes for Cpp but i'm still in the "Knowing your Windows PC" "How to press a SpaceBar" section (lol) And i would love to turn my batch program into 100% Cpp at some point, but for now i just need a Cpp program with a clean GUI for my program that i can also learn from
    umm... Umm... UMM... UMM!!!...!!! kjgbsdsojfkjabnsdfnf43thf498ry234fnewaefbiu!!!!! Panda....

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Help with a really simple program

    Ok, if your decision for C++/CLI as the language of choice has been taken, and if your goal is a program that performs something that has been done earlier by a set of batch files (or if your program is intended to just provide a superficial emulation of that), it's still worth consideration to impement the parts, that originally were solved at the batch level, in C++/CLI now.

    Note that re-implementing simple batch-typical tasks in C++/CLI (or practically any other HLL, for that matter) is most likely considerably simpler compared to pulling up an adequate interface layer in C++/CLI to adapt to your pre-existing batch files (even more so if interfacing involves temporary batch files to be written by your C++/CLI interfacing code, in order to be used by other batch files, as it seems to be).

    Sorry, apparently there's something gone wrong with the attachments you uploaded. Clicking the respective links gives me nothing more than an "Invalid attachment" error message, so they're not really enlightening to me. Thanks for trying, though.
    Last edited by Eri523; November 25th, 2014 at 10:46 AM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured