Creating Kiosk applications

Erel

B4X founder
Staff member
Licensed User
Longtime User
Sometimes there is a need to "protect" the user from itself and not allow him to quit your application.
These kind of applications are called kiosk applications.
There are three things you should do to create a kiosk application:
  1. The application should be full screen so the user will not be able to reach the Today menu.
  2. Override the hardware buttons functionality.
  3. Put a shortcut for your application under \Windows\StartUp
How it's done?
  1. Use FormLib.FullScreen method.
  2. Use the updated Hardware library. Read the keys values from the registry and catch all the keys.
  3. This can be done in the installation package.
    You need to change line 144 of the SetupBuilder from:
    if chkShortCut.Checked = true then FileWrite(c,AppName & ",0," & lstFiles.Item(e) & ",%CE11%")
    to:
    if chkShortCut.Checked = true then FileWrite(c,AppName & ",0," & lstFiles.Item(e) & ",%CE4%")
    This will create the shortcut under \Windows\StartUp instead of \Windows\Programs
See the attached source code for an example of a kiosk application.
 

Attachments

  • Kiosk.zip
    34.6 KB · Views: 1,111
Last edited:

pallonivel

New Member
Licensed User
Windows Mobile

Hi,

Should this work on Windows Mobile? If I run Kiosk.sbp on my PDA, I can't catch any key presses. Should this work in PDA editor or do I have to create the installation package?
 

Tex8503

Active Member
Licensed User
Longtime User
Hey Erel,
This is really cool and I'm looking at adding this code into my application - I tried to do an implementation for working across multiple forms - but it seems the title and menu bar pop up anytime you're moving amonst the forms. Is there anyway to prevent this?

Thanks!
 

Tex8503

Active Member
Licensed User
Longtime User
Hmm I tried that but the menu and title bar flash up on the screen between form changes. Is there anyway to prevent that ?
 

Cableguy

Expert
Licensed User
Longtime User
Hum, do you really need several Forms?
Is it possible to you to use panels instead?
That way you only set form1 as a FullScreen form, and the "flickering" would not exist, and you can place the same controls on a panel as weel as in a form...Then you only needed to make the right panel visible when needed...

Hope this helps..
 

Tex8503

Active Member
Licensed User
Longtime User
CableGuy - This is a possibility. I didn't even consider that. I'll have to rework some things - but this might work :)
 

Tex8503

Active Member
Licensed User
Longtime User
Erel - Just found another quirky thing with the kiosk code and I don't know if there's a way around it.

I'm now trying to run my application with your kiosk snippet here on a device with Win CE 5.0 and your kiosk code gets rid of the top bar, but not the bottom task bar. Any idea on how I might hide this as well to achieve the same functionality as on a Windows Mobile device?

Thanks!
 

Tex8503

Active Member
Licensed User
Longtime User
No dice. The Task bar disappeared, but it was replaced with a bar of the same height that was the color of the background and all the B4P UI elements appeared behind it. Worse yet, when I exited my application, the tast bar didn't reappear - I had to warm reset the device.

Getting closer though. I'm gonna expierment and I'll post my results if there's anything note worthy.
 

Tex8503

Active Member
Licensed User
Longtime User
I don't know if this helps; my knowledge of Win CE is limited, but there is an option in the taskbar and start menu options to have the task bar 'Always on top' - if this is unchecked, B4P operates in the foreground and the task bar is hidden - which is what I'm looking for.

Maybe this is a setting in the registry ?
 

lupiana

Member
Licensed User
Longtime User
Unistall Kiosk

Hi Erel,
I tried your file Kiosk, but every time I create another program that always appears.
How can I delete it?

How unistall?

Thanks

Lupiana
 

rbsoft

Active Member
Licensed User
Longtime User
I don't know if this will be helpful since I do not have Basic4PPC, but maybe it could point you to the right direction. This is some code that I used way back in eVB. Maybe it can be adapted to Basic4ppc.

B4X:
'Api Declares
Public Declare Function GetSystemMetrics Lib "coredll" ( _
            ByVal nIndex As Long) As Long

Public Declare Function SetForegroundWindow Lib "coredll" ( _
            ByVal hwnd As Long) As Long

Public Declare Function SetWindowPos Lib "coredll" ( _
            ByVal hwnd As Long, _
            ByVal hWndInsertAfter As Long, _
            ByVal x As Long, _
            ByVal y As Long, _
            ByVal cx As Long, _
            ByVal cy As Long, _
            ByVal wFlags As Long) As Long

Public Declare Function ShowWindow Lib "coredll" ( _
            ByVal hwnd As Long, _
            ByVal nCmdShow As Long) As Long

Public Declare Function FindWindow Lib "coredll" Alias "FindWindowW" ( _
            ByVal lpClassName As String, _
            ByVal lpWindowName As String) As Long

Public Const SWP_SHOWWINDOW = &H40
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOPMOST = -1
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5

'This does the job
Sub HideTaskbar()
  hwnd = FindWindow("HHTaskBar", "")
  lRet = ShowWindow(hwnd, SW_HIDE)
  '--- Code to set the form on top.
  lRet = SetForegroundWindow(Me.hwnd)
  lRet = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, _
  GetSystemMetrics(SM_CXSCREEN) + 50, GetSystemMetrics(SM_CYSCREEN), _
  SWP_SHOWWINDOW)
End Sub

Rolf
 

rbsoft

Active Member
Licensed User
Longtime User
@Erel:
In case you comment was addressed to me, I am using Basic4Android. The above Code was written in Embedded Visal Basic (eVB) and uses WindowsMobile API calls. Since I do not have Basic4ppc I could not translate it (if it is possible at all).

But I figured it might help to find directions.

Rolf
 
Top