Sunday, March 25, 2007

Windows Mobile 6 SDK Released

The new Windows Mobile 6 SDK's have now been released, codenamed "Crossbow".

The names have changed again though!

The Smartphone is now named: Windows Mobile Standard

The Pocket PC / Windows Mobile is now named: Windows Mobile Classic

The Pocket PC / Windows Mobile Phone Edition is now named: Windows Mobile Professional

Download:
http://www.microsoft.com/downloads/details.aspx?familyid=06111a3a-a651-4745-88ef-3d48091a390b&displaylang=en

Implementing Tap and Hold funtionality in CF

When creating your own user control maybe an owner drawn list of items in either CF1 or CF2 you might want to implement the standard Windows Mobile tap and hold little red dots that appear can be achieved by P/invoking SHRecognizeGesture which can be found in the aygshell.dll module.

The following code shows how this can be achieved. You would typically call the ShowMenu() method from an OnMouseDown event in your user control.



using System;

namespace RecognizeGesture
{

public class RGesture
{
///
/// Structure used by SHRecognizeGesture
///

internal struct SHRGINFO
{
public int cbSize;
public IntPtr hwndClient;
public int ptDownX;
public int ptDownY;
public SHRGFLags dwFlags;
}

///
/// SHRGINFO flags
///

[Flags]
internal enum SHRGFLags
{
SHRG_RETURNCMD = 0x00000001,
SHRG_NOTIFYPARENT = 0x00000002,
///
/// use the longer (mixed ink) delay timer
/// useful for cases where you might click down first, verify you're
/// got the right spot, then start dragging... and it's not clear
/// you wanted a context menu
///

SHRG_LONGDELAY = 0x00000008,
SHRG_NOANIMATION = 0x00000010,
}

[DllImport("aygshell")]
extern private static int SHRecognizeGesture(ref SHRGINFO shr);

private void ShowMenu()
{
SHRGINFO shr = new SHRGINFO();
shr.cbSize = Marshal.SizeOf(typeof(SHRGINFO));
shr.dwFlags = SHRGFLags.SHRG_RETURNCMD;
shr.ptDownX = x;
shr.ptDownY = y;
shr.hwndClient = Handle;

//Ask shell to track the gesture.
int ret = SHRecognizeGesture(ref shr);

//If user used tap-and-hold - track popup menu.
if (ret == 1000)
{
//Display menu.
}
}
}
}

Monday, March 19, 2007

Obfuscating CF Code

Many people have complained time and time again about the .NET Obfuscator that comes with Visual Studio (2003 and 2005) not working effectively with CF applications. I too have had my applications running and working until I obfuscate it using the tool that comes with VS and then my app doesn't behave correctly...

Well.... believe it or not but there are loads of .NET obfuscator tools available out there, I admit not free, but you get what you pay for in life ;)

Once you have obfuscated your code, you can use a free tool such as Reflector to check the results.

See this link: http://www.howtoselectguides.com/dotnet/obfuscators/

Executing a CAB file for Windows Mobile Devices

After recently wanting to do this I couldn't find much information about it on the web with regards to command-line parameters etc.

WCELOAD.exe is the application required to install CAB files for Windows CE. It is located in the \Windows directory.

/noui - Specifies no user interface while the install is taking place.

/noaskdesk - Do not ask the user where to install the application (Storage card, RAM).

/nouninstall - Specifies that the application cannot be removed. No .unload file will be created if this flag is set.

An example of the command could be:
\windows\wceload /noui /noaskdesk \Storage card\myapp.cab.

Note: If the /nouninstall flag is not set, an .unload file is created in the \Windows directory which has this naming convention: .unload.


This is a useful link that contains more information on the subject:
http://msdn2.microsoft.com/en-us/library/ms933760.aspx