Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
I want to know which event is firing in window form(winforms) if the user click on the taskbar. I just tried Activated and Deactivated events and, it's not working.I mean these events are triggering so many times.
Posted 22-Jan-13 17:50pm
sai sagar1.9K
Comments
Sergey Alexandrovich Kryukov at 22-Jan-13 23:15pm
   
What do you try to achieve?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Task bar events are not part of your application at all. They interact with Windows shell, and the shell activate or deactivate your application. You idea about looking into these events was correct, but you cannot say that "it's not working" or "triggering so many times". They are triggered exactly in exactly right way. You "many times" is simply a consequence of your debugging, which naturally contributes to deactivation. To assert the real behavior, use, for example, logging instead of the debugger.
 
So, in a "regular" application you cannot handle these events: they belong to the process "Explorer", not yours. Delete Explorer by "Windows Task Manager", and you will see it (warning! this experiment will require system re-boot).
 
Maybe you need something similar (please see my comment to the question). You can develop your application based on System.Windows.Forms.NotifyIcon: http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx[^].
 
In this approach, the UI will be based on your clicks in the task bar, but on its custom toolbars area (normally on system tray on the right of task bar). You still can use Forms with that.
 
[EDIT #1]
 
Conclusion: most likely, you still need to handle activation events and nothing else. NotifyIcon style is used for applications, which are "special", when it's good to keep an eye on them. Look at the tool bars installed for standard system utilities.
 
[EDIT #2]
 
One important advice if you use NotifyItem and a form. In this case, showing your form(s) in task bar is totally redundant, so use the property System.Windows.Forms.Form.ShowInTaskbar, assign it to false.
 
—SA
  Permalink  
v2
Comments
Kuthuparakkal at 22-Jan-13 23:45pm
   
my5
Sergey Alexandrovich Kryukov at 22-Jan-13 23:49pm
   
Thank you very much,
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 189
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100