470,849 Members | 1,081 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

function??

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::CenterS creen;
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;
}

May 24 '06 #1
1 1058
"joshua siew" <jo********@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
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.

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::CenterS creen;
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;
}

Jun 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by domeceo | last post: by
5 posts views Thread by phil_gg04 | last post: by
2 posts views Thread by laredotornado | last post: by
2 posts views Thread by sushil | last post: by
8 posts views Thread by Olov Johansson | last post: by
3 posts views Thread by Beta What | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.