Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

implement locking windows with "always on top" dialog.

Posted on 2002-06-22
7
Medium Priority
?
273 Views
Last Modified: 2008-02-01
Hi,
I'm trying to implement a screen that locks the computer like the windows standard lock screen.
I used a dialog that I open as maximized and allways on top. In this dialog, I implement OnActivate() and every time I'm being deactivated I'm doing SetWindowPos(&wndTopMost,...), so even after ALT+Tab i'm on top.
Now to business: My problem is that although I'm on top after ALT+Tab, the keyboard typings are going to the other application. So I see the lock screen but can write in the application that I can't see.
I tried to mess with SetCapture() and SetFocus() too, but it didn't work.
If you have any other idea about locking the computer like windows but wothout windows lock, I'd like to here that..
BTW, I'm working under Win2k, with VC6 and MFC.

  lidorc
0
Comment
Question by:lidorc
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 450 total points
ID: 7100809
You could use a system-wide hook to filter all keyboard and mouse input - see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_hooks32.asp ("Win32 Hooks")
0
 

Expert Comment

by:weicco
ID: 7102026
Thats pretty impossible. You can set keyboard hooks but so can other processes too.

Keyboard hook can be set by calling SetWindowsHookEx with parameter WH_KEYBOARD_LL. You need DLL file where you set callback that is called when key is pressed. Then you can decide do you want to send that key press to other applications or not.

But if other application has set hook below you, you can't prevent it getting that key press.

If you really want to lock everything, I think you need to implement custom GINA.DLL.
0
 
LVL 22

Expert Comment

by:ambience
ID: 7102719
Did you try SetForeGroundWindow ? does that not help.

[wild thoughts ... ]

Writing a GINA dll is too much work on its own, If nothing helps at all, i would suggest you try DirectInput, sounds stupid but with DirectInput you can have Exclusive access onver input devices, so perhaps while you are locking you can maintains exclusive cooperative level for keyboard and that would also inhibit Alt-Tab (not sure though), but perhaps worth a try.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:weicco
ID: 7103312
Or even more wilder idea, write your own intermediate keyboard driver that blocks all keyboard events when asked.

A little more information on problem would be nice, like what is the basic problem, why do you need this kind of software.
0
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 7112773
how about everytime you lose focus set back the focus on your app?
0
 

Expert Comment

by:weicco
ID: 7115703
Call SetFocus when OS sends you message about focus change, dunno.

But you can prevent focus change by hooking mouse with SetWindowsHookEx. When mouse button is pressed, check if it's pressed over your program's window. If not block the mouse event, otherwise send mouse event to forward with CallNextHookEx.
0
 
LVL 1

Author Comment

by:lidorc
ID: 7152362
thanks jkr,
and sorry everybody for the delyed answer.

   lidorc
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question