I've recently started poking around in Visual Studio 2005, and I'm mucking about in Visual C++. When I double click on a control in the designer, it opens the .h file, which I've understood to be for prototype declarations, and if I put all the guts to the functions in there, I can get my program to work, but I don't like having the code in the .h file.
However, when I put things in a .cpp file, I can't seem to access the controls at all. I get a lot of compiler errors and such, and I'm wondering what VC++ is expecting, as I'm more used to a GCC/MinGW environment.
The errors I receive the most are:
error C2228: left of '.trackBar1/.value/.etc' must have class/struct/union
error C2227: left of '->trackBar1/->Value/->etc' must point to class/struct/union/generic type
I've tried the following to access the control:
Junk::Form1::trackBar1->value
Junk::Form1::trackBar1.value
Junk::Form1->trackBar1
Junk->Form1->trackBar1
this->trackBar1->value //This is legal in the .h file, and how I can get it to work there
trackBar1->value
And a few others that are just attempts out of desperation. I've tried specifying the same namespace and everything as present in the .h file, and I still cannot seem to access the control.
I'm using Visual Studio 2005, with a Visual C++ CLR Win32 form application. The code that Visual Studio uses to create instances of the controls is:
this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
In Dev-C++ or code::blocks, I'm used to putting the class declarations in the .h file, and then specifying the functions in the .cpp file by doing class::function, but in Visual Studio, I just cannot seem to figure out why I can't do the same, or what I'm doing horribly wrong and stupid.
Thank you.