| View previous topic :: View next topic |
| Author |
Message |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Dec 16, 2010 6:38 pm Post subject: Re: C++ CODE. |
|
|
| Shrooms wrote: | If anyone knows how to code in vc++, here is my question.
You have on your form called (Main) a pictureBox.
You click this pictureBox and it opens a second form called (General).
Back on the form (Main) that same picture box we clicked is displaying a picture.
Right when you clicked it to open the General form, I want it to switch to a new picture.
How can this be done?
I have decided to do this in my Main.h;
Code:
private: System::Void pictureBox10_Click(System::Object^ sender, System::EventArgs^ e) {
general->Visible = true;
if(general->Visible == true)
{
Main->pictureBox10->ImageLocation = "http://localhostr.com/files/yI6Yoct/general-icon.png";
}
else
{
Main->pictureBox10->ImageLocation = "http://localhostr.com/files/4RMoB8y/box-icon.png";
}
}
here are the errors;
1>c:\users\*****\documents\visual studio 2010\projects\*****\*************\****\Main.h(484) : error C2143: syntax error : missing ';' before '->'
1>c:\users\*****\documents\visual studio 2010\projects\*****\*************\****\Main.h(484) : error C2143: syntax error : missing ';' before '->'
1>c:\users\*****\documents\visual studio 2010\projects\*****\*************\****\Main.h(488) : error C2143: syntax error : missing ';' before '->'
1>c:\users\*****\documents\visual studio 2010\projects\*****\*************\****\Main.h(488) : error C2143: syntax error : missing ';' before '->'
I put the headers for general and those errors reflect back to the code with the url |
shouldn't it be like this?
| Code: |
private: System::Void pictureBox10_Click(System::Object^ sender, System::EventArgs^ e) {
general.Visible = true;
if(general.Visible == true)
{
Main.pictureBox10.ImageLocation = "http://localhostr.com/files/yI6Yoct/general-icon.png";
}
else
{
Main.pictureBox10.ImageLocation = "http://localhostr.com/files/4RMoB8y/box-icon.png";
}
} |
|
|
| Back to top |
|
 |
Up2Admin I'm a spammer
Reputation: 126
Joined: 17 Oct 2007 Posts: 6548 Location: Texas
|
Posted: Thu Dec 16, 2010 7:05 pm Post subject: |
|
|
Visual C++?
_________________
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Dec 16, 2010 7:10 pm Post subject: |
|
|
| Shrooms wrote: | I will try that now!
Edit: GoGoodr, that code does not work, gives a lot of errors. |
care to post the errors?
--- forget it. I forget every single thing I knew about C++ after being so much time with C#
ugh: I'm trying again
btw: shouldn't you be doing this in your .cpp instead of the header file?
| Quote: | private: System::Void pictureBox10_Click(System::Object^ sender, System::EventArgs^ e) {
general->Visible = true;
if(general->Visible == true)
{
pictureBox10->ImageLocation = "http://localhostr.com/files/yI6Yoct/general-icon.png";
}
else
{
pictureBox10->ImageLocation = "http://localhostr.com/files/4RMoB8y/box-icon.png";
}
} |
Last edited by gogodr on Thu Dec 16, 2010 7:48 pm; edited 1 time in total |
|
| Back to top |
|
 |
407 Master Cheater
Reputation: 0
Joined: 25 Oct 2007 Posts: 357
|
Posted: Thu Dec 16, 2010 7:41 pm Post subject: |
|
|
| You're missing a
|
|
| Back to top |
|
 |
Crinchy Expert Cheater
Reputation: 0
Joined: 27 Dec 2008 Posts: 193
|
Posted: Thu Dec 16, 2010 7:51 pm Post subject: |
|
|
It should be
_________________
When life throws bricks at you, throw bananas right back at it! |
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Thu Dec 16, 2010 8:18 pm Post subject: |
|
|
Visual C++
OH MAH GOD
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Thu Dec 16, 2010 11:19 pm Post subject: |
|
|
| Shrooms wrote: | | gogodr wrote: | | Shrooms wrote: | I will try that now!
Edit: GoGoodr, that code does not work, gives a lot of errors. |
care to post the errors?
--- forget it. I forget every single thing I knew about C++ after being so much time with C#
ugh: I'm trying again
btw: shouldn't you be doing this in your .cpp instead of the header file?
| Quote: | private: System::Void pictureBox10_Click(System::Object^ sender, System::EventArgs^ e) {
general->Visible = true;
if(general->Visible == true)
{
pictureBox10->ImageLocation = "http://localhostr.com/files/yI6Yoct/general-icon.png";
}
else
{
pictureBox10->ImageLocation = "http://localhostr.com/files/4RMoB8y/box-icon.png";
}
} |
|
ILUV U!!!
I am doing in .h as general is not declared in .cpp and I dun know how to declare in cpp. |
well if it works fine then it is ok
|
|
| Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Fri Dec 17, 2010 7:01 am Post subject: |
|
|
You use the .h file to define what functions and given parameters are used in the .cpp file. You include the .h file in the cpp file, create a function using
NAMEOFCLASS::myHeaderFunction(PARA1, PARA2) {
return STUFFHERE;
}
Also, you forgot a ; somewhere. Syntax errors; the number one cause of compiling errors.
|
|
| Back to top |
|
 |
|