CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: password protect application icon in system tray?

  1. #1
    Join Date
    Jul 2012
    Posts
    6

    Exclamation password protect application icon in system tray?

    Hello, I have written an application which by default starts in the system tray. I would like to password protect the application such that whenever anyone either double-clicks on the icon, or does a right click on it, a password confirmation popups up, and does not allow the user to access the application until the password matches. However, the password should not be shown whenever the application itself starts (startup with windows), only when mouse click actions are performed on it.
    Anyone can help me with this?

  2. #2
    Join Date
    Apr 2010
    Posts
    131

    Re: password protect application icon in system tray?

    Set a flag (like a global bool) to "false" in the initial code/construct. Then, in the load event, set it to true. Then, attach an if/then to your resize event:

    if(global.shouldShowPasswordForm){
    //show password form
    }

    Set global.shouldShowPassordForm (a static member of a static class) to true when the program is minimized to the taskbar, and false while it is not. This will allow the program to load without showing the screen, and to be resized/minimized without the screen, as well - only showing it when the program is resized up from the taskbar. Hope this helps!

  3. #3
    Join Date
    Jul 2012
    Posts
    6

    Re: password protect application icon in system tray?

    thanks for the insight, however am having trouble with my app, since it does not have any form, just a Component class acting as a container for a context menu, where my app resides in the system tray, and right-clicking on it brings up the context menu with its associated option. Its this right click that should be password protected (well I think - sorry my knowledge in C# is very poor as am still learning around)

  4. #4
    Join Date
    Apr 2010
    Posts
    131

    Re: password protect application icon in system tray?

    I'd think you'd have to bring up a form for the login, unless that's being handled by the component. Either way, the logic would be the same:

    1) Set a boolean to true when the container is firt loaded, after minimization;
    2) On click (or whatever event you are monitoring to pull up the context menu), check if boolean is true, if it is, then fire your login logic. If false, skip the login logic and show the menu;
    3) Set boolean to false so login logic does not fire again until you want it to;
    4) when you want it to, set boolean to true again;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)