Hi again JParis,
... So what can you do?
Now we can talk about (Windows-)Services and so on, but I think easiest for you is just to start your app when the Computer starts (Autostart, registry entry) and let it run in the background (only visible for the user through the NotifyIcon).
Just create one app - let one "part" trigger the reminders (watch "events") and the other "part" showing the reminders (BaloonTips).
Use the NotifyIcon instead of the taskbar if your app is minimized.
Autostart your app when Windows starts (could use "AutoStart" or setting the "Run" registry key for your app.
Maybe you want to play arround with the following (runnable) example showing a typical NotifyIcon resisizing and minimizing szenario. I also added some code to read and write the registry "Autostart" entry - You must have rights to access registry (best run as admin)! Otherwise writing to the registry will fail! So whats left is to add your own Icon for the NotifyIcon instead of the one I used to test the example project.
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
namespace NotifyIcon_AutoStartSample
{
static class Program
{
class SampleForm : Form
{
NotifyIcon m_notifyicon;
ContextMenuStrip m_ctxmenuNotify;
ToolStripMenuItem m_miNotifyExit;
ToolStripMenuItem m_miNotifyRestore;
CheckBox m_cbShowInTaskbarWhenMinimized;
CheckBox m_cbAutoRunWithWindows;
public SampleForm()
{
m_ctxmenuNotify = new ContextMenuStrip();
m_ctxmenuNotify.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuNotifyOpening);
m_miNotifyExit = new ToolStripMenuItem("Exit");
m_miNotifyExit.Click += new EventHandler(MenuNotifyExitOnClick);
m_miNotifyRestore = new ToolStripMenuItem("Restore");
m_miNotifyRestore.Click += new EventHandler(MenuNotifyRestoreOnClick);
m_ctxmenuNotify.Items.Add(m_miNotifyExit);
m_ctxmenuNotify.Items.Add(m_miNotifyRestore);
m_notifyicon = new NotifyIcon();
m_notifyicon.Icon = NotifyIcon_AutoStartSample.Properties.Resources.Icon1;
m_notifyicon.Text = Text;
m_notifyicon.Visible = true;
m_notifyicon.Click += new EventHandler(NotifyIconOnClick);
m_notifyicon.ContextMenuStrip = m_ctxmenuNotify;
m_cbShowInTaskbarWhenMinimized = new CheckBox();
m_cbShowInTaskbarWhenMinimized.Text = "Show in Taskbar when minimized";
m_cbShowInTaskbarWhenMinimized.Dock = DockStyle.Top;
m_cbAutoRunWithWindows = new CheckBox();
m_cbAutoRunWithWindows.Text = "AutoStart with windows";
m_cbAutoRunWithWindows.Dock = DockStyle.Top;
m_cbAutoRunWithWindows.Checked = IsAutoRunWithWindowsEnabled();
m_cbAutoRunWithWindows.CheckedChanged += new EventHandler(m_cbAutoRunWithWindows_CheckedChanged);
Controls.Add(m_cbShowInTaskbarWhenMinimized);
Controls.Add(m_cbAutoRunWithWindows);
}
void ContextMenuNotifyOpening(object obj, System.ComponentModel.CancelEventArgs cea)
{
if (WindowState == FormWindowState.Minimized)
m_miNotifyRestore.Text = "Restore";
else
m_miNotifyRestore.Text = "Minimize";
}
void MenuNotifyRestoreOnClick(object obj, EventArgs ea)
{
if (WindowState == FormWindowState.Minimized)
{
Visible = true;
WindowState = FormWindowState.Normal;
Activate();
}
else
{
WindowState = FormWindowState.Minimized;
}
}
void NotifyIconOnClick(object obj, EventArgs ea)
{
MouseEventArgs mea = ea as MouseEventArgs;
if (mea.Button != MouseButtons.Left)
return;
if (WindowState == FormWindowState.Minimized)
{
Visible = true;
WindowState = FormWindowState.Normal;
}
Activate();
}
void MenuNotifyExitOnClick(object obj, EventArgs ea)
{
Close();
}
protected override void OnResize(EventArgs ea)
{
if (!m_cbShowInTaskbarWhenMinimized.Checked)
{
if (WindowState == FormWindowState.Minimized)
Visible = false;
}
base.OnResize(ea);
}
protected override void OnClosed(EventArgs ea)
{
base.OnClosed(ea);
if (m_notifyicon != null)
m_notifyicon.Dispose();
}
void m_cbAutoRunWithWindows_CheckedChanged(object sender, EventArgs e)
{
SetAutoRunWithWithWindows(m_cbAutoRunWithWindows.Checked, String.Empty);
}
static public bool SetAutoRunWithWithWindows(bool bEnable, string strArgs)
{
RegistryKey regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (regkey == null)
return false;
string strPath = Application.ExecutablePath + (String.IsNullOrEmpty(strArgs) ? String.Empty : " " + strArgs);
if (bEnable)
{
regkey.SetValue(Path.GetFileNameWithoutExtension(Application.ExecutablePath), strPath, RegistryValueKind.String);
}
else
{
regkey.DeleteValue(Path.GetFileNameWithoutExtension(Application.ExecutablePath), false);
}
return true;
}
static public bool IsAutoRunWithWindowsEnabled()
{
RegistryKey regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
if (regkey == null)
return false;
if (!String.IsNullOrEmpty((string)regkey.GetValue(Path.GetFileNameWithoutExtension(Application.ExecutablePath))))
return true;
return false;
}
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SampleForm());
}
}
}
I hope this helps you in deciding what to do for your app - feel free to ask if you have any further questions.
Kind regards Johannes