Free book on LINQ, and teaser chapters on ASP.NET AJAX and Silverlight ...
Click Here: Microsoft Press - Visual Studio 2008 Free E-Book Offer
del.icio.us Tags:
Visual Studio,
books
I just helped a customer with a problem he was having with this web application : when correcting an entry in an edit field by pressing the 'back' key, instead of the last character getting deleted and the cursor moving one space to the left, the application would quit. This was very frustrating since the same scenario works with Internet Explorer Mobile. His application is using the Web Browser control to display the web pages that make up his application. The Web Browser control allows you to use the full power of Internet Explorer Mobile, with the ability to provide your own menus and to capture and respond to events from the DOM. The application is running on Window Mobile Standard 6.0 and 5.0. This is an important point since Windows Mobile Professional devices do not have a 'back' key.
'Back' Key causing App to Quit?
So what is going on here? Why does 'back' in the Web Browser control not behave as it does in IE Mobile? By default, the web browser control does not do any special handling of the back key. The default behavior of the back key is to activate the previously top level window in the Z-order. (His application was not actually quitting, it was just going to the bottom of the Z-order.) To duplicate the IE Mobile back key behavior you need to capture the 'back' key press, and forward it to the window that has the focus. Fortunately, the Windows Mobile SDK includes an API to do just that : the SHCMBM_OVERRIDEKEY message and the API SHSendBackToFocusWindow(). I modified the SDK sample miniPie using the code below:
LRESULT CMainWindow::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/,
LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
...
// For devices that have a back key (i.e. Smartphones),
// override the back key since we have an edit control
CWindow(mbi.hwndMB).SendMessage(SHCMBM_OVERRIDEKEY,
VK_TBACK, MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
...
return 1; // Let the system set the focus
}
LRESULT CMainWindow::OnHotKey(UINT uMsg, WPARAM wParam,
LPARAM lParam, BOOL& /*bHandled*/)
{
if (VK_TBACK == HIWORD(lParam)) // Smartphone-only
{
SHSendBackToFocusWindow(uMsg, wParam, lParam);
}
return 0;
}
This is a great deal for Windows Mobile Developers: Free Certification Testing and Code Signing Vouchers. Free Technical Support. These are a couple of the benefits of the just launched Innovate On Windows Mobile site: http://www.innovateonwindowsmobile.com
Enjoy!
Thanks to those of you that attended Reed and my presentation at the Windows Mobile Partner Summit. As promised, here is the PowerShell Script used in the demo. Click Here.
Here is a quick summary of the purpose of this script and how to run it.
Adapt your App: As you know, WM Professional now supports five different screen resolutions and three different DPIs. WM Standard supports two different screen resolutions and two different DPIs. (more info) Professional also supports dynamic screen rotation. The types of screens supported will very likely change in the future. Case in point: the HTC s720 (Standard) is the first Standard device to support dynamic screen rotation!
So how can you quickly test your application on several different screen types simultaneously? You can leverage the Device Emulator Manager or the CoreCon .NET Class: Microsoft.SmartDevices.Connectivity, to test the application. The script here uses the later. For an exhaustive and informative discussion of the Device Emulator Manager, check out Jim Wilson's MSDN article here.
1. The script simply loads three emulator types:
240 x 320 @ 96 DPI, 480 x 640 @ 192 DPI (VGA), and 240 x 240 @ 96 DPI (Square)
I chose these to give good representation of the major screen types available. You could load more, but keep in mind each emulator image takes about 250 MB to load.
2. The script then waits for each image to connect and then copies the executable from the desktop to the emulator.
3. The script then launches the application on the emulator.
4. After the application launches, try pressing the Calendar button to invoke the screen rotation.
How does your app look? How can you fix it? Another great Jim Wilson blog post can help here.
Can you tell why this application does not display properly in the VGA emulator? (The source code can be found in the sample PocketOutlookSample that ships with the WM6 SDK.)
To use this script you will need:
Windows Mobile 5.0 or 6 SDKs Windows PowerShell 1.0 To run the script, from the command line:
powershell .\emulator.ps1 [DeviceTargetDirectory\ApplicationName.exe]
the device application should be in the same directory as the script.
Thanks Loke Uei Tan for the inspiration here.
Hi there! My name is Mike Francis. I've worked at Microsoft for twelve years in various roles including Technical Account Manager for Windows Mobile OEMs, Customer Support Services for C++, and now as an Application Developer Consultant (ADC) working with the Windows Mobile Development community providing advice, support, and best practices to developers worldwide.
In this blog, I plan to share common problems and solutions as they come up while helping you, the Windows Mobile developer community.
What's my primary WM device? Today its the T-Mobile Dash.
Mike Francis