tags:

views:

63

answers:

4

I am working in a windows application using c#. My application have 5 forms totally. My program controls all the 5 forms to block the user for different reasons they are invoked based on the UDP message my program recieves. Only one form will be UP at one time. I want the behavior of all the forms such like It should block the entire screen and user should not be able to bipass the form untill my program recieves a specific UDP message. [This is Kiosk application and user is blocked from using Alt + Tab and Task Manager]

The problem is, some application parrelley in full screen mode forces my form to go behind. That should not be the case.

I tried using SetWindowPos Function, But not helping.

what will be the other way to do it ?

A: 

You will probably need to look into the WinAPI for controlling all the other windows. When your program needs to be at the front, you're probably going to need to catch all system keyboard events while also enumerating the windows that are open and minimising them.

I would be surprised if those required features were available in the native .Net library, so an api reference is going to be needed.

mrwayne
I already tried using SetWindowPos windows API
Anuya
+1  A: 

Yes, this is expected behavior if you disable all your windows. Windows goes looking for another window to set the focus to and it will select a window of another application if necessary and make that window the foreground window. Your windows will disappear behind it.

Setting your form's TopMost property to True is not a real fix, you'll still lose if another application's window is top-most as well. The real fix is to not set your form's Enable property to False but to disable the controls on that form. Easiest way to do that is to put a panel on that form and move all controls in to it. Set its Dock property to Fill. Set the panel's Enable property to False, all controls will be disabled as well. But not the window.

Btw: don't use UDP for important messages.

Hans Passant
A: 

Maybe you could have a form saying something like "Waiting for X" or something like that that has no close buttons etc and that you pop up when needed as a application modal dialog, that way you avoid the issue with all windows of the app being disabled while at the same time giving feedback to the user of why he can't do anything

ho1
A: 

Guys...using SetWindowPos windows API really helped now. Thanks.

Anuya