我正在研究一个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!
发布评论
评论(1)
你不能,因为没有。
屏幕上的所有XAML控件最终都由属于父窗口的单个HWND支持,即单个控件在Win UI中没有自己的手柄。
只有一个顶级手柄,并且控件在此HWND中被渲染为内容。
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.