软件工程

本类阅读TOP10

·PHP4 + MYSQL + APACHE 在 WIN 系统下的安装、配置
·Linux 入门常用命令(1)
·Linux 入门常用命令(2)
·使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
·DirectShow学习(八): CBaseRender类及相应Pin类的源代码分析
·基于ICE方式SIP信令穿透Symmetric NAT技术研究
·Windows 2003网络负载均衡的实现
·一网打尽Win十四种系统故障解决方法
·数百种 Windows 软件的免费替代品列表
·收藏---行百里半九十

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
将你的程序带到前台或后台

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

这篇文章将向你展示如何在你的程序得到或失去屏幕焦点的时候控制它们和怎样控制它们。

在焦点改变的时候开始。Series 60系列的框架将在程序得到或失去屏幕焦点的时候通过CAknAppUi::HandleForegroundEventL(TBool aForeground)发出通知。当你的程序得到焦点的时候参数aForeground为ETrue,失去焦点的时候为EFalse。

如果你需要做一些特定的操作,你需要重载这个函数。这有一个不失去焦点的例子
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
...
}
}


改变焦点。你总是能够请求改变你程序的焦点使用命令TApaTask::SendToBackground() and TApaTask::BringToForeground()。下面代码片段显示怎样从AppUi使用它们:
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();
}

我没有测试下面的代码,但你可能可以使用下面的代码控制其他的程序:

// Bring the application "theApp" to background
TApaTaskList tasklist(iCoeEnv->WsSession());
TApaTask task(tasklist.FindApp(_L("theApp")));
task.SendToBackground(); // or BringToForeground()



相关文章

相关软件