2013-04-22 85 views

回答

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 
    } 
}