View previous topic :: View next topic |
Author |
Message |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Aug 21, 2007 7:18 pm Post subject: [Help: C++] Opening a New Form |
|
|
i searched around and only thing i could really find that helped me was this: (modified for my form)
Code: | private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
frmAbout ^ dlg1 = gcnew frmAbout();
dlg1->ShowDialog(); |
Errors i get:
Quote: | 1>c:\documents and settings\kyle h\my documents\visual studio 2005\projects\temp conversion v2\temp conversion v2\Form1.h(406) : error C2065: 'frmAbout' : undeclared identifier
1>c:\documents and settings\kyle h\my documents\visual studio 2005\projects\temp conversion v2\temp conversion v2\Form1.h(406) : error C2065: 'dlg1' : undeclared identifier
1>c:\documents and settings\kyle h\my documents\visual studio 2005\projects\temp conversion v2\temp conversion v2\Form1.h(406) : error C2061: syntax error : identifier 'frmAbout'
1>c:\documents and settings\kyle h\my documents\visual studio 2005\projects\temp conversion v2\temp conversion v2\Form1.h(407) : error C2227: left of '->ShowDialog' must point to class/struct/union/generic type |
Help is GREATLY appreciated, for it will help me for the rest of my C++ programming...
Note: i have included frmAbout.h (#include "frmAbout.h") at the top of my Form1 Header/Class
_________________
Last edited by lurc on Wed Aug 22, 2007 9:06 am; edited 1 time in total |
|
Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Tue Aug 21, 2007 7:35 pm Post subject: |
|
|
Is frmAbout a class? Because it doesn't look like it is, and you seem to be using it as if it is.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Aug 21, 2007 7:46 pm Post subject: |
|
|
not a clue? its a UI i added...
uh.. teach me
_________________
|
|
Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Tue Aug 21, 2007 7:58 pm Post subject: |
|
|
C++ syntax for declaring an instance of a class:
className classInstanceName = new classConstructor(args);
classConstructor is a method with the same name as the class name.
MS VC++ has an extension of the language allowing for a built-in garbage collector. This feature is used like so:
className^ classInstanceName = gcnew classConstructor(args);
^ "indicates a handle to an object on the garbage collected heap".
gcnew "allocates types on the garbage collected heap".
~nog_lorp
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Aug 21, 2007 8:11 pm Post subject: |
|
|
uhhh example code plz....
i know ur talkin about the code i have, but if its calling a class, why is it saying that the identifyer isnt there. and i've already declared the header in the Form1 Header
_________________
|
|
Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Tue Aug 21, 2007 8:26 pm Post subject: |
|
|
You do not declare a header, you include one...
Read the header file, see what classes are declared in it.
One more thing, dlg1 is not a class pointer, so you should use . (or ::, not sure) and not ->. classptr->method is the same as (classptr*).method
~nog_lorp
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Aug 21, 2007 8:41 pm Post subject: |
|
|
i have included it. thats what i ment by Declare.
Edit: i figured it out, thanks
_________________
|
|
Back to top |
|
 |
|