Solved

implement locking windows with "always on top" dialog.

Posted on 2002-06-22
7
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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

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!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

627 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