如何在wp8上长按windows键时处理事件

时间:2013-04-22 02:03:36

标签: windows-phone-8

我使用的是纯粹的cpp。

长按Windows键时,会出现语音助手,但d3d线程不会暂停。 对于我的应用程序是一个游戏,我想在语音助手出现时暂停游戏,我找不到它的api。

1 个答案:

答案 0 :(得分:1)

我在Win8官方演示中找到了代码,它适用于Wp8。

<强>伪代码

CoreApplicationView->Activated += OnActivated;

void OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
{
    CoreWindow::GetForCurrentThread()->Activated += OnWindowActivationChanged;
}

void OnWindowActivationChanged
(Windows::UI::Core::CoreWindow^,Windows::UI::Core::WindowActivatedEventArgs^ args)
{
    CoreWindowActivationState newState = args->WindowActivationState;
    if (newState == CoreWindowActivationState::Deactivated)
    {
        DEACTIVATE code
    }
    else if (newState == CoreWindowActivationState::CodeActivated
    || newState == CoreWindowActivationState::PointerActivated)
    {
        ACTIVATE code
    }
}