pub struct MessageBox<'a, T> { /* private fields */ }
Expand description
A builder for a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information.
The type of the message box is specified by T
(See Options for available options).
Implementations§
Source§impl<'a, T> MessageBox<'a, T>
impl<'a, T> MessageBox<'a, T>
Sourcepub fn new(text: &'a str) -> Self
pub fn new(text: &'a str) -> Self
Creates a new message box with a specified text
to be displayed.
If the string consists of more than one line,
you can separate the lines using a carriage return and/or linefeed character between each line.
Sourcepub fn title(self, title: &'a str) -> Self
pub fn title(self, title: &'a str) -> Self
The dialog box title. If this parameter is null, the default title is Error.
Examples found in repository?
More examples
6fn main() -> Result<()> {
7 let response = win_msgbox::error::<CancelTryAgainContinue>("Couldn't download resource")
8 .title("Download Error")
9 .show()?;
10
11 match response {
12 Cancel => println!("Cancelling downlaod..."),
13 TryAgain => println!("Attempting redownload..."),
14 Continue => println!("Skipping resource"),
15 }
16
17 Ok(())
18}
Sourcepub fn hwnd(self, hwnd: HWND) -> Self
pub fn hwnd(self, hwnd: HWND) -> Self
A handle to the owner window of the message box to be created.
If this parameter is 0
, the message box has no owner window (default).
Sourcepub fn modal(self, modal: Modal) -> Self
pub fn modal(self, modal: Modal) -> Self
Set the modality of the dialog box. See Modal for options.
Set the default button of the dialog box. See DefaultButton for options.
Sourcepub fn default_desktop_only(self) -> Self
pub fn default_desktop_only(self) -> Self
Same as desktop of the interactive window station. For more information, see Window Stations. If the current input desktop is not the default desktop, show does not return until the user switches to the default desktop.
Sourcepub fn rtl_reading(self) -> Self
pub fn rtl_reading(self) -> Self
Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.
Sourcepub fn set_foreground(self) -> Self
pub fn set_foreground(self) -> Self
The message box becomes the foreground window. Internally, the system calls the SetForegroundWindow function for the message box.
Sourcepub fn service_notification(self) -> Self
pub fn service_notification(self) -> Self
The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer.
Terminal Services: If the calling thread has an impersonation token, the function directs the message box to the session specified in the impersonation token.
If this is called, hwnd
must not be called - it must remain 0
.
his is so that the message box can appear on a desktop other than the desktop corresponding to the hwnd
.
For information on security considerations in regard to using this flag, see Interactive Services. In particular, be aware that this flag can produce interactive content on a locked desktop and should therefore be used for only a very limited set of scenarios, such as resource exhaustion.
Source§impl<T: Options> MessageBox<'_, T>
impl<T: Options> MessageBox<'_, T>
Sourcepub fn show(self) -> Result<T>
pub fn show(self) -> Result<T>
Shows the message box, returning the option the user clicked on.
If a message box has a Cancel button, the function returns the Cancel
value
if either the ESC key is pressed or the Cancel button is selected.
If the message box has no Cancel button, pressing ESC will no effect - unless an Ok button is present.
If an Ok button is displayed and the user presses ESC, the return value will be Ok
.
Examples found in repository?
More examples
6fn main() -> Result<()> {
7 let response = win_msgbox::error::<CancelTryAgainContinue>("Couldn't download resource")
8 .title("Download Error")
9 .show()?;
10
11 match response {
12 Cancel => println!("Cancelling downlaod..."),
13 TryAgain => println!("Attempting redownload..."),
14 Continue => println!("Skipping resource"),
15 }
16
17 Ok(())
18}
Source§impl<'a, T> MessageBox<'a, T>
impl<'a, T> MessageBox<'a, T>
Sourcepub fn exclamation(text: &'a str) -> Self
pub fn exclamation(text: &'a str) -> Self
Creates a new message box where its icon is set to Exclamation.
Sourcepub fn warning(text: &'a str) -> Self
pub fn warning(text: &'a str) -> Self
Creates a new message box where its icon is set to Warning.
Sourcepub fn information(text: &'a str) -> Self
pub fn information(text: &'a str) -> Self
Creates a new message box where its icon is set to Information.
Sourcepub fn asterisk(text: &'a str) -> Self
pub fn asterisk(text: &'a str) -> Self
Creates a new message box where its icon is set to Asterisk.