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
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.
: most likely, you still need to handle activation events and nothing else.
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.
One important advice if you use
and a form. In this case, showing your form(s) in task bar is totally redundant, so use the property
, assign it to false.—SA