Blog

  • MOTODEV Summit

    Following on from the developer contest I mentioned a while ago, Motorola are running a series of developer summits later this year. They will be covering development across their range of platforms and devices, including Windows Mobile. They will have a UK event in London on the 9th of November, which conflicts with Tech Ed Developers 2007 in Barcelona which I’m already committed to – more details on that to follow…


    Full details – MOTODEV Summit

  • System.Media.SoundPlayer versus the PlaySound API

    In .NETCF v3.5 there is a new namespace – System.Media which brings audio support to the Compact Framework. Previously the common way to add sounds to your application was to use the PlaySound API (either P/Invoking yourself or using one of many wrappers). Now that the framework itself has built-in support, which matches the desktop .NET v2.0 framework it makes sense to standardise on the SoundPlayer component.


    There are some differences in behaviour which you’ll need to be aware of. When you specify a filename this doesn’t simply call through to the native APIs passing the filename, the file is first loaded into memory and then the WaveOut APIs are used to play it. This means that if you simply create a new SoundPlayer and call Play the file will not be loaded, the Play method will have to first load the file contents, and then play the sound. This will create a noticable delay before the sound is heard. The class allows you to load the file at any time prior to calling play – you can use either Load or LoadAsync to do this. Once the file is loaded the Play method will be able to immediately begin playing the file. Exactly where you call the Load/LoadAsync method will depend on your application design. Keeping a large audio file cached will tie up valuable memory, you should dispose of the SoundPlayer instance once you have finished with it.

  • Using the UnInstall Configuration Service Provider

    Among the Configuration providers in Windows Mobile is one which allows you to programmatically uninstall package from the device. The UnInstall provider is documented here:-


    http://msdn2.microsoft.com/en-us/library/aa455977.aspx


    To see if your package can be uninstalled you send the following XML – e.g. using DMProcessConfig.XML or ProcessConfiguration in managed code.


    <wap-provisioningdoc>
       <characteristic type=”UnInstall”>
          <characteristic-query type=”YourAppName”/>
       </characteristic>
    </wap-provisioningdoc>


    Replacing YourAppName with the name of your installation package usually “CompanyName Product” as defined in your device CAB project. The response will look something like this if the package name is found:-

    <wap-provisioningdoc>
    <characteristic type=”UnInstall”>
    <characteristic type=”YourAppName”>
    <parm name=”uninstall” value=”0″/>
    </characteristic>
    </characteristic>
    </wap-provisioningdoc>

    Then you can uninstall the package using:-


    <wap-provisioningdoc>
       <characteristic type=”UnInstall”>
          <characteristic type=”YourAppName”>
             <parm name=”uninstall” value=”1″/>   
          </characteristic>
       </characteristic>
    </wap-provisioningdoc>

  • Desktop ActiveSync Registry Settings

    In March I showed how to get the version of a connected device from the desktop. This post documents the rest of the registry settings used to store device information. There are two registry locations, the first at HKEY_CURRENT_USERSoftwareMicrosoftWindows CE Services contains information about the currently connected device. The second, HKEY_CURRENT_USERSoftwareMicrosoftWindows CE ServicesPartners contains information for each of the partnerships established on the desktop PC.


    When the device is docked, regardless of whether a partnership is established, the following keys are populated in HKEY_CURRENT_USERSoftwareMicrosoftWindows CE Services:-



    • DeviceHardwareId -String containing a unique Guid for the device

    • DeviceOemInfo – OEM specific string (as returned by SystemParametersInfo using SPI_GETOEMINFO) e.g. WIZA200 (HTC Wizard)

    • DeviceProcessorType – DWORD value – 2577 (ARM) for all Windows Mobile devices

    • DeviceType – string containing platform type (as returned by SystemParamtersInfo using SPI_GETPLATFORMTYPE) e.g. PocketPC or SmartPhone

    • DeviceVersion – DWORD value – see my previous post.

    The partnerships are stored with a unique DWORD partnership id e.g.


    HKEY_CURRENT_USERSoftwareMicrosoftWindows CE ServicesPartners12345678


    There are additional values to describe sync behaviour and some Windows Mobile Device Center specific values e.g. to specify the display icon for a device. Otherwise all of the above values are duplicated here for the partner device, except with some naming differences:-



    • DeviceHardwareId

    • OemInfo

    • ProcessorType

    • DeviceType

    • Version

    Each partnership has a directory containing any resources used, this includes the icon etc. The path is retrieved from the DataFolder value. This is a path beneath the users roaming application data folder which you would get using System.Environment.GetFolder(System.Environment.SpecialFolder.ApplicationData)


    The icon is specified in DeviceIconFile and if you append this to the path you’ll have the full filename of the icon.

  • Skydriving

    Windows Live Folders is now Windows Live Skydrive and the beta has been extended to locales outside the US. The service provides a free 500mb of online storage for you to use however you want. Beyond the new look and feel and new name there is one great addition – a drag and drop upload tool which makes it much easier to upload multiple files. Previously you had to browse for files individually and upload in batches of 5. This is a great addition to the other Live services and gives you somewhere handy to store your own files online, as well as share public files with others.

  • Multiline Button

    On the newsgroup somebody asked how to have multiple lines of text on a .NETCF Button control. The native control supports this but the appropriate style is not set by default. The following code snippet shows how to enable this:-


    private const int BS_MULTILINE = 0x00002000;
    private const int GWL_STYLE = -16;

    [System.Runtime.InteropServices.DllImport(“coredll”)]
    private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

    [System.Runtime.InteropServices.DllImport(“coredll”)]
    private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

    public static void MakeButtonMultiline(Button b)
    {
        IntPtr hwnd = b.Handle;
        int currentStyle = GetWindowLong(hwnd, GWL_STYLE);
        int newStyle = SetWindowLong(hwnd, GWL_STYLE, currentStyle | BS_MULTILINE);
    }


    The usage is simple, just pass the specific Button control to MakeButtonMultiline:-


    MakeButtonMultiline(button1);


    Here is what the amended button looks like on the left (default appearance on the right)




    The designer fully supports entering multiple lines for the Button Text property, just click the dropdown at the end of the field and it will pop up a window into which you can add linebreaks with your text.

  • More POOM Anomalies

    Every version of POOM (Pocket Outlook Object Model) brings great improvements, however there are always a few things which just have you screaming “Why!”. One of those examples is the implementation of IItem::Edit. This method is used to open an item in edit mode, and is implemented on Windows Mobile 5.0 and above, with the exception of Appointments on Smartphone (Standard) devices. This makes no sense because otherwise the Appointment item follows the same pattern as the other item types. A dialog is implemented on the Smartphone/Standard platform and this has a perfectly usable edit screen – why this wasn’t implemented in the API beggars belief. Below is a table of supported configurations for the various display methods:-

































































    Method WM 5.0 Pocket PC WM 5.0 Smartphone WM 6 Professional WM 6 Standard
    IAppointment::Display() Yes No Yes No
    IContact::Display() Yes No Yes No
    ITask::Display() Yes No Yes No
    IItem::Display() (Appointment) Yes Yes Yes Yes
    IItem::Display() (Contact) Yes Yes Yes Yes
    IItem::Display() (Task) Yes Yes Yes Yes
    IItem::Edit() (Appointment) Yes No Yes No
    IItem::Edit() (Contact) Yes Yes Yes Yes
    IItem::Edit() (Task) Yes No* Yes Yes

     


    *WM5.0 Smartphone Tasks application doesn’t support editing

  • More Facebook Progress

    I’m now a member of the CodePlex workspace for the Facebook Developer Toolkit. I’ve been working on porting across my modifications into the codebase. The .NETCF v2.0 version uses a project called Facebook.Compact but refers to the existing source files from the desktop project. Then some conditional compilation is used to hide a few unsupported features from .NETCF and implement some workarounds for missing functionality. This will be a familiar technique if you’ve been to Daniel‘s sessions (or read his blog posts on the subject). It’s not quite working yet since my code made use of a couple of my own libraries for speed, so I’ll need to implement a few of the features within those in the Facebook.Compact project.

  • Facebook API and the Compact Framework

    The Facebook API allows third-party web and desktop applications to interact with Facebook features. There is an excellent shared-source library for .NET to wrap the Facebook calls but currently it only supports the full framework. I did some work converting this source to compile and run on .NETCF v2.0. There are some example screens here of the login process, and pulling back information about our book group.


       


    Since the login screen uses the same page as the desktop it’s not a great fit on a Pocket PC screen, so that’s an area for improvement.