Skip to main content
gamedev.net
🔒 Locked

WM_KILLFOCUS

Started by _Madman_ Jul 12, 2006 at 9:24 AM 5 replies 1.2k views
Original Post
_Madman_
_Madman_
Is there a way to disable focus stealing under Windows. I have a screen saver that does some nasty stuff in background and in a no way I can alow that someone comes to pc, presses space and gets into still logged account, especialy if it's admins account. Intercepting WM_KILLFOCUS is not working too good. As soon as I call another app the focus goes to it, even if I call SetForegroundWindow upon receiving the WM_KILLFOCUS message...
______Madman
ApochPiQ
ApochPiQ
Erm... there are a heck of a lot of barriers in Windows (the NT-based versions, at least) which are specifically designed to prevent that kind of hijacking. That's why XP Professional provides the Ctrl+Alt+Del login box, for example.

What, specifically, are you trying to do here? If by "nasty stuff" you mean something malicious, don't expect too much help. If on the other hand you just mean really, really hackish code... well, the solution is to unhackify your code [wink]
_Madman_
_Madman_
I kinda need to run Folding@Home like app in a background as soon as pc is idle. But it's not too good when call like system("copy a b") for instance steals focus and leaves it to start menu.

And talking about barriers, isn't screen saver SUPPOSED to be topmost window that dies to password prompt if something touches it just to prevent bad guys from getting access to someones account?
______Madman
ApochPiQ
ApochPiQ
Maybe you should start from the beginning... why are you making calls to system in the first place? What is your app doing that needs to prevent users from using their OS the way it was designed to function? Is it a background app (Folding@Home style) or is it a foreground app that needs to blanket the entire display, as a screensaver would? I'm really not clear on what you're doing or why...
tj963
tj963
Sounds like you could look into creating a hook into the global message queue. If you're not careful you can really slow down the computer, but that's probably what you want

tj963
tj963
_Madman_
_Madman_
I need the app to run in background behind the screen saver and system calls are an easy way to do some stuff safely and easily, why code pages when you can just use what's allready there.
______Madman
ApochPiQ
ApochPiQ
Because system is a legacy call from DOS (or, depending on your point of view, exists for compatibility with the Unixes). In either case it is exceedingly poor practice to be calling system from a Windows application; use the Win32 API or another platform-aware library instead. There's nothing at all wrong with using what's already written (in fact it's a very good habit), but make sure you pick the right stuff [wink]

Further, calls to system will make it impossible to control your app focus precisely and predictably. On the flip side, if you program your app correctly to behave the way it should on the Windows platform, running a background process is very easy - and you will never have these focus problems.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.