microsoft/windows-app-rs

Can't use `implement` macro for `Application`

ZoeyR opened this issue · 3 comments

ZoeyR commented

Problem

I am trying to use the implement macro to implement a subclass of Microsoft::UI::Xaml::Application. It produces a build error

error[E0599]: no function or associated item named `new` found for struct `windows_app::Microsoft::UI::Xaml::IApplication_Vtbl` in the current scope
error[E0599]: no function or associated item named `matches` found for struct `windows_app::Microsoft::UI::Xaml::IApplication_Vtbl` in the current scope

I think this is dependent on #37, which ran into a few snags. @riverar

Sorry to keep you waiting, missed this issue.

Earlier versions of the windows-app crate didn't emit the implement feature (or bring in the upstream windows implement feature). #37 does but I'll pull that out and merge it separately today. Standby.

@ZoeyR Give that a spin. Let me know if you run into any other issues. There's a new sample too that may be helpful.

#[implement(IApplicationOverrides)]
struct App {
_window: RefCell<Option<Window>>,
}
#[allow(non_snake_case)]
impl App {
fn new() -> windows::core::Result<App> {
let app = App {
_window: RefCell::new(None),
};
Ok(app)
}
}
impl IApplicationOverrides_Impl for App {
fn OnLaunched(&self, _: &Option<LaunchActivatedEventArgs>) -> windows::core::Result<()> {
let window = Window::new()?;
window.SetTitle("WinUI 3 Desktop, Unpackaged (Rust)")?;