void TSAPI HandleMenuEntryFromhContact(int iSelection) { HWND hWnd = M->FindWindow((HANDLE)iSelection); SESSION_INFO *si = NULL; if (iSelection == 0) return; if (hWnd && IsWindow(hWnd)) { struct TContainerData *pContainer = 0; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { ActivateExistingTab(pContainer, hWnd); pContainer->hwndSaved = 0; SetForegroundWindow(pContainer->hwnd); } else CallService(MS_MSG_SENDMESSAGE, (WPARAM)iSelection, 0); } else if ((si = SM_FindSessionByHCONTACT((HANDLE)iSelection)) != NULL) { if (si->hWnd) { // session does exist, but no window is open for it struct TContainerData *pContainer = 0; SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { ActivateExistingTab(pContainer, si->hWnd); if (GetForegroundWindow() != pContainer->hwnd) SetForegroundWindow(pContainer->hwnd); SetFocus(GetDlgItem(pContainer->hwndActive, IDC_CHAT_MESSAGE)); } else goto nothing_open; } else goto nothing_open; } else { nothing_open: CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)iSelection, 0); } }
void TSAPI HandleMenuEntryFromhContact(MCONTACT hContact) { if (hContact == 0) return; HWND hWnd = M.FindWindow(hContact); if (hWnd && IsWindow(hWnd)) { TContainerData *pContainer = 0; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { ActivateExistingTab(pContainer, hWnd); pContainer->hwndSaved = 0; SetForegroundWindow(pContainer->hwnd); } else CallService(MS_MSG_SENDMESSAGE, hContact, 0); return; } SESSION_INFO *si = SM_FindSessionByHCONTACT(hContact); if (si != NULL) { // session does exist, but no window is open for it if (si->hWnd) { TContainerData *pContainer = 0; SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { ActivateExistingTab(pContainer, si->hWnd); if (GetForegroundWindow() != pContainer->hwnd) SetForegroundWindow(pContainer->hwnd); SetFocus(GetDlgItem(pContainer->hwndActive, IDC_CHAT_MESSAGE)); return; } } } CallService(MS_CLIST_CONTACTDOUBLECLICKED, hContact, 0); }
void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) { if (si == NULL) return; if (si->hWnd != NULL) { ActivateExistingTab(si->pContainer, si->hWnd); return; } TCHAR szName[CONTAINER_NAMELEN + 2]; szName[0] = 0; TContainerData *pContainer = si->pContainer; if (pContainer == NULL) { GetContainerNameForContact(si->hContact, szName, CONTAINER_NAMELEN); if (!g_Settings.bOpenInDefault && !_tcscmp(szName, _T("default"))) _tcsncpy(szName, _T("Chat Rooms"), CONTAINER_NAMELEN); szName[CONTAINER_NAMELEN] = 0; pContainer = FindContainerByName(szName); } if (pContainer == NULL) pContainer = CreateContainer(szName, FALSE, si->hContact); if (pContainer) si->hWnd = CreateNewRoom(pContainer, si, TRUE, TRUE, FALSE); }
HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, int isSend, const char *pszInitialText, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup, HANDLE hdbEvent) { TCHAR newcontactname[128], tabtitle[128]; int newItem; DBVARIANT dbv = {0}; if (M.FindWindow(hContact) != 0) { _DebugPopup(hContact, _T("Warning: trying to create duplicate window")); return 0; } // if we have a max # of tabs/container set and want to open something in the default container... if (hContact != 0 && M.GetByte("limittabs", 0) && !_tcsncmp(pContainer->szName, _T("default"), 6)) { if ((pContainer = FindMatchingContainer(_T("default"), hContact)) == NULL) { TCHAR szName[CONTAINER_NAMELEN + 1]; mir_sntprintf(szName, CONTAINER_NAMELEN, _T("default")); if ((pContainer = CreateContainer(szName, CNT_CREATEFLAG_CLONED, hContact)) == NULL) return 0; } } TNewWindowData newData = {0}; newData.hContact = hContact; newData.isWchar = isSend; newData.szInitialText = pszInitialText; char *szProto = GetContactProto(newData.hContact); ZeroMemory(&newData.item, sizeof(newData.item)); // obtain various status information about the contact TCHAR *contactName = pcli->pfnGetContactDisplayName(newData.hContact, 0); /* * cut nickname if larger than x chars... */ if (contactName && lstrlen(contactName) > 0) { if (M.GetByte("cuttitle", 0)) CutContactName(contactName, newcontactname, SIZEOF(newcontactname)); else { lstrcpyn(newcontactname, contactName, SIZEOF(newcontactname)); newcontactname[127] = 0; } //Mad: to fix tab width for nicknames with ampersands Utils::DoubleAmpersands(newcontactname); } else lstrcpyn(newcontactname, _T("_U_"), SIZEOF(newcontactname)); WORD wStatus = (szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(newData.hContact, szProto, "Status", ID_STATUS_OFFLINE)); TCHAR *szStatus = pcli->pfnGetStatusModeDescription(szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); if (M.GetByte("tabstatus", 1)) mir_sntprintf(tabtitle, SIZEOF(tabtitle), _T("%s (%s) "), newcontactname, szStatus); else mir_sntprintf(tabtitle, SIZEOF(tabtitle), _T("%s "), newcontactname); newData.item.pszText = tabtitle; newData.item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; newData.item.iImage = 0; newData.item.cchTextMax = 255; HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS); // hide the active tab if (pContainer->hwndActive && bActivateTab) ShowWindow(pContainer->hwndActive, SW_HIDE); { int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->iChilds * 100); int iCount = TabCtrl_GetItemCount(hwndTab); TCITEM item = {0}; int relPos; int i; pContainer->iTabIndex = iCount; if (iCount > 0) { for (i = iCount - 1; i >= 0; i--) { item.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, i, &item); HWND hwnd = (HWND)item.lParam; TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (dat) { relPos = M.GetDword(dat->hContact, "tabindex", i * 100); if (iTabIndex_wanted <= relPos) pContainer->iTabIndex = i; } } } } newItem = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &newData.item); SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0); if (bActivateTab) TabCtrl_SetCurSel(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), newItem); newData.iTabID = newItem; newData.iTabImage = newData.item.iImage; newData.pContainer = pContainer; newData.iActivate = (int) bActivateTab; pContainer->iChilds++; newData.bWantPopup = bWantPopup; newData.hdbEvent = hdbEvent; HWND hwndNew = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGSPLITNEW), GetDlgItem(pContainer->hwnd, IDC_MSGTABS), DlgProcMessage, (LPARAM)&newData); /* * switchbar support */ if (pContainer->dwFlags & CNT_SIDEBAR) { TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndNew, GWLP_USERDATA); if (dat) pContainer->SideBar->addSession(dat, pContainer->iTabIndex); } SendMessage(pContainer->hwnd, WM_SIZE, 0, 0); // if the container is minimized, then pop it up... if (IsIconic(pContainer->hwnd)) { if (bPopupContainer) { SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); SetFocus(pContainer->hwndActive); } else { if (pContainer->dwFlags & CNT_NOFLASH) SendMessage(pContainer->hwnd, DM_SETICON, 0, (LPARAM)LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); else FlashContainer(pContainer, 1, 0); } } if (bActivateTab) { ActivateExistingTab(pContainer, hwndNew); SetFocus(hwndNew); RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_ERASENOW); UpdateWindow(pContainer->hwnd); if (GetForegroundWindow() != pContainer->hwnd && bPopupContainer == TRUE) SetForegroundWindow(pContainer->hwnd); } else if (!IsIconic(pContainer->hwnd) && IsWindowVisible(pContainer->hwnd)) { SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); RedrawWindow(pContainer->hwndActive, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); RedrawWindow(pContainer->hwndActive, NULL, NULL, RDW_ERASENOW | RDW_UPDATENOW); } //MaD if (PluginConfig.m_HideOnClose&&!IsWindowVisible(pContainer->hwnd)) { WINDOWPLACEMENT wp={0}; wp.length = sizeof(wp); GetWindowPlacement(pContainer->hwnd, &wp); BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation if (wp.showCmd == SW_SHOWMAXIMIZED) ShowWindow(pContainer->hwnd, SW_SHOWMAXIMIZED); else { if (bPopupContainer) ShowWindow(pContainer->hwnd, SW_SHOWNORMAL); else ShowWindow(pContainer->hwnd, SW_SHOWMINNOACTIVE); } SendMessage(pContainer->hwndActive, WM_SIZE, 0, 0); } if (PluginConfig.m_bIsWin7 && PluginConfig.m_useAeroPeek && CSkin::m_skinEnabled) CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING|MB_OK); if (ServiceExists(MS_HPP_EG_EVENT) && ServiceExists(MS_IEVIEW_EVENT) && db_get_b(0, "HistoryPlusPlus", "IEViewAPI", 0)) if (IDYES == CWarning::show(CWarning::WARN_HPP_APICHECK, MB_ICONWARNING|MB_YESNO)) db_set_b(0, "HistoryPlusPlus", "IEViewAPI", 0); return hwndNew; // return handle of the new dialog }