Problem:
Customer is developing a WPF application and would like to display a Windows Message Box that has a Yes and No button. How can the application tell which one of these buttons was pressed after returning?
The Message Box is being displayed as follows:
invoke type System.Windows.MessageBox::Show("My Text", "My Caption",
type System.Windows.MessageBoxButton::YesNo,
type System.Windows.MessageBoxImage::Question,
type System.Windows.MessageBoxResult::Yes,
type System.Windows.MessageBoxOptions::RightAlign)
Resolution:
The result is returned from the Show method as type System.Windows.MessageBoxResult so you can just test for the result directly in a conditional statement like:
evaluate type System.Windows.MessageBox::Show(
"My Text",
"My Caption",
type System.Windows.MessageBoxButton::YesNo
type System.Windows.MessageBoxImage::Question
type System.Windows.MessageBoxResult::Yes
type System.Windows.MessageBoxOptions::RightAlign)
when type MessageBoxResult::Yes
perform yes-processing
when type MessageBoxResult::No
perform no-processing
end-evaluate