MrSimple

Hi.

I am trying to learn C++/CLR but it seems very tricky compared to things I have done in the past.

I wish to open a second form when I click a button, it should be simple but just refuses to work.

From the MSDN:
Code Snippet

void ShowMyDialogBox()
{
Form2^ testDialog = gcnew Form2;

// Show testDialog as a modal dialog and determine if DialogResult = OK.
if ( testDialog->ShowDialog( this ) == ::DialogResult::OK )
{
// etc etc etc.


However, I have added a second form (Project->Add New Item->Windows Form) Form2. When I get to testDialog->ShowDialog(this) it says "Expression to the left of . or -> has a type which could not be resolved". I have done lots of fiddling but cant work out what I am doing wrong.

When I type it all in anyway I get the following compile errors;

Error 1 error C2065: 'Form2' : undeclared identifier 86
Error 2 error C2065: 'test' : undeclared identifier 86
Error 3 error C2061: syntax error : identifier 'Form2' 86
Error 4 error C2227: left of '->ShowDialog' must point to class/struct/union/generic type 87


Any ideas

I had it working in seconds using C# and obviously a minor alteration of code.

Another thing I noticed was that C# IDE has a much better autocomplete feature than the C++ IDE, is this just a problem with me, or is it meant to be like it

Thank you for your time!


Re: Visual C++ Language Open a form / ->ShowDialog problems.

Nishant Sivakumar

Perhaps Form2 is in a different namespace If so, you need to specify the fully qualified name for the type.





Re: Visual C++ Language Open a form / ->ShowDialog problems.

MrSimple

Hi,
I have already checked that, I even tried using CPPTest::Form2 but to no avail (they are both in the namespace CPPTest)

What I did notice to be strange is that when I type CPPTest::Form2, the Form2 bit autocompletes, as if it has detected Form2 fine, however, I get the compile error "Form2 is not a member of CPPTest"

What else could I have done wrong
Thanks!




Re: Visual C++ Language Open a form / ->ShowDialog problems.

MrSimple

Code Snippet

#include "Form2.h" //At the top of form 1


It only took 3 hours to figure out. haha.






Re: Visual C++ Language Open a form / ->ShowDialog problems.

arun.j

Hai,

As a beginer in Visual C++, It helped me alot.

thanks.