Click here to Skip to main content
13,139,034 members (53,673 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 16:50pm
Sergey Alexandrovich Kryukov 22-Jan-13 23:15pm
What do you try to achieve?

1 solution

Rate this: bad
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:[^].

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.

Kuthuparakkal 22-Jan-13 23:45pm
Sergey Alexandrovich Kryukov 22-Jan-13 23:49pm
Thank you very much,

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2017
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