Archive Browser
Download AppActivationDemo.zip, last updated 29/12/2013 (11.64 KB)
Download- md5: 3d84cc965982745d60d01044853821d7
 
using System;
// How to be notified when your application is activated and deactivated
// http://cyotek.com/blog/how-to-be-notified-when-your-application-is-activated-and-deactivated
namespace AppActivationDemo
{
  internal partial class MainForm : BaseApplicationForm
  {
    #region Constructors
    public MainForm()
    {
      InitializeComponent();
    }
    #endregion
    #region Overridden Members
    protected override void OnActivated(EventArgs e)
    {
      base.OnActivated(e);
      this.LogEvent("Activated");
    }
    protected override void OnApplicationActivated(EventArgs e)
    {
      base.OnApplicationActivated(e);
      this.LogEvent("ApplicationActivated");
    }
    protected override void OnApplicationDeactivated(EventArgs e)
    {
      base.OnApplicationDeactivated(e);
      this.LogEvent("ApplicationDeactivated");
    }
    protected override void OnDeactivate(EventArgs e)
    {
      base.OnDeactivate(e);
      this.LogEvent("Deactivate");
    }
    #endregion
    #region Members
    private void LogEvent(string text)
    {
      logTextBox.AppendText(string.Format("{0}\t{1}\n\n", DateTime.UtcNow.ToString("hh:mm:ss"), text));
    }
    #endregion
    #region Event Handlers
    private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
    {
      using (AboutDialog dialog = new AboutDialog())
        dialog.ShowDialog(this);
    }
    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
      this.Close();
    }
    #endregion
  }
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate