gpt4 book ai didi

wpf - 使用 Windows.Forms.Cursor 作为 WPF 光标?

转载 作者:行者123 更新时间:2023-12-02 22:02:14 27 4
gpt4 key购买 nike

我有一个 System.Windows.Forms.Cursor,想将其分配给 WPF 的 image.Cursor 属性,该属性恰好是 System.Windows.Input.Cursor 类型。这里的约束是,前一个 Cursor 类型是由我们的框架返回的,我无法修改它。有没有办法将前者转换为后者?

最佳答案

这对我有用:

SafeFileHandle panHandle = new SafeFileHandle(System.Windows.Forms.Cursors.PanNorth.Handle, false);
this.Cursor = System.Windows.Interop.CursorInteropHelper.Create(panHandle);

SafeFileHandle 的文档警告不要对第二个参数使用 false,但无论我使用 true (即使我使用 Cursors.PanNorth.CopyHandle()),我都会得到 SEHExceptions

关于wpf - 使用 Windows.Forms.Cursor 作为 WPF 光标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6991023/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com