Wednesday, February 21, 2007

Ricavision's Vista SideShow Remote Control

Ricavision has announced their latest remote control that supports the Windows Vista SideShow technology. It supports IrDA and Class-1 Bluetooth, and a very sexy 2.5" QVGA LCD for SideShow. Enuff said, a picture is worth a thousand words.

New ASUS motherboards support SideShow

If you are looking to build a new PC to run Windows Vista, be sure to first checkout the new motherboards from ASUS - P5B Premium Vista Edition, M2N32-SLI Premium Vista Edition, P5B-Plus Vista Edition and M2N-Plus SLI Vista Edition. These 4 models include numerous features specifically designed for Vista, among them my favorite is no doubt the ScreenDuo, which is a SideShow device. SideShow is a auxiliary display supported in Windows Vista that allows you to view important information without needing to keep your PC on all the time. Some of the early SideShow devices are commonly found in notebooks, but the four motherboards listed above brings SideShow devices to the desktop.

And of course, SideShow devices are useless unless you got a way to program them to display useful information. Well, of course you can! Stay tuned! ;-)

Monday, February 19, 2007

Sony Ericsson W850i

Recently, my old phone - the old trusty Motorola E398, gave way and I was searching for a new phone. As I have always been a great fan of Sony Ericsson, I finally decided on the W850i Walkman phone (I got the black one). This is a handsome handset that supports 3G and it has all the great features that you have come to expect from Sony Ericsson's line of Walkman phones. Sound quality is superb and it features a 2MP camera. It comes with a 1GB Memory Stick Pro Duo and hence I can reuse my memory stick for my Sony T10 camera.

I am still exploring the phone but so far I am a happy user!

Preorder Harry Potter and the Deathly Hallows (Book 7)

If you are a Harry Potter fan, be sure to pre-order the "Harry Potter and the Deathly Hallows (Book 7)" from Amazon.com.

Sunday, February 18, 2007

Download my articles on CoDe Magazine!

In the Sep/Oct 2006 and Nov/Dec 2006 issues of CoDe Magazine, I have the following articles:

Programming Windows Mobile 5.0 Applications using the .NET Compact Framework

Fun with RFID

Thanks to the generosity of Code Magazine, they have kindly made the PDF copies of the article/magazine available for download. You can simply click on the above links to download the articles.

If you like CoDe magazine, be sure to check the following link for a great discount offer for subscribers! https://www.code-magazine.com/subscribe/vip ($10 discount plus they get a CD with the past 5 years of CoDe on it).

Thursday, February 15, 2007

GPS Module for your Symbol MC70

Another really cool device I tried recently is the 1058-GPS from Technology Solutions (UK) Ltd. This is another plug-in for the MC70 and it draws the power from the MC70 directly. Accessing it programmatically is a no-brainer - simply listen to COM1 and interpret the NMEA data sentences that it spew out. For industries that need to track the whereabouts of their staff and delivery vehicles, this is a perfect accessory for your MC70, which has GPRS and Wi-Fi capabilities, allowing you to transmit the geographical locations back to the server real time using wireless connections (GPRS or wireless hotspots).

I have an actual sample on how to perform real-time tracking using GPS and Pocket PCs at: http://www.devx.com/wireless/Article/32938/1763.

I will be covering how to use the 1058-GPS Module in the upcoming course -

RFID Solutions for your Symbol MC70

If you are looking for a RFID solution and are searching for the mobile devices and its accompanying accessories, look no further. Recently, I had the opportunity to work with the 1059 HF Multi-ISO RFID Reader from Technology Solutions (UK) Ltd. The 1059 HF Multi-ISO RFID Reader is a plug-in for the Symbol MC70 and it draws its power from the MC70, and hence it does not require any external sources of power. It provides the ability to read and write to a wide variety of transponders at 13.56 MHz including ISO 15693, ICODE (I & II) and the complete Mifare family of ISO14443 (A&B).

Using the 1059 HF Multi-ISO RFID Reader, you can retain the barcode scanning capabilities of the MC70 and at the same time equip your MC70 with RFID capabilities.

I will be covering how to use the 1059-HF Multi-ISO RFID Reader module in the upcoming course -
Windows Mobile 5.0 Pocket PC Programming using the .NET Compact Framework 2.0. Register for the course today!

Wednesday, February 14, 2007

101 Ways to Manipulate the DataGridView Control

The DataGridView control, new in Windows Forms 2.0, is so versatile and powerful that beginners can easily be overwhelmed by the options. Here's an at-your-fingertips reference to some of the most common and useful things you can do with it. (OK there aren't really 101 ways but there are a lot!)

Monitor Your Web Cam from a Remote Computer

We've offered a few solutions for working with web cams within .NET to create fun and intriguing monitoring applications. In this article, we extend those ideas so that web cam images can be shared with multiple clients over the Web.

Sunday, February 11, 2007

Windows Mobile 6.0 SDK released!

Microsoft has recently announced the next version of Windows Mobile - Windows Mobile 6.0. In place of the current offerings, Microsoft has grouped them into three specific classes:

Microsoft SmartPhone ---> Windows Mobile Standard
Windows Mobile Pocket PC Phone Edition ---> Windows Mobile Professional
Windows Mobile Pocket PC ---> Windows Mobile Classic

You can now download the SDK for Windows Mobile 6.0 Standard and Professional.

Note:
To install the Windows Mobile 6.0 SDKs, you need to have the following:
1. Visual Studio 2005
2. ActiveSync 4.5
3. .NET CF 2.0 SP1

I will post more information after I have experimented with it! Stay tuned!

Friday, February 09, 2007

My Programming Sudoku book translated into French!

Today, I received a little surprise in the mail...I received a copy of my Programming Sudoku book translated into French! ;-) I hope I get the language right, for I do not understand a single word in the book, except my name and the familar screen shots. ;-)

So if there are french readers out there who have read this book, I really welcome your feedback!

Wednesday, February 07, 2007

Course on Windows Mobile 5.0 Programming


UPDATES: Includes coverage of Bluetooth Printing using Zebra Bluetooth Printers!!!

I am conducting a course on Windows Mobile 5.0 Programming on the 11th May 2007. Here are the details:

Course Title: Windows Mobile 5.0 Programming
Topics: RFID, GPS, IrDA Programming (and more!) on the Windows Mobile 5.0 Pocket PC
Date: 11th May 2007
Venue: Symbol Technologies Asia, Inc
Cost: S$299 (if you register before 11th March). S$399 after 11th March. Includes 1 lunch and 2 tea breaks
Register by: 11th April 2007.

To register, please send an email to weimenglee@gmail.com for the registration form. Alternatively, you can download the registration form directly here.

Synopsis
This course will introduce to participants the various techniques to program their Windows Mobile 5.0 Pocket PC devices. Far from being an introductory course, this feature-packed course will show you how to interface with external devices, communicate wirelessly with other devices, as well as access the data of built-in applications (such as Contacts, Outlook Mobile, and Calendar) from within your own.

What You Will Learn

  • How to access the information of your contacts in Contacts
  • How to integrate telephony functions into your application
  • How to connect to serial devices (e.g. GPS, computers) using Bluetooth
  • How to obtain geographical location information using a GPS
  • How to send and receive SMS messages
  • How to capture images using the built-in camera
  • How to perform barcode scanning
  • How to capture signature
  • How to program the IrDA port
  • How to connect to a remote computer using sockets programming
  • How to program RFID
Venue
Symbol Technologies Asia, Inc
230 Victoria Street
#12-06/10
Bugis Junction Office Tower
Singapore 188024

Important Note
You will be required to bring your own notebook computer for the course. The required software will be sent to you one week before the commencement of the course. Please ensure that the required software is installed before attending the course.

Loaner Windows Mobile 5.0 devices will be provided during the course for testing purposes.

Saturday, January 20, 2007

Intercepting the Arrow Keys in a Windows Forms Application

Question
I have a Windows Form populated with a few controls. I want to let the user use the arrow keys to control some of the actions on the window. However, it seems like every time the user presses the arrow key, the controls (such as Button control) on the form receives the event and acts on it instead. How do I disable this behavior?

Answer
By default, special keys (such as Left, Right, Up, Down, etc) are filtered for focus management. That is to say, when you press the one of the arrow keys, Windows will automatically choose the next control on your form and set the focus on it. However, you can override this behavior by writing some code.

If your form has got no controls on it (or has controls that does not handle any keyboard inputs (such as the Panel control)), the easiest way would be to handle the KeyDown event of the form, like the following:

Private Sub Form1_KeyDown( _
   ByVal sender As Object, _
   ByVal e As System.Windows.Forms.KeyEventArgs) _
   Handles Me.KeyDown
        If e.KeyData = Keys.Up Or _
           e.KeyData = Keys.Down Or _
           e.KeyData = Keys.Left Or _
           e.KeyData = Keys.Right Then
            '---perform your own action---
            e.Handled = True
        End If
    End Sub

However, if the form contains controls that handles keyboard input (such as the TextBox and Button controls), then things get a little tricky.

Assuming you have some Button controls on your form and you want to disable the arrow keys having an effect on them. You need to do the following:

  1. Extend the Button control and override the IsInputKey function:

Public Class ExtendedButton
    Inherits Button
    Public Event ArrowClicked(ByVal key As Keys)

Protected Overrides Function IsInputKey( _
   ByVal key As Keys) As Boolean
        Select Case (key)
            Case Keys.Up, Keys.Down, _
               Keys.Left, Keys.Right
                RaiseEvent ArrowClicked(key)
                Return True
        End Select
        Return MyBase.IsInputKey(key)
    End Function
End Class

  1. Programmatically add the extended Button control to your form:

Private Sub Form1_Load( _
   ByVal sender As System.Object, _
   ByVal e As System.EventArgs) _
   Handles MyBase.Load

        Dim b1 As New ExtendedButton
        With b1
            .Text = "Button 1"
            .Location = New Point(10, 20)
            AddHandler .ArrowClicked, _
               AddressOf ArrowClicked
        End With
        Me.Controls.Add(b1)

        Dim b2 As New ExtendedButton
        With b2
            .Text = "Button 2"
            .Location = New Point(100, 20)
            AddHandler .ArrowClicked, _
               AddressOf ArrowClicked
            Me.Controls.Add(b2)
        End With
    End Sub

  1. Define the ArrowClicked event handler:

Public Sub ArrowClicked( _
   ByVal key As Windows.Forms.Keys)
        '---insert code here to do what
        ' you are supposed to do---
        Console.WriteLine("key pressed " & _
           key.ToString)
    End Sub

That’s it! When the user now presses one of the arrow keys, the ArrowClicked event will be fired. You can insert the code to do whatever you are supposed to do here, such as animating some actions on your form, etc.

Friday, January 19, 2007

Apple Confidential 2.0


As you are probably aware, I spend most of my time writing code and exploring new technologies happening in the Windows world. However, several years back I started venturing into the Mac as I was fascinated with the Mac OS X. However, my primary interest on the Mac was still pretty much constrained to using it as an end-user. As a result, I contributed to a few Mac consumer books, such as Mac OS X Unwired, Mac OS X Hacks, Mac OS X Panther Hacks, and Mac OS X Panther in a Nutshell, as well as several articles on MacDevCenter.

I have always been very interested in reading the success stories of companies, and I have a dozen of books on Microsoft, Apple, and Dell. Among all these books, my personal all-time favorite is still Apple Confidential 2.0 (updated edition of Apple Confidential). If you enjoy reading about how the Mac came about (or just anything about Steve Jobs and Steve Wozniak, and all others that played a role in shaping Apple), this book is a very captivating read. It covers Apple’s history since the beginning till the era of the iPod. As this book was published in 2004, it does miss out some of the important events in Apple’s history, such as the transition to Intel platform, the tremendous success of the iPod, and of course, the announcement of the iPhone. But all these do not make the book any less interesting. I especially like the sidebars that appear on almost every page, which provides little snippets of interesting information.

This book will give you a good explanation to the following questions:
  • Why did Apple kill the clones?

  • Heard of Newton? Why is it not around today?

  • How the design of iMac came around?

  • Who is the true father of the Macintosh?

Thursday, January 18, 2007

Programmatically Switch to Another Running Application/Process

Question
In my Windows application, I want to be able to switch to another application running on my computer. For example, I want to switch to Internet Explorer and make it the active window. How do I do that?

Answer
To solve this problem, you need to first obtain the list of processes currently running on your system. You then need to find the required application/process to switch to and then make that window active.

First, import the following namespace:

using System.Diagnostics;

Then, declare the following functions from the user32.dll (yes, you will use P/Invoke to switch the current active window):

    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
           private static extern bool
           SetForegroundWindow(IntPtr hWnd);

        [DllImport("user32.dll")]
           private static extern bool ShowWindowAsync(
           IntPtr hWnd, int nCmdShow);

Define the following constant:

        private const int SW_RESTORE = 9;
     
Assuming that you want to switch to IE, the following function will retrieve the list of processes running, look for IE, and then make it the active window:

        private void SwitchToIE()
        {
            Process[] procs = Process.GetProcesses();
            if (procs.Length != 0)
            {
                for (int i = 0; i < procs.Length; i++)
                {
                    try
                    {
                        if (procs[i].MainModule.ModuleName ==
                           "IEXPLORE.EXE")
                        {
                            IntPtr hwnd =
                               procs[i].MainWindowHandle;
                            ShowWindowAsync(hwnd, SW_RESTORE);
                            SetForegroundWindow(hwnd);
                            return;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("No process running");
                return;
            }
            MessageBox.Show(
               "Internet Explorer is not running");
        }

Voila! If at least one instance of IE is running, you will be able to switch to it; else it will display the message “Internet Explorer is not running”.

Wednesday, January 17, 2007

How to find out the number of lines taken up in a TextBox control?

Question
How do I find out the number of lines taken up in a TextBox control?

Answer
Before we discuss the solution, let's recap that the TextBox control supports multiline using the Multiline property. If you set it to True, then you can span your text input over multiple lines. It also exposes the Lines property (supported only on .NET framework but not .NET CF), where you can check how many lines are stored in the TextBox control. However, the Lines property only reports the number of lines separated by a carriage return character. Hence, if you have a single long line that spans more than the width of the TextBox control, it would still report that you have a single line in it.

To really count the number of lines in it, you have to use P/Invoke.

.NET CF Solution
Declare the functions as follows:

Public Class Form1
<Runtime.InteropServices.DllImport("coredll.dll")> _
Shared Function SendMessage( _

ByVal hwnd As IntPtr, ByVal msg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function

<Runtime.InteropServices.DllImport("coredll.dll")> _
Shared Function GetCapture() As IntPtr
End Function


Then, declare the constant and variable:

Private Const EM_GETLINECOUNT = &HBA
Dim hnd As IntPtr

Finally, do this in your code:

TextBox1.Capture = True
hnd = GetCapture()
TextBox1.Capture = False
Dim linecount as Integer = SendMessage(hnd, EM_GETLINECOUNT, 0, 0)


.NET Solution
Declare the following function:

Public Class Form1
Private Declare Function SendMessageAsLong Lib "user32" _
Alias "SendMessageA" ( _
ByVal hWnd As Integer, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As Integer


Define the following constant:

Private Const EM_GETLINECOUNT = &HBA


Finally, do this in your code:

Dim linecount As Long = SendMessageAsLong(TextBox1.Handle, EM_GETLINECOUNT, 0, 0)






Do you want more information about a prospective babysitter? Searching for an old relative? A people finder website can often help in many ways.

How to programmatically cause your Pocket PC to vibrate

Question:
I have a Pocket PC Phone Edition device and I want to programmatically cause it to vibrate. How do I do that?

Answer:
The easiest way would be to use the Smart Device Framework 2.0. The OpenNETCF's Smart Device Framework is an extension to the .NET Compact Framework (.NET CF) and it fills the gap between the full .NET Framework and its subset - .NET CF.

For Smartphones, you can use the Play() method in the OpenNETCF.WindowsMobile.Vibrate class to start the vibration. Unfortunately, this method only works for Smarthphones. For Pocket PC devices, you have to use the notification led to emulate vibration.

The following code shows how to cause your Pocket PC to vibrate for 0.5 second:

Dim vib As New OpenNETCF.WindowsCE.Notification.Led
'---start vibration---
vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.On)
System.Threading.Thread.Sleep(500)
'---stop vibration---
vib.SetLedStatus(1, OpenNETCF.WindowsCE.Notification.Led.LedState.Off)


The first parameter of the SetLedStatus() method takes in an integer representing the led number. You may need to trial-and-error to find the number that works correctly on your device.

Monday, January 15, 2007

Practical .NET 2.0 Networking Projects

I have an uncoming book to be released on the 29th of this month - Practical .NET 2.0 Networking Projects. This book demonstrates some of the key networking technologies that are being made easily accessible through .NET Framework 2.0. It discusses communication between wired machines and between networks and mobile devices. The book teaches you about the technologies by walking you through sample projects in a straightforward and direct way.
The book begins by discussing background theory so you'll get comfortable with the layout of the .NET Framework and Compact Framework from a networking perspective. Then you'll use the APIs within these frameworks to build a variety of cutting-edge networking applications that cover everything from Bluetooth and RFID communication to sockets programming and chat servers. You'll build working examples for each project, which you can also customize and use for your own purposes. The featured projects cover:
  • Basic introduction to network programming in .NET 2.0
  • Sockets programming
  • Serial communication
  • Bluetooth and GPS
  • Infrared networking to mobile devices
  • RFID

It is available for pre-order now at Amazon.com. Check it out!

Windows Mobile Device Center (a.k.a. ActiveSync)

If you are a Pocket PC (Windows Mobile) user and have been syncing it with your Windows XP computer, you will be in for a surprise when you move to Windows Vista. In Windows Vista, ActiveSync is no longer supported. In place of ActiveSync is Windows Mobile Device Center, which enables you to set up new partnerships, synchronize content and manage music, pictures and video with any Windows Mobile 2003 or Windows Mobile 5.0 powered device. The Windows Mobile Device Center Beta is only supported on Windows Vista RC1 or later.

Applications Switching in Windows Vista

In the previous versions of Windows (XP, 2003, 2000, etc), you press Alt-Tab to switch between applications. One of the frustrations with using the Alt-Tab is that if you have a large number of applications open you have to cycle through each of them one-by-one; you can't simply click to select the application you want to switch to.With Vista, you have two choices:
  • Alt-Tab - You can cycle through all the open applications and click to select the application you want to switch to.
  • Windows-Tab - This will give you a 3-D view of all the open applications. You can also click to select the application to switch to. For this feature, you need to have the Aero Glass enabled.

Using Visual Studio 2005 in Windows Vista

If you are using Visual Studio 2005 in Windows Vista, be sure to update it with the following service packs (in the order shown):

Sunday, January 14, 2007

Building your own PC?

In the last 18 years, I have owned numerous computers and interestingly, of all the machines I have used, only one is factory built (the first PC I own). I still remember the excitement I had the first time I got a PC – that was a IBM-compatible XT (running the Intel 8088 chip), 640KB of memory with two disk drives – one 5.25” and the other 3.5”. Hard disk at that time was a luxury and I just could not afford one. And so I happily programmed on it and even partitioned part of the 640KB as a virtual drive to speed up the performance of the PC. After saving enough money two years later, I finally upgraded the PC to an AT (Advanced Technology) running the Intel 80286 chip. I brought the PC to an upgrade shop and changed the motherboard to an 80286 and added a 40MB (yes, you read it right!) Western Digital hard disk.

At that time, you can “low-level” format, as well as “high-level” format a hard disk. I am not sure what happened then, but after formatting the hard disk, it started making funny noises and stopped working. And so I had to lug the PC down to the repair shop again to change a new one. Fortunately, I managed to change a new one or else I had to folk out another USD$300 for a new hard disk. But that incident made me determined to learn more about the inner workings of my PC and I started to read more about the parts that goes into a PC. Along the way, I bought second-hand parts like casings, hard disks and motherboards and try to assemble them together. I learnt things the hard way – sometimes the parts don’t work together, or are of the wrong dimensions to fit into my casing. But learning through mistakes is the best way to learn. And eventually I was good enough to assemble PCs for friends and made some money to buy more computer books ;-)

Recalling my past experiences, if you want to learn more about the PC hardware you are using, I have the following suggestions:

* Pop into a local hardware shop and immerse in the tech-talk. Get yourself acquainted with the different jargons – ATX, S-ATA, Core 2 Duo, RAID, DDR2, ECC, etc. You may not understand everything the first time you encounter these terms, but trust me – after walking a few more shops you will have a good idea of what each term means.

* When in doubt, ask. Always ask the difference between variations of a product. For example, you can always ask the difference between a P-ATA and an S-ATA hard disk. The shop who is willing to do business with you will be delighted to share more information with you.

* Get a good book. After seeing and touching the hardware, it is always good to find a moment to recap what you have learnt and understand the theory behind it. In the early days, I was always very fascinated with hard disks and I thoroughly enjoyed the “The Hard Disk Survival Guide” by Mark Minasi. Today, I keep the “Building the Perfect PC” (1st and 2nd editions; written by Robert Thompson, Barbara Fritchman Thompson) by my side so that I can always refer to it whenever I need to. Robert and Barbara have done a good job sharing with you their experiences in building the perfect PC for different kinds of tasks. I highly recommend this book as it gives you various advices in choosing the best part for your PC so that you can avoid making the costly mistake yourself. I just wished the book was around when I first started computing.

And the final suggestion is, of course, get your hands dirty!

Tuesday, January 09, 2007

Performing Transactions in Windows Workflow

A transaction-oriented application is one of the common things that developers are tasked with handling, but that doesn't mean it's easy. Transactions are tricky thanks to tricky rollback conditions that must execute flawlessly. Find out why Windows Workflow can take the pain out of building transactions with a visual roadmap.

Input Validation

I demonstrate how to use the validation controls in ASP.NET, as well as how the validation controls have been improved in ASP.NET 2.0.

* Membership required to view the article.

Build Snippets with Code Snippet Editor for Visual Basic 2005

Want to create code snippets for Visual Studio 2005, but don't want to get your hands dirty? I show you how to do it by using the Code Snippet Editor for Visual Basic 2005, a shared source project developed by the Visual Basic developer community.

Building FTP Services Using .NET 2.0

.NET 2.0 provides two new managed classes for performing FTP accesses. With them, you can incorporate FTP into your applications easily. I show you how to perform the most common FTP functions using these two new classes.

Build Your Own Media Center PC, Part 2

Windows Media Center turns your ordinary PC into an all-in-one home entertainment center to watch and record TV programs, play DVDs, listen to music, share your digital photos, and more. In this second part of a two-part series, I show you how to assemble the PC and watch and record TV.

Monday, January 08, 2007

A good resource on Windows development tools

Windows Developer Power Tools: Turbocharge Windows Development with More Than 140 Free and Open Source Tools (Paperback)
by James Avery, Jim Holmes

I am currently reading this book and at close to 1300 pages it is a very comprehensive resource if you are a Windows developer. If you are a Visual Studio developer, then this book is for you as it contains a lot of coverage on .NET related tools and add-ons.

What I am reading now...

iWoz: From Computer Geek to Cult Icon: How I Invented the Personal Computer, Co-Founded Apple, and Had Fun Doing It (Hardcover)
by Steve Wozniak, Gina Smith

Wednesday, January 03, 2007

New Course on .NET 2.0

This month, I am launching a new course on .NET 2.0 (3 days). If your company/school is interested to get jumpstarted in key .NET 2.0 technologies, contact me at wei_meng_lee@hotmail.com for a quote.

Here are the key topics covered:

1) Windows Forms 2.0
2) ASP.NET 2.0
3) ASP.NET AJAX Framework
4) Hands-on Projects
* Mesh-up - Using Google Maps with GPS
* AJAX-enabling an ASP.NET Web site
* Hardware Integration – Incorporating fingerprint recognition into your .NET applications
* Hardware Integration – Incorporating a webcam into your .NET applications