In case you use Qt, this would do the job:
MyClass::MyClass(QWidget *parent)
: QDialog(parent)
{
hide(); // Gui is hidden
createTrayMenu();
}
void MyClass::createTrayMenu()
{
QAction* settingsAction = new QAction(tr("&Settings"), this);
connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()));
QAction* quitAction = new QAction(tr("&Exit"), this);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QMenu * trayIconMenu = new QMenu(this); // Qt parent takes care of freeing
trayIconMenu->addAction(settingsAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
// Create Icon and add to Tray
QSystemTrayIcon* trayIcon = new QSystemTrayIcon(this);
trayIcon->setIcon( setIcon(QIcon(QPixmap("Icon.png"))) );
trayIcon->setContextMenu(trayIconMenu);
}
hide()
removes the GUI.
trayIcon
should be best a class-member, so you can change the Icon easily to reflect the state of your Program.