Hey Everyone
I am having troubles. i tried looking up how to make the main for invisable but i cant figure out how. i saw some examples but they made no scence to me.
What i am trying to do is change from one form to another and hide the first one. Its basicly a calculator and when someone clicks on the advanced button it flicks to another form that has the advanced settings.
i am using VC++ 2010. I just cant figure this out. this is the code i got so far sorry for the lenght the main bulk of it is at the bottom and a few bits at the top making pointer etc.
#pragma once
#include "help.h"
#include "about.h"
#include "CAadvanced.h"
namespace SSCalculator {
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
{
private:
help ^form;
about ^form2;
CAadvanced ^advance;
public:
Form1(void)
{
InitializeComponent();
form = gcnew help;
form2 = gcnew about;
advance = gcnew CAadvanced;
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::ComboBox^ Gravity;
private: System::Windows::Forms::ComboBox^ Atmos;
protected:
private: System::Windows::Forms::TextBox^ CAinput;
private: System::Windows::Forms::Button^ Calc;
private: System::Windows::Forms::ComboBox^ Temp;
private: System::Windows::Forms::Label^ gravtext;
private: System::Windows::Forms::Label^ atmostext;
private: System::Windows::Forms::Label^ temptext;
private: System::Windows::Forms::Label^ catext;
private: System::Windows::Forms::TextBox^ inputText;
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ viewToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ cACalculatorToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ basicViewToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ advancedViewToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ shipFittingToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ baseCalculatorToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ howToUseToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem;
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->Gravity = (gcnew System::Windows::Forms::ComboBox());
this->Atmos = (gcnew System::Windows::Forms::ComboBox());
this->CAinput = (gcnew System::Windows::Forms::TextBox());
this->Calc = (gcnew System::Windows::Forms::Button());
this->Temp = (gcnew System::Windows::Forms::ComboBox());
this->gravtext = (gcnew System::Windows::Forms::Label());
this->atmostext = (gcnew System::Windows::Forms::Label());
this->temptext = (gcnew System::Windows::Forms::Label());
this->catext = (gcnew System::Windows::Forms::Label());
this->inputText = (gcnew System::Windows::Forms::TextBox());
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->viewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->cACalculatorToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->basicViewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->advancedViewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->shipFittingToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->baseCalculatorToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->howToUseToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// Gravity
//
this->Gravity->AllowDrop = true;
this->Gravity->FormattingEnabled = true;
this->Gravity->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"Heavy", L"Normal", L"Low"});
this->Gravity->Location = System::Drawing::Point(12, 82);
this->Gravity->Name = L"Gravity";
this->Gravity->Size = System::Drawing::Size(121, 21);
this->Gravity->TabIndex = 0;
this->Gravity->Text = L"Selection";
this->Gravity->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::Gravity_SelectedIndexChanged);
//
// Atmos
//
this->Atmos->FormattingEnabled = true;
this->Atmos->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"Gaseous", L"Noxious", L"Terran"});
this->Atmos->Location = System::Drawing::Point(12, 182);
this->Atmos->Name = L"Atmos";
this->Atmos->Size = System::Drawing::Size(121, 21);
this->Atmos->TabIndex = 1;
this->Atmos->Text = L"Selection";
this->Atmos->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::Atmos_SelectedIndexChanged);
//
// CAinput
//
this->CAinput->BackColor = System::Drawing::Color::White;
this->CAinput->Location = System::Drawing::Point(163, 82);
this->CAinput->Name = L"CAinput";
this->CAinput->ReadOnly = true;
this->CAinput->Size = System::Drawing::Size(121, 20);
this->CAinput->TabIndex = 6;
this->CAinput->Text = L"Enter your CA Level";
this->CAinput->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::CAinput_KeyDown);
//
// Calc
//
this->Calc->ForeColor = System::Drawing::SystemColors::ControlLightLight;
this->Calc->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"Calc.Image")));
this->Calc->Location = System::Drawing::Point(12, 209);
this->Calc->Name = L"Calc";
this->Calc->Size = System::Drawing::Size(79, 21);
this->Calc->TabIndex = 8;
this->Calc->Text = L"Calculate";
this->Calc->UseVisualStyleBackColor = true;
this->Calc->Click += gcnew System::EventHandler(this, &Form1::Calc_Click);
//
// Temp
//
this->Temp->AccessibleRole = System::Windows::Forms::AccessibleRole::ComboBox;
this->Temp->BackColor = System::Drawing::SystemColors::Window;
this->Temp->FormattingEnabled = true;
this->Temp->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"Blistering", L"Frozen", L"Temperate"});
this->Temp->Location = System::Drawing::Point(12, 132);
this->Temp->Name = L"Temp";
this->Temp->Size = System::Drawing::Size(121, 21);
this->Temp->TabIndex = 11;
this->Temp->Text = L"Selection";
this->Temp->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::Temp_SelectedIndexChanged);
//
// gravtext
//
this->gravtext->AutoSize = true;
this->gravtext->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->gravtext->ForeColor = System::Drawing::SystemColors::ControlLightLight;
this->gravtext->Location = System::Drawing::Point(13, 61);
this->gravtext->Name = L"gravtext";
this->gravtext->Size = System::Drawing::Size(54, 18);
this->gravtext->TabIndex = 12;
this->gravtext->Text = L"Gravity";
this->gravtext->Click += gcnew System::EventHandler(this, &Form1::gravtext_Click);
//
// atmostext
//
this->atmostext->AutoSize = true;
this->atmostext->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->atmostext->ForeColor = System::Drawing::SystemColors::ControlLightLight;
this->atmostext->Location = System::Drawing::Point(13, 161);
this->atmostext->Name = L"atmostext";
this->atmostext->Size = System::Drawing::Size(58, 18);
this->atmostext->TabIndex = 13;
this->atmostext->Text = L"Climate";
this->atmostext->Click += gcnew System::EventHandler(this, &Form1::atmostext_Click);
//
// temptext
//
this->temptext->AutoSize = true;
this->temptext->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->temptext->ForeColor = System::Drawing::SystemColors::ControlLightLight;
this->temptext->Location = System::Drawing::Point(13, 111);
this->temptext->Name = L"temptext";
this->temptext->Size = System::Drawing::Size(92, 18);
this->temptext->TabIndex = 14;
this->temptext->Text = L"Temperature";
this->temptext->Click += gcnew System::EventHandler(this, &Form1::temptext_Click_1);
//
// catext
//
this->catext->AutoSize = true;
this->catext->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->catext->ForeColor = System::Drawing::SystemColors::ControlLightLight;
this->catext->Location = System::Drawing::Point(169, 61);
this->catext->Name = L"catext";
this->catext->Size = System::Drawing::Size(70, 18);
this->catext->TabIndex = 15;
this->catext->Text = L"CA Level:";
this->catext->Click += gcnew System::EventHandler(this, &Form1::catext_Click_1);
//
// inputText
//
this->inputText->BackColor = System::Drawing::Color::White;
this->inputText->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->inputText->ForeColor = System::Drawing::Color::ForestGreen;
this->inputText->Location = System::Drawing::Point(12, 38);
this->inputText->Name = L"inputText";
this->inputText->ReadOnly = true;
this->inputText->Size = System::Drawing::Size(272, 21);
this->inputText->TabIndex = 16;
this->inputText->TabStop = false;
this->inputText->TextChanged += gcnew System::EventHandler(this, &Form1::inputText_TextChanged);
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->viewToolStripMenuItem,
this->helpToolStripMenuItem});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(295, 24);
this->menuStrip1->TabIndex = 17;
this->menuStrip1->Text = L"menuStrip1";
//
// viewToolStripMenuItem
//
this->viewToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->cACalculatorToolStripMenuItem,
this->shipFittingToolStripMenuItem, this->baseCalculatorToolStripMenuItem});
this->viewToolStripMenuItem->Name = L"viewToolStripMenuItem";
this->viewToolStripMenuItem->Size = System::Drawing::Size(44, 20);
this->viewToolStripMenuItem->Text = L"View";
//
// cACalculatorToolStripMenuItem
//
this->cACalculatorToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->basicViewToolStripMenuItem,
this->advancedViewToolStripMenuItem});
this->cACalculatorToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"cACalculatorToolStripMenuItem.Image")));
this->cACalculatorToolStripMenuItem->Name = L"cACalculatorToolStripMenuItem";
this->cACalculatorToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->cACalculatorToolStripMenuItem->Text = L"CA Calculator";
//
// basicViewToolStripMenuItem
//
this->basicViewToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"basicViewToolStripMenuItem.Image")));
this->basicViewToolStripMenuItem->Name = L"basicViewToolStripMenuItem";
this->basicViewToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->basicViewToolStripMenuItem->Text = L"Basic View";
//
// advancedViewToolStripMenuItem
//
this->advancedViewToolStripMenuItem->Name = L"advancedViewToolStripMenuItem";
this->advancedViewToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->advancedViewToolStripMenuItem->Text = L"Advanced View";
this->advancedViewToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::advancedViewToolStripMenuItem_Click_1);
//
// shipFittingToolStripMenuItem
//
this->shipFittingToolStripMenuItem->Name = L"shipFittingToolStripMenuItem";
this->shipFittingToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->shipFittingToolStripMenuItem->Text = L"Ship Fitting";
this->shipFittingToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::shipFittingToolStripMenuItem_Click);
//
// baseCalculatorToolStripMenuItem
//
this->baseCalculatorToolStripMenuItem->Name = L"baseCalculatorToolStripMenuItem";
this->baseCalculatorToolStripMenuItem->Size = System::Drawing::Size(155, 22);
this->baseCalculatorToolStripMenuItem->Text = L"Base Calculator";
this->baseCalculatorToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::baseCalculatorToolStripMenuItem_Click);
//
// helpToolStripMenuItem
//
this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->howToUseToolStripMenuItem,
this->aboutToolStripMenuItem});
this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem";
this->helpToolStripMenuItem->Size = System::Drawing::Size(44, 20);
this->helpToolStripMenuItem->Text = L"Help";
//
// howToUseToolStripMenuItem
//
this->howToUseToolStripMenuItem->Name = L"howToUseToolStripMenuItem";
this->howToUseToolStripMenuItem->Size = System::Drawing::Size(135, 22);
this->howToUseToolStripMenuItem->Text = L"How to Use";
this->howToUseToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::howToUseToolStripMenuItem_Click);
//
// aboutToolStripMenuItem
//
this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
this->aboutToolStripMenuItem->Size = System::Drawing::Size(135, 22);
this->aboutToolStripMenuItem->Text = L"About";
this->aboutToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::aboutToolStripMenuItem_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(295, 244);
this->Controls->Add(this->menuStrip1);
this->Controls->Add(this->inputText);
this->Controls->Add(this->catext);
this->Controls->Add(this->temptext);
this->Controls->Add(this->atmostext);
this->Controls->Add(this->gravtext);
this->Controls->Add(this->Temp);
this->Controls->Add(this->Calc);
this->Controls->Add(this->CAinput);
this->Controls->Add(this->Atmos);
this->Controls->Add(this->Gravity);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"Form1";
this->Text = L"Star Sonata Calculator";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
float gravholder;
float atmosholder;
float tempholder;
int calcholder;
int calevelholder;
int cacalc;
private: System::Void Temp_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
String^ temptextholder = this->Temp->Text;
if (temptextholder == "Blistering")
{
tempholder = 0.5;
}
if (temptextholder == "Frozen")
{
tempholder = 0.75;
}
if (temptextholder == "Temperate")
{
tempholder = 1;
}
if (Calc->CanFocus){
Calc->Focus();
}
}
private: System::Void Atmos_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
String^ atmostextholder = this->Atmos->Text;
if (atmostextholder == "Gaseous")
{
atmosholder = 0.5;
}
if (atmostextholder == "Noxious")
{
atmosholder = 0.75;
}
if (atmostextholder == "Terran")
{
atmosholder = 1;
}
if (Calc->CanFocus){
Calc->Focus();
}
}
private: System::Void Gravity_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
String^ gravtextholder = this->Gravity->Text;
if (gravtextholder == "Heavy")
{
gravholder = 0.5;
}
if (gravtextholder == "Low")
{
gravholder = 0.75;
}
if (gravtextholder == "Normal")
{
gravholder = 1;
}
if (Calc->CanFocus){
Calc->Focus();
}
}
private: System::Void CAinput_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {
if (e->KeyCode == Keys::Enter){
Calculation();
}
if (this->CAinput->Focus()){
if (this->CAinput->Text == "Enter your CA Level"){
this->CAinput->Text = "";
}
}
else {
this->CAinput->Text = "Enter your CA Level";
}
if (e->KeyCode == Keys::Back) {
int store;
if (this->CAinput->Text->Length > 0) {
store = this->CAinput->Text->Length;
this->CAinput->Text = this->CAinput->Text->Remove(store -1, 1);
}
}
if (e->KeyCode == Keys::D0) {
this->CAinput->Text += "0";
}
if (e->KeyCode == Keys::D1) {
this->CAinput->Text += "1";
}
if (e->KeyCode == Keys::D2) {
this->CAinput->Text += "2";
}
if (e->KeyCode == Keys::D3) {
this->CAinput->Text += "3";
}
if (e->KeyCode == Keys::D4) {
this->CAinput->Text += "4";
}
if (e->KeyCode == Keys::D5) {
this->CAinput->Text += "5";
}
if (e->KeyCode == Keys::D6) {
this->CAinput->Text += "6";
}
if (e->KeyCode == Keys::D7) {
this->CAinput->Text += "7";
}
if (e->KeyCode == Keys::D8) {
this->CAinput->Text += "8";
}
if (e->KeyCode == Keys::D9) {
this->CAinput->Text += "9";
}
if (e->KeyCode == Keys::NumPad0) {
this->CAinput->Text += "0";
}
if (e->KeyCode == Keys::NumPad1) {
this->CAinput->Text += "1";
}
if (e->KeyCode == Keys::NumPad2) {
this->CAinput->Text += "2";
}
if (e->KeyCode == Keys::NumPad3) {
this->CAinput->Text += "3";
}
if (e->KeyCode == Keys::NumPad4) {
this->CAinput->Text += "4";
}
if (e->KeyCode == Keys::NumPad5) {
this->CAinput->Text += "5";
}
if (e->KeyCode == Keys::NumPad6) {
this->CAinput->Text += "6";
}
if (e->KeyCode == Keys::NumPad7) {
this->CAinput->Text += "7";
}
if (e->KeyCode == Keys::NumPad8) {
this->CAinput->Text += "8";
}
if (e->KeyCode == Keys::NumPad9) {
this->CAinput->Text += "9";
}
if (this->CAinput->Text->Length > 0) {
calevelholder = System::Convert::ToInt32(this->CAinput->Text);
}
if (calevelholder > 30) {
this->CAinput->Text = "30";
}
}
private: System::Void Calc_Click(System::Object^ sender, System::EventArgs^ e) {
Calculation();
}
private: System::Void temptext_Click_1(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void atmostext_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void catext_Click_1(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void gravtext_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void inputText_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void gothrough_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void Calculation() {
calcholder = (gravholder*atmosholder*tempholder)*100;
cacalc = ((calevelholder*0.05)*calcholder)+calcholder;
if (cacalc > 125) {
cacalc = 125;
}
this->inputText->Text = cacalc.ToString() + "%";
}
private: System::Void howToUseToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
form->Visible = true;
}
private: System::Void advancedViewToolStripMenuItem_Click_1(System::Object^ sender, System::EventArgs^ e) {
advance->Visible = true;
}
private: System::Void shipFittingToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Ship Fittings Calculator is not included in your version of SS Calculator.");
}
private: System::Void baseCalculatorToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Base Calculator is not included in your version of SS Calculator.");
}
private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
form2->Visible = true;
}
};
}
My idea was if its not posible to hide the main form i was wanting to make a new main for that did nothing. that would be hidden and just link to the form i userly have pop up first.
but i just cant figure out how to hide the main for. im not sure whats legal and whats not thats my problem lol.
so if someone could suggest a good way to handle this i would be very greatfull.
Kind Regards,
Jordan