Windows Mobile: Kiosk Mode Series, part 1

Print This Post Print This Post

Hello

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 CSharp 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, dont 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 what we can do to hide the Start icon for a new form:

        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() save 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 dont 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:

        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.

        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.

Download LockDown.cs: DOWNLOAD:LockDown.cs - (Hits: 1374, size: 2.19 kB)

5 Comments

  1. Sebastien P. says:

    Thank you a lot ! Your blogpost and your provided code save my day (and my end user software experience). I am making a PDA inventory system on Windows Embedded Handheld (6.5.3) and I was struggling with its OS Form system (the “close” button that does not close the form but minimize it…) : I couldn’t manage to catch a minimize event to free ressource so I was scared about not being able to control user interactions with standard OS button tiles. The solution : Wipe them out ! Thank to your article and particularly the focus on the temporary registry modification, I will be able to serve an application much more robust.

    I will continue to follow your blog.

    Sebastien.

  2. Jason says:

    Thank you for this article. This has solved an issue I was having with some barcode scanning software on newly delivered 6.5 units. We’d been on 6.1 up until now but the supplier has now updated them. The solution works well and cleans up the screen a lot.

    Your class file is great and I’ve re-used the concepts in my application.

    Thanks again, great blog!!

  3. Rozy says:

    Hi,

    I want to hide status bar on smart device application(only want full screen page ) .

    i went through your blog, now i understood i can hide with this code.

    I downloaded code and added in application
    But don’t know how to implement this code in application.

    Kindly please help me to get resolve this issue.

    Many thanks in advance.
    I am new in this programming.

    Regards,
    Rozy Singhani

  4. josef says:

    Hello Rozy

    just follow the code described with “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”. That is the menu item Maximize click handler code that shows how to make fullscreen.

    ~Josef

Leave a Reply