如何得到其他程序焦点变化和启动的通知

来源:互联网 发布:java和嵌入式 编辑:程序博客网 时间:2024/06/05 19:36

Getting notifications of focus change and launching of other applications


From Forum Nokia Wiki

 

Description
Sometimes applications need to get notifications about the change of the application in focus or launching of another application.

 


Solution


The notifications can be enabled using the following code:

 

In the constructL of the AppUi, add the following lines:

 iCoeEnv->RootWin().EnableFocusChangeEvents();
 //To get notifications about Focus change events
 iCoeEnv->RootWin().EnableGroupChangeEvents();
 //To get notifications about launching of other applications

 

After these functions are called, the events are delivered to the window server every time the particular event occurs. The code to handle the notifications is as follows:

 

 void CMyAppUi::HandleWsEventL( const TWsEvent& aEvent, 
                                CCoeControl* aDestination )
     {
     if(aEvent.Type() == EEventFocusGroupChanged)
         {
         //Focus change event
         //Handling to be done here
         }
     else if(aEvent.Type() ==  EEventWindowGroupsChanged)
         {
         //Group change event (launching of other applications)
         //Handling to be done here
         }
     CAknAppUi::HandleWsEventL(aEvent,aDestination);
     }

原创粉丝点击