Cannot find macro 'ui' in this scope

This is contents of my main.rs:
use windows::{
core::, Data::Xml::Dom::, Win32::Foundation::, Win32::System::Threading::,
Win32::UI::WindowsAndMessaging::*,
};
fn main() {

let details_window = ui! {
    Window title("Crash Details") visible(show_details) modal(true) hsize(600) vsize(400)
         halign(Alignment::Fill) valign(Alignment::Fill)
    {
         VBox margin(10) spacing(10) halign(Alignment::Fill) valign(Alignment::Fill) {
                Scroll halign(Alignment::Fill) valign(Alignment::Fill) {
                    TextBox content(details) halign(Alignment::Fill) valign(Alignment::Fill)
                },
                Button halign(Alignment::End) on_click(move || *show_details.borrow_mut() = false)
             {
                 Label text("Ok")
             }
         }
     }
};

}

This is the contents of my cargo.toml
[package]
name = "agtech"
version = "0.1.0"
edition = "2021"

[dependencies]

[dependencies.windows]
version = "0.56"
features = [
"Data_Xml_Dom",
"Win32_Foundation",
"Win32_Security",
"Win32_System_Threading",
"Win32_UI_WindowsAndMessaging",
]

[dependencies.windows-sys]
version = "0.52"
features = [
"Win32_Foundation",
"Win32_Security",
"Win32_System_Threading",
"Win32_UI_WindowsAndMessaging",
]
I don't know how to resolve this errror.

It looks like you copied this code from https://hacks.mozilla.org/2024/04/porting-a-cross-platform-gui-application-to-rust/. The article is describing the ui! macro as something they wrote, not part of Rust or windows. If you want to use it, you'll have to find it and import it too.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.