From 15267ea2d489606fb4b99d011bc3ea7c2a644a9f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Mar 2013 14:22:17 +0000 Subject: fix for popup-related memory leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@4077 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/main.cpp | 1 + plugins/Popup/src/notifications.cpp | 30 +- plugins/Popup/src/notifications.h | 1 + plugins/Popup/src/opt_class.cpp | 814 +++++++++++++++++------------------- plugins/Popup/src/services.cpp | 82 ++-- plugins/Popup/src/services.h | 1 + 6 files changed, 449 insertions(+), 480 deletions(-) (limited to 'plugins/Popup/src') diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index b68a7e54f6..9eb494ad05 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -413,6 +413,7 @@ MIRAPI int Load(void) CreateServiceFunction(MS_POPUP_REGISTERVFX, PopUp_RegisterVfx); CreateServiceFunction(MS_POPUP_REGISTERCLASS, PopUp_RegisterPopupClass); + CreateServiceFunction(MS_POPUP_UNREGISTERCLASS, PopUp_UnregisterPopupClass); CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, PopUp_CreateClassPopup); //load icons / create hook diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index aa2a92338a..5c01266b9f 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -71,16 +71,21 @@ void LoadNotifications() g_hntfError = RegisterNotification(¬ification); } -void UnloadTreeData() +void FreePopupClass(POPUPTREEDATA *ptd) { - for (int i=0; i < gTreeData.getCount(); ++i) { - if (gTreeData[i]->typ == 2) { - mir_free(gTreeData[i]->pupClass.pszName); - mir_free(gTreeData[i]->pupClass.pszDescription); - } - mir_free(gTreeData[i]->pszTreeRoot); - mir_free(gTreeData[i]->pszDescription); + if (ptd->typ == 2) { + mir_free(ptd->pupClass.pszName); + mir_free(ptd->pupClass.pszDescription); } + mir_free(ptd->pszTreeRoot); + mir_free(ptd->pszDescription); + mir_free(ptd); +} + +void UnloadTreeData() +{ + for (int i=0; i < gTreeData.getCount(); ++i) + FreePopupClass(gTreeData[i]); gTreeData.destroy(); } @@ -234,11 +239,12 @@ HANDLE RegisterNotification(POPUPNOTIFICATION *notification) HANDLE FindTreeData(LPTSTR group, LPTSTR name, BYTE typ) { for(int i=0; i < gTreeData.getCount(); i++) { - if ( gTreeData[i]->typ == typ && - (!group || (_tcscmp(gTreeData[i]->pszTreeRoot, group) == 0)) && - (!name || (_tcscmp(gTreeData[i]->pszDescription, name) == 0))) + POPUPTREEDATA *p = gTreeData[i]; + if (p->typ == typ && + (!group || (_tcscmp(p->pszTreeRoot, group) == 0)) && + (!name || (_tcscmp(p->pszDescription, name) == 0))) { - return gTreeData[i]; + return p; } } return NULL; diff --git a/plugins/Popup/src/notifications.h b/plugins/Popup/src/notifications.h index 76b7bd2869..98aae6e144 100644 --- a/plugins/Popup/src/notifications.h +++ b/plugins/Popup/src/notifications.h @@ -49,6 +49,7 @@ extern HANDLE g_hntfError, g_hntfWarning, g_hntfNotification; int TreeDataSortFunc(const POPUPTREEDATA *p1, const POPUPTREEDATA *p2); HANDLE FindTreeData(LPTSTR group, LPTSTR name, BYTE typ); +void FreePopupClass(POPUPTREEDATA *ptd); void UnloadTreeData(); void LoadNotifications(); diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index c3fce0c0b6..246eef9bfa 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -43,503 +43,453 @@ int ComboBox_SelectItem(HWND hwndCtl, int indexStart, char* data) { //--------------------------------------------------------------------------- //Dialog Proc -INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static TVITEM tvi = {0}; - static struct { - UINT idCtrl; - BYTE onTyp0; - BYTE onTyp1; - BYTE onTyp2; - } ctrlsAll[] = { - {IDC_TXT_TITLE1 ,0 ,1 ,1}, - {IDC_ENABLE ,0 ,1 ,1}, - - {IDC_TXT_TIMEOUT ,0 ,1 ,1}, - {IDC_TIMEOUT ,0 ,1 ,1}, - {IDC_TIMEOUT_SPIN ,0 ,1 ,1}, - {IDC_TXT_TIMEOUT_SEC ,0 ,1 ,1}, - {IDC_TXT_TIMEOUT_DEFAULT ,0 ,1 ,1}, - {IDC_TXT_TIMEOUT_INFINITE ,0 ,1 ,1}, - - {IDC_TXT_LACTION ,0 ,1 ,1}, - {IDC_LACTION ,0 ,1 ,1}, - - {IDC_TXT_RACTION ,0 ,1 ,1}, - {IDC_RACTION ,0 ,1 ,1}, - - {IDC_CHECKWINDOW ,0 ,0 ,0}, //may be delete ?? - - {IDC_TXT_TITLE3 ,0 ,1 ,0}, - {IDC_SOFFLINE ,0 ,1 ,0}, - {IDC_SONLINE ,0 ,1 ,0}, - {IDC_SAWAY ,0 ,1 ,0}, - {IDC_SNA ,0 ,1 ,0}, - {IDC_SOCCUPIED ,0 ,1 ,0}, - {IDC_SDND ,0 ,1 ,0}, - {IDC_SFREE4CHAT ,0 ,1 ,0}, - {IDC_SINVISIBLE ,0 ,1 ,0}, - {IDC_SPHONE ,0 ,1 ,0}, - {IDC_SLUNCH ,0 ,1 ,0}, - - {IDC_TXT_TITLE4 ,0 ,0 ,0}, - {IDC_SOFFLINE2 ,0 ,0 ,0}, - {IDC_SONLINE2 ,0 ,0 ,0}, - {IDC_SAWAY2 ,0 ,0 ,0}, - {IDC_SNA2 ,0 ,0 ,0}, - {IDC_SOCCUPIED2 ,0 ,0 ,0}, - {IDC_SDND2 ,0 ,0 ,0}, - {IDC_SFREE4CHAT2 ,0 ,0 ,0}, - {IDC_SINVISIBLE2 ,0 ,0 ,0}, - {IDC_SPHONE2 ,0 ,0 ,0}, - {IDC_SLUNCH2 ,0 ,0 ,0}, - - {IDC_ICO_INFO ,0 ,1 ,1}, - {IDC_TXT_COLORS ,0 ,1 ,1}, - {IDC_MORE ,0 ,1 ,1}, - - {IDC_PREVIEW ,0 ,1 ,1}, - }; - - static UINT ctrlsClass[] = { - IDC_TXT_TITLE1, /*IDC_TXT_TITLE3,*/ - IDC_TXT_TIMEOUT, IDC_TIMEOUT, - IDC_TIMEOUT_SPIN, IDC_TXT_TIMEOUT_SEC, - IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE, - IDC_TXT_LACTION, IDC_LACTION, - IDC_TXT_RACTION, IDC_RACTION, - IDC_ICO_INFO, IDC_TXT_COLORS, - }; - - static UINT ctrlsEnable[] = { - IDC_TXT_TIMEOUT, IDC_TIMEOUT, IDC_TIMEOUT_SPIN, - IDC_TXT_TIMEOUT_SEC , IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE, - IDC_TXT_LACTION, IDC_LACTION, - IDC_TXT_RACTION, IDC_RACTION, - /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE3, IDC_TXT_TITLE4, - IDC_ICO_INFO, IDC_TXT_COLORS, IDC_MORE, - - IDC_SOFFLINE, IDC_SONLINE, IDC_SAWAY, IDC_SNA, - IDC_SOCCUPIED, IDC_SDND, IDC_SFREE4CHAT, - IDC_SINVISIBLE, IDC_SPHONE, IDC_SLUNCH, - - IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2, - IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2, - IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2, - }; - - static UINT ctrlsContact[] = { - /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE4, - IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2, - IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2, - IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2, - }; - - static int titleIds[] = { - IDC_TXT_TITLE1, - IDC_TXT_TITLE3, - IDC_TXT_TITLE4, - }; - - static struct { - int idCtrl; - int iconId; - char *title; - DWORD statusFlag; - DWORD disableWhenFlag; - } statusButtons[] = { - {IDC_SOFFLINE, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE}, - {IDC_SONLINE, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE}, - {IDC_SAWAY, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY}, - {IDC_SNA, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY}, - {IDC_SOCCUPIED, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND}, - {IDC_SDND, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND}, - {IDC_SFREE4CHAT, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT}, - {IDC_SINVISIBLE, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE}, - {IDC_SPHONE, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE}, - {IDC_SLUNCH, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH}, - - {IDC_SOFFLINE2, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE<<16}, - {IDC_SONLINE2, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE<<16}, - {IDC_SAWAY2, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY<<16}, - {IDC_SNA2, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY<<16}, - {IDC_SOCCUPIED2, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND<<16}, - {IDC_SDND2, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND<<16}, - {IDC_SFREE4CHAT2, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT<<16}, - {IDC_SINVISIBLE2, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE<<16}, - {IDC_SPHONE2, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE<<16}, - {IDC_SLUNCH2, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH<<16}, - }; +struct { + UINT idCtrl; + BYTE onTyp0; + BYTE onTyp1; + BYTE onTyp2; +} +static ctrlsAll[] = { + {IDC_TXT_TITLE1 ,0 ,1 ,1}, + {IDC_ENABLE ,0 ,1 ,1}, + + {IDC_TXT_TIMEOUT ,0 ,1 ,1}, + {IDC_TIMEOUT ,0 ,1 ,1}, + {IDC_TIMEOUT_SPIN ,0 ,1 ,1}, + {IDC_TXT_TIMEOUT_SEC ,0 ,1 ,1}, + {IDC_TXT_TIMEOUT_DEFAULT ,0 ,1 ,1}, + {IDC_TXT_TIMEOUT_INFINITE ,0 ,1 ,1}, + + {IDC_TXT_LACTION ,0 ,1 ,1}, + {IDC_LACTION ,0 ,1 ,1}, + + {IDC_TXT_RACTION ,0 ,1 ,1}, + {IDC_RACTION ,0 ,1 ,1}, + + {IDC_CHECKWINDOW ,0 ,0 ,0}, //may be delete ?? + + {IDC_TXT_TITLE3 ,0 ,1 ,0}, + {IDC_SOFFLINE ,0 ,1 ,0}, + {IDC_SONLINE ,0 ,1 ,0}, + {IDC_SAWAY ,0 ,1 ,0}, + {IDC_SNA ,0 ,1 ,0}, + {IDC_SOCCUPIED ,0 ,1 ,0}, + {IDC_SDND ,0 ,1 ,0}, + {IDC_SFREE4CHAT ,0 ,1 ,0}, + {IDC_SINVISIBLE ,0 ,1 ,0}, + {IDC_SPHONE ,0 ,1 ,0}, + {IDC_SLUNCH ,0 ,1 ,0}, + + {IDC_TXT_TITLE4 ,0 ,0 ,0}, + {IDC_SOFFLINE2 ,0 ,0 ,0}, + {IDC_SONLINE2 ,0 ,0 ,0}, + {IDC_SAWAY2 ,0 ,0 ,0}, + {IDC_SNA2 ,0 ,0 ,0}, + {IDC_SOCCUPIED2 ,0 ,0 ,0}, + {IDC_SDND2 ,0 ,0 ,0}, + {IDC_SFREE4CHAT2 ,0 ,0 ,0}, + {IDC_SINVISIBLE2 ,0 ,0 ,0}, + {IDC_SPHONE2 ,0 ,0 ,0}, + {IDC_SLUNCH2 ,0 ,0 ,0}, + + {IDC_ICO_INFO ,0 ,1 ,1}, + {IDC_TXT_COLORS ,0 ,1 ,1}, + {IDC_MORE ,0 ,1 ,1}, + + {IDC_PREVIEW ,0 ,1 ,1}, +}; + +static UINT ctrlsClass[] = { + IDC_TXT_TITLE1, /*IDC_TXT_TITLE3,*/ + IDC_TXT_TIMEOUT, IDC_TIMEOUT, + IDC_TIMEOUT_SPIN, IDC_TXT_TIMEOUT_SEC, + IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE, + IDC_TXT_LACTION, IDC_LACTION, + IDC_TXT_RACTION, IDC_RACTION, + IDC_ICO_INFO, IDC_TXT_COLORS, +}; + +static UINT ctrlsEnable[] = { + IDC_TXT_TIMEOUT, IDC_TIMEOUT, IDC_TIMEOUT_SPIN, + IDC_TXT_TIMEOUT_SEC , IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE, + IDC_TXT_LACTION, IDC_LACTION, + IDC_TXT_RACTION, IDC_RACTION, + /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE3, IDC_TXT_TITLE4, + IDC_ICO_INFO, IDC_TXT_COLORS, IDC_MORE, + + IDC_SOFFLINE, IDC_SONLINE, IDC_SAWAY, IDC_SNA, + IDC_SOCCUPIED, IDC_SDND, IDC_SFREE4CHAT, + IDC_SINVISIBLE, IDC_SPHONE, IDC_SLUNCH, + + IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2, + IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2, + IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2, +}; + +static UINT ctrlsContact[] = { + /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE4, + IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2, + IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2, + IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2, +}; + +static int titleIds[] = { + IDC_TXT_TITLE1, + IDC_TXT_TITLE3, + IDC_TXT_TITLE4, +}; + +struct { + int idCtrl; + int iconId; + char *title; + DWORD statusFlag; + DWORD disableWhenFlag; +} +static statusButtons[] = { + {IDC_SOFFLINE, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE}, + {IDC_SONLINE, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE}, + {IDC_SAWAY, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY}, + {IDC_SNA, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY}, + {IDC_SOCCUPIED, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND}, + {IDC_SDND, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND}, + {IDC_SFREE4CHAT, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT}, + {IDC_SINVISIBLE, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE}, + {IDC_SPHONE, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE}, + {IDC_SLUNCH, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH}, + + {IDC_SOFFLINE2, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE<<16}, + {IDC_SONLINE2, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE<<16}, + {IDC_SAWAY2, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY<<16}, + {IDC_SNA2, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY<<16}, + {IDC_SOCCUPIED2, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND<<16}, + {IDC_SDND2, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND<<16}, + {IDC_SFREE4CHAT2, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT<<16}, + {IDC_SINVISIBLE2, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE<<16}, + {IDC_SPHONE2, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE<<16}, + {IDC_SLUNCH2, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH<<16}, +}; + +INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int i; switch ( msg ) { case WM_INITDIALOG: - { - int i; TranslateDialogDefault( hwnd ); - - //Treeview - HWND hwndTree = GetDlgItem(hwnd, IDC_TREE1); { - int iconIndex = 0; - char iconName[MAXMODULELABELLENGTH]; - TCHAR itemName[MAXMODULELABELLENGTH]; + //Treeview + HWND hwndTree = GetDlgItem(hwnd, IDC_TREE1); + + int iconIndex = 0; + char iconName[MAXMODULELABELLENGTH]; + TCHAR itemName[MAXMODULELABELLENGTH]; TreeView_DeleteAllItems(hwndTree); //Treeview create image list HIMAGELIST hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR|ILC_COLOR32|ILC_MASK, 5, num_classes+1); ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(ICO_OPT_GROUP,0)); TreeView_SetImageList(hwndTree, hImgLst, TVSIL_NORMAL); - for (i = 0; i < gTreeData.getCount(); ++i) { + for (i=0; i < gTreeData.getCount(); ++i) { switch (gTreeData[i]->typ) { - case 1: //Treeview part for typ 1 (notification) - mir_snprintf(iconName, sizeof(iconName), "%s_%S_%S", MODULNAME, gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); - iconIndex = ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(iconName)); - wsprintf(itemName, _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); - break; - case 2: //Treeview part typ 2 (popup class api) - iconIndex = ImageList_ReplaceIcon(hImgLst, -1, gTreeData[i]->pupClass.hIcon); - wsprintf(itemName, _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription); - break; - default: - break; + case 1: //Treeview part for typ 1 (notification) + mir_snprintf(iconName, sizeof(iconName), "%s_%S_%S", MODULNAME, gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); + iconIndex = ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(iconName)); + wsprintf(itemName, _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); + break; + case 2: //Treeview part typ 2 (popup class api) + iconIndex = ImageList_ReplaceIcon(hImgLst, -1, gTreeData[i]->pupClass.hIcon); + wsprintf(itemName, _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription); + break; } OptTree_AddItem(hwndTree, itemName, (LPARAM)gTreeData[i], iconIndex); } OptTree_Translate(hwndTree); - } // end Treeview - //Bold Title - for (i = 0; i < SIZEOF(titleIds); ++i) - { - LOGFONT lf; - GetObject((HFONT)SendDlgItemMessage(hwnd, titleIds[i], WM_GETFONT, 0, 0), sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - SendDlgItemMessage(hwnd, titleIds[i], WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE); - } + //Bold Title + for (i = 0; i < SIZEOF(titleIds); ++i) { + LOGFONT lf; + GetObject((HFONT)SendDlgItemMessage(hwnd, titleIds[i], WM_GETFONT, 0, 0), sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + SendDlgItemMessage(hwnd, titleIds[i], WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE); + } - //spindown for Timeout - SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_LIFETIME_MAX, SETTING_LIFETIME_INFINITE)); - SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)0, TRUE); - //status buttons - for (i = 0; i < SIZEOF(statusButtons); ++i) - { - SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASPUSHBTN, TRUE, 0); - SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BM_SETIMAGE, - IMAGE_ICON, (LPARAM)LoadSkinnedIcon(statusButtons[i].iconId)); - SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONADDTOOLTIP, - (WPARAM)Translate(statusButtons[i].title), 0); + //spindown for Timeout + SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_LIFETIME_MAX, SETTING_LIFETIME_INFINITE)); + SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)0, TRUE); + //status buttons + for (i = 0; i < SIZEOF(statusButtons); ++i) { + SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASFLATBTN, TRUE, 0); + SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASPUSHBTN, TRUE, 0); + SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BM_SETIMAGE, + IMAGE_ICON, (LPARAM)LoadSkinnedIcon(statusButtons[i].iconId)); + SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONADDTOOLTIP, + (WPARAM)Translate(statusButtons[i].title), 0); + } + //info icon + SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_MISC_NOTIFY,0), 0); + //more button + EnableWindow(GetDlgItem(hwnd, IDC_MORE), FALSE); + //preview button + ShowWindow(GetDlgItem(hwnd, IDC_CHECKWINDOW), SW_HIDE); + + SendMessage(hwnd, WM_USER, 0, 0); } - //info icon - SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_MISC_NOTIFY,0), 0); - //more button - EnableWindow(GetDlgItem(hwnd, IDC_MORE), FALSE); - //preview button - ShowWindow(GetDlgItem(hwnd, IDC_CHECKWINDOW), SW_HIDE); - - SendMessage(hwnd, WM_USER, 0, 0); - return TRUE; - } + case WM_USER: - { - int i; - HWND hTV = GetDlgItem(hwnd, IDC_TREE1); - //get TreeView selection - tvi.hItem = TreeView_GetSelection(hTV); - tvi.mask = TVIF_PARAM|TVIF_HANDLE|TVIF_TEXT; - if (tvi.hItem) TreeView_GetItem(hTV, &tvi); - SetWindowLongPtr(hwnd, GWLP_USERDATA, tvi.lParam); - - if (tvi.lParam) { - POPUPTREEDATA* ptd = (POPUPTREEDATA *)tvi.lParam; - HWND hCtrl = 0; - LPTSTR psztSelect = NULL; - int index = 0; - //combo left action (default) - { - hCtrl = GetDlgItem(hwnd, IDC_LACTION); + { + HWND hTV = GetDlgItem(hwnd, IDC_TREE1); + //get TreeView selection + TVITEM tvi = { 0 }; + tvi.hItem = TreeView_GetSelection(hTV); + tvi.mask = TVIF_PARAM|TVIF_HANDLE|TVIF_TEXT; + if (tvi.hItem) TreeView_GetItem(hTV, &tvi); + SetWindowLongPtr(hwnd, GWLP_USERDATA, tvi.lParam); + + if (tvi.lParam) { + POPUPTREEDATA* ptd = (POPUPTREEDATA *)tvi.lParam; + LPTSTR psztSelect = NULL; + int index = 0; + //combo left action (default) + + HWND hCtrl = GetDlgItem(hwnd, IDC_LACTION); ComboBox_ResetContent(hCtrl); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_DISMISS)),POPUP_ACTION_DISMISS); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_NOTHING)),POPUP_ACTION_NOTHING); - } - //combo right action (default) - { + + //combo right action (default) hCtrl = GetDlgItem(hwnd, IDC_RACTION); ComboBox_ResetContent(hCtrl); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_DISMISS)),POPUP_ACTION_DISMISS); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_NOTHING)),POPUP_ACTION_NOTHING); - } - - //element typ1 (Notification) - if (ptd->typ == 1) { - LPTSTR psztAction = NULL; - //Timeout - SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE); - SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1)); - //combo left action (EXTRA) - hCtrl = GetDlgItem(hwnd, IDC_LACTION); - for (i = 0; i < ptd->notification.actionCount; ++i) { - psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle); - mir_free(psztAction); psztAction = NULL; - } - //combo right action (EXTRA) - hCtrl = GetDlgItem(hwnd, IDC_RACTION); - psztAction = NULL; - for (i = 0; i < ptd->notification.actionCount; ++i) { - psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle); - ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle); - mir_free(psztAction); psztAction = NULL; + + //element typ1 (Notification) + if (ptd->typ == 1) { + LPTSTR psztAction = NULL; + //Timeout + SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE); + SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1)); + //combo left action (EXTRA) + hCtrl = GetDlgItem(hwnd, IDC_LACTION); + for (i = 0; i < ptd->notification.actionCount; ++i) { + psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle); + mir_free(psztAction); psztAction = NULL; + } + //combo right action (EXTRA) + hCtrl = GetDlgItem(hwnd, IDC_RACTION); + psztAction = NULL; + for (i = 0; i < ptd->notification.actionCount; ++i) { + psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle); + ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle); + mir_free(psztAction); psztAction = NULL; + } + //enable all controls + for (i = 0; i < SIZEOF(ctrlsAll); ++i){ + ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1 ? SW_SHOW : SW_HIDE); + EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1); + } + //enable or disable controls ctrlsEnable + for (i = 0; i < SIZEOF(ctrlsEnable); ++i) + EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled ? TRUE : FALSE); + //show or hide controls ctrlsContact + for (i = 0; i < SIZEOF(ctrlsContact); ++i) + ShowWindow(GetDlgItem(hwnd, ctrlsContact[i]), ptd->notification.dwFlags&PNF_CONTACT ? SW_SHOW : SW_HIDE); + //statusButtons state + for (i = 0; i < SIZEOF(statusButtons); ++i) + CheckDlgButton(hwnd, statusButtons[i].idCtrl, ptd->disableWhen & statusButtons[i].disableWhenFlag ? TRUE : FALSE); } - //enable all controls - for (i = 0; i < SIZEOF(ctrlsAll); ++i){ - ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1 ? SW_SHOW : SW_HIDE); - EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1); + //element typ2 (CLASS Plugins) + else if (ptd->typ == 2) { + //Timeout + SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE); + SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1)); + //enable ctrls + for (i = 0; i < SIZEOF(ctrlsAll); ++i){ + ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2 ? SW_SHOW : SW_HIDE); + EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2); + } } - //enable or disable controls ctrlsEnable - for (i = 0; i < SIZEOF(ctrlsEnable); ++i) - EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled ? TRUE : FALSE); - //show or hide controls ctrlsContact - for (i = 0; i < SIZEOF(ctrlsContact); ++i) - ShowWindow(GetDlgItem(hwnd, ctrlsContact[i]), ptd->notification.dwFlags&PNF_CONTACT ? SW_SHOW : SW_HIDE); - //statusButtons state - for (i = 0; i < SIZEOF(statusButtons); ++i) - CheckDlgButton(hwnd, statusButtons[i].idCtrl, ptd->disableWhen & statusButtons[i].disableWhenFlag ? TRUE : FALSE); - } - //element typ2 (CLASS Plugins) - else if (ptd->typ == 2) { - //Timeout - SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE); - SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1)); - //enable ctrls - for (i = 0; i < SIZEOF(ctrlsAll); ++i){ - ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2 ? SW_SHOW : SW_HIDE); - EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2); + //checkbox enable notify + CheckDlgButton(hwnd, IDC_ENABLE, ptd->enabled ? TRUE : FALSE); + //combo left action (SELECT) + hCtrl = GetDlgItem(hwnd, IDC_LACTION); + ComboBox_SelectItem (hCtrl, -1, ptd->leftAction); //use Workaround for MS bug ComboBox_SelectItemData + //combo right action (SELECT) + hCtrl = GetDlgItem(hwnd, IDC_RACTION); + ComboBox_SelectItem (hCtrl, -1, ptd->rightAction); //use Workaround for MS bug ComboBox_SelectItemData + } //end if (tvi.lParam) + else { + //enable / disable controls + for (int i=0; i < SIZEOF(ctrlsAll); ++i) { + ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0 ? SW_SHOW : SW_HIDE); + EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0); } } - //checkbox enable notify - CheckDlgButton(hwnd, IDC_ENABLE, ptd->enabled ? TRUE : FALSE); - //combo left action (SELECT) - hCtrl = GetDlgItem(hwnd, IDC_LACTION); - ComboBox_SelectItem (hCtrl, -1, ptd->leftAction); //use Workaround for MS bug ComboBox_SelectItemData - //combo right action (SELECT) - hCtrl = GetDlgItem(hwnd, IDC_RACTION); - ComboBox_SelectItem (hCtrl, -1, ptd->rightAction); //use Workaround for MS bug ComboBox_SelectItemData - } //end if (tvi.lParam) - else { - //enable / disable controls - for (int i=0; i < SIZEOF(ctrlsAll); ++i) { - ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0 ? SW_SHOW : SW_HIDE); - EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0); - } } break; - } + case WM_COMMAND: - { - UINT idCtrl = LOWORD(wParam); - POPUPTREEDATA* ptd = (POPUPTREEDATA *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (!ptd) break; - switch (HIWORD(wParam)) { - int i; + { + UINT idCtrl = LOWORD(wParam); + POPUPTREEDATA* ptd = (POPUPTREEDATA *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (!ptd) break; + switch (HIWORD(wParam)) { case BN_CLICKED: //Button controls switch(idCtrl) { - case IDC_ENABLE: - ptd->enabled = (BYTE)Button_GetCheck((HWND)lParam); - for (i = 0; i < SIZEOF(ctrlsEnable); ++i) - EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled); - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - case IDC_PREVIEW: - { - POPUPDATA2 ppd = {0}; - ppd.cbSize = sizeof(ppd); - ppd.flags = PU2_TCHAR; - ppd.lptzTitle = ptd->pszDescription; - ppd.lptzText = TranslateT("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!"); - ppd.iSeconds = ptd->timeoutValue; - ppd.colorBack = ptd->colorBack; - ppd.colorText = ptd->colorText; - POPUPTREEDATA *ptdPrev = NULL; - if (ptd->typ == 1) { - //we work with a copy for preview - ptdPrev = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA)); - memcpy(ptdPrev, ptd, sizeof(POPUPTREEDATA)); - ptdPrev->enabled = ptd->enabled; - ptdPrev->timeoutValue = ptd->timeoutValue; - strcpy(ptdPrev->leftAction, ptd->leftAction); //geht noch nicht?? - strcpy(ptdPrev->rightAction, ptd->rightAction); //geht noch nicht?? - ptdPrev->disableWhen = ptd->disableWhen; - - ppd.lchNotification = (HANDLE)ptdPrev; - } - else if (ptd->typ == 2) - ppd.lchIcon = ptd->pupClass.hIcon; - - CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY); - mir_free(ptdPrev); ptdPrev = NULL; - } - break; - case IDC_MORE: - { - OPENOPTIONSDIALOG ood = {0}; - ood.cbSize = sizeof(OPENOPTIONSDIALOG); - ood.pszGroup = "Customize"; - ood.pszPage = "Fonts & Colors"; - Options_Open(&ood); - } - break; - case IDC_SOFFLINE: case IDC_SONLINE: case IDC_SAWAY: case IDC_SNA: case IDC_SOCCUPIED: - case IDC_SDND: case IDC_SFREE4CHAT: case IDC_SINVISIBLE: case IDC_SPHONE: case IDC_SLUNCH: - case IDC_SOFFLINE2: case IDC_SONLINE2: case IDC_SAWAY2: case IDC_SNA2: case IDC_SOCCUPIED2: - case IDC_SDND2: case IDC_SFREE4CHAT2: case IDC_SINVISIBLE2: case IDC_SPHONE2: case IDC_SLUNCH2: - { - ptd->disableWhen = 0; - for (i = 0; i < SIZEOF(statusButtons); ++i) { - if (IsDlgButtonChecked(hwnd, statusButtons[i].idCtrl)) - ptd->disableWhen |= statusButtons[i].disableWhenFlag; - if (idCtrl == statusButtons[i].idCtrl) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } + case IDC_ENABLE: + ptd->enabled = (BYTE)Button_GetCheck((HWND)lParam); + for (i = 0; i < SIZEOF(ctrlsEnable); ++i) + EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled); + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; + + case IDC_PREVIEW: + { + POPUPDATA2 ppd = {0}; + ppd.cbSize = sizeof(ppd); + ppd.flags = PU2_TCHAR; + ppd.lptzTitle = ptd->pszDescription; + ppd.lptzText = TranslateT("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!"); + ppd.iSeconds = ptd->timeoutValue; + ppd.colorBack = ptd->colorBack; + ppd.colorText = ptd->colorText; + POPUPTREEDATA *ptdPrev = NULL; + if (ptd->typ == 1) { + //we work with a copy for preview + ptdPrev = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA)); + memcpy(ptdPrev, ptd, sizeof(POPUPTREEDATA)); + ptdPrev->enabled = ptd->enabled; + ptdPrev->timeoutValue = ptd->timeoutValue; + strcpy(ptdPrev->leftAction, ptd->leftAction); //geht noch nicht?? + strcpy(ptdPrev->rightAction, ptd->rightAction); //geht noch nicht?? + ptdPrev->disableWhen = ptd->disableWhen; + + ppd.lchNotification = (HANDLE)ptdPrev; } - break; - default: - break; + else if (ptd->typ == 2) + ppd.lchIcon = ptd->pupClass.hIcon; + + CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY); + mir_free(ptdPrev); ptdPrev = NULL; + } + break; + case IDC_MORE: + { + OPENOPTIONSDIALOG ood = { sizeof(ood) }; + ood.pszGroup = "Customize"; + ood.pszPage = "Fonts & Colors"; + Options_Open(&ood); + } + break; + + case IDC_SOFFLINE: case IDC_SONLINE: case IDC_SAWAY: case IDC_SNA: case IDC_SOCCUPIED: + case IDC_SDND: case IDC_SFREE4CHAT: case IDC_SINVISIBLE: case IDC_SPHONE: case IDC_SLUNCH: + case IDC_SOFFLINE2: case IDC_SONLINE2: case IDC_SAWAY2: case IDC_SNA2: case IDC_SOCCUPIED2: + case IDC_SDND2: case IDC_SFREE4CHAT2: case IDC_SINVISIBLE2: case IDC_SPHONE2: case IDC_SLUNCH2: + ptd->disableWhen = 0; + for (i = 0; i < SIZEOF(statusButtons); ++i) { + if (IsDlgButtonChecked(hwnd, statusButtons[i].idCtrl)) + ptd->disableWhen |= statusButtons[i].disableWhenFlag; + if (idCtrl == statusButtons[i].idCtrl) + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } } break; + case CBN_SELCHANGE: //ComboBox controls switch(idCtrl) { - //lParam = Handle to the control - case IDC_LACTION: - lstrcpynA(ptd->leftAction, - (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)), - sizeof(ptd->leftAction)); - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - case IDC_RACTION: - lstrcpynA(ptd->rightAction, - (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)), - sizeof(ptd->rightAction)); - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - default: - break; + case IDC_LACTION: + lstrcpynA(ptd->leftAction, + (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)), + sizeof(ptd->leftAction)); + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; + case IDC_RACTION: + lstrcpynA(ptd->rightAction, + (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)), + sizeof(ptd->rightAction)); + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; } break; + case EN_CHANGE: //Edit controls switch(idCtrl) { - //lParam = Handle to the control - case IDC_TIMEOUT: - { - int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE); - if ( seconds >= SETTING_LIFETIME_INFINITE && - seconds <= SETTING_LIFETIME_MAX && - seconds != ptd->timeoutValue) { - ptd->timeoutValue = seconds; - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } - } - break; - default: - break; + case IDC_TIMEOUT: + int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE); + if (seconds >= SETTING_LIFETIME_INFINITE && seconds <= SETTING_LIFETIME_MAX && seconds != ptd->timeoutValue) { + ptd->timeoutValue = seconds; + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } } break; + case EN_KILLFOCUS: //Edit controls lost fokus switch(idCtrl) { - //lParam = Handle to the control - case IDC_TIMEOUT: - { - int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE); - if (seconds > SETTING_LIFETIME_MAX) - ptd->timeoutValue = SETTING_LIFETIME_MAX; - else if (seconds < SETTING_LIFETIME_INFINITE) - ptd->timeoutValue = SETTING_LIFETIME_INFINITE; - if (seconds != ptd->timeoutValue) { - SetDlgItemInt(hwnd, idCtrl, ptd->timeoutValue, TRUE); - ErrorMSG(SETTING_LIFETIME_INFINITE, SETTING_LIFETIME_MAX); - SetFocus((HWND)lParam); - } - } - break; - default: - break; - }//end switch(idCtrl) - break; - default: - break; + case IDC_TIMEOUT: + int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE); + if (seconds > SETTING_LIFETIME_MAX) + ptd->timeoutValue = SETTING_LIFETIME_MAX; + else if (seconds < SETTING_LIFETIME_INFINITE) + ptd->timeoutValue = SETTING_LIFETIME_INFINITE; + if (seconds != ptd->timeoutValue) { + SetDlgItemInt(hwnd, idCtrl, ptd->timeoutValue, TRUE); + ErrorMSG(SETTING_LIFETIME_INFINITE, SETTING_LIFETIME_MAX); + SetFocus((HWND)lParam); + } + } + } } break; - } + case WM_NOTIFY: - { switch(((LPNMHDR)lParam)->idFrom) { - case 0: - { - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - { - for(int i=0; i < gTreeData.getCount(); ++i) { - switch (gTreeData[i]->typ) { - case 1: - LoadNotificationSettings(gTreeData[i], "PopUpNotifications"); - break; - case 2: //not finish - LoadClassSettings(gTreeData[i], PU_MODULCLASS); - gTreeData[i]->timeoutValue = gTreeData[i]->pupClass.iSeconds; - break; - default: - break; - } - } - return TRUE; - } - case PSN_APPLY: - { - for(int i=0; i < gTreeData.getCount(); ++i) { - switch (gTreeData[i]->typ) { - case 1: - gTreeData[i]->notification.iSeconds = gTreeData[i]->timeoutValue; - SaveNotificationSettings(gTreeData[i],"PopUpNotifications"); - break; - case 2: //not finish - gTreeData[i]->pupClass.iSeconds = gTreeData[i]->timeoutValue; - SaveClassSettings(gTreeData[i],"PopUpCLASS"); - break; - default: - break; - } - } - return TRUE; + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_RESET: + for(i=0; i < gTreeData.getCount(); ++i) { + switch (gTreeData[i]->typ) { + case 1: + LoadNotificationSettings(gTreeData[i], "PopUpNotifications"); + break; + case 2: //not finish + LoadClassSettings(gTreeData[i], PU_MODULCLASS); + gTreeData[i]->timeoutValue = gTreeData[i]->pupClass.iSeconds; + break; } } - break; - } - - case IDC_TREE1: - { - switch (((LPNMHDR)lParam)->code) - { - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - PostMessage(hwnd, WM_USER, 0, 0); + return TRUE; + + case PSN_APPLY: + for(i=0; i < gTreeData.getCount(); ++i) { + switch (gTreeData[i]->typ) { + case 1: + gTreeData[i]->notification.iSeconds = gTreeData[i]->timeoutValue; + SaveNotificationSettings(gTreeData[i],"PopUpNotifications"); + break; + case 2: //not finish + gTreeData[i]->pupClass.iSeconds = gTreeData[i]->timeoutValue; + SaveClassSettings(gTreeData[i],"PopUpCLASS"); break; } } + return TRUE; + } + break; + + case IDC_TREE1: + switch (((LPNMHDR)lParam)->code) { + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + PostMessage(hwnd, WM_USER, 0, 0); break; } } break; } - - case WM_DESTROY: - ZeroMemory(&tvi,sizeof(tvi)); - break; - - default: - return FALSE; - } return FALSE; } diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 191cb42e47..9e3c4ca797 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -28,28 +28,24 @@ int num_classes = 0; //for core class api support // isWorkstationLocked() code from core bool isWorkstationLocked() { - bool rc = false; - if (OpenInputDesktop != NULL) { HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); if (hDesk == NULL) - rc = true; - else if (CloseDesktop != NULL) + return true; + if (CloseDesktop != NULL) CloseDesktop(hDesk); } - return rc; + return false; } // isFullScreen() code from core static bool isFullScreen() { RECT rcScreen = {0}; - rcScreen.right = GetSystemMetrics(SM_CXSCREEN); rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); - if (MonitorFromWindow != NULL) - { + if (MonitorFromWindow != NULL) { HMONITOR hMon = MonitorFromWindow(GetForegroundWindow(), MONITOR_DEFAULTTONEAREST); MONITORINFO mi; mi.cbSize = sizeof(mi); @@ -461,24 +457,24 @@ INT_PTR PopUp_RegisterVfx(WPARAM wParam, LPARAM lParam) } //===== PopUp/RegisterClass (for core class api support) -INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) { +INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) +{ char setting[256]; - POPUPCLASS *pc = (POPUPCLASS *)lParam; - POPUPTREEDATA *ptd = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA)); - memset(ptd,0,sizeof(POPUPTREEDATA)); - ptd->cbSize = sizeof(POPUPTREEDATA); + POPUPCLASS *pc = (POPUPCLASS *)lParam; + POPUPTREEDATA *ptd = (POPUPTREEDATA *)mir_calloc(sizeof(POPUPTREEDATA)); + ptd->cbSize = sizeof(POPUPTREEDATA); ptd->signature = 0/*PopupNotificationData_SIGNATURE*/; - ptd->typ = 2; + ptd->typ = 2; memcpy(&ptd->pupClass, pc, sizeof(POPUPCLASS)); - ptd->pszTreeRoot = mir_a2t(pc->pszName); - ptd->pupClass.pszName = mir_strdup(pc->pszName); + ptd->pszTreeRoot = mir_a2t(pc->pszName); + ptd->pupClass.pszName = mir_strdup(pc->pszName); if (pc->flags & PCF_UNICODE) { ptd->pupClass.pwszDescription = mir_wstrdup(pc->pwszDescription); - ptd->pszDescription = mir_u2t(pc->pwszDescription); + ptd->pszDescription = mir_u2t(pc->pwszDescription); } else { - ptd->pupClass.pszDescription = mir_strdup (pc->pszDescription); - ptd->pszDescription = mir_a2t(pc->pszDescription); + ptd->pupClass.pszDescription = mir_strdup(pc->pszDescription); + ptd->pszDescription = mir_a2t(pc->pszDescription); } LoadClassSettings(ptd, PU_MODULCLASS); @@ -514,8 +510,23 @@ INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) { gTreeData.insert(ptd); num_classes++; + return (INT_PTR)ptd; +} - return 0; +INT_PTR PopUp_UnregisterPopupClass(WPARAM wParam, LPARAM lParam) +{ + POPUPTREEDATA *ptd = (POPUPTREEDATA*)lParam; + if (ptd == NULL) + return 1; + + for (int i=0; i < gTreeData.getCount(); i++) + if (gTreeData[i] == ptd) { + gTreeData.remove(i); + FreePopupClass(ptd); + return 0; + } + + return 1; } //===== PopUp/AddPopupClass (for core class api support) @@ -527,32 +538,31 @@ INT_PTR PopUp_CreateClassPopup(WPARAM wParam, LPARAM lParam) { POPUPCLASS *pc = NULL; POPUPTREEDATA *ptd = NULL; - if (wParam) pc = (POPUPCLASS *)wParam; + if (wParam) pc = (POPUPCLASS*)wParam; else { LPTSTR group = mir_a2t(pdc->pszClassName); ptd = (POPUPTREEDATA *)FindTreeData(group, NULL, 2); if (ptd) pc = &ptd->pupClass; } if (pc) { - POPUPDATA2 ppd2 = {0}; - ppd2.cbSize = sizeof(POPUPDATA2); - ppd2.colorBack = pc->colorBack; - ppd2.colorText = pc->colorText; - ppd2.lchIcon = pc->hIcon; - ppd2.iSeconds = pc->iSeconds; - ppd2.PluginWindowProc = pc->PluginWindowProc; + POPUPDATA2 ppd2 = { sizeof(ppd2) }; + ppd2.colorBack = pc->colorBack; + ppd2.colorText = pc->colorText; + ppd2.lchIcon = pc->hIcon; + ppd2.iSeconds = pc->iSeconds; + ppd2.PluginWindowProc= pc->PluginWindowProc; if (pc->flags & PCF_UNICODE) { - ppd2.flags = PU2_UNICODE; - ppd2.lpwzTitle = (WCHAR*)pdc->pwszTitle; - ppd2.lpwzText = (WCHAR*)pdc->pwszText; + ppd2.flags = PU2_UNICODE; + ppd2.lpwzTitle = (WCHAR*)pdc->pwszTitle; + ppd2.lpwzText = (WCHAR*)pdc->pwszText; } else { - ppd2.flags = PU2_ANSI; - ppd2.lpzTitle = (char *)pdc->pszTitle; - ppd2.lpzText = (char *)pdc->pszText; + ppd2.flags = PU2_ANSI; + ppd2.lpzTitle = (char *)pdc->pszTitle; + ppd2.lpzText = (char *)pdc->pszText; } - ppd2.lchContact = pdc->hContact; - ppd2.PluginData = pdc->PluginData; + ppd2.lchContact = pdc->hContact; + ppd2.PluginData = pdc->PluginData; ret = PopUp_AddPopUp2((WPARAM)&ppd2, 0); } diff --git a/plugins/Popup/src/services.h b/plugins/Popup/src/services.h index 30258db64a..1e965fbbe2 100644 --- a/plugins/Popup/src/services.h +++ b/plugins/Popup/src/services.h @@ -50,6 +50,7 @@ INT_PTR PopUp_UnhookEventAsync(WPARAM wParam, LPARAM lParam); INT_PTR PopUp_RegisterVfx(WPARAM wParam, LPARAM lParam); INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam); +INT_PTR PopUp_UnregisterPopupClass(WPARAM wParam, LPARAM lParam); INT_PTR PopUp_CreateClassPopup(WPARAM wParam, LPARAM lParam); #endif // __services_h__ -- cgit v1.2.3