博客园丁

我是博客园的一丁,我会永不停顿,不停创新。
posts - 99, comments - 119, trackbacks - 21, articles - 22
   :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理


当在系统设置中设置了“实时监控”,此时手机画面的指示面板上应该出现一个图标,表明有程序在后台运行。
本文就是探讨怎样在S60指示面板上画图标。为了在电源面板附近显示图标,你必须要作相应的编码。

我写了一个CIndicatorIcon的类,它继承自CCoeControl。
二次构造函数ConstructL()代码如下:

void CIndicatorIcon::ConstructL()
        {
        iMyWindowGroup 
= RWindowGroup(iCoeEnv->WsSession());
        User::LeaveIfError(iMyWindowGroup.Construct((TUint32)
&iMyWindowGroup));

        iMyWindowGroup.SetOrdinalPosition(
0, ECoeWinPriorityAlwaysAtFront);
        iMyWindowGroup.EnableReceiptOfFocus(EFalse);

        CreateWindowL(
&iMyWindowGroup);

        
// by default setting the indicator icon to inactive
        SetIndicatorIconL(EIndicatorIconAppActive);

        ActivateL();
        }

注意,RWindowGroup需要W32std.h头文件,连接时需要添加Ws32.lib。
在构造函数中,调用另外一个函数SetIndicatorIconL()来设置图标:


void CIndicatorIcon::SetIndicatorIconL(TIndicatorIcon aIndicatorIconType, TBool aRedraw)
        {
        
switch(aIndicatorIconType)
                {
                
case EIndicatorIconEmpty:
                        iIndicator 
= CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_empty);
                        iIndicatorMask 
= CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_empty_mask);
                        
break;

                
case EIndicatorIconAppActive:
                        iIndicator 
= CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_bt_connect_on);
                        iIndicatorMask 
= CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_bt_connect_on_mask);
                        
break;

                
case EIndicatorIconAppInactive:
                        iIndicator 
= CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_bt_audio);
                        iIndicatorMask 
= CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_bt_audio_mask);
                        
break;

                
default:
                        
break;
                }

        SetRect(TRect(TPoint(KIndicatorPosX, KIndicatorPosY),iIndicator
->SizeInPixels()));
        
        
// if aRedraw == ETrue just draw the canvas again.
        if(aRedraw)
                {
                DrawNow();
                }
        }

上面把指示面板需要显示的图标设置好了,但是必须要重载CCoeControl的Draw()函数来显示这个图标,Draw()代码如下:

void CIndicatorIcon::Draw(const TRect& aRect) const
        {
        CWindowGc
& gc = SystemGc();

        gc.Clear();
        gc.SetBrushStyle(CGraphicsContext::ENullBrush);
        gc.BitBltMasked(TPoint(aRect.iTl.iX, aRect.iTl.iY), 
                iIndicator, 
                TRect(TPoint(
00), iIndicator->SizeInPixels()), 
                iIndicatorMask, 
                ETrue);
        }

最后在AppUi类的构造函数中添加如下两行代码:
        iIndicatorIcon = CIndicatorIcon::NewL();
        // The next line will set the icon to draw and it'll draw to the screen.
        iIndicatorIcon->SetIndicatorIconL(CIndicatorIcon::EIndicatorIconAppInactive, ETrue);

效果图如下:

 

(JPEG)
Indicator icon when application is running in the foreground.

 
(JPEG)
Indicator icon when application is running in the background..

(JPEG)
Indicator icon when application is running in the background with the task view..

你可以在这里下载示例程序的源代码:
Zip - 66.1 kb

Sample code for showing icon on the IndicatorPane

Feedback

#1楼    回复  引用    

2006-12-30 06:01 by li[匿名] [未注册用户]
cheap dofus kamas from www.dofus.us
[url=http://www.dofus.us]dofus[/url]
<a href="http://www.dofus.us">dofus</a>

cheap mesos from www.maple-story.org
[url=http://www.maple-story.org]maple story[/url]
<a href="http://www.maple-story.org">maple story</a>

cheapest gaia gold on sale www.gaiaonline.in
[url=http://www.gaiaonline.in/]Gaia Online Gold[/url];
<a href="http://www.gaiaonline.in/">Gaia Online Gold</a>

#2楼    回复  引用    

2006-12-30 11:32 by ivan[匿名] [未注册用户]
支持,虽然我不懂手机编程.

#3楼    回复  引用    

2007-02-27 06:55 by hh [未注册用户]



<marquee><img src=http://pic.xiaonei.com/pic001/20070219/1550/large1177818.jpg
width=500 height=350><br><font color=0000ff size=4 face=华文行楷><b>幻想情侣,让你的另一半在这个冬天出现~.~</b></font></marquee> <TABLE style="FILTER: glow(color:#FF00FF,direction=2)">被幸福平静的包围时

一些平凡的爱意

总被渴望激情和浪漫的心忽略

爱!在双方引起的许多个微不足道的动作里,

从来就没有固定的模式

只有爱

可以是任何一中平淡无奇的形式

花朵、浪漫

不过是浮在生活表面的浅浅点缀

在它们的下面才是我们真真的生活 </table>
<body background="http://www.ln2.cn/UploadFiles/2006-11/1116598226.jpg"bgproperties="fixed"><style type="text/css"><!--#homepage{color : #ffffff;cursor : url(http://eed.xmu.edu.cn/myfile/zidou/ani/458.cur);}#header{display : none;}#userFriend{display : none;}#userFriendUniv{display : none;}#PersonalInfo{display : none;}#userEvent{display : block;}#userAlbum{display : block;}#userBlog{display : block;}#userPandora{display : block;}#userGroup{display : none;}#footer{display : none;}#homepage a:link{color : #ff99cc;}#sidebar .block{display : none;}--></style><style type=text/css><!--#userProfile{width:540px; position:relative; left:-145px; } --></style><!-移动个人资料->
<style type=text/css><!--#userAlbum{width:540px; position:relative; left:-145px; } --></style><!-移动相册->
<style type=text/css><!--#userBlog{width:540px; position:relative; left:-145px; } --></style><!-移动日志->
<style type=text/css><!--#content #userPandora {overflow:visible; width:750px; position:relative; left:-355px; } --></style><!-移动涂鸦板->
<style type=text/css><!--#content{overflow:visible; width:750px; position:relative; left:-150px; } --></style><!-移动content->
<style type=text/css><!--#homepage{overflow:visible; overflow:visible; width:750px; position:relative; left:270px; } --></style><!-移动homepage->
<style type=text/css><!--#sidebar {z-index:1; width:130px; position:absolute;; left:480px; top:50px;}#sidebar li{border:0px; }#sidebar li a{border:solid;border:1px; border-color: #999999;} #sidebar li{margin:0;padding-top:10px; } --></style><!--左侧导航栏-->
<embed style="position: absolute;top: 50px; left: -145px;" align="right" src="http://eed.xmu.edu.cn/myfile/zidou/flash/37.swf"width="1000" height="500" quality="high" wmode="transparent"></embed><embed style="position: absolute;top: -700px; left: -145px;" align="right" src="http://eed.xmu.edu.cn/myfile/zidou/flash/54.swf"width="1000" height="500" quality="high" wmode="transparent"></embed><embed style="position: absolute;top: -700px; left: -145px;" align="right" src="http://eed.xmu.edu.cn/myfile/zidou/flash/69.swf"width="1000" height="500" quality="high" wmode="transparent"></embed>


</div>
</div>

#4楼    回复  引用    

2007-06-13 10:32 by 为了学习 [未注册用户]
你好啊 能把你上面的 怎样在S60指示面板上画图标,原代码+示意图 的全部代码 整成ZIP 文件 可以下载吗

#5楼    回复  引用    

2008-03-18 10:49 by EagleLin [未注册用户]
你写的方法是可以把图画上去,但图如果不是正规形状,它就必定会有一个白色的正规形状的背景边框,请问是否有试过被背后的背景框弄成透明色

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接: