4 Replies - 834 Views - Last Post: 27 February 2011 - 02:38 PM

#1 Guest_Scott Gallagher*


Reputation:

I am designing a Car infotainment unit using VC++

Posted 26 February 2011 - 07:02 AM

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

Is This A Good Question/Topic? 0

Replies To: I am designing a Car infotainment unit using VC++

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3911
  • View blog
  • Posts: 11,448
  • Joined: 18-April 07

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...

// 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! :)
Was This Post Helpful? 0
  • +
  • -

#3 Scott Gallagher  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-February 11

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 :)
Was This Post Helpful? 0
  • +
  • -

#4 Scott Gallagher  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-February 11

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.

#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'
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5723
  • View blog
  • Posts: 22,635
  • Joined: 23-August 08

Re: I am designing a Car infotainment unit using VC++

Posted 27 February 2011 - 02:38 PM

Moved to CLI C++
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1