Wednesday, August 23, 2006

Subclassing

Subclassing is something new I learnt today. To me it looked like a naughty method of inheritance. In simple term subclassing is a technique using which one can intercept the messages send to a window. Once captured these message can be processed, forwarded or cancelled. I call it a naughty method of inheritance since it allows us to tweak/add the functionality of existing windows/controls without rewriting from scratch.

Every window has a message processing function. What we need to do is that replace this with our message processing function. We do this by calling SetWindowLong function and setting the new WNDPROC.

In our managed code, we can derive a class from MessageWindow and override WndProc. This class has a hwnd property (the window handle). We can call this handle in our new message processing function (the one we make in native code), to pass messages to the managed code.

For more: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_subclas3.asp

I used it to capture the smartphone's "Escape" key.

Monday, August 21, 2006

Placing help file link in \Windows\Help directory

Workaround is to create your .lnk file without the “.lnk” extension. This link file needs to be in the PocketPC link file format which is:
numberOfCharactersInTargetFilePath#TargetFilePath

Now put this file in the \Help folder of your cab file project and then rename it to .lnk

If you now notice the cab file, you will see that the lnk file will be placed in the %HelpDir% directory

Descriptive error messages

Today I was stuck reading the same uncommunicative error message while running my PocketPC application.

To see descriptive error message I installed Install System_SR_ENU.cab. The standard installation directory is C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\CompactFramework\2.0\v1.0\WindowsCE\Diagnostics