Click here to Skip to main content
15,885,365 members
Articles / Mobile Apps / Windows Mobile

Windows Mobile: Kiosk Mode Series: Part 1

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
20 May 2012CPOL3 min read 22.5K   6   1
How can you achieve a kiosk mode application, where the user is only allowed to do what you define.

I would like to start a series of articles of how you can lockdown your application user in your application. How can you achieve a kiosk mode application, where the user is only allowed to do what you define.

The first article is about the Windows Start and Done Icon in menu bar and about fullscreen. You may already know how to hide the start and done icon permanently from a Windows Embedded Handheld (Windows Mobile 6.5.3) device: Link

But there is also a temporary way using the same approach. The trick is to change the registry keys, that make the OS believe you have hardware buttons for Start and Done, before you show your C# form.

Before Windows Embedded Handheld (WEH, or Windows Mobile 6.5.3), you are able to use SHFullScreen API calls. But this will not work with WEH. Neither the flags SHFS_HIDESIPBUTTON nor SHFS_HIDESTARTICON will work. The LockDown.cs class also includes code for that and you may test the functions with the Test-Application.

The class I am talking about is called LockDown. There is also a Test-Application (OEMTitleBarHandler, don't ask me about the name selection) to test all functions I will describe.

Left is Windows Mobile 6.1 and right image shows Windows Embedded Handheld 6.5.3! You can use the ShFullScreen menu on both, but it will only work with Mobile 6.1. But the test “Form without StartIcon” will bring up a form without Start button.

OK, let’s look at what we can do to hide the Start icon for a new form:

C#
private void mnuStartIconTestForm_Click(object sender, EventArgs e)
{
  Lockdown.LockDown.SaveRegistryFullScreen();
  Lockdown.LockDown.SetRegistryFullScreen(true, false, false);
  LockDownTestForm frm = new LockDownTestForm();
  frm.ShowDialog();
  Lockdown.LockDown.RestoreRegistryFullScreen();
  frm.Dispose();
}

The function SaveRegistryFullScreen() saves the state of the registry values of TextmodeEnabled, HardwareStartKeyEnabled, and HardwareDoneKeyEnabled below “HKLM\SOFTWARE\Microsoft\Shell\BubbleTiles”.

The function SetRegistryFullScreen(bool bStartButtonPresent, bool bDoneButtonPresent, bool bTextMode) sets the registry key according to the args. So, if bStartButtonPresent is set to true, the registry value of HardwareStartKeyEnabled is set to 1. With this setting, the next form or window is shown without Start button. Easy, isn’t it. The other args work similar.

RestoreRegistryFullScreen will restore the registry to the state saved with SaveRegistryFullScreen().

How can you remove all buttons that enable the user to quit or minimize a form? To show a compact framework form with or without Done or Minimize buttons, you just have to set the right properties of the form. But don't forget to give the user an option to get back from a form.

The ControlBox property switches the (X)/ (OK) button display. The clicking an (OK) button will close and exit a form or application:

C#
private void mnuControlBox_Click(object sender, EventArgs e)
{
  if (this.ControlBox)
  {
    //show the (X) button, hide OK button
    this.ControlBox = false;
    mnuControlBox.Checked = false;
  }
  else
  {
    //remove the (X) button in title, show the OK button
    this.ControlBox = true;
    mnuControlBox.Checked = true;
  }
}

The MinimizeBox property of a compact framework form switches the (OK) button to a (X) button. Where (X) stands for minimize window.

C#
private void mnuMinimizeBox_Click(object sender, EventArgs e)
{
if (this.MinimizeBox)
{
//hide minimize button (OK)
this.MinimizeBox = false;
mnuMinimizeBox.Checked = false;
}
else
{
//show minimize button (OK)
this.MinimizeBox = true;
mnuMinimizeBox.Checked = true;
}
}

The Test application has also menu options to test these properties as “Window Options”.

The menu option Maximize shows the testform maximized (oh, wonder), but that means only, that the taskbar at the top is hidden and the client area is larger. If you additionally set the menu to null, you will get a real full screen form:

You have to press the Escape key (hopefully you have one) to bring the menu back in the test application.

The class file LockDown offers some more functions, but these are left for another article.

The whole code with the test application is available here. You need a subversion client like TortoiseSVN or AnkhSVN to checkout the source code.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Royston Rodrigues30-Jun-12 18:01
Royston Rodrigues30-Jun-12 18:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.