Solved

implement locking windows with "always on top" dialog.

Posted on 2002-06-22
7
260 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 150 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now