Moving an application to foreground / to background
1. Being notified of the focus change
Override HandleForegroundEventL() function In AppUi Class Like
void CMyAppUi::HandleForegroundEventL(TBool aForeground)
{
// Call Base class method
CAknAppUi::HandleForegroundEventL(aForeground);
if(aForeground)
{
// We have gained the focus
...
}
else
{
// We have lost the focus
...
}
}
2. Bring Application To ForeGround
void CMyAppUi::BringToForeground()
{
// Construct en empty TApaTask object
// giving it a reference to the Window Server session
TApaTask task(iEikonEnv->WsSession( ));
// Initialise the object with the window group id of
// our application (so that it represent our app)
task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
// Request window server to bring our application
// to foreground
task.BringToForeground();
}
3. Send Application To BackGround
void CMyAppUi::BringToForeground()
{
// Construct en empty TApaTask object
// giving it a reference to the Window Server session
TApaTask task(iEikonEnv->WsSession( ));
// Initialise the object with the window group id of
// our application (so that it represent our app)
task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
// Request window server to Snedour application
// to BackGround
task.SendToBackground();
}
Other Method If you want to Send or Bring Focus to Other Application
TApaTaskList tasklist(iCoeEnv->WsSession());
TApaTask task(tasklist.FindApp(_L("TestApp")));
task.SendToBackground(); // or BringToForeground()
Library: apgrfx.lib
Wednesday, March 14, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment