<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-11847577</id><updated>2025-08-29T18:16:18.216+01:00</updated><category term="SQL Compact"/><category term="OLE DB"/><category term="User Interface"/><category term="Windows Mobile"/><category term="WTL"/><category term="Products"/><category term="Bluetooth"/><category term="GDI"/><category term="GPS"/><category term="HOWTO"/><category term="ATL"/><category term="Shell"/><category term="Visual Studio"/><category term="Accelerometer"/><category term="Article"/><category term="GDI+"/><category term="Gestures"/><category term="MAPI"/><category term="MSDN Magazine"/><category term="Menu"/><category term="Off topic"/><category term="Tech Ed"/><category term="XML"/><title type='text'>Native Mobile</title><subtitle type='html'>Thoughts on native mobile development on Microsoft platforms</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default?alt=atom'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default?alt=atom&amp;start-index=26&amp;max-results=25'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>342</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-11847577.post-6562230356376519610</id><published>2016-08-26T17:13:00.001+01:00</published><updated>2016-08-26T17:13:23.302+01:00</updated><title type='text'>New blog</title><content type='html'>You can follow my data science learning rambles on&amp;nbsp;&lt;a href=&quot;https://sagaceco.blogspot.com/&quot; target=&quot;_blank&quot;&gt;my new blog&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/6562230356376519610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/6562230356376519610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6562230356376519610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6562230356376519610'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2016/08/new-blog.html' title='New blog'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-4759028230601276450</id><published>2010-04-28T13:57:00.004+01:00</published><updated>2010-04-28T15:07:21.958+01:00</updated><title type='text'>New blog</title><content type='html'>I am moving all my blogging activity to a new roof, where I will discuss more than just native code on mobile devices. Please follow me on the &lt;a href=&quot;http://smilingsmith.blogspot.com/&quot;&gt;Smiling Smith&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/4759028230601276450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/4759028230601276450' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/4759028230601276450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/4759028230601276450'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/04/new-blog.html' title='New blog'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-3827757788069315123</id><published>2010-02-17T09:32:00.002+00:00</published><updated>2010-02-17T09:35:51.664+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Windows Mobile 6.5.3 Developer Tool Kit</title><content type='html'>You can now download the Windows Mobile 6.5.3 Developer Tool Kit from this &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=c0213f68-2e01-4e5c-a8b2-35e081dcf1ca&amp;amp;displaylang=en&quot;&gt;link&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/3827757788069315123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/3827757788069315123' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/3827757788069315123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/3827757788069315123'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/02/windows-mobile-653-developer-tool-kit.html' title='Windows Mobile 6.5.3 Developer Tool Kit'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-6774428860323923020</id><published>2010-02-15T15:29:00.001+00:00</published><updated>2010-02-15T15:31:30.085+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Windows Mobile 7 is here</title><content type='html'>Actually, it&#39;s &quot;Windows Phone 7 Series&quot;. Go have a look at the &lt;a href=&quot;http://windowsteamblog.com/blogs/windowsphone/archive/2010/02/15/windows-phone-7-series-show-and-tell.aspx&quot;&gt;Windows Phone team blog&lt;/a&gt;!</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/6774428860323923020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/6774428860323923020' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6774428860323923020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6774428860323923020'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/02/windows-mobile-7-is-here.html' title='Windows Mobile 7 is here'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-8091772362426234361</id><published>2010-02-04T10:40:00.001+00:00</published><updated>2010-02-04T10:42:04.454+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Gesture magic</title><content type='html'>The February edition of MSDN Magazine is now out with a very interesting and informative article on Windows Mobile 6.5 gestures: &lt;a href=&quot;http://msdn.microsoft.com/en-us/magazine/ee309880.aspx&quot;&gt;Gesture Magic&lt;/a&gt;. A must read, I would say...</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/8091772362426234361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/8091772362426234361' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/8091772362426234361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/8091772362426234361'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/02/gesture-magic.html' title='Gesture magic'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-7297555158630275590</id><published>2010-01-26T09:17:00.003+00:00</published><updated>2010-01-26T09:20:03.939+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Not yet...</title><content type='html'>The Windows Mobile 6.5 SDK I announced was removed due to some issues (apparently it was prematurely uploaded). Here&#39;s the story from &lt;a href=&quot;http://www.theunwired.net/?item=developing-microsoft-releases-windows-mobile-6-5-professional-and-standard-sdks&quot;&gt;the::unwired&lt;/a&gt;. Apparently we will have to wait a bit more before te final version is released.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/7297555158630275590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/7297555158630275590' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/7297555158630275590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/7297555158630275590'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/01/not-yet.html' title='Not yet...'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-3344116739303027105</id><published>2010-01-24T13:28:00.002+00:00</published><updated>2010-01-24T13:29:12.567+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Windows Mobile 6.5.3 SDK</title><content type='html'>The new Windows Mobile 6.5.3 SDK is now available for download &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=c5241738-0fe6-4396-a4e5-5a516deb1bc5&amp;amp;displayLang=en&quot;&gt;here&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/3344116739303027105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/3344116739303027105' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/3344116739303027105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/3344116739303027105'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/01/windows-mobile-653-sdk.html' title='Windows Mobile 6.5.3 SDK'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-1436684288134439544</id><published>2010-01-14T09:22:00.003+00:00</published><updated>2010-01-14T09:25:02.437+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>New development certificates</title><content type='html'>Here I am, back from the December hibernation (not a vacation) with a renewed MVP award. Thank you for that, Microsoft!&lt;br /&gt;&lt;br /&gt;It&#39;s time to get this blog rolling again, so here&#39;s a heads up for you:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://windowsteamblog.com/blogs/wmdev/archive/2010/01/12/new-windows-mobile-developer-certificates.aspx&quot;&gt;New Windows Mobile development certificates&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/1436684288134439544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/1436684288134439544' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1436684288134439544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1436684288134439544'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2010/01/new-development-certificates.html' title='New development certificates'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-1224889243496921765</id><published>2009-12-06T23:12:00.005+00:00</published><updated>2009-12-11T11:50:44.085+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>An alternative way to create the menu bar</title><content type='html'>I don&#39;t like resources. I really don&#39;t. I can understand their usefulness for features such as string tables or embedded icons, but when it comes to the Windows Mobile menu bar definition, I just hate the whole thing. Take a good look at how the CrypSafe sample app&#39;s menu bar is defined:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;ATL_IDW_MENU_BAR SHMENUBAR DISCARDABLE&lt;br /&gt;BEGIN&lt;br /&gt;IDR_MAINFRAME,&lt;br /&gt;2,&lt;br /&gt;I_IMAGENONE, ID_ACTION, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE,&lt;br /&gt;ID_ACTION, 0, NOMENU,&lt;br /&gt;I_IMAGENONE, ID_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN  TBSTYLE_AUTOSIZE,&lt;br /&gt;ID_MENU, 0, 0,&lt;br /&gt;END&lt;br /&gt;&lt;/pre&gt;Intuitive, right? Incidentally, this resource is defined in the .rc2 file and the &lt;span style=&quot;font-family:courier new;&quot;&gt;ATL_IDW_MENU_BAR&lt;/span&gt; identifier is used as a default parameter of the &lt;span style=&quot;font-family:courier new;&quot;&gt;CreateSimpleCEMenuBar&lt;/span&gt; method of the &lt;span style=&quot;font-family:courier new;&quot;&gt;CFrameWindowImplBase&lt;/span&gt; class template. So what do you have to do in order to change the menu bar? Gasp!&lt;br /&gt;&lt;br /&gt;There is a better way, fortunately. A way that you can encapsulate and that makes the whole process a bit more transparent.&lt;br /&gt;&lt;br /&gt;You create a Windows Mobile menu bar by calling the &lt;a style=&quot;FONT-FAMILY: courier new&quot; href=&quot;http://msdn.microsoft.com/en-us/library/aa453678.aspx&quot;&gt;SHCreateMenuBar&lt;/a&gt; API typically from your main window&#39;s &lt;span style=&quot;font-family:courier new;&quot;&gt;WM_CREATE&lt;/span&gt; handler. As you can see the function takes a single parameter, a pointer to a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa453721.aspx&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;SHMENUBARINFO&lt;/span&gt;&lt;/a&gt; structure where you define the menu bar. There are two ways to create a menu bar: you either specify a menu bar resource ID or you provide your own &lt;span style=&quot;font-family:courier new;&quot;&gt;HMENU&lt;/span&gt; by specifying the &lt;span style=&quot;font-family:courier new;&quot;&gt;SHCMBF_HMENU&lt;/span&gt; flag. This is in fact a much more palatable alternative because you can declaratively create your menu bar in a single location of your application&#39;s code. Using my beloved WTL, here&#39;s how the code would look like on the main frame&#39;s OnCreate handler:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;if(m_mainMenu.CreateMenu())&lt;br /&gt;{&lt;br /&gt;  m_mainMenu.AppendMenu(MF_BYCOMMAND  MF_ENABLED  MF_STRING,&lt;br /&gt;                        ID_BACK, _T(&quot;Back&quot;));&lt;br /&gt;  m_mainMenu.AppendMenu(MF_BYCOMMAND  MF_ENABLED  MF_STRING,&lt;br /&gt;                        ID_MENU, _T(&quot;Menu&quot;));&lt;br /&gt;&lt;br /&gt;  SHMENUBARINFO mbi = { 0 };&lt;br /&gt;  mbi.cbSize        = sizeof(mbi);&lt;br /&gt;  mbi.hwndParent    = m_hWnd;&lt;br /&gt;  mbi.dwFlags       = SHCMBF_HMENU;&lt;br /&gt;  mbi.nToolBarId    = (UINT)(HMENU)m_mainMenu;&lt;br /&gt;  mbi.hInstRes      = ModuleHelper::GetResourceInstance();&lt;br /&gt;  mbi.nBmpId        = 0;&lt;br /&gt;  mbi.cBmpImages    = 0;&lt;br /&gt;  mbi.hwndMB        = NULL;&lt;br /&gt;&lt;br /&gt;  BOOL bRet = ::SHCreateMenuBar(&amp;amp;mbi);&lt;br /&gt;  if(bRet != FALSE)&lt;br /&gt;  {&lt;br /&gt;      m_hWndCECommandBar = mbi.hwndMB;&lt;br /&gt;      SizeToMenuBar();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;The &lt;span style=&quot;font-family:courier new;&quot;&gt;m_mainMenu&lt;/span&gt; variable is a &lt;span style=&quot;font-family:courier new;&quot;&gt;CMenu&lt;/span&gt;, of course. The advantage of this approach is that you create the main menu bar in a very explicit way and if you later want to change it you know where to find the code, and stop guessing what that crappy &lt;span style=&quot;font-family:courier new;&quot;&gt;SHMENUBAR&lt;/span&gt; resource declaration means...&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:smaller&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=47486&quot; rel=&quot;tag&quot;&gt;CodeProject&lt;/a&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/1224889243496921765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/1224889243496921765' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1224889243496921765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1224889243496921765'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/12/alternative-way-to-create-menu-bar.html' title='An alternative way to create the menu bar'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-1326753523251420919</id><published>2009-12-01T19:33:00.003+00:00</published><updated>2009-12-01T21:45:46.256+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>A simple header button</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwFIUiSCTZZXC2JR8O8vPFgwm719tlJ0XgbwNc83KZaaZ7-oJYJjyzhjgm29fca6A1Mr6D2JykgMIZ5cGBmmYGOqCGkMn5vsjAgMgzgjY0PRDJ50lBZdK7n4qUqnGYd5hrXZHddQ/s1600/HeaderButton.png&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 240px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwFIUiSCTZZXC2JR8O8vPFgwm719tlJ0XgbwNc83KZaaZ7-oJYJjyzhjgm29fca6A1Mr6D2JykgMIZ5cGBmmYGOqCGkMn5vsjAgMgzgjY0PRDJ50lBZdK7n4qUqnGYd5hrXZHddQ/s320/HeaderButton.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5410353285042314530&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;Now that we have a header for the application, what about adding some useful stuff to it, like buttons? The picture on the left shows the second version of the touch header in action with a &quot;back&quot; button that implements the same functionality as the menu bar&#39;s &quot;Back&quot; menu. This button should only be visible when there is somewhere to go back to, so we should be able to add it and remove it as we please.&lt;br /&gt;&lt;br /&gt;For now, the header button is a very simple object containing up to 3 &lt;span style=&quot;font-family: courier new;&quot;&gt;CImage&lt;/span&gt; objects (for the normal, depressed and disabled states). This is not a regular Windows button but instead a &quot;sensitive area&quot; of the header that just behaves like a button (just like what happens with regular toolbars).&lt;br /&gt;&lt;br /&gt;The button itself is implemented in the &lt;span style=&quot;font-family: courier new;&quot;&gt;CTouchToolbarItem&lt;/span&gt; class (see sample code below). It derives from &lt;span style=&quot;font-family: courier new;&quot;&gt;CRefCount&lt;/span&gt; so you can use the &lt;span style=&quot;font-family: courier new;&quot;&gt;CRefPtr&lt;/span&gt; smart pointer class template to manage it and forget about deleting... The class contains three &lt;span style=&quot;font-family: courier new;&quot;&gt;CImage&lt;/span&gt; instances, one for each possible state (these will later be changed to smart pointers as well in order to allow for better reuse).&lt;br /&gt;&lt;br /&gt;Buttons are set through the virtual &lt;span style=&quot;font-family: courier new;&quot;&gt;SetupTouchHeader&lt;/span&gt; method in each of the child views. Instead of just setting the header text, you can now set up to two buttons (left with index zero and right with index one). The button activation messaging is very similar to a regular menu: the &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_COMMAND&lt;/span&gt; message is sent to the parent window (the main frame) with the command ID as the &lt;span style=&quot;font-family: courier new;&quot;&gt;wParam&lt;/span&gt; parameter.&lt;br /&gt;&lt;br /&gt;A final thought: the header belongs to the frame window and is set up by the child view when they are shown. Is this a good design? I&#39;m wondering if these should &quot;belong&quot; to the child view instead and be replaced along with it, possibly with some fancy animation. What do you think?&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/CrypSafe08.zip&quot;&gt;CrypSafe08.zip&lt;/a&gt; (406 KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/1326753523251420919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/1326753523251420919' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1326753523251420919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1326753523251420919'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/12/simple-header-button.html' title='A simple header button'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwFIUiSCTZZXC2JR8O8vPFgwm719tlJ0XgbwNc83KZaaZ7-oJYJjyzhjgm29fca6A1Mr6D2JykgMIZ5cGBmmYGOqCGkMn5vsjAgMgzgjY0PRDJ50lBZdK7n4qUqnGYd5hrXZHddQ/s72-c/HeaderButton.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-8063748251467871362</id><published>2009-11-15T12:07:00.004+00:00</published><updated>2009-11-15T12:31:16.708+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>A basic header</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdrscOhc5FwQIfrvBPpd2-UsU7B43rYZcK91mGz4rNvpnIpZZ4GT0ofvI2hM-s2nLXsxDPgWV_HSgnCre4qHDVnYPRT4NNvShGCO6U4TlwbZdTDu04c5gLBOO7C5eNRmcbQoUZJw/s1600-h/TouchHeader.png&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 240px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdrscOhc5FwQIfrvBPpd2-UsU7B43rYZcK91mGz4rNvpnIpZZ4GT0ofvI2hM-s2nLXsxDPgWV_HSgnCre4qHDVnYPRT4NNvShGCO6U4TlwbZdTDu04c5gLBOO7C5eNRmcbQoUZJw/s320/TouchHeader.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5404300923082519714&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;In this post I&#39;m adding a very simple header to the CrypSafe sample, as you can see from the picture. Graphically it is a simple gray gradient with some text printed with an embossed look. Despite of the sleek look, the implementation is quite simple, as you can see from reading the &lt;span style=&quot;font-family:courier new;&quot;&gt;CTouchHeader&lt;/span&gt; class source code (see sample source below).&lt;br /&gt;&lt;br /&gt;The header is implemented as a simple WTL header window. The WTL protocol for headers and footers is quite simple: the frame window sends an empty &lt;span style=&quot;font-family:courier new;&quot;&gt;WM_SIZE&lt;/span&gt; message (both width and height are set to zero) to the header and footer signaling these to position themselves in the main frame client rectangle. The remaining space will be occupied by the child view window.&lt;br /&gt;&lt;br /&gt;Implementing this protocol is quite simple: handle the WM_SIZE message and reposition the header at the top of the main frame:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;void CTouchHeader::OnSize(UINT nType, CSize size)&lt;br /&gt;{&lt;br /&gt;   if(size.cx == 0 &amp;amp;&amp;amp; size.cy == 0)&lt;br /&gt;   {&lt;br /&gt;       CWindow wndParent(GetParent());&lt;br /&gt;       CRect   rc;&lt;br /&gt;&lt;br /&gt;       wndParent.GetClientRect(&amp;amp;rc);&lt;br /&gt;       rc.bottom = rc.top + m_cyHeader;&lt;br /&gt;       MoveWindow(&amp;amp;rc);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The &lt;span style=&quot;font-family: courier new;&quot;&gt;m_cyHeader&lt;/span&gt; variable contains the height in pixels of the header. Now, you just need to paint the header with your favorite gradient. Painting the text with the embossed look is also a simple task: you just need to paint it twice in different colors, offsetting the second painting by one or two pixels down. You get the best effect by painting first with a darker color.&lt;br /&gt;&lt;br /&gt;As of this implementation, you don&#39;t get a very smart header control: it just paints the text it is given. However, we can make this text change according to some application context just like when you switch views. In the sample code below, the header is always present between view switches and the &lt;span style=&quot;font-family: courier new;&quot;&gt;CChildViewManager&lt;/span&gt; merely asks each &lt;span style=&quot;font-family: courier new;&quot;&gt;CChildView&lt;/span&gt; that is brought into view to update the header text through the virtual &lt;span style=&quot;font-family: courier new;&quot;&gt;SetupTouchHeader&lt;/span&gt; function.&lt;br /&gt;&lt;br /&gt;Now that this is in place, we can add more features to the header and make it more useful for the whole UI...&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/CrypSafe07.zip&quot;&gt;CrypSafe07.zip&lt;/a&gt; (345 Kb)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/8063748251467871362/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/8063748251467871362' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/8063748251467871362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/8063748251467871362'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/11/basic-header.html' title='A basic header'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdrscOhc5FwQIfrvBPpd2-UsU7B43rYZcK91mGz4rNvpnIpZZ4GT0ofvI2hM-s2nLXsxDPgWV_HSgnCre4qHDVnYPRT4NNvShGCO6U4TlwbZdTDu04c5gLBOO7C5eNRmcbQoUZJw/s72-c/TouchHeader.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-5034872100370029288</id><published>2009-11-06T08:56:00.003+00:00</published><updated>2009-11-06T09:03:08.723+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HOWTO"/><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>HOWTO: Close Application on Minimize</title><content type='html'>This is a popular question lately: how do I close my application when the user clicks the &quot;smart minimize button&quot;? This button does exactly that - it minimizes your application and does not close it. Your main application window is minimized when it receives a &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_SIZE&lt;/span&gt; message with the &lt;span style=&quot;font-family: courier new;&quot;&gt;SIZE_MINIMIZED&lt;/span&gt; constant in the &lt;span style=&quot;font-family: courier new;&quot;&gt;wParam&lt;/span&gt; parameter. All you have to do is call &lt;span style=&quot;font-family: courier new;&quot;&gt;PostMessage(WM_CLOSE)&lt;/span&gt; and you are done. Here&#39;s a sample WTL handler:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;LRESULT CCloseOnMinFrame::OnSize(UINT /*uMsg*/, &lt;br /&gt;                                 WPARAM wParam, &lt;br /&gt;                                 LPARAM /*lParam*/, &lt;br /&gt;                                 BOOL&amp;amp; bHandled)&lt;br /&gt;{&lt;br /&gt;    if(wParam == SIZE_MINIMIZED)&lt;br /&gt;    {&lt;br /&gt;        PostMessage(WM_CLOSE);&lt;br /&gt;        bHandled = TRUE;&lt;br /&gt;        return 0;&lt;br /&gt;    }&lt;br /&gt;    // Not handled here&lt;br /&gt;    bHandled = FALSE;&lt;br /&gt;    return 1;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/5034872100370029288/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/5034872100370029288' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/5034872100370029288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/5034872100370029288'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/11/howto-close-application-on-minimize.html' title='HOWTO: Close Application on Minimize'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-3139679164873249027</id><published>2009-11-01T11:37:00.001+00:00</published><updated>2009-11-01T11:39:39.956+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Article"/><category scheme="http://www.blogger.com/atom/ns#" term="Gestures"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>Article about Windows Mobile 6.5 Gestures</title><content type='html'>There is a new article on &lt;a href=&quot;http://www.codeproject.com/KB/mobile/IntroToGesturesAPI.aspx&quot;&gt;CodeProject&lt;/a&gt; about Windows Mobile 6.5 Gestures, and it&#39;s fully written in native code. Go there and have a look!</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/3139679164873249027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/3139679164873249027' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/3139679164873249027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/3139679164873249027'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/11/article-about-windows-mobile-65.html' title='Article about Windows Mobile 6.5 Gestures'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-1957893120259535068</id><published>2009-10-26T22:41:00.003+00:00</published><updated>2009-10-26T22:57:36.007+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GDI"/><category scheme="http://www.blogger.com/atom/ns#" term="HOWTO"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>HOWTO: Implement a text ticker</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlP4nVZ92cC0tKZ3VdTkSabDBT_vQrw62iOjX_Dy2DQvytGHRg-nQufMsP2NTMdcvLyVHlay6TxWcV5Bg4zJxKOxdRAACb7bKkfdBbZK_TzQBjUF8rdLYRX9I0hjSXk62BPGX7eg/s1600-h/TextTicker.png&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 150px; height: 200px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlP4nVZ92cC0tKZ3VdTkSabDBT_vQrw62iOjX_Dy2DQvytGHRg-nQufMsP2NTMdcvLyVHlay6TxWcV5Bg4zJxKOxdRAACb7bKkfdBbZK_TzQBjUF8rdLYRX9I0hjSXk62BPGX7eg/s200/TextTicker.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5397046594514934546&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Here&#39;s the answer to yet another question asked on the &lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/61794db0-700d-48b5-939d-633e7832f2f4&quot;&gt;Windows Mobile Developer Center Forums&lt;/a&gt;: How to implement a text ticker. The request implied for a flicker-free implementation, so a memory bitmap is required. This bitmap is generated whenever the screen changes size (&lt;span style=&quot;font-family:courier new;&quot;&gt;CTextTickerView::OnSize&lt;/span&gt;) or when the text itself changes (&lt;span style=&quot;font-family:courier new;&quot;&gt;CTextTickerView::SetTickerText&lt;/span&gt;). To calculate the text size when printed with the given font, a call is made to &lt;span style=&quot;font-family:courier new;&quot;&gt;CDC::GetTextExtent&lt;/span&gt; which returns both the height and the width of the text in pixels. The off-screen is then created using the screen width and the text height plus a few padding pixels (&lt;span style=&quot;font-family:courier new;&quot;&gt;CTextTickerView::ResizeBitmap&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;Scrolling of the ticker is achieved through a timer that shifts the ticker printing position every 100 ms. The ticker is painted by invalidating its own rectangle and the whole painting process is performed on &lt;span style=&quot;font-family:courier new;&quot;&gt;CTextTickerView::OnPaint&lt;/span&gt;. Note how the ticker text gets painted a second time tailing the first instance in order to give a continuous feel. Also note how the &lt;span style=&quot;font-style: italic;&quot;&gt;x&lt;/span&gt; offset is incremented by the timer handler. Go and have a look at the code!&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/TextTicker.zip&quot;&gt;TextTicker.zip&lt;/a&gt; (114 KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/1957893120259535068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/1957893120259535068' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1957893120259535068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1957893120259535068'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/howto-implement-text-ticker.html' title='HOWTO: Implement a text ticker'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlP4nVZ92cC0tKZ3VdTkSabDBT_vQrw62iOjX_Dy2DQvytGHRg-nQufMsP2NTMdcvLyVHlay6TxWcV5Bg4zJxKOxdRAACb7bKkfdBbZK_TzQBjUF8rdLYRX9I0hjSXk62BPGX7eg/s72-c/TextTicker.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-6240019152442037878</id><published>2009-10-26T13:42:00.003+00:00</published><updated>2009-10-26T13:47:14.922+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HOWTO"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><title type='text'>HOWTO: Show the Today or Home screen</title><content type='html'>I recently answered this question on an MSDN forum: how can I show the Today screen from my application? The answer is actually quite simple:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;HWND hWndDesktop = GetDesktopWindow();&lt;br /&gt;SetForegroundWindow((HWND)(((ULONG) hWndDesktop) | 0x01) );&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The first line of code retrieves the &quot;desktop&quot; window handle (the Today screen) and in the second you set it to the foreground. Easy.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/6240019152442037878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/6240019152442037878' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6240019152442037878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6240019152442037878'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/howto-show-today-or-home-screen.html' title='HOWTO: Show the Today or Home screen'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-5551951370759061548</id><published>2009-10-19T19:42:00.003+01:00</published><updated>2009-10-19T22:07:57.934+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GDI"/><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>The Hold Gesture</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQm3nQQszMlzx99T9QYfF6maQLjMznbK-6eOGhwgNMOxoQWbHPL-35GC9fbI8dUyWDKJvcXvgyuG3aPwA1GoMqg_zASvDvwO_S8Z49hMj8trGxoe2Zmvdl0VP9U-Bt7m3hmNhwIw/s1600-h/HoldSample.png&quot;&gt;&lt;img style=&quot;margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 240px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQm3nQQszMlzx99T9QYfF6maQLjMznbK-6eOGhwgNMOxoQWbHPL-35GC9fbI8dUyWDKJvcXvgyuG3aPwA1GoMqg_zASvDvwO_S8Z49hMj8trGxoe2Zmvdl0VP9U-Bt7m3hmNhwIw/s320/HoldSample.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5394418213127120258&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;After writing my last post, I started wondering if I could implement other useful gestures to control the touch list. So I started to wonder what kind of gestures would be needed for a real list-based application, like the CrypSafe prototype I have been working on. One of the issues that you will be confronted with is the requirement of, somehow, single out a single list item and then apply some sort of command to it. Think about deleting a list item: wouldn&#39;t it be nice that by clicking the item in a special way you would be able to do just so? There are a lot of other actions you might want to perform in a list item this way (edit, move up or down, you name it). Microsoft actually solved this issue some time ago with the &quot;tap-and-hold&quot; gesture, but gave it a very specific implementation with those circles rolling around the screen to denote it. Alas, I don&#39;t like it so I decided to reinvent the wheel and tweak the &lt;span style=&quot;font-family:courier new;&quot;&gt;CTouchGesture&lt;/span&gt; in order to implement this gesture. It&#39;s actually quite simple: if you press an area of the screen and you don&#39;t move or release the finger for some time, a hold gesture is returned by the timer event.&lt;br /&gt;&lt;br /&gt;To illustrate the use of this gesture, I implemented a very simple demo based on AppStart (yes, I was lazy) a so that it shows a &quot;context toolbar&quot; when you hold a given list item (see picture). In this case I added an &quot;edit&quot; and a &quot;delete&quot; button that you could use to change the list item. To make the whole thing a bit more fun, I added a small animation to the hold gesture where you can see the item expanding to reveal the &quot;toolbar&quot;. Getting information about the pressed toolbar button would be a simple matter of overriding the &lt;span style=&quot;font-family: courier new;&quot;&gt;HitTest&lt;/span&gt; function. Note that when the toolbar is displayed you can still flick and click because the item merely changed its size.&lt;br /&gt;&lt;br /&gt;Here is the sample app: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/AppStart05.zip&quot;&gt;AppStart05.zip&lt;/a&gt; (268 KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/5551951370759061548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/5551951370759061548' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/5551951370759061548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/5551951370759061548'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/hold-gesture.html' title='The Hold Gesture'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQm3nQQszMlzx99T9QYfF6maQLjMznbK-6eOGhwgNMOxoQWbHPL-35GC9fbI8dUyWDKJvcXvgyuG3aPwA1GoMqg_zASvDvwO_S8Z49hMj8trGxoe2Zmvdl0VP9U-Bt7m3hmNhwIw/s72-c/HoldSample.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-5067795664940223172</id><published>2009-10-18T16:48:00.001+01:00</published><updated>2009-10-18T16:49:57.428+01:00</updated><title type='text'>Ooops!</title><content type='html'>Please discard the AppStart03.zip file as the project contains a bug. The corrected version is here: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/AppStart04.zip&quot;&gt;AppStart04.zip&lt;/a&gt; (169 KB).</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/5067795664940223172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/5067795664940223172' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/5067795664940223172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/5067795664940223172'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/ooops.html' title='Ooops!'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-2874526891946575983</id><published>2009-10-18T11:37:00.002+01:00</published><updated>2009-10-18T12:02:37.906+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>Minor touch improvements</title><content type='html'>In this blog post I&#39;m returning to the touch window code to show you a couple of improvements that were needed.&lt;br /&gt;&lt;br /&gt;First, there was the issue of stopping the list halfway through a scroll. If you start dragging the list and then stop, wait a little and then release the finger or stylus, the list would still scroll. This is not an intended (nor intuitive) behavior: the user scrolls the list up to a position and he / she wants it to stay put by stopping the finger / stylus for a fraction of a second and then releasing it.&lt;br /&gt;&lt;br /&gt;The second issue happened when the list was &quot;bouncing back&quot; if you forced it to scroll down from the top (or scrolling up from the bottom). Under some occasions you could actually stop the list from scrolling back to its &quot;rest&quot; position leaving it in an awkward state.&lt;br /&gt;&lt;br /&gt;To solve the first issue I changed the bulk of the code in the &lt;span style=&quot;font-family: courier new;&quot;&gt;CTouchGesture&lt;/span&gt; class and turned it into a state machine with four inputs:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Press - The user pressed the finger / stylus&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Move - The user is dragging the finger / stylus&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Release - The user released the finger / stylus&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Timer - Called every 200 ms in order to check transient conditions&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;Each input is implemented by a method with the same name and the novelty here is that each of the first three returns a value of &lt;span style=&quot;font-family: courier new;&quot;&gt;GestureType&lt;/span&gt; (&lt;span style=&quot;font-family: courier new;&quot;&gt;NoGesture&lt;/span&gt;, &lt;span style=&quot;font-family: courier new;&quot;&gt;ClickGesture&lt;/span&gt;, &lt;span style=&quot;font-family: courier new;&quot;&gt;FlickGesture&lt;/span&gt;). The return type is used by the &lt;span style=&quot;font-family: courier new;&quot;&gt;CTouchWindow&lt;/span&gt; mouse event handlers to determine what to do (nothing, a click or a flick). When flicking through the list, the &lt;span style=&quot;font-family: courier new;&quot;&gt;CTouchGesture&lt;/span&gt; returns the delta movement through the new &lt;span style=&quot;font-family: courier new;&quot;&gt;GetDelta&lt;/span&gt; function.&lt;br /&gt;&lt;br /&gt;By implementing the gesture recognition as a state machine we get a much better chance of determining and handling the harder to detect situations, such as:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Input noise such as when the user flicks and accidentally releases the screen for a very short period. This is now handled by the code and the state machine assumes that the previous flick is still happening.&lt;/li&gt;&lt;li&gt;Intermediate motion stop, such as when the user is flicking and stops halfway. This situation is detected by the timer event that essentially resets all displacement and time accumulators and assumes that the user wants to do nothing (this is not interpreted as a click, of course).&lt;/li&gt;&lt;/ul&gt;Finally, I changed the code a little bit so that it does not allow the list to be in an &quot;unnatural&quot; position. Whenever the list stops it is checked for such a situation (showing the canvas to the top or bottom when the list is larger than the window). When such a situation is detected, the list is automatically scrolled back into position.&lt;br /&gt;&lt;br /&gt;To illustrate all of this, I turned back to the AppStart sample simply because it has a bigger list. Here it is for your viewing pleasure (or not...):&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/AppStart03.zip&quot;&gt;AppStart03.zip&lt;/a&gt; (166 KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/2874526891946575983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/2874526891946575983' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/2874526891946575983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/2874526891946575983'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/minor-touch-improvements.html' title='Minor touch improvements'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-1949707316962089600</id><published>2009-10-11T18:56:00.003+01:00</published><updated>2009-10-11T20:40:42.346+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="OLE DB"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Compact"/><title type='text'>It&#39;s not a bug...</title><content type='html'>... it&#39;s a feature! Really! I&#39;m talking about my &lt;a href=&quot;http://nativemobile.blogspot.com/2009/10/command-parameter-handling.html&quot;&gt;last post&lt;/a&gt; where I jumped to the conclusion that I had a bug in a particular line of code. In fact, that line of code is correct - the bug lies elsewhere. Let me explain.&lt;br /&gt;&lt;br /&gt;As I stated before, there is no way (at least I never found a way to) use storage object with SQL Compact command parameters. To overcome this limitation the code must allocate the full size of the BLOB data on the binding buffer (which is not very efficient, but it&#39;s a viable solution). The problem with this is that the code has to know the size of the BLOB and adjust the binding buffer accordingly. If you use ADO .NET then you know how this issue is solved: the developer must create SqlCeParameters with the given maximum size of the parameter data. The whole purpose of this code is to avoid this situation and let the OLE DB library handle that chore for you.&lt;br /&gt;&lt;br /&gt;Command parameter information is requested when you prepare a command and this is the reason why you see the dreaded 1024 constant in the code (the value is pretty arbitrary, by the way). This was the value I chose to represent the default value of the BLOB just to assume a value for it&#39;s length. The code then expects that you call &lt;span style=&quot;font-family:courier new;&quot;&gt;SetParam&lt;/span&gt; for each parameter and explicitly set its size then. When the command is executed, the whole set of command parameters is looped through in order to get the size of the new binding buffer. If the new binding buffer is larger than the previous one it gets reallocated. And this is exactly where the bug was: the existing buffers were not being deleted and an obvious memory leaked was being created (the complaint reason from the reader who sent me the email message thet prompted me to look at this issue again).&lt;br /&gt;&lt;br /&gt;To prove that the memory leak issue is gone in the new code, I set up a very simple demo project where three JPG images are inserted into a sample database table. The images are inserted using a SQL INSERT command and the code is arranged so that the images are processed in an increasing size order. This way you can actually see how the binding buffer increases.&lt;br /&gt;&lt;br /&gt;Incidentally, the &lt;span style=&quot;font-style: italic;&quot;&gt;real&lt;/span&gt; bug was on the &lt;span style=&quot;font-family:courier new;&quot;&gt;CCommand::BindParameters&lt;/span&gt; method where the &lt;span style=&quot;font-family:courier new;&quot;&gt;m_pBuffer&lt;/span&gt; and &lt;span style=&quot;font-family:courier new;&quot;&gt;m_pBindStatus&lt;/span&gt; arrays are allocated. These must be freed if non null before allocation.&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/BigParams.zip&quot;&gt;BigParams.zip&lt;/a&gt; (789 KB)&lt;br /&gt;&lt;br /&gt;Note that the sample application expects both the sdf and jpg files on the &lt;span style=&quot;font-weight: bold;&quot;&gt;\Storage Card\Temp&lt;/span&gt; directory. You can change this by editing the &lt;span style=&quot;font-family:courier new;&quot;&gt;BigParamsFrame.cpp&lt;/span&gt; file.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/1949707316962089600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/1949707316962089600' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1949707316962089600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1949707316962089600'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/its-not-bug.html' title='It&#39;s not a bug...'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-6325454010197936523</id><published>2009-10-08T10:36:00.002+01:00</published><updated>2009-10-08T22:38:44.464+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="OLE DB"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Compact"/><title type='text'>Command Parameter Handling</title><content type='html'>I recently got an email from an interested reader pointing out an error in the SQL command parameter handling OLE DB Client code. If you remember my previous ramblings on this issue, the OLE DB provider for SQL Compact is unable to handle BLOB SQL command parameter through storage objects. This means that you must provide some information about the BLOB before using the command, just like you have to do if you use the ADO .NET stack. Now, if you look at the &lt;span style=&quot;font-family: courier new;&quot;&gt;CCommand::CreateParameter&lt;/span&gt; method you will see the error:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;ULONG nParamSize = bIsLong ? 1024 : pParamInfo-&gt;ulParamSize;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Let me assure you that I was not taking any medication (or smoking funny stuff) when I wrote this line. This is a piece of code that I just did not return to so the error crept in and started to create lots of memory leaks. Solving this issue is not a simple matter of correcting this line to:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;ULONG nParamSize = pParamInfo-&gt;ulParamSize;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Like I said, we must specify all the BLOB parameter sizes before we prepare the command and this means that &lt;span style=&quot;font-family: courier new;&quot;&gt;CCommand::Prepare&lt;/span&gt; must also change. Instead of getting parameter information in the call to &lt;span style=&quot;font-family: courier new;&quot;&gt;Prepare&lt;/span&gt;, the user will have the option of calling another method to get this information. In any case, there must be an option to provide custom command parameters. This is the topic of my next post.</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/6325454010197936523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/6325454010197936523' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6325454010197936523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6325454010197936523'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/10/command-parameter-handling.html' title='Command Parameter Handling'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-6822861309472838002</id><published>2009-09-28T09:07:00.002+01:00</published><updated>2009-09-28T09:28:07.197+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>Improvements</title><content type='html'>After reading Vincent&#39;s comment on my last post, I took a second look at the scrolling code and scuttled the &lt;span style=&quot;font-family: courier new;&quot;&gt;InvalidateRect&lt;/span&gt; scrolling mechanism. The fact is that while on some older devices this did work in an acceptable fashion, it did not work that well on more recent models and you can actually see some &quot;bumps&quot; in the scrolling speed. The code now uses a timer (again) but instead of indirectly painting the window through the &lt;span style=&quot;font-family: courier new;&quot;&gt;InvalidateRect&lt;/span&gt; / &lt;span style=&quot;font-family: courier new;&quot;&gt;UpdateWindow&lt;/span&gt; calls, it now directly invokes the painting function. The result is a very smooth scroll on all devices I have tested the code with.&lt;br /&gt;&lt;br /&gt;I also changed the way the &lt;span style=&quot;font-family: courier new;&quot;&gt;ScrollLeft&lt;/span&gt; and &lt;span style=&quot;font-family: courier new;&quot;&gt;ScrollRight&lt;/span&gt; view transitions work. Instead of painting the bitmap at full speed, I added a very small sleep period to each iteration so that each transition is performed in approximately 250 milliseconds. The first paint operation is timed and a per-iteration sleep period is calculated so that the whole process takes the quarter-second period to unfold. With this improvement, you will be able to see the view transition on all devices (especially the ones with a faster CPU and QVGA screen).&lt;br /&gt;&lt;br /&gt;Finally, I decided to add a couple of new view transitions: Fade and Explode / Implode. The first transition uses the &lt;span style=&quot;font-family: courier new;&quot;&gt;AlphaBlend&lt;/span&gt; API function to fade from the existing view to the new view (like in a Power Point presentation). I have to say that this is not a very compelling transition, but inspired me to write the second. The Explode / Implode view transition also tries to mimic one of the most famous iPhone view transitions (when you launch an application). The existing view is zoomed in while the new view fades in while also zooming in from half its original size. The Implode effect does the reverse. The result was a bit disappointing because &lt;span style=&quot;font-family: courier new;&quot;&gt;AlphaBlend&lt;/span&gt; operation seems to be very greedy (you can replace it by a simple &lt;span style=&quot;font-family: courier new;&quot;&gt;StretchBlt&lt;/span&gt; and compare the results). The GDI is not very good at this stuff, unfortunately...&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/CrypSafe06.zip&quot;&gt;CrypSafe06.zip&lt;/a&gt; (323KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/6822861309472838002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/6822861309472838002' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6822861309472838002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/6822861309472838002'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/09/improvements.html' title='Improvements'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-1510112541254455049</id><published>2009-09-20T19:03:00.003+01:00</published><updated>2009-09-20T21:37:13.071+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>View transitions</title><content type='html'>Now that I managed to get some decent finger feedback from the list, it&#39;s time to get back to the CrypSafe prototype and add some view transitions. The code I&#39;m using is based on an article I published last year on CodeProject: &lt;a href=&quot;http://www.codeproject.com/KB/mobile/SlideView.aspx&quot;&gt;Animating View Transitions on Windows Mobile&lt;/a&gt;. Please read it before continuing as what you will see here is an extension of what I wrote there.&lt;br /&gt;&lt;br /&gt;Essentially this article explored the ability to do some fashionable (read iPhone-like) view transitions using child views implemented as regular Win32 controls (such as a tree view, a list view or even a dialog). The view transitions were implemented using a very simple mechanism:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Capture the existing view as a bitmap;&lt;/li&gt;&lt;li&gt;Remove the from the frame container;&lt;/li&gt;&lt;li&gt;Paint the view bitmap on the frame client area;&lt;/li&gt;&lt;li&gt;Create the new child view window off screen;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Enter a loop where the bitmap is scrolled to the requested direction a few pixels;&lt;/li&gt;&lt;li&gt;Every time the bitmap is scrolled, move the new child window to the contiguous position thus creating the illusion that both windows are moving in lockstep.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;That was a bit crude but worked. One of the lessons I learned from writing this article is that, generally, you cannot force an arbitrary window to paint itself to a memory DC. This would be very useful for some advanced visual effects. By reading the docs you might even be tempted (as I was) to send a &lt;span style=&quot;font-family:courier new;&quot;&gt;WM_PAINT&lt;/span&gt; message to the hidden window with your memory DC in the &lt;span style=&quot;font-family:courier new;&quot;&gt;WPARAM&lt;/span&gt; and expect it to paint there, but that just doesn&#39;t work for all windows. That&#39;s why I had to use &lt;span style=&quot;font-family:courier new;&quot;&gt;MoveWindow&lt;/span&gt; for the animation.&lt;br /&gt;&lt;br /&gt;Now that we are rendering the touch windows and lists directly on a memory DC, there is a better chance to improve on the original algorithm and implement a smoother view transition algorithm. This is what you will find in the sample code (see below).&lt;br /&gt;&lt;br /&gt;The major change I made to the code was to &lt;span style=&quot;font-family:courier new;&quot;&gt;CChildViewBase&lt;/span&gt; where you can now see a &lt;span style=&quot;font-family:courier new;&quot;&gt;GetBitmap&lt;/span&gt; virtual method. If this method returns &lt;span style=&quot;font-family:courier new;&quot;&gt;NULL&lt;/span&gt;, then the child view is not able to render itself on a bitmap and the old brute-force method will be used. If, on the other hand, the child view is able to render itself to a bitmap it must do so here. Note how this is implemented in the &lt;span style=&quot;font-family:courier new;&quot;&gt;CCrypSafeView&lt;/span&gt; class: the painting engine is called directly and a new &lt;span style=&quot;font-family:courier new;&quot;&gt;HBITMAP&lt;/span&gt; is returned for the child view manager to paint.&lt;br /&gt;&lt;br /&gt;The results are here for you to see: acceptable on some devices, way too fast on others and slower on older devices. What we need to do here is quite simple: use the same kinematics equations to control the view transition motion and leave nothing to chance.&lt;br /&gt;&lt;br /&gt;Comments and suggestions are welcome!&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/CrypSafe05.zip&quot;&gt;CrypSafe05.zip&lt;/a&gt; (349 KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/1510112541254455049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/1510112541254455049' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1510112541254455049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/1510112541254455049'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/09/view-transitions.html' title='View transitions'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-4982487089632574575</id><published>2009-09-15T22:17:00.004+01:00</published><updated>2009-09-15T22:28:55.496+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="OLE DB"/><title type='text'>Feedback</title><content type='html'>I just received a very nice email from one of you (you know who you are) reporting a bug in the OLE DB Client library, more specifically on the &lt;span style=&quot;font-family: courier new;&quot;&gt;CDbValueRef&lt;/span&gt; class (file&lt;span style=&quot;font-family: courier new;&quot;&gt; DbValue.cpp&lt;/span&gt;, line 758). The line must read:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;*m_pLength = nStrLen * sizeof(wchar_t);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The original code did not multiply the string size with the Unicode character size, so you got a wrong byte count and a bug.&lt;br /&gt;&lt;br /&gt;It&#39;s always very rewarding to receive emails with correction and suggestions from you (it means someone is reading this... - hehe). Thank you for all the feedback!</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/4982487089632574575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/4982487089632574575' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/4982487089632574575'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/4982487089632574575'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/09/feedback.html' title='Feedback'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-261985284543170608</id><published>2009-09-13T19:56:00.002+01:00</published><updated>2009-09-13T22:11:55.622+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="WTL"/><title type='text'>Better touch</title><content type='html'>My professional life changed quite a bit recently and that&#39;s why I have not been posting as frequently as usual. I finally seem to have reached some balance and now&#39;s the time to resume my blog work.&lt;br /&gt;&lt;br /&gt;One of the faults I found in the last version of the published code concerned finger sensitivity. This is a real issue in touch screens based on resistive technology (see a discussion about this topic on &lt;a href=&quot;http://blogs.msdn.com/marcpe/archive/2009/06/29/let-s-talk-about-touch-part1.aspx&quot;&gt;Marcus Perryman&#39;s blog&lt;/a&gt;). The bottom line is simple: resistive screens were made for a stylus, not for your finger. They are much more precise than capacitive screens (like the one found on the iPod Touch and iPhone), but require pressure. Capacitive screens are less precise but require only a very soft finger contact in order to operate. Resistive screens expect a very small pressure area (the tip of a stylus). An adult index finger uses up a very large area on the touch screen and the net result is noise and erratic motion messages.&lt;br /&gt;&lt;br /&gt;You can see this in the last sample code I published: flick the list and then click it. It should stop the list but it doesn&#39;t (that&#39;s how it works on my HTC Touch Pro). What happens is that a single finger press is interpreted by the highly sensitive resistive screen as a sequence of one &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_LBUTTONDOWN&lt;/span&gt; message, a couple of &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_MOUSEMOVE&lt;/span&gt; messages and the final &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_LBUTTONUP&lt;/span&gt;. Inspecting the &lt;span style=&quot;font-family: courier new;&quot;&gt;LPARAM&lt;/span&gt; parameter you will see that the &lt;span style=&quot;font-family: courier new;&quot;&gt;POINT&lt;/span&gt; structure shows some fluctuations on the &lt;span style=&quot;font-style: italic;&quot;&gt;x&lt;/span&gt; and &lt;span style=&quot;font-style: italic;&quot;&gt;y&lt;/span&gt; coordinates. This means that a single finger press is actually equivalent to a small doodle drawn with your stylus. You will be lucky if the first and last &lt;span style=&quot;font-family: courier new;&quot;&gt;POINT&lt;/span&gt; values are the same (they almost never are).&lt;br /&gt;&lt;br /&gt;To mitigate this issue and provide better (more reliable) finger action feedback I made some adjustments to the code. The first thing I realized is that one of the sources of &quot;position noise&quot; was the first &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_MOUSEMOVE&lt;/span&gt; message. The offset between the &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_LBUTTONDOWN&lt;/span&gt; position and the first &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_MOUSEMOVE&lt;/span&gt; message seems to provide more variance than the offset to the second &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_MOUSEMOVE&lt;/span&gt;. To even things out a little bit I now discard the first offset and start calculating the gesture from the first &lt;span style=&quot;font-family: courier new;&quot;&gt;WM_MOUSEMOVE&lt;/span&gt; message. Also, I brought back the concept of sensitivity to filter out smaller movements. Finally take a look at the code in &lt;span style=&quot;font-family: courier new;&quot;&gt;CTouchGesture::Move&lt;/span&gt; method. Instead of calculating the move offset in a single &lt;span style=&quot;font-family: courier new;&quot;&gt;if&lt;/span&gt; clause, I split the code into two, one for the vertical motion and the other for the horizontal motion.&lt;br /&gt;&lt;br /&gt;The final result feels a bit better and more reliable on all the machines I have tested the code with, but the final word is yours.&lt;br /&gt;&lt;br /&gt;Sample code: &lt;a href=&quot;http://www.primeworks-mobile.com/Downloads/Blog/AppStart02.zip&quot;&gt;AppStart02.zip&lt;/a&gt; (164 KB)</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/261985284543170608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/261985284543170608' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/261985284543170608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/261985284543170608'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/09/better-touch.html' title='Better touch'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11847577.post-427477199583065266</id><published>2009-09-10T11:20:00.005+01:00</published><updated>2009-09-10T11:22:26.389+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Accelerometer"/><title type='text'>Shaken, not stirred...</title><content type='html'>The September 2009 issue of MSDN Magazine presents us with a &lt;a href=&quot;http://msdn.microsoft.com/en-us/magazine/ee413721.aspx&quot;&gt;very nice article&lt;/a&gt; on how to detect shaking with the HTC accelerometer. Note that the article is for managed developers, but that should be no problem for you...</content><link rel='replies' type='application/atom+xml' href='http://nativemobile.blogspot.com/feeds/427477199583065266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11847577/427477199583065266' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/427477199583065266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11847577/posts/default/427477199583065266'/><link rel='alternate' type='text/html' href='http://nativemobile.blogspot.com/2009/09/shaken-not-stirred.html' title='Shaken, not stirred...'/><author><name>João Paulo Figueira</name><uri>http://www.blogger.com/profile/01808451986712386444</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>