Hi all,
I am having a bit of trouble when it comes to my design.
I have tried searching through the site for any help on linking a few windows forms to a main homepage one, but to be honest I have not found anything that is really useful. I have 6 .h files that I need to link but as I have not been programming in C++ I am a little lost on where to find any help.
My other problem I am having is to do with my created media player, I have created it, although I cannot get the open file button to actually try and retrieve any files to play.
Any help or guidence would be great, or even a point to a site where I could find some information.
Thanks
4 Replies - 834 Views - Last Post: 27 February 2011 - 02:38 PM
#1 Guest_Scott Gallagher*
I am designing a Car infotainment unit using VC++
Posted 26 February 2011 - 07:02 AM
Replies To: I am designing a Car infotainment unit using VC++
#2
Re: I am designing a Car infotainment unit using VC++
Posted 26 February 2011 - 11:02 AM
I assume you are wanting to have a main screen navigational menu where they click a button and it shows another form right? This is a matter of simply creating instances of a window and showing it. Then closing it when it is time to go back to the main screen. So if I have a form called "NewForm" in my project and I am wanting to show it from the main screen I would first include NewForm.h at the top of the main screen .h file and then through a button I can show it like so...
Now if you do not fully understand this code, I suggest you go back and learn some basic C++ because other than a slight syntax difference, this is typical button event creating a class instance and using that instance to reference a method.
You probably should be well versed in C++ before using VC++ to create something like an infotainment system. There isn't much out there in VC++ code tutorials because most people go from C++ straight to C#. VC++ is on the outskirts and I wouldn't be surprised if Microsoft drops it in the next few years.
I know it isn't much, but hopefully you can use this code to get your forms "linked" together. Do keep in mind that a form owns its own data so if you want to access fields/controls of that form you have to...
1) Make them public (usually a bad idea)
2) Provide public properties on the form which then accesses the controls on its behalf (recommended method)
3) Make the two classes friends (really not that great of design choice)
Hope this helps you!
// Button on my "Main Car Infotainment Screen"
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
// Create instance of NewForm and call it myform.
NewForm^ myform = gcnew NewForm();
// Now that I have an instance, use it to show the form (display it)
myform->Show();
}
Now if you do not fully understand this code, I suggest you go back and learn some basic C++ because other than a slight syntax difference, this is typical button event creating a class instance and using that instance to reference a method.
You probably should be well versed in C++ before using VC++ to create something like an infotainment system. There isn't much out there in VC++ code tutorials because most people go from C++ straight to C#. VC++ is on the outskirts and I wouldn't be surprised if Microsoft drops it in the next few years.
I know it isn't much, but hopefully you can use this code to get your forms "linked" together. Do keep in mind that a form owns its own data so if you want to access fields/controls of that form you have to...
1) Make them public (usually a bad idea)
2) Provide public properties on the form which then accesses the controls on its behalf (recommended method)
3) Make the two classes friends (really not that great of design choice)
Hope this helps you!
#3
Re: I am designing a Car infotainment unit using VC++
Posted 27 February 2011 - 01:52 PM
Hey Martyr2, I am goin to be a pain, but I know obvuisly that the headers go in the .h file but the other part you put in, would that go in the .h file aswell or in the .ccp file?
Cheers for the help
Cheers for the help
#4
Re: I am designing a Car infotainment unit using VC++
Posted 27 February 2011 - 02:27 PM
Hey, managed to find where I should of put the code, I do apoligise for sounding so dumb when it comes to all this. I have now hit the problem with errors saying things aren't declared etc.
Here is the code I have put in, if I need to add in the headers and things to show let me know as I have them added in aswell.
The errors I am getting are these
error C2065: 'satnav' : undeclared identifier
error C2061: syntax error : identifier 'SatNav'
error C2065: 'satnav' : undeclared identifier
error C2227: left of '->Show' must point to class/struct/union/generic type type is ''unknown-type'
Here is the code I have put in, if I need to add in the headers and things to show let me know as I have them added in aswell.
#pragma endregion
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void SatNav_Click(System::Object^ sender, System::EventArgs^ e) {
SatNav^ satnav = gcnew SatNav();
satnav->Show();
}
};
The errors I am getting are these
error C2065: 'satnav' : undeclared identifier
error C2061: syntax error : identifier 'SatNav'
error C2065: 'satnav' : undeclared identifier
error C2227: left of '->Show' must point to class/struct/union/generic type type is ''unknown-type'
#5
Re: I am designing a Car infotainment unit using VC++
Posted 27 February 2011 - 02:38 PM
Moved to CLI C++
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote









|