native_windows_gui2/controls/
message_window.rs

1/*!
2    A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not
3    receive broadcast messages. The window simply dispatches messages.
4
5    A MessageWindow do not have any builder parameter, but still provides the API for the derive macro.
6
7    Requires the `message-window` feature.
8
9    ## Example
10    ```
11    use native_windows_gui2 as nwg;
12
13    let mut window = Default::default();
14    nwg::MessageWindow::builder().build(&mut window);
15    ```
16
17    When making a system-tray application (with TrayNotification), this is the recommended top level window type.
18*/
19use super::ControlHandle;
20use crate::NwgError;
21use crate::win32::window::create_message_window;
22
23/**
24    A message only top level window. At least one top level window is required to make a NWG application.
25    See the module documentation
26*/
27#[derive(Default, PartialEq, Eq)]
28pub struct MessageWindow {
29    pub handle: ControlHandle,
30}
31
32impl MessageWindow {
33    pub fn builder() -> MessageWindowBuilder {
34        MessageWindowBuilder {}
35    }
36}
37
38impl Drop for MessageWindow {
39    fn drop(&mut self) {
40        self.handle.destroy();
41    }
42}
43pub struct MessageWindowBuilder {}
44
45impl MessageWindowBuilder {
46    pub fn build(self, out: &mut MessageWindow) -> Result<(), NwgError> {
47        *out = Default::default();
48        out.handle = create_message_window()?;
49        Ok(())
50    }
51}