There are 2 buttons. One of them starts the loading, then the other goes to the next page. I use an if statement for the second button, which says basically says 'if checkbox ticked, make backup folder'. I haven't actually done any of the coding for backing up or moving the files yet. So its just basically a loading bar, that creates a folder. The only thing is the folder doesn't get created (when I the checkbox is ticked).
Here's the code:
#pragma once
#include "Finished.h"
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
#include <time.h>
namespace ProgressbarTutorial {
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::ProgressBar^ progressBar1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Timer^ timer1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::CheckBox^ checkBox1;
private: System::ComponentModel::IContainer^ components;
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->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
this->button1 = (gcnew System::Windows::Forms::Button());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
this->label1 = (gcnew System::Windows::Forms::Label());
this->button2 = (gcnew System::Windows::Forms::Button());
this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
this->SuspendLayout();
//
// progressBar1
//
this->progressBar1->Location = System::Drawing::Point(12, 211);
this->progressBar1->Name = L"progressBar1";
this->progressBar1->Size = System::Drawing::Size(477, 53);
this->progressBar1->TabIndex = 0;
this->progressBar1->Click += gcnew System::EventHandler(this, &Form1::progressBar1_Click);
//
// button1
//
this->button1->Location = System::Drawing::Point(12, 122);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(77, 55);
this->button1->TabIndex = 1;
this->button1->Text = L"Begin Download";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// timer1
//
this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// label1
//
this->label1->AutoSize = true;
this->label1->BackColor = System::Drawing::Color::Transparent;
this->label1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
this->label1->Location = System::Drawing::Point(12, 180);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(0, 13);
this->label1->TabIndex = 2;
this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(412, 122);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(77, 55);
this->button2->TabIndex = 3;
this->button2->Text = L"Continue...";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Location = System::Drawing::Point(312, 99);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(177, 17);
this->checkBox1->TabIndex = 4;
this->checkBox1->Text = L"Save a backup of minecraft.jar\?";
this->checkBox1->UseVisualStyleBackColor = true;
this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(501, 276);
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->progressBar1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"Form1";
this->Text = L"LucidHacks - Install";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->timer1->Start();
}
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
int iSecret;
/* initialize random seed: */
srand ( time(NULL) );
/* generate secret number: */
iSecret = rand() % 3 + 1;
this->progressBar1->Increment(iSecret);
}
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void progressBar1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
if ((checkBox1->Checked == true) && (this->progressBar1->Value == 100));
{
{
mkdir("%appdata%\.minecraft\backup");
}
}
if (this->progressBar1->Value == 100)
Finished().ShowDialog();
else if (this->progressBar1->Value == 0)
MessageBox::Show("Program must load first!");
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
}
};
}
Here are some pictures:
Picture 1, the install wizard with the checkbox ticked.

Picture 2, showing the final page, after the backup folder should have been created.

Picture 3, showing where the backup folder should of been created (but its not :C )

New Topic/Question
Reply


MultiQuote





|