开发者

Port Windows CE app to Windows Mobile

开发者 https://www.devze.com 2022-12-18 17:02 出处:网络
I have a rather complex application that was originally built for Windows CE (using Visual Studio 2008, C# 2.0).I\'m now trying to get it to run on a Windows Mobile device.There are a few UI quirks, h

I have a rather complex application that was originally built for Windows CE (using Visual Studio 2008, C# 2.0). I'm now trying to get it to run on a Windows Mobile device. There are a few UI quirks, however. I notice that the background color is all white and there doesn't appear to be any borders around a lot of the controls like there is on WinCE. However, my bigges开发者_C百科t issue is that my application seems to take up the full screen so I can't see the top task bar with the start menu and the click (and presumably the close button for my app?). I also can't see the bottom bar (taskbar?) that normally has the icon to show/hide the keypad.

My form is set to maximized on CE so it should take most of the screen space but not the taskbar(s). I've noticed that Visual Studio prompts for the target platform (either Windows CE or Windows Mobile) when creating a new smart device project. I really hope that I don't have to recompile my application to work properly on Windows Mobile.


On Windows Mobile setting your form's WindowsState property to FormWindowState.Maximized will cause the form to become fullscreen covering the nav bar at the top etc.

I have done a lot of Windows Mobile <--> Windows CE porting and in general if I need to resolve differences like this I end up setting the applicable properties at runtime after I've performed a platform detection check.

Using .NET CF 3.5 you could end up with something like the following:

using Microsoft.WindowsCE.Forms;

if (SystemSettings.Platform == WinCEPlatform.WinCEGeneric)
  this.WindowState = FormWindowState.Maximized;
else
  this.WindowState = FormWindowState.Normal; // Pocket PC or Smartphone

Luckily there are not too many cases where such differences pop up.

With respect to Visual Studio prompting you to select the target platform, for the most part (atleast for.NET CF based projects) this simply changes the list of emulators and controls from the form designer toolbox that you are able to select.

In most cases you should be able to build your application against one platform and run the resultant executable on another.

One handy use of this feature is the fact that it will provide you with warnings if you attempt to use something not supported by a particular platform. For example selecting a smartphone platform will issue warnings if you attempt to use System.Windows.Forms.Button controls, since these are not supported on smartphone (non touch screen) devices.


As you have found out by now, Windows Mobile apps have a little less screen estate than Windows CE. You will have a top and bottom bar and sometimes an additional bottom bar for tray icons.

To get around this problem you should do a platform check and then make your form smaller if it's windows mobile. If you can't do that without making changes to the form (like in most of my cases) you can try to utilise the soft keys and get rid of any buttons, checkboxes etc. The soft keys can act as buttons or they can be menus and even menus inside menus if you want.

Don't worry much about the target platform if you already have a working app in Windows CE. You don't have to switch to Windows Mobile, although you will get access to the emulators and the supported controls in the toolbox as have been pointed out already.

0

精彩评论

暂无评论...
验证码 换一张
取 消