Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when implementing a COM interface #3156

Closed
leexgone opened this issue Jul 10, 2024 · 3 comments
Closed

Error when implementing a COM interface #3156

leexgone opened this issue Jul 10, 2024 · 3 comments
Labels
question Further information is requested

Comments

@leexgone
Copy link

Summary

#[implement] can't work after updated from windows 0.57.0 to windwos 0.58.0.

error[E0277]: the trait bound `MyEvent_Impl: IUIAutomationEventHandler_Impl` is not satisfied
    --> src/main.rs:24:1
     |
24   | #[implement(IUIAutomationEventHandler)]
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IUIAutomationEventHandler_Impl` is not implemented for `MyEvent_Impl`
     |
     = help: the trait `IUIAutomationEventHandler_Impl` is implemented for `MyEvent`
note: required by a bound in `IUIAutomationEventHandler_Vtbl::new`
    --> C:\Users\leexg\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-0.58.0\src\Windows\Win32\UI\Accessibility\impl.rs:7477:19
     |
7475 |     pub const fn new<Identity: windows_core::IUnknownImpl, const OFFSET: isize>() -> IUIAutomationEventHandler_Vtbl
     |                  --- required by a bound in this associated function
7476 |     where
7477 |         Identity: IUIAutomationEventHandler_Impl,
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `IUIAutomationEventHandler_Vtbl::new`
     = note: this error originates in the attribute macro `implement` (in Nightly builds, run with -Z macro-backtrace for more info)

Crate manifest

[package]
name = "impl_test"
version = "0.1.0"
edition = "2021"

[dependencies.windows]
version = "0.58.0"
features = [
    "implement",
    "Win32_System_Com",
    "Win32_UI_Accessibility",
    "Win32_System_Ole",
    "UI_UIAutomation",
]

[dependencies.windows-core]
version = "0.58.0"

Crate code

use windows::core::implement;
use windows::core::Result;
use windows::Win32::System::Com::CoCreateInstance;
use windows::Win32::System::Com::CoInitializeEx;
use windows::Win32::System::Com::CLSCTX_ALL;
use windows::Win32::System::Com::COINIT_MULTITHREADED;
use windows::Win32::UI::Accessibility::CUIAutomation;
use windows::Win32::UI::Accessibility::IUIAutomation;
use windows::Win32::UI::Accessibility::IUIAutomationEventHandler;
use windows::Win32::UI::Accessibility::IUIAutomationEventHandler_Impl;

fn main() -> Result<()> {
    unsafe {
        CoInitializeEx(None, COINIT_MULTITHREADED).ok()?;

        let auto: IUIAutomation = CoCreateInstance(&CUIAutomation, None, CLSCTX_ALL)?;

        // let handler: IUIAutomationEventHandler

        Ok(())
    }
}

#[implement(IUIAutomationEventHandler)]
pub struct MyEvent();

impl IUIAutomationEventHandler_Impl for MyEvent {
    fn HandleAutomationEvent(&self,sender:Option<&windows::Win32::UI::Accessibility::IUIAutomationElement>,eventid:windows::Win32::UI::Accessibility::UIA_EVENT_ID) -> windows::core::Result<()> {
        todo!()
    }
}
@leexgone leexgone added the bug Something isn't working label Jul 10, 2024
@kennykerr
Copy link
Collaborator

This is a necessary breaking change introduced in #3065 - the fix is fortunately simple enough.

@kennykerr kennykerr added question Further information is requested and removed bug Something isn't working labels Jul 10, 2024
@Zerowalker
Copy link

Do you actually need to add the windows-core dependency now along with windows?

@leexgone
Copy link
Author

leexgone commented Jul 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants