﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-塞班岛-随笔分类-C/C++</title><link>http://www.cppblog.com/siwei/category/7607.html</link><description>siwei的S60之旅</description><language>zh-cn</language><lastBuildDate>Tue, 20 Apr 2010 22:55:45 GMT</lastBuildDate><pubDate>Tue, 20 Apr 2010 22:55:45 GMT</pubDate><ttl>60</ttl><item><title>判断PenInput界面是否打开</title><link>http://www.cppblog.com/siwei/archive/2010/04/19/112991.html</link><dc:creator>siwei</dc:creator><author>siwei</author><pubDate>Mon, 19 Apr 2010 07:18:00 GMT</pubDate><guid>http://www.cppblog.com/siwei/archive/2010/04/19/112991.html</guid><wfw:comment>http://www.cppblog.com/siwei/comments/112991.html</wfw:comment><comments>http://www.cppblog.com/siwei/archive/2010/04/19/112991.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/siwei/comments/commentRss/112991.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/siwei/services/trackbacks/112991.html</trackback:ping><description><![CDATA[<img style="width: 205px; height: 211px;"  src="http://www.cppblog.com/images/cppblog_com/siwei/20_200906051342481CGYd.jpg" border="0"><br><br>包含头文件<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">peninputsrveventhandler.h</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">peninputclient.h</span><span style="color: #000000;">&gt;</span></div>
<br>定义变量<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RPeninputServer&nbsp;iPeninputServer;</span></div>
<br>这里一个比较搞笑的地方在于RPeninputServer这个类竟然是定义在peninputclient.h中的。<br>为什么一个服务器要定义在名叫client的文件中啊搞不懂。<br><br>将MPenUiActivationHandler子类化，并且重写函数<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">:&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;from&nbsp;MPenUiActivationHandler</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">/*</span><span style="color: #008000;">*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@see&nbsp;MPenUiActivationHandler<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">*/</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;OnPeninputUiDeactivated();<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">/*</span><span style="color: #008000;">*<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@see&nbsp;MPenUiActivationHandler<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">*/</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;OnPeninputUiActivated();</span></div>
<br>构造的时候连接服务器并且注册回调类<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(&nbsp;AknLayoutUtils::PenEnabled()&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User::LeaveIfError(&nbsp;iPeninputServer.Connect()&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iPeninputServer.AddPenUiActivationHandler(&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">,&nbsp;EPluginInputModeAll&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div>
<br>使用AknLayoutUtils::PenEnabled()判断是否为触摸屏手机是必要的。<br><br>别忘了在析构时候关闭服务器<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;iPeninputServer.RemovePenUiActivationHandler();<br>&nbsp;&nbsp;&nbsp;&nbsp;iPeninputServer.Close();</span></div>
<br>最后就是要加入<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">LIBRARY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;peninputClient.lib</span></div>
<br>我最初以为只需要从一个M类继承并且实现相关函数就可以了，谁知道还需要连接一个Peninput Server。感觉这样做并不好，第一名字混淆了，就是刚才说的那个问题；第二就是一旦其他程序操作不当或者server本身挂掉了，所有功能也就都失效了；最后一点，也是Symbian特色了，用一个功能就要加入一大堆头文件用一大堆API，程序搭积木似的就会越来越臃肿。<br><img src ="http://www.cppblog.com/siwei/aggbug/112991.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/siwei/" target="_blank">siwei</a> 2010-04-19 15:18 <a href="http://www.cppblog.com/siwei/archive/2010/04/19/112991.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>