#!/perl/bin/perl use strict; use warnings; use Win32; my @pressed = qw( Error OK Cancel Abort Retry Ignore Yes No ); popup('Starting Win32::Msg Demo', ['Information'], 'Demo'); my $output = popup('Should I continue?.', ['YesNo', 'DefaultButton2', +'Question']); print "You pressed '", $pressed[$output], "'\n"; print $output == 6 ? "Continuing now...\n" : "Finished.\n"; my $format = popup("Windows has performed an illegal operation.\nShoul +d I format C:?", ['Critical', 'YesNo'], 'Big Uh Oh'); print $format == 6 ? "Are you nuts?\n" : "It was only a joke!\n"; sub popup { my $option; my $message = shift; my $options = shift; my $title = shift || ''; my %flags = ( OKOnly => 0, # Display OK button only. OKCancel => 1, # Display OK and Cancel buttons. AbortRetryIgnore => 2, # Display Abort, Retry, and Ignore butto +ns. YesNoCancel => 3, # Display Yes, No, and Cancel buttons. YesNo => 4, # Display Yes and No buttons. RetryCancel => 5, # Display Retry and Cancel buttons. Critical => 16, # Display Critical Message icon. Question => 32, # Display Warning Query icon. Exclamation => 48, # Display Warning Message icon. Information => 64, # Display Information Message icon. DefaultButton1 => 0, # First button is default. DefaultButton2 => 256, # Second button is default. DefaultButton3 => 512, # Third button is default. DefaultButton4 => 768, # Fourth button is default. ApplicationModal => 0, # The user must respond to the message b +ox before continuing work in the current application. SystemModal => 4096, # All applications are suspended until t +he user responds to the message box. ); my @options = @{$options}; $option += $flags{$_} for @options; Win32::MsgBox($message, $option, $title); }
In reply to Passing Named Flags to Win32::MsgBox by Mr. Muskrat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |