Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make form system modal using C#?

Tags:

c#

.net

security

I need to show form as top level system-wide, e.g. over /all/ other windows on screen. I do realize this is usually /bad UI practice/, but I have very specific scenario in mind.

We intend to use normal Windows PCs for POS cash registrators. There is an option on the screen to open cash drawer. It would be rather bad for someone just to press something on a screen and get access to money when clerk isn't looking. So we equiped PCs with RFID readers and each clerk has his/her own RFID card which will be used for authentication.

I need however an mechanism to lock the computer (or make it unusable) when clerk goes away. Logging off seems too much of a nuisance.

Any ideas welcome.

LP, Dejan

like image 528
Dejan Stanič Avatar asked Jul 23 '09 09:07

Dejan Stanič


People also ask

How do you show a modal form?

To display a form modally use the ShowDialog method.

What is a system modal?

A systems model is a collection of elements that are interconnected in some specific way.

What is ShowDialog C#?

ShowDialog() Shows the form as a modal dialog box. ShowDialog(IWin32Window) Shows the form as a modal dialog box with the specified owner.

How do I show modal popup from code behind?

Add logic to the click event to re-open the modal after the post back OR look for an alternative method of posting back to the server such as using AJAX. If you want to do it via AJAX, remove the OnClick event from the button. Add a [WebMethod] to your code behind and call that webmethod using $. ajax.


1 Answers

Well, after a day of trial and error I came to sort of solution.

It involves the following steps:

1. When "Lock" button is pressed new (empty) /desktop/ is created. Program is run in this desktop with full screen form and login procedure. There is nothing else to switch to or run on this desktop.

2. Task manager is disabled via registry. Of course, somebody uninvited can still access the Ctrl-Alt-Delete menu, but there is nothing of particular harm he can do there.

3. Alt-F4 and such are disabled.

4. When authentication is made, program switches back to original desktop and everything proceeds as normal.

There is some P/Invoking required, of course. If someone wants to do something similar, perhaps s/he will find my bare bones example helpful - link text

LP, Dejan

like image 127
Dejan Stanič Avatar answered Oct 02 '22 08:10

Dejan Stanič