How to show a MessageBox outside the form.h module?

  • Thread starter Thread starter joye
  • Start date Start date
J

joye

Hi,

I know how the show a MessageBox in Form.h module by using VC.NET.
But I don't know how to show the MessageBox at another class such as
task.cpp which called by the Form.h; my question is how to pass the
arguments from Form.h to a MessageBox::Show() which included in a class
method.

Thanks.
Tsung-Yu Liu
 
if I get it correct, you need to add namespace:

System::Windows::Forms at the beginning of MessageBox::Show().
Therefore:

System::Windows::Forms::MessageBox::Show();

should work well.

You can also use one of the following forms to call a function, use a
class, or use anything else in a namespace:

using namespace System::Windows::Forms; // allows your code to access
whole System::Windows::Forms namespace
using System::Windows::Forms::MessageBox; // allows your code to access
only System::Windows::Forms::MessageBox

If you, however, use latter one, you may not specify parameters for
Show method of the messagebox because parameters are also in
System::Windows::Forms.

Ismail
 
Back
Top