

With ISysTray it is possible to show a program icon in the sytsem tray...
And you can create a menu for this system tray icon...
Code: Select all
//! create and show system tray menu
void showSysTray(HINSTANCE hInstance){
static HINSTANCE hThisInstance = 0;
if(hInstance) hThisInstance = hInstance;
if(!sysTray && hThisInstance){
//! create System-Tray-Icon
sysTray = createSystemTrayIcon(hThisInstance, TRAY_ICON_ID, "Tray-Test", &tray_Callback);
if(sysTray){
//! create the menu
sysTray->addMenuItem(1001, "sub 1");
sysTray->addMenuItem(1003, "sub 2", 1001);
sysTray->addMenuItem(1004, "item 1", 1003);
sysTray->addMenuItem(1002, "item 2", 1001)->Checked = true;
sysTray->addMenuItem(1005, "item 3");
sysTray->addMenuItem(1006, "")->Separator = true;
sysTray->addMenuItem(MENU_CLOSE_PROGRAM, "Close Program");
//! you can save the menu
// sysTray->saveMenu("menu.xml");
//! and you can load the menu
// sysTray->loadMenu("menu.xml");
//! show icon in system tray
sysTray->show();
}
}
}
Code: Select all
//! handle tray menu events
bool tray_Callback(SMenuItem* itm, void* user_data){
if(itm == TRAY_MENU_SHOW_WINDOW){
// show the window
}else{
// menu item clicked
switch(itm->ID){
case MENU_CLOSE_PROGRAM:{
closeProgram();
}break;
default:{
printf("menu: %d: %s\n", itm->ID, itm->Text.c_str());
}
}
}
return true;
}