native_windows_gui/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_gui 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::win32::window::create_message_window;
21use crate::NwgError;
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
34 pub fn builder() -> MessageWindowBuilder {
35 MessageWindowBuilder {}
36 }
37
38}
39
40impl Drop for MessageWindow {
41 fn drop(&mut self) {
42 self.handle.destroy();
43 }
44}
45pub struct MessageWindowBuilder {
46}
47
48impl MessageWindowBuilder {
49
50 pub fn build(self, out: &mut MessageWindow) -> Result<(), NwgError> {
51 *out = Default::default();
52 out.handle = create_message_window()?;
53 Ok(())
54 }
55
56}