/** * Displays a popup * * @param hContact - contact to display popup for * @param eventType - indicates which popup settings to apply * @param DaysToAnniv - days left until anniversary occures * @param pszDesc - this is the headline * @param szMsg - message to display * * @return return value of the popup service **/ static INT NotifyWithPopup(HANDLE hContact, CEvent::EType eventType, INT DaysToAnniv, LPCTSTR pszDesc, LPCTSTR pszMsg) { if (gRemindOpts.bPopups) { POPUPDATAT_V2 ppd; ZeroMemory(&ppd, sizeof(POPUPDATAT_V2)); ppd.PluginWindowProc = (WNDPROC)PopupWindowProc; ppd.iSeconds = (INT)DB::Setting::GetByte(SET_POPUP_DELAY, 0); if (hContact) { ppd.lchContact = hContact; mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName), _T("%s - %s"), TranslateTS(pszDesc), DB::Contact::DisplayName(hContact)); } else { mir_tcsncpy(ppd.lptzContactName, TranslateT("Reminder"), SIZEOF(ppd.lptzContactName)); } mir_tcsncpy(ppd.lptzText, pszMsg, MAX_SECONDLINE); ppd.lchIcon = GetAnnivIcon(CEvent(eventType, DaysToAnniv)); switch (eventType) { case CEvent::BIRTHDAY: switch (DB::Setting::GetByte(SET_POPUP_BIRTHDAY_COLORTYPE, POPUP_COLOR_CUSTOM)) { case POPUP_COLOR_WINDOWS: ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); break; case POPUP_COLOR_CUSTOM: ppd.colorBack = DB::Setting::GetDWord(SET_POPUP_BIRTHDAY_COLOR_BACK, RGB(192,180,30)); ppd.colorText = DB::Setting::GetDWord(SET_POPUP_BIRTHDAY_COLOR_TEXT, 0); break; } break; case CEvent::ANNIVERSARY: switch (DB::Setting::GetByte(SET_POPUP_ANNIVERSARY_COLORTYPE, POPUP_COLOR_CUSTOM)) { case POPUP_COLOR_WINDOWS: ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); break; case POPUP_COLOR_CUSTOM: ppd.colorBack = DB::Setting::GetDWord(SET_POPUP_ANNIVERSARY_COLOR_BACK, RGB(90, 190, 130)); ppd.colorText = DB::Setting::GetDWord(SET_POPUP_ANNIVERSARY_COLOR_TEXT, 0); break; } } return PUAddPopUpT(&ppd); } return 1; }
/** * name: PlacesBarSubclassProc * params: hWnd - handle, to control's window * uMsg - the message to handle * wParam - message dependend parameter * lParam - message dependend parameter * return: depends on message **/ static LRESULT CALLBACK PlacesBarSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == TB_ADDBUTTONS) { TBBUTTON *tbb = (TBBUTTON *)lParam; TCHAR szBtnText[MAX_PATH]; int iString; HWND hWndToolTip; if (tbb) { // miranda button switch (tbb->idCommand) { case 41063: ZeroMemory(szBtnText, sizeof(szBtnText)); mir_tcsncpy(szBtnText, TranslateT("Miranda NG"), SIZEOF(szBtnText)); iString = SendMessage(hWnd, TB_ADDSTRING, NULL, (LPARAM)szBtnText); if (iString != -1) tbb->iString = iString; // set tooltip hWndToolTip = (HWND)SendMessage(hWnd, TB_GETTOOLTIPS, NULL, NULL); if (hWndToolTip) { TOOLINFO ti; ZeroMemory(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.hwnd = hWnd; ti.lpszText = TranslateT("Shows Miranda's installation directory."); ti.uId = tbb->idCommand; SendMessage(hWndToolTip, TTM_ADDTOOL, NULL, (LPARAM)&ti); } break; // profile button case 41064: // set button text iString = SendMessage(hWnd, TB_ADDSTRING, NULL, (LPARAM) TranslateT("Profile")); if (iString != -1) tbb->iString = iString; // set tooltip hWndToolTip = (HWND)SendMessage(hWnd, TB_GETTOOLTIPS, NULL, NULL); if (hWndToolTip) { TOOLINFO ti; ZeroMemory(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.hwnd = hWnd; ti.lpszText = TranslateT("Shows the directory with all your Miranda's profiles."); ti.uId = tbb->idCommand; SendMessage(hWndToolTip, TTM_ADDTOOL, NULL, (LPARAM)&ti); } // unmap registry and delete keys ResetAlteredPlaceBars(); break; } } } return mir_callNextSubclass(hWnd, PlacesBarSubclassProc, uMsg, wParam,lParam); }
static BOOLEAN CheckAnniversaries(HANDLE hContact, MTime &Now, CEvent &evt, BOOLEAN bNotify) { INT numAnniversaries = 0; INT Diff; MAnnivDate mta; INT i; TCHAR szAnniv[MAX_PATH]; TCHAR strMsg[MAX_SECONDLINE]; BOOLEAN bOverflow = FALSE; WORD wDaysEarlier; if ((gRemindOpts.RemindState == REMIND_ANNIV) || (gRemindOpts.RemindState == REMIND_ALL)) { for (i = 0; i < ANID_LAST && !mta.DBGetAnniversaryDate(hContact, i); i++) { mta.DBGetReminderOpts(hContact); if (mta.RemindOption() != BST_UNCHECKED) { wDaysEarlier = (mta.RemindOption() == BST_CHECKED) ? mta.RemindOffset() : -1; if (wDaysEarlier == (WORD)-1) { wDaysEarlier = gRemindOpts.wDaysEarlier; } Diff = mta.CompareDays(Now); if ((Diff >= 0) && (Diff <= wDaysEarlier)) { if (evt._wDaysLeft > Diff) { evt._wDaysLeft = Diff; evt._eType = CEvent::ANNIVERSARY; } numAnniversaries++; // create displayed text for popup if (bNotify && !bOverflow) { // first anniversary found if (numAnniversaries == 1) { mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%s has the following anniversaries:\0"), ContactGender(hContact)); mir_tcsncpy(strMsg, szAnniv, mir_tcslen(szAnniv)); } switch (Diff) { case 0: { mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%d. %s today\0"), mta.Age(), mta.Description()); } break; case 1: { mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%d. %s tomorrow\0"), mta.Age() + 1, mta.Description()); } break; default: { mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%d. %s in %d days\0"), mta.Age() + 1, mta.Description(), Diff); } } if (mir_tcslen(szAnniv) >= MAX_SECONDLINE - mir_tcslen(strMsg)) { if (strMsg) mir_tcsncat(strMsg, _T("\n...\0"), SIZEOF(strMsg)); else mir_tcsncpy(strMsg, _T("\n...\0"), mir_tcslen(_T("\n...\0"))); bOverflow = TRUE; } else { if (strMsg) mir_tcsncat(strMsg, _T("\n- \0"), SIZEOF(strMsg)); else mir_tcsncpy(strMsg, _T("\n- \0"), mir_tcslen(_T("\n- \0"))); mir_tcsncat(strMsg, szAnniv, SIZEOF(strMsg)); } } } } } } // show one popup for all anniversaries if (numAnniversaries != 0 && bNotify) { NotifyWithPopup(hContact, CEvent::ANNIVERSARY, Diff, LPGENT("Anniversaries"), strMsg); } return numAnniversaries != 0; }