Saturday, June 28, 2008

Only 2 Days Left…

Today’s application is CallBlock. It is designed to watch incoming calls, and check and see if they match any on the block phone numbers list. If they do match then the phone is “blocked”.

 

image

CallBlock

The first thing you should notice is the flashy logo at the top of the form. I create this logo with an online 3D logo generator. The one simple touch adds a lot of professional polish to the application. I really like red and white so I didn’t change the background color this time. But I am starting to wish I had. It seems a little “blah” to me now.

Next we have our phone number input text box. The user enters the phone number here, and presses the Block menu item to add it to the block number list below. On the main menu we also have options to Unblock, and Unblock All. And we have our almost universal About and Exit menu items.

There are two main pieces to this application. One part is the State and Notification Broker code to give us an event to catch incoming phone calls.

I actually got myself painted into a corner, I assumed you could just programmatically ignore of phone call but it isn’t that simple. Fortunately, a good friend of mine, Lou Vega, came up with a very slick workaround for this. And that is the second part which is the keybd_event method that allows us to send keypresses to the OS to Ignore the phone call.

CallBlock Core Code

   1: const int KEYEVENTF_KEYDOWN = 0x0;
   2: const int KEYEVENTF_KEYUP = 0x2;
   3:  
   4: [DllImport("coredll.dll", EntryPoint = "keybd_event", SetLastError = true)]
   5: internal static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
   6:  
   7: SystemState phoneIncomingCall = new SystemState(SystemProperty.PhoneIncomingCall);
   8: private void frmMain_Load(object sender, EventArgs e)
   9: {
  10:     phoneIncomingCall.Changed += new ChangeEventHandler(phoneIncomingCall_Changed);
  11: }
  12:  
  13: void phoneIncomingCall_Changed(object sender, ChangeEventArgs args)
  14: {
  15:     string phoneNumber = RemoveText(SystemState.PhoneIncomingCallerNumber);
  16:  
  17:     if(listBoxBlockedNumbers.Items.Contains(phoneNumber))
  18:     {
  19:         keybd_event(115, 0, KEYEVENTF_KEYDOWN, 0);
  20:         keybd_event(115, 0, KEYEVENTF_KEYUP, 0);
  21:     }
  22: }

 

Possibilities:

It would be easy to add support for blocking SMS text messages as well. We’ve done all the code for this already in previous applications. Also the application could really use a persistent data store to remember number to block in case the user closes the application. It would be nice to allow user formatting of entered phone numbers for increased readability.

Download executable: callBlock.cab

Download Source Code: callBlock.zip

Feedback:

Want more? What else would you like to see? Time’s running out on submitting ideas. Be sure to get yours in soon!


Saturday, June 28, 2008 16:07:00 (Eastern Standard Time, UTC-05:00)  #    Comments [2]  |  Trackback Tracked by:
"30 Days of .NET [Windows Mobile Applications] – ..." (windows) [Trackback]
"30 Days of .NET [Windows Mobile Applications] - Week Four" (Chris Craft's Blog) [Trackback]

Theme design by Jelle Druyts

Pick a theme: