I have a WPF app that runs in the System Tray. It is based on the NotifyIcon project (http://www.codeproject.com/Articles/36468/WPF-NotifyIcon).
I need to get it to respond to the WM_CLOSE command that is issued by the taskkill /IM
command (that is run from the command line).
Does anyone know what method I need in my app to respond to WM_CLOSE ?
UPDATE
I should have made clear, for a system tray app, there might not be a window present.
I tried adding onClosing
to the Window object. However if I issue taskkill /IM ...
it only gets fired if the window is open.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
base.OnClosing(e);
}
So I guess I need something on the application. For the application, I have tried overriding OnExit
and the Exit
event - but neither got triggered.