HOW TO shorten the RESULT for Messagebox::Show in a winform C++

Hi,

How to shorten or convert the full path for the RESULT from Messagebox()

The following is tried and is NOT working
::Yes
DialogResult::Yes
::DialogResult::Yes
etc...

So I have to include the full path -> System::Windows::Forms::DialogResult::Yes

CODE used (yes this is compiled, build and runs OK):

if (MessageBox::Show("Do you want to exit?","My Application", MessageBoxButtons::YesNo,MessageBoxIcon::Question)==System::Windows::Forms::DialogResult::Yes)
{
MessageBox::Show("You pressed YES!", "STATUS INDICATION");
}
else
{
MessageBox::Show("You pressed NO!", "STATUS INDICATION");
}

But I'm sure there is a simpler more userfriendly way.
***********************************************************************
I can give more information if necessary on the where the code is used
some info is maybe interesting:

It's within
private BUTTONclick {
}

in the GUI.H file made by Visual Studio 2010 after building a GUI with a button and here I describe what should happen and in this case I want to give the user a choice. So it's NOT the MAIN.CPP file, as this ONLY opens the form (the GUI itselve).
Not sure if these are in classes, enums or in namespaces, but try:
1
2
3
4
5
6
7
8
9
10
11
12
13
using MessageBoxButtons::YesNo;
using MessageBoxIcon::Question;
using System::Windows::Forms::DialogResult::Yes;

MessageBox msgBox;
if (msgBox.Show("Do you want to exit?", "My Application", YesNo, Question) == Yes )
{
  msgBox.Show("You pressed YES!", "STATUS INDICATION");
}
else
{
  msgBox.Show("You pressed NO!", "STATUS INDICATION");
}
Hi Stewbond!

Super THANKS!
Really wonder why this is not easy to find!
As I made several searches on the internet.

It also makes me aware that I have to do some reading in classes and framework etc..! Has been long time using C++ and I see some things have vanished true the years.

Again thanks stewbond.
Topic archived. No new replies allowed.