int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild) { TWindowData *dat = (TWindowData*) GetWindowLongPtr(hwndChild, GWLP_USERDATA); // needed to obtain the hContact for the message window if (!dat || !pContainer) return FALSE; NMHDR nmhdr = { 0 }; nmhdr.code = TCN_SELCHANGE; if (TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS)) > 1 && !(pContainer->dwFlags & CNT_DEFERREDTABSELECT)) { TabCtrl_SetCurSel(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), GetTabIndexFromHWND(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), hwndChild)); SendMessage(pContainer->hwnd, WM_NOTIFY, 0, (LPARAM)&nmhdr); // just select the tab and let WM_NOTIFY do the rest } if (dat->bType == SESSIONTYPE_IM) SendMessage(pContainer->hwnd, DM_UPDATETITLE, dat->hContact, 0); if (IsIconic(pContainer->hwnd)) { SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); SetForegroundWindow(pContainer->hwnd); } //MaD - hide on close feature if (!IsWindowVisible(pContainer->hwnd)) { WINDOWPLACEMENT wp={0}; wp.length = sizeof(wp); GetWindowPlacement(pContainer->hwnd, &wp); /* * all tabs must re-check the layout on activation because adding a tab while * the container was hidden can make this necessary */ BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); if (wp.showCmd == SW_SHOWMAXIMIZED) ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED); else { ShowWindow(pContainer->hwnd, SW_SHOWNA); SetForegroundWindow(pContainer->hwnd); } SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); // make sure the active tab resizes its layout properly } //MaD_ else if (GetForegroundWindow() != pContainer->hwnd) SetForegroundWindow(pContainer->hwnd); if (dat->bType == SESSIONTYPE_IM) SetFocus(GetDlgItem(hwndChild, IDC_MESSAGE)); return TRUE; }
void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p) { SESSION_INFO *si = SM_FindSessionByHCONTACT(p->hContact); if (si == 0) return; TWindowData *dat = 0; if (si->hWnd) { dat = si->dat; if (dat) { p->bInactive = dat->pContainer->hwnd != GetForegroundWindow(); p->bActiveTab = (dat->pContainer->hwndActive == si->hWnd); } if (p->sound && Utils::mustPlaySound(si->dat)) SkinPlaySound(p->sound); } else if (p->sound) SkinPlaySound(p->sound); if (dat) { HWND hwndTab = GetParent(si->hWnd); BOOL bForcedIcon = (p->hNotifyIcon == pci->hIcons[ICON_HIGHLIGHT] || p->hNotifyIcon == pci->hIcons[ICON_MESSAGE]); if ((p->iEvent & si->iLogTrayFlags) || bForcedIcon) { if (!p->bActiveTab) { if (p->hNotifyIcon == pci->hIcons[ICON_HIGHLIGHT]) dat->iFlashIcon = p->hNotifyIcon; else { if (dat->iFlashIcon != pci->hIcons[ICON_HIGHLIGHT] && dat->iFlashIcon != pci->hIcons[ICON_MESSAGE]) dat->iFlashIcon = p->hNotifyIcon; } dat->mayFlashTab = TRUE; SetTimer(si->hWnd, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL); } } if (dat->pWnd) { dat->pWnd->updateIcon(p->hNotifyIcon); dat->pWnd->setOverlayIcon(p->hNotifyIcon, true); } // autoswitch tab.. if (p->bMustAutoswitch) { if ((IsIconic(dat->pContainer->hwnd)) && !IsZoomed(dat->pContainer->hwnd) && PluginConfig.haveAutoSwitch() && dat->pContainer->hwndActive != si->hWnd) { int iItem = GetTabIndexFromHWND(hwndTab, si->hWnd); if (iItem >= 0) { TabCtrl_SetCurSel(hwndTab, iItem); ShowWindow(dat->pContainer->hwndActive, SW_HIDE); dat->pContainer->hwndActive = si->hWnd; SendMessage(dat->pContainer->hwnd, DM_UPDATETITLE, (WPARAM)dat->hContact, 0); dat->pContainer->dwFlags |= CNT_DEFERREDTABSELECT; } } } /* * flash window if it is not focused */ if (p->bMustFlash && p->bInactive) if (!(dat->pContainer->dwFlags & CNT_NOFLASH)) FlashContainer(dat->pContainer, 1, 0); if (p->hNotifyIcon && p->bInactive && ((p->iEvent & si->iLogTrayFlags) || bForcedIcon)) { if (p->bMustFlash) dat->hTabIcon = p->hNotifyIcon; else if (dat->iFlashIcon) { dat->hTabIcon = dat->iFlashIcon; TCITEM item = {0}; item.mask = TCIF_IMAGE; item.iImage = 0; TabCtrl_SetItem(GetParent(si->hWnd), dat->iTabID, &item); } HICON hIcon = (HICON)SendMessage(dat->pContainer->hwnd, WM_GETICON, ICON_BIG, 0); if (p->hNotifyIcon == pci->hIcons[ICON_HIGHLIGHT] || (hIcon != pci->hIcons[ICON_MESSAGE] && hIcon != pci->hIcons[ICON_HIGHLIGHT])) { SendMessage(dat->pContainer->hwnd, DM_SETICON, (WPARAM)dat, (LPARAM)p->hNotifyIcon); dat->pContainer->dwFlags |= CNT_NEED_UPDATETITLE; } } if (p->bMustFlash && p->bInactive) UpdateTrayMenu(dat, si->wStatus, si->pszModule, dat->szStatus, si->hContact, p->bHighlight ? 1 : 1); } mir_free(p); }