Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Trap Task Manager SwitchTo message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SwedeFlyer - 19 Sep 2007 16:22 GMT
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
Jason Newell - 20 Sep 2007 21:00 GMT
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

> I have an application that when it is locked I activate a password dialog.  I
> trigger it by adding a message filter.
[quoted text clipped - 30 lines]
> Thanks,
> SwedeFlyer
SwedeFlyer - 20 Sep 2007 21:18 GMT
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

> Have you tried usng Spy++ to see what messages your window is receiving?
>
[quoted text clipped - 38 lines]
> > Thanks,
> > SwedeFlyer

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.