如何在c++中的winui3中获取一个控件?

发布于 2025-01-27 15:47:50 字数 661 浏览 3 评论 0 原文

我正在研究一个C ++ Winui3项目,并遇到了这个问题。如何获得XAML网格的手柄?

QT中这样的事情可以实现:

HWND m_hwnd;

m_hwnd =(hwnd)(ui.label-> winid());

但是我在winui3中找不到类似的东西。 我在Internet上查找,但只找到C#中的解决方案:

get-a-controls handle in-xaml

,Microsoft提供了此功能,但它仅用于窗口句柄,而不是XAML控件。

有人可以帮我吗?任何建议都会很棒!

I am working on a C++ WinUI3 project and got this problem. How do I obtain the handle of a XAML grid?

Something like this in QT can achieve it:

HWND m_hWnd;

m_hWnd = (HWND)(ui.label->winId());

But I couldn't find the similar thing in WinUI3.
I look up on the Internet, but only find this solution which is in C#:

Get-a-controls-handle-in-XAML

And the Microsoft provide this, but it is only working for window handle, not XAML controls.

Retrieve a window handle (HWND)

Could anyone help me with it? Any suggestions will be great!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2025-02-03 15:47:50

如何获得XAML网格的手柄?

你不能,因为没有。

屏幕上的所有XAML控件最终都由属于父窗口的单个HWND支持,即单个控件在Win UI中没有自己的手柄。

只有一个顶级手柄,并且控件在此HWND中被渲染为内容。

How do I obtain the handle of a XAML grid?

You can't because there is none.

All XAML controls on the screen are ultimately backed by a single HWND that belongs to the parent window, i.e. an individual control doesn't have its own handle in Win UI.

There is only a single top-level handle and the controls are rendered as content inside this HWND.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文