Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MessageBox in VC++ Windows Form

MessageBox in VC++ Windows Form

MessageBox in VC++ Windows Form

I'm trying to pop up a confirmation dialog box in a Windows Forms app, but I keep getting an error at compile time.

Here's the code snippet:

using namespace System::Windows::Forms;
int Form1::myMethod(void)
if (System::Windows::Forms::MessageBox::Show(msg,"Warning",System::Windows::Forms::MessageBoxButtons::OKCancel))
   return 0;

The error message is:
error C2039: 'MessageBoxA' is not a member of 'System::Windows::Controls'
error C2660: System::Windows::Forms::Control::Show' : function does not take 3 arguments

Nowhere do I have a MessageBoxA, I assume this is somehow an alias of or referenced by the MessageBox definition?

Also being new to this platform, I wonder if there's just an include file or DLL that I'm missing?

This is VC++ in the visual studio 2003 environment, using a simple single-form window.

RE: MessageBox in VC++ Windows Form

The first error is most likely due to the type of variable msg is. Check you arn't mixing managed and unmanaged code.
The second is a result of the first. Try...


String^ msg("The Message"); string on the managed heap

if (MessageBox::Show(msg,"Warning",MessageBoxButtons::OKCancel) == System::Windows::Forms::DialogResult::Cancel)
return 0;
or similar.
This works for me in C++VS2005

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close