Creating Kiosk applications

Discussion in 'Code Samples & Tips' started by Erel, Jul 1, 2007.

  1. Erel

    Erel Administrator Staff Member Licensed 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.
     

    Attached Files:

    Last edited: Jan 14, 2008
  2. lee inmo

    lee inmo New Member Licensed User

    HI:)

    GOOD
    thank you
     
  3. pallonivel

    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?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It works on most devices. However it tries to read the keys from the registry. It is possible that on your device the registry is a bit different.
     
  5. Tex8503

    Tex8503 Active Member Licensed 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!
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You need to create one FormLib object for each form:
    Code:
    flb.New1("Form1",B4PObject(1))
        flb.FullScreen(
    True)
        flb2.New1(
    "Form2",B4PObject(1))
        flb2.FullScreen(
    True)
        ...
     
  7. Tex8503

    Tex8503 Active Member Licensed 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 ?
     
  8. Cableguy

    Cableguy Expert Licensed 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..
     
  9. Tex8503

    Tex8503 Active Member Licensed User

    CableGuy - This is a possibility. I didn't even consider that. I'll have to rework some things - but this might work :)
     
  10. Tex8503

    Tex8503 Active Member Licensed 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!
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Please download the attached Hardware library. It contains a new method named "HideTaskBar".
    Call it and see if it works.
     

    Attached Files:

  12. Tex8503

    Tex8503 Active Member Licensed 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.
     
  13. Tex8503

    Tex8503 Active Member Licensed 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 ?
     
  14. Tex8503

    Tex8503 Active Member Licensed User

    Hey Erel,
    I was wondering if you had any more luck on this?

    Thanks!
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    Sorry but no.
     
  16. lupiana

    lupiana Member Licensed 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
     
  17. rbsoft

    rbsoft Active Member Licensed 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.

    Code:
    '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 StringAs 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, 
    00, _
      GetSystemMetrics(SM_CXSCREEN) + 
    50, GetSystemMetrics(SM_CYSCREEN), _
      SWP_SHOWWINDOW)
    End Sub
    Rolf
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    Are you using Basic4ppc or Basic4android?
     
  19. rbsoft

    rbsoft Active Member Licensed 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
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    It was addressed to lupiana. I'm pretty sure that it was meant to be asked in Basic4android forum.
     
Loading...