WPF in kiosk mode - taskbar troubles
Asked Answered
R

1

4

I'm trying to build an application that needs to lock down access to the PC while it is running. I need to make the app run topmost, in full screen mode, and ensure that alt-tabbing doesn't allow access to other apps or the taskbar.

So far I have set TopMost = true, WindowStyle = WindowStyle.None and WindowState = WindowState.Maximized which achieves most of what I need, but I still get instances where the taskbar becomes visible. I've tried to implement the LostFocus behaviour on the window, but that doesn't seem to give me the behaviour I need.

Can anyone point me in the direction I need to implement this behaviour, please?

Additional Info
Unfortunately, the nature of this project is such that we can't alter the client machines, and they are running a mix of XP, Vista and Win7. The PCs are not owned by us, but are to be used for delivery of content in as secure a manner as possible. The owners of the PCs are aware of the restrictions for running the software, and are happy for them to be "locked down" during execution of our application, but they cannot otherwise be altered.

Other ways
HakonB mentioned Scott Hanselman's BabySmash application, so I went looking for his way of handling the situation. As HakonB says, it isn't the cleanest method of handling lost focus, but it seems to work, or at least should do until I find a better solution. He uses a timer that fires every second, and fires off a call to user32.dll's SetForegroundWindow(IntPtr hWnd) method to grab focus, regardless of whether it has focus or not. Thanks for the heads-up, HakonB!

Retrorocket answered 27/11, 2009 at 12:32 Comment(3)
Do you know that there's a Kiosk version of Windows (I think it's XP Embedded or something)? Maybe that will suite your need :)Electrodynamics
The TaskBar is rendered by Explorer.exe, so you could kill that or prevent it from starting. I vaguely remember there being a registry key that selects the Windows shell — possibly this could be removed so that no shell starts. You would still be able to start Explorer manually using the Task Manager (from Ctrl-Shift-Escape or the Ctrl-Alt-Delete menu).Particularize
Unfortunately, the nature of this project is such that we can't alter the client machines, and they are running a mix of XP, Vista and Win7. The PCs are not owned by us, but are to be used for delivery of content in as secure a manner as possible. I'll update the question, too.Retrorocket
D
4

Take a look at Scott Hanselman's BabySmash. You can find the site at BabySmash

He had a couple of blog entries describing his work to make the application. It features a baby-safe application in kiosk mode.

You can find the project on Codeplex

Durnan answered 27/11, 2009 at 12:39 Comment(2)
I've had a look at BabySmash already, and haven't been able to infer from the code/XAML how he achieved hiding the taskbar in this way. I'll go re-read the blog posts, though, in the hope of enlightenment. Thanks.Retrorocket
He doesn't achieve it as cleanly as I would have liked it: He has a timer that fires once every second and in the timer event he makes sure that his main window is the foreground window. The logic is in the Controller.cs file. Btw, my son didn't break anything while smashing :-)Durnan

© 2022 - 2024 — McMap. All rights reserved.