Trap Task Manager SwitchTo message

G

Guest

I have an application that when it is locked I activate a password dialog. I
trigger it by adding a message filter.
public class AuthenticationMessageFilter : IMessageFilter
{
private const int SC_RESTORE = 0xF120;
private const int SC_MAXIMIZE = 0xF030;
private const int WM_SYSCOMMAND = 0x112;


public bool PreFilterMessage(ref Message m)
{
bool bKeepLocked = false;
if (m.Msg == WM_SYSCOMMAND)
{
if ((int)m.WParam == SC_MAXIMIZE || (int)m.WParam == SC_RESTORE)
{
...... here do the authentication
}
}
}
}


and activated through:

AuthenticationMessageFilter filter = new AuthenticationMessageFilter();
Application.AddMessageFilter(filter);

This code works great if you switch using either alt-tab or the task bar,
however when you use task manager switch to ---- I cannot for the life of me
figure out what message to trap.

So my question is how do I trap the switchTo message from task manager.

Thanks,
SwedeFlyer
 
J

Jason Newell

Have you tried usng Spy++ to see what messages your window is receiving?

"C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\spyxx.exe"

Jason Newell
Software Engineer
www.jasonnewell.net
 
G

Guest

Yes I get several activate messages to my application for all child windows.
now I guess I could trap one of them looking at my current window state
(minimized if locked) and do the authentication and then ignore the rest of
them. The reason why I am not keen on that approach is that the prefilter
message get all windows messages to the application (mouse_move etc.),
Whatever processing gets done there has to be slim and fast. I guess what I
am looking for is some recipe on how to catch the task manager switch-to
action when it targets your application.
Someone must have solved this already I would think, that's why I posted it.
Cheers,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top