Geeks With Blogs
Prabhu Kumar a tech twaddler.. Applications
Windows Phone 7: Translation, rotation, scaling and the effect of ‘BitmapCache’ on performance
I just published a post on my blog at, here is the link: ......

Posted On Thursday, March 10, 2011 2:38 AM

Windows Phone 7: Building a simple dictionary web client
Like I mentioned in this post a while back, I came across a dictionary web service called Aonaware that serves up word definitions from various dictionaries and is really easy to use. The services page on their website, lists all the operations that are supported by the dictionary service. Here they are, Word Dictionary Web Service The following operations are supported. For a formal definition, please review the Service Description. Define ......

Posted On Thursday, December 30, 2010 1:06 AM

Windows Phone 7 : Dragging and flicking UI controls
Who would want to flick and drag UI controls!? There might not be many use cases but I think some concepts here are worthy of a post. So we will create a simple silverlight application for windows phone 7, containing a canvas element on which we’ll place a button control and an image and then, as the title says, drag and flick the controls. Here’s Mainpage.xaml, <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition ......

Posted On Sunday, December 19, 2010 10:18 PM

Windows Phone 7 : UI Control Boundaries
I was working on an application at work when I needed to figure out a really trivial case, well, trivial in theory at least. All I wanted to know was if a button was completely inside a rectangle. Could anything else be simpler you think. Just check the button bounds against the rectangle bounds, pseudocode if (Button.Top > Rectangle.Top && Button.Left > Rectangle.Left && Button.Right < Rectangle.Right && Button.Bottom < Rectangle.Bottom) { //Button is inside rectangle ......

Posted On Monday, November 22, 2010 11:37 PM

Edit boxes and default text selection
While working on an application of mine, I had to display ‘Help’ information. I chose to use a read-only multiline edit box along with SetWindowText() to display the text, sounds simple enough. But I ran into a small but annoying problem. The text displayed was all selected, and I thought why would the text be selected by default!? Here is a sample program to demonstrate this, #include <windows.h> #include <aygshell.h> #include "resource.h" HINSTANCE g_hInst; BOOL CALLBACK EditBoxSelTextDlgProc(HWND, ......

Posted On Friday, August 20, 2010 7:39 PM

HTC HD2, Accelerometer and Windows Phone 7 – Source Code
If you haven’t seen the video demo in my last post, I suggest you watch it first to get a better understanding. So in this post we are going to see how the WCF service, the .NET Compact Framework application running on HD2 and the Silverlight application running on the Windows Phone 7 emulator work together. The Objective We are going to write three applications, a simple WCF service hosted in a windows console application which implements two functions, one called UploadAccelData() and the other ......

Posted On Sunday, August 1, 2010 10:56 PM

Shake detection on HTC HD2
In the previous post I mentioned that the acceleration vector or the force vector can be used to detect gestures like shake. Here is a crude implementation of shake detection, private const double SHAKE_THRESHOLD = 5.0f; private bool IsShakeDetected(HTCSensorData sensorData) { bool isShake = false; double x = (double)sensorData.tiltX / 1000; double y = (double)sensorData.tiltY / 1000; double z = (double)sensorData.tiltZ / 1000; double forceSqrd = x * x + y * y + z * z; System.Console.WriteLine("F... ......

Posted On Saturday, July 24, 2010 5:53 PM

Applications: The Mathematics of Movement, Part 3
Previously: Part 1, Part 2 As promised in the previous post, this post will cover two variations of the marble move program. The first one, Infinite Move, keeps the marble moving towards the click point, rebounding it off the screen edges and changing its direction when the user clicks again. The second version, Finite Move, is the same as first except that the marble does not move forever. It moves towards the click point, rebounds off the screen edges and slowly comes to rest. The amount of time ......

Posted On Saturday, June 12, 2010 7:32 PM

Applications: The Mathematics of Movement, Part 2
In part 1 of this series we saw how we can make the marble move towards the click point, with a fixed speed. In this post we’ll see, first, how to get rid of Atan2(), sine() and cosine() in our calculations, and, second, reducing the speed of the marble as it approaches the destination, so it looks like the marble is easing into it’s final position. As I mentioned in one of the previous posts, this is achieved by making the speed of the marble a function of the distance between the marble and the ......

Posted On Sunday, June 6, 2010 1:53 PM

Applications: The Mathematics of Movement, Part 1
Before you continue reading this post, a suggestion; if you haven’t read “Programming Windows Phone 7 Series” by Charles Petzold, go read it. Now. If you find 150+ pages a little too long, at least go through Chapter 5, Principles of Movement, especially the section “A Brief Review of Vectors”. This post is largely inspired from this chapter. At this point I assume you know what vectors are, how they are represented using the pair (x, y), what a unit vector is, and given a vector how you would normalize ......

Posted On Sunday, May 23, 2010 11:30 AM

Applications: How to create a custom dialog box for Windows Mobile 6 (native)
Ashraf, on the MSDN forum, asks, “Is there a way to make a default choice for the messagebox that happens after a period of time if the user doesn't choose (Clicked ) Yes or No buttons.” To elaborate, the requirement is to show a message box to the user with certain options to select, and if the user does not respond within a predefined time limit (say 8 seconds) then the message box must dismiss itself and select a default option. Now such a functionality is not available with the MessageBox() api, ......

Posted On Thursday, April 22, 2010 9:17 AM

Applications: Colliding Marbles in C Sharp
If you follow this blog, you know how much I love marbles. I was staying up for Microsoft's It's Time To Share event and I thought I'll write up a C# version of Colliding Marbles. It's a pretty straight forward port from the native version, the only major difference being in the drawing primitives. Video follows. The solution was created using Visual Studio 2008 and the source code is shared below. Source Code: [Shared on SkyDrive] Video ......

Posted On Monday, April 12, 2010 12:13 PM

Applications: Using the System Clipboard in Windows Mobile

This post demonstrates how to use the system clipboard in a Windows Mobile application.

Posted On Monday, March 1, 2010 5:58 AM

Fun with menus Part II, Radio Menu Items and CheckMenuRadioItem()
Previously - Fun with menus - Part I A few days back I set about trying to get radio items into menus. This is helpful if you want only one of the items in the menu to be active at a time, say, for e.g. a "Select Level" popup menu which has "Level 1", "Level 2" and "Level 3" subitems and only one of them needs to be shown as active or currently selected. You get the idea. No? Here, this pic should help, A bit of searching led me to the CheckMenuRadioItem() API, and I thought, this is simple. I just ......

Posted On Thursday, January 28, 2010 8:52 AM

Using the 'Open File' and 'Save File' dialogs, GetOpenFileName and GetSaveFileName APIs
Recently, someone on the MSDN forum asked if there are any built-in 'Open File' and 'Save File' dialogs available in the Windows Mobile platform. The answer, of course, is yes. The APIs that get the task done are GetOpenFileName() and GetSaveFileName(). These APIs allow the user to select directories or files for opening or saving. I wrote a small application to demonstrate how to use these APIs. The application has a multiline edit control and menu options for opening or saving text files (see video ......

Posted On Sunday, January 24, 2010 7:10 AM

Applications: Minesweeper approaches completion, slowly but steadily
So this weekend I got some time to push Minesweeper forward. You can now play a full game. Now that the basic game is up and running work needs to be done on other aspects. For now, here is a couple of clips: and ......

Posted On Sunday, October 25, 2009 7:02 AM

Applications: Getting device information (embedded exe, rapi and more)
I was working on this application which runs on the PC and gets information about the windows mobile device which is connected to the PC over active sync. Now there are a couple of ways in which you can do this: 1) Create a PC app which gets all the information using RAPI api's and displays it. 2) Create two binaries, one for the PC and one for the WinMob device. The PC app launches the WinMob app remotely using RAPI API's, the WinMob app runs and writes all the information it can gather into a file ......

Posted On Thursday, October 22, 2009 11:09 PM

Applications: Appending text to a multiline Edit control
Today I was developing a small utility application where I needed to append some text to a multiline edit control. When I ran through the list of Edit control messages, I could not find any that could be used to append text. WM_SETTEXT was overwriting the previous contents. And doing a WM_GETTEXT first, appending to it and then WM_SETTEXT seemed like an overkill. A little bit of searching led me to EM_REPLACESEL message. This message is used to replace the currently selected text in the edit control ......

Posted On Wednesday, October 21, 2009 12:46 AM

Applications: So we got the numbers going now..

Posted On Wednesday, October 7, 2009 12:42 PM

Applications: A game unfolds..
Hey there! If you are wondering what I was upto in the last couple of days, well, here it is. A few years back I had written Minesweeper as a project in college. I had used java and swing for the UI. I thought I will port it over to win mob, well, 'port' is the wrong word and I have had to write everything from scratch. Java-Swing and C++-WinMob-DirectDraw are like zenith and nadir apart. Skipping to the interesting part, here is a video of where things stand now, still a lot of work to be done. ......

Posted On Tuesday, October 6, 2009 12:01 PM

Applications: Painting problems with windowed directdraw app
Well, the painting problem that I mentioned in my last post is solved. Thanks to Joel for helping me out (: When I look in retrospect, the answer was in the question all the time. Painting problem, WM_PAINT message. It was stupid of me to have missed that (; But looking at the bright side I have a much better understanding of how WM_PAINT works now. The only thing that I needed to do was to display the frame every time my window got a WM_PAINT message. So that our client area is re-drawn and is displayed ......

Posted On Thursday, October 1, 2009 1:16 PM

Applications: Running an application when a specified event occurs

This post explains how to run applications automatically when certain events occur.

Posted On Monday, September 28, 2009 11:30 AM

Applications: Displaying a notification using SHNOTIFICATIONDATA

This post explains how to display a notification to user using SHNotificationAdd() api. The notification will show as a bubble popup and can also have an icon on the system tray.

Posted On Saturday, September 26, 2009 3:02 PM

Applications: Creating a windowed DirectDraw application

This post explains how to create a windowed directdraw application for windows mobile.

Posted On Friday, September 25, 2009 11:40 AM

Fun with menus!

This post deals with Menu items and defining menu items in resource files. How to get popup menus for both left and right softkey and much more.

Posted On Thursday, July 9, 2009 12:42 PM

Applications: Adding Image to your application
Well, back from work and I was sitting idle. I thought the first screen of my application looks a bit stale really, so, I decided to add a small picture to the main screen. Adding an image resource to your project: This is really easy. 1. Copy the bitmap file into you project directory. 2. Go to Resource View, right click and select "Add Resource.." 3. Select "Bitmap" and click on "Import.." 4. Point it to the file you copied in step 1 5. Note the ID assigned to your bitmap. In my case it was IDB_BITMAP1 ......

Posted On Monday, April 27, 2009 11:43 PM

Applications: Creating a simple UI application for Windows Mobile 6 using Visual Studio 2005: Part 3
So now our program displays the system width and height in a Message box. Let us see how this message box evolves into a Dialog box. Instead of displaying the system metrics in a Message box, we will display the same information in a full screen dialog box. The dialog box will have a menu bar, with the left soft key as "Back" and the right soft key as "Refresh". We'll see what "Refresh" will do later. First lets add the dialog box resource to our project. You can add a new dialog using the resource ......

Posted On Sunday, April 26, 2009 2:24 PM

Applications: Creating a simple UI application for Windows Mobile 6 using Visual Studio 2005: Part 2
Ok now that we have our basic application up and running, lets make some changes. First, I want to change the right soft key from "HELP" to "Menu", somehow "HELP" is not very appealing. One more thing, I use the resource editor only to add new resources to the project, any further changes or modification I like to do it by manually editing the resource files (To do that, just right click on the .rc file and select "View Code"). If you open HelloWorld.cpp and in function WndProc go to the case where ......

Posted On Thursday, April 16, 2009 12:11 AM

Applications: Creating a simple UI application for Windows Mobile 6 using Visual Studio 2005: Part 1
Time to do some actual work. As the title suggests, I will be creating a simple UI application for windows mobile 6 professional device using visual studio 2005 and improve it step by step. I will cover the developments over maybe 2 or 3 posts and lets see how it goes. Make sure you have installed Visual Studio 2005 and Windows Mobile 6 professional SDK before you proceed. Note: When creating new smart device projects with VS2005 you might get a script failure error saying that the project creation ......

Posted On Wednesday, April 15, 2009 10:35 PM

Copyright © TechTwaddle | Powered by: