Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Sorc.Polgara on January 18, 2005, 06:11 PM

Title: [C++ .Net] MessageBox::Show
Post by: Sorc.Polgara on January 18, 2005, 06:11 PM
I'm using this book for C++ .Net that I mistakenly bought awhile back because I thought it was for C++ (not .Net).  I had forgotten that I had it.

So now I can actually use it because I [MyndFyre-Edit]legitimately acquired[/MyndFyre-Edit] Visual Studio .Net.

Back on topic.

I am told to code:

MessageBox::Show(S"It worked!", S"Message...");


However, I can't compile it.  It gives me two errors that make completely no sense.

Quote
c:\Documents and Settings\John Doe\Desktop\Forms\CppForm.cpp(24): error C2653: 'MessageBoxA' : is not a class or namespace name

c:\Documents and Settings\John Doe\Desktop\Forms\CppForm.cpp(24): error C2660: 'System::Windows::Forms::Control::Show' : function does not take 2 arguments

This is totally whack.  I am not trying to use this "MessageBoxA".  wtf.  I didn't even type that in...

I am definitely sure that I have included the right #using information and namespaces because I'm done every step-by-step instruction that I was given.

Anyone have any idea what the problem is?
Title: Re: [C++ .Net] MessageBox::Show
Post by: MyndFyre on January 18, 2005, 06:17 PM
Just to be sure, you definitely included:


#using <System.Windows.Forms.dll>

using namespace System::Windows::Forms;

?

Also, you're probably #including <windows.h>, right?  Well, I believe <windows.h> includes a #define something like this:


#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif


Amazing!  I just did an MSDN library search to see what header it was in, but hell I didn't need to!  This article (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcmg_macrosandthepreprocessor.asp) describes exactly the problem you're having!  :)
Title: Re: [C++ .Net] MessageBox::Show
Post by: Sorc.Polgara on January 18, 2005, 06:20 PM
Quote from: MyndFyre on January 18, 2005, 06:17 PM
Just to be sure, you definitely included:


#using <System.Windows.Forms.dll>

using namespace System::Windows::Forms;

?

Also, you're probably #including <windows.h>, right?  Well, I believe <windows.h> includes a #define something like this:


#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif


Amazing!  I just did an MSDN library search to see what header it was in, but hell I didn't need to!  This article (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcmg_macrosandthepreprocessor.asp) describes exactly the problem you're having!  :)

yeah... that fixed it!  sorry kekekekeke