function??

G

Guest

Dear all who is nice,

I'm the DUMBEST person on earth who just started to use VC++....
need some help on the below coding....please check the NOTE section....

thanks in advanced...

=================================
#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

__gc class frmStart : public Form
{
public:
frmStart();

private:
String* UserSelect_str;

Label *fxcommUserSelDisp_lab; // Declare an instance to a Label class

// Declare an instance to a ComboBox class and also the events
ComboBox *fxcomm_cbox;
void evtSelectionChanged(Object *Sender, EventArgs *Args);

// Declare an instance to a Button class and also the events
Button *exit_btn;
void evtExitButtonClick(Object *Sender, EventArgs *Args);

Button *execute_btn;
void evtExecuteButtonClick(Object *Sender, EventArgs *Args);

//Declare every fx comm as a subproc
void subBRInit(); void subWRInit(); void subBWInit(); void subWWInit();

};

frmStart::frmStart()
{

this->StartPosition =
System::Windows::Forms::FormStartPosition::CenterScreen;
this->Size = System::Drawing::Size(568, 260);

// The caption of the form
this->Text = S"MITSUBISHI: Fx Communication selection...";

// Declare all the neccessary controls in the forms
// Use the instance of the combo box to initialize the class
fxcomm_cbox = new ComboBox;
fxcomm_cbox->DropDownStyle = ComboBoxStyle::DropDownList; // ComboBox Style
fxcomm_cbox->Size = Drawing::Size(72, 21); // Width & Height
fxcomm_cbox->Location = Point(4, 16); // position the combo box X & Y
// Add each item to the combo box according to fx communication commands
fxcomm_cbox->Items->Add(S"BR");
fxcomm_cbox->Items->Add(S"WR");
fxcomm_cbox->Items->Add(S"BW");
fxcomm_cbox->Items->Add(S"WW");
fxcomm_cbox->Items->Add(S"BT");
fxcomm_cbox->Items->Add(S"WT");
fxcomm_cbox->Items->Add(S"RR");
fxcomm_cbox->Items->Add(S"RS");
fxcomm_cbox->Items->Add(S"PC");
fxcomm_cbox->Items->Add(S"GW");
fxcomm_cbox->Items->Add(S"__");
fxcomm_cbox->Items->Add(S"TT");
// fxcomm_cbox->Text = S"BR"; // Specific first display
// Add the Combo box events of user selection
fxcomm_cbox->add_SelectedIndexChanged(new EventHandler(this,
evtSelectionChanged));
// After creating the control, add it to the form control
this->Controls->Add(fxcomm_cbox);

exit_btn = new Button;
exit_btn->Text = S"E&XIT";
exit_btn->Location = Point(488, 212);
exit_btn->Size = Drawing::Size(64, 20);
exit_btn->FlatStyle = FlatStyle::Flat;
exit_btn->add_Click(new EventHandler(this, evtExitButtonClick));
this->Controls->Add(exit_btn);

execute_btn = new Button;
execute_btn->Text = S"E&XIT";
execute_btn->Location = Point(388, 212);
execute_btn->Size = Drawing::Size(64, 20);
execute_btn->FlatStyle = FlatStyle::Flat;
execute_btn->add_Click(new EventHandler(this, evtExecuteButtonClick));
this->Controls->Add(execute_btn);

fxcommUserSelDisp_lab = new Label;
fxcommUserSelDisp_lab->Location = Point(80, 16);
fxcommUserSelDisp_lab->Size = Drawing::Size(472, 184);
fxcommUserSelDisp_lab->BackColor = Drawing::Color::LightCyan;
// fxcommUserSelDisp_lab->Text = S"BR";
this->Controls->Add(fxcommUserSelDisp_lab);

// ENF declare all the neccessary controls in the forms


}

void frmStart::evtSelectionChanged(Object *Sender, EventArgs *Args)
{
UserSelect_str = fxcomm_cbox->Text;

fxcommUserSelDisp_lab->Text = "In progress...please be patient.";

if ( String::Compare( UserSelect_str, "BR" ) == 0 )
{ subBRInit(); }
else if ( String::Compare( UserSelect_str, "WR" ) == 0 )
{ subWRInit(); }
else if ( String::Compare( UserSelect_str, "BW" ) == 0 )
{ subBWInit(); }
else if ( String::Compare( UserSelect_str, "WW" ) == 0 )
{ subWWInit(); }
else if ( String::Compare( UserSelect_str, "BT" ) == 0 )
{ }
else if ( String::Compare( UserSelect_str, "WT" ) == 0 )
{ }
else if ( String::Compare( UserSelect_str, "RR" ) == 0 )
{ }
else if ( String::Compare( UserSelect_str, "RS" ) == 0 )
{ }
else if ( String::Compare( UserSelect_str, "PC" ) == 0 )
{ }
else if ( String::Compare( UserSelect_str, "GW" ) == 0 )
{ }
else if ( String::Compare( UserSelect_str, "__" ) == 0 )
{ }
}

void frmStart::subBRInit()
{
fxcommUserSelDisp_lab->Text = "Bit devices read in units of 1 point.";
}
void frmStart::subWRInit()
{
String* s = String::Concat(S"Bit devices read in units of 16 point, \r\n");
s = String::Concat(s, S"or word devices read in units of 1 point.");
fxcommUserSelDisp_lab->Text = s;
}
void frmStart::subBWInit()
{
fxcommUserSelDisp_lab->Text = "Bit devices written in units of 1 point.";
}
void frmStart::subWWInit()
{
fxcommUserSelDisp_lab->Text = "Bit devices written in units of 16 point,
or word devices read in units of 1 point.";
}

void frmStart::evtExecuteButtonClick(Object *Sender, EventArgs *Args)
{
//NOTE: I need the below value is a RETURN result by passing 1 parameter
//PLEASE LET ME KNOW WHERE SHOULD I DECLARED THE FUNCTION AND HOW TO
//USE IT....thanks a lot
fxcommUserSelDisp_lab->Text = "test";
}


void frmStart::evtExitButtonClick(Object *Sender, EventArgs *Args)
{ this->Close(); }
int __stdcall WinMain()
{
frmStart *SF = new frmStart();
Application::Run(SF);
return 0;
}
 
B

Ben Voigt

joshua siew said:
Dear all who is nice,

I'm the DUMBEST person on earth who just started to use VC++....
need some help on the below coding....please check the NOTE section....

If you just started, then you are wasting your time with Managed C++. MC++
is dead. VS2005 (the express edition is a free download and many
opportunities to get standard edition free too, i.e. learn2asp.net) uses a
new syntax C++/CLI for programming .NET applications.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top