Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jimmyh

C++ Forms MessageBox::Show Error

This topic is 5175 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m pretty new to c++ forms in .net 2003, and I''ve been trying to display a message box. Here is the line of code i''m using MessageBox::Show(S"Text", S"Text", MessageBoxButtons::OK, MessageBoxIcon::Exclamation); I get two compile errors with this code. error C2653: ''MessageBoxA'' : is not a class or namespace name error C2660: ''System::Windows::Forms::Control::Show'' : function does not take 4 arguments Any one got any ideas? Cheers. James.

Share this post


Link to post
Share on other sites
Advertisement
Well are you including the System.Window.Forms namespace? You also need to reference the System.Window.Forms assmebly.

EDIT: Your error message says MessagBoxA....typo?



There's no place like 127.0.0.1


[edited by - rohde on May 19, 2004 7:13:44 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by rohde
Well are you including the System.Window.Forms namespace? You also need to reference the System.Window.Forms assmebly.

EDIT: Your error message says MessagBoxA....typo?



There''s no place like 127.0.0.1


[edited by - rohde on May 19, 2004 7:13:44 AM]


I''m including this line
using namespace System::Windows::Forms;

but not sure what you mean by assembly?

Cheers.
James.

Share this post


Link to post
Share on other sites
You are probably including windows.h, and it''s not fully compatible with the dotnet framework. There are some macros that are bad, and MessageBox is one of them. It defines it as either MessageBoxA or MessageBoxW, depending on your characterset.

Avoid including windows.h if possible, but if it isn''t you should put a #undef MessageBox right after the windows.h include.

Share this post


Link to post
Share on other sites
If you're using VS.NET you need to include a reference to the System.Window.Forms assembly if it isn't already added. Look for the "References" node in the "Solution Explorer".

If you're using the command line compiler you need to use the option: "/reference:System.Windows.Forms.dll" f.ex.:
"csc MyForm.cs /reference:System.Windows.Forms.dll"


EDIT: The example is for the C# compiler.



There's no place like 127.0.0.1


[edited by - rohde on May 19, 2004 7:22:37 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by fredizzimo
You are probably including windows.h, and it''s not fully compatible with the dotnet framework. There are some macros that are bad, and MessageBox is one of them. It defines it as either MessageBoxA or MessageBoxW, depending on your characterset.

Avoid including windows.h if possible, but if it isn''t you should put a #undef MessageBox right after the windows.h include.


Thank you very much, that has fixed the problem.

I''ve just removed the include for windows.h, not sure how it go there tho.

Cheers.
James.

Share this post


Link to post
Share on other sites
oh and one more thing, how do you test the return code for the message box?

Thanks for your input also rohde.

Cheers.
James.

Share this post


Link to post
Share on other sites
The MessageBox class' Show method returns a DialogResult object which indicates which button was clicked.



There's no place like 127.0.0.1


[edited by - rohde on May 19, 2004 7:26:36 AM]

[edited by - rohde on May 19, 2004 7:26:51 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!