question

srfpala avatar image
0 Votes"
srfpala asked AryaDing-MSFT answered

MessageBox in Blank App ( U W - C++/CX )

Thanks for the previous help.
I now have a form with a button.
On click event I'd like to display a MessageBox()
MessageBox::Show("Ready","Button Test", MessageBoxButtons::OK);
The above raises an error C2653 'MessageBox' is not a class or a namespace.
I added using namespace Windows::System;
But it didn't help.
Any ideas ?

windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AryaDing-MSFT avatar image
0 Votes"
AryaDing-MSFT answered

Hi,

Welcome to Microsoft Q&A!

For Universal Apps, it does not provide such api about Messagebox, it is always to use MessageDialog to show message. As follows:

 using namespace Windows::UI::Popups;
 void Messa::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
 {
     MessageDialog^ msg = ref new MessageDialog("No internet connection has been found.");
     UICommand^ continueCommand = ref new UICommand("Yes");
     UICommand^ upgradeCommand = ref new UICommand("No");
       
     msg->DefaultCommandIndex = 0;
     msg->CancelCommandIndex = 1;
     msg->Commands->Append(continueCommand);
     msg->Commands->Append(upgradeCommand);
     msg->ShowAsync();
 }

More info could be found here.



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.