【发布时间】:2021-10-19 05:20:52
【问题描述】:
我想在我的 DX12 UWP C++/CX 应用程序中隐藏鼠标光标:
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
这会在我使用触摸板/鼠标移动光标后隐藏光标。在此之前它不会隐藏光标。之后我还尝试了其他设置光标位置的建议:
CoreWindow::GetForCurrentThread()->PointerPosition = Point(0, 0);
这没有效果。
我看过的所有地方都说将指针设置为 null 可以解决问题,但事实并非如此。我错过了什么?这感觉像是一个错误。
提前致谢。
编辑:
尝试了以下方法:
SetWindow
OnActivated
Run
编辑 2:
auto applicationView = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
while (!applicationView->TryEnterFullScreenMode()) {
Sleep(10);
}
auto coreWindow = CoreWindow::GetForCurrentThread();
coreWindow->PointerPosition = Point(coreWindow->Bounds.Width / 2, coreWindow->Bounds.Height / 2);
coreWindow->PointerCursor = nullptr;
uiThreadDispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([]() {
auto coreWindow = CoreWindow::GetForCurrentThread();
coreWindow->PointerPosition = Point(coreWindow->Bounds.Width / 2, coreWindow->Bounds.Height / 2);
coreWindow->PointerCursor = nullptr;
}));
已经发生了,光标在应用启动时偶尔消失,但这是不可重复的。无论何时何地调用这些方法,唯一保证让光标消失的方法是当我用鼠标或触摸板移动光标时。
【问题讨论】:
标签: uwp c++-cx directx-12