From 57884d14f2085b95b253c37f5e142b19d42d586e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 11 Apr 2013 14:53:30 +0000 Subject: - massive extinction of clutches in tabSRMM; - loop packing git-svn-id: http://svn.miranda-ng.org/main/trunk@4424 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/TSButton.cpp | 2 +- plugins/TabSRMM/src/chat/tools.cpp | 2 +- plugins/TabSRMM/src/chat/window.cpp | 6 +- plugins/TabSRMM/src/container.cpp | 86 +++++++--------- plugins/TabSRMM/src/containeroptions.cpp | 32 +++--- plugins/TabSRMM/src/eventpopups.cpp | 4 +- plugins/TabSRMM/src/generic_msghandlers.cpp | 16 +-- plugins/TabSRMM/src/hotkeyhandler.cpp | 151 +++++++++++++--------------- plugins/TabSRMM/src/mim.cpp | 4 +- plugins/TabSRMM/src/msgdialog.cpp | 2 +- plugins/TabSRMM/src/msgoptions.cpp | 3 +- plugins/TabSRMM/src/msgs.cpp | 44 ++++---- plugins/TabSRMM/src/msgs.h | 2 +- plugins/TabSRMM/src/nen.h | 2 +- plugins/TabSRMM/src/selectcontainer.cpp | 25 ++--- plugins/TabSRMM/src/tabctrl.cpp | 13 +-- plugins/TabSRMM/src/templates.cpp | 4 +- plugins/TabSRMM/src/themes.cpp | 36 ++++--- plugins/TabSRMM/src/themes.h | 2 +- 19 files changed, 193 insertions(+), 243 deletions(-) diff --git a/plugins/TabSRMM/src/TSButton.cpp b/plugins/TabSRMM/src/TSButton.cpp index e32ab00173..e721fe6e0d 100644 --- a/plugins/TabSRMM/src/TSButton.cpp +++ b/plugins/TabSRMM/src/TSButton.cpp @@ -559,7 +559,7 @@ static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, bct->dimmed = (wParam != 0); break; case BUTTONSETCONTAINER: - bct->pContainer = (struct TContainerData *)wParam; + bct->pContainer = (TContainerData *)wParam; break; case BUTTONSETASTITLE: bct->bTitleButton = TRUE; diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 85167448e8..81ce3559ca 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -296,7 +296,7 @@ static BOOL DoTrayIcon(SESSION_INFO* si, GCEVENT * gce) static BOOL DoPopup(SESSION_INFO* si, GCEVENT* gce, struct TWindowData* dat) { int iEvent = gce->pDest->iType; - struct TContainerData *pContainer = dat ? dat->pContainer : NULL; + TContainerData *pContainer = dat ? dat->pContainer : NULL; char *szProto = dat ? dat->szProto : si->pszModule; TCHAR *bbStart, *bbEnd; diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 46e761e8cf..82f8b00e77 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -3484,7 +3484,7 @@ LABEL_SHOWWINDOW: break; case DM_CONTAINERSELECTED: { - struct TContainerData *pNewContainer = 0; + TContainerData *pNewContainer = 0; TCHAR *szNewName = (TCHAR *)lParam; if (!_tcscmp(szNewName, TranslateT("Default container"))) szNewName = CGlobals::m_default_container_name; @@ -3505,7 +3505,7 @@ LABEL_SHOWWINDOW: // container API support functions case DM_QUERYCONTAINER: { - struct TContainerData **pc = (struct TContainerData **) lParam; + TContainerData **pc = (TContainerData **) lParam; if (pc) *pc = dat->pContainer; return 0; @@ -3522,7 +3522,7 @@ LABEL_SHOWWINDOW: int iTabs, i; TCITEM item = {0}; RECT rc; - struct TContainerData *pContainer = dat->pContainer; + TContainerData *pContainer = dat->pContainer; BOOL bForced = (lParam == 2); iTabs = TabCtrl_GetItemCount(hwndTab); diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index c37642d345..931ac22915 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -134,12 +134,12 @@ void TSAPI SetAeroMargins(TContainerData *pContainer) * pointer and for removing the struct from the linked list. */ -struct TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDLE hContactFrom) +TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDLE hContactFrom) { char *szKey = "TAB_ContainersW"; int iFirstFree = -1, iFound = FALSE; - struct TContainerData *pContainer = (struct TContainerData *)calloc(sizeof(struct TContainerData), 1); + TContainerData *pContainer = (TContainerData *)calloc(sizeof(TContainerData), 1); if (!pContainer) return NULL; @@ -200,7 +200,7 @@ struct TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDL static LRESULT CALLBACK ContainerWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - struct TContainerData *pContainer = (struct TContainerData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + TContainerData *pContainer = (TContainerData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); BOOL bSkinned = CSkin::m_skinEnabled ? TRUE : FALSE; switch (msg) { @@ -553,13 +553,12 @@ static BOOL fHaveTipper = FALSE; static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - struct TContainerData *pContainer = 0; // pointer to our struct ContainerWindowData int iItem = 0; TCITEM item; HWND hwndTab; BOOL bSkinned; - pContainer = (struct TContainerData *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + TContainerData *pContainer = (TContainerData *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); bSkinned = CSkin::m_skinEnabled ? TRUE : FALSE; hwndTab = GetDlgItem(hwndDlg, IDC_MSGTABS); @@ -580,7 +579,7 @@ static INT_PTR CALLBACK DlgProcContainer(HWND hwndDlg, UINT msg, WPARAM wParam, fHaveTipper = ServiceExists("mToolTip/ShowTip"); fForceOverlayIcons = M->GetByte("forceTaskBarStatusOverlays", 0) ? true : false; - pContainer = (struct TContainerData *) lParam; + pContainer = (TContainerData*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) pContainer); mir_subclassWindow(hwndDlg, ContainerWndProc); @@ -2212,48 +2211,43 @@ int TSAPI CutContactName(const TCHAR *oldname, TCHAR *newname, unsigned int size * functions for handling the linked list of struct ContainerWindowData *foo */ -static struct TContainerData* TSAPI AppendToContainerList(struct TContainerData *pContainer) { - struct TContainerData *pCurrent = 0; - +static TContainerData* TSAPI AppendToContainerList(TContainerData *pContainer) +{ if (!pFirstContainer) { pFirstContainer = pContainer; - pFirstContainer->pNextContainer = NULL; + pFirstContainer->pNext = NULL; return pFirstContainer; - } else { - pCurrent = pFirstContainer; - while (pCurrent->pNextContainer != 0) - pCurrent = pCurrent->pNextContainer; - pCurrent->pNextContainer = pContainer; - pContainer->pNextContainer = NULL; - return pCurrent; } + + TContainerData *p = pFirstContainer; + while (p->pNext != 0) + p = p->pNext; + p->pNext = pContainer; + pContainer->pNext = NULL; + return p; } -struct TContainerData* TSAPI FindContainerByName(const TCHAR *name) { - struct TContainerData *pCurrent = pFirstContainer; - +TContainerData* TSAPI FindContainerByName(const TCHAR *name) +{ if (name == NULL || lstrlen(name) == 0) return 0; - if (M->GetByte("singlewinmode", 0)) { // single window mode - always return 0 and force a new container + if (M->GetByte("singlewinmode", 0)) // single window mode - always return 0 and force a new container return NULL; - } - while (pCurrent) { - if (!_tcsncmp(pCurrent->szName, name, CONTAINER_NAMELEN)) - return pCurrent; - pCurrent = pCurrent->pNextContainer; - } + for (TContainerData *p = pFirstContainer; p; p = p->pNext) + if (!_tcsncmp(p->szName, name, CONTAINER_NAMELEN)) + return p; + // error, didn't find it. return NULL; } -static struct TContainerData* TSAPI RemoveContainerFromList(struct TContainerData *pContainer) { - struct TContainerData *pCurrent = pFirstContainer; - +static TContainerData* TSAPI RemoveContainerFromList(TContainerData *pContainer) +{ if (pContainer == pFirstContainer) { - if (pContainer->pNextContainer != NULL) - pFirstContainer = pContainer->pNextContainer; + if (pContainer->pNext != NULL) + pFirstContainer = pContainer->pNext; else pFirstContainer = NULL; @@ -2263,16 +2257,16 @@ static struct TContainerData* TSAPI RemoveContainerFromList(struct TContainerDat return pFirstContainer; } - do { - if (pCurrent->pNextContainer == pContainer) { - pCurrent->pNextContainer = pCurrent->pNextContainer->pNextContainer; + for (TContainerData *p = pFirstContainer; p; p = p->pNext) { + if (p->pNext == pContainer) { + p->pNext = p->pNext->pNext; if (pLastActiveContainer == pContainer) // make sure, we don't reference this container anymore pLastActiveContainer = pFirstContainer; return 0; } - } while (pCurrent = pCurrent->pNextContainer); + } return NULL; } @@ -2283,22 +2277,20 @@ static struct TContainerData* TSAPI RemoveContainerFromList(struct TContainerDat * rc is the RECT obtained by GetClientRect(hwndTab) */ -void TSAPI AdjustTabClientRect(struct TContainerData *pContainer, RECT *rc) +void TSAPI AdjustTabClientRect(TContainerData *pContainer, RECT *rc) { HWND hwndTab = GetDlgItem(pContainer->hwnd, IDC_MSGTABS); - RECT rcTab, rcTabOrig; - DWORD dwBottom, dwTop; DWORD tBorder = pContainer->tBorder; DWORD dwStyle = GetWindowLongPtr(hwndTab, GWL_STYLE); + RECT rcTab, rcTabOrig; GetClientRect(hwndTab, &rcTab); - dwBottom = rcTab.bottom; - dwTop = rcTab.top; + DWORD dwBottom = rcTab.bottom; + DWORD dwTop = rcTab.top; if (!(pContainer->dwFlags & CNT_SIDEBAR) && (pContainer->iChilds > 1 || !(pContainer->dwFlags & CNT_HIDETABS))) { - DWORD dwTopPad; rcTabOrig = rcTab; TabCtrl_AdjustRect(hwndTab, FALSE, &rcTab); - dwTopPad = rcTab.top - rcTabOrig.top; + DWORD dwTopPad = rcTab.top - rcTabOrig.top; rc->left += tBorder; rc->right -= tBorder; @@ -2348,7 +2340,6 @@ void TSAPI AdjustTabClientRect(struct TContainerData *pContainer, RECT *rc) int TSAPI GetContainerNameForContact(HANDLE hContact, TCHAR *szName, int iNameLen) { DBVARIANT dbv; - if (M->GetByte("singlewinmode", 0)) { // single window mode using cloned (temporary) containers _tcsncpy(szName, _T("Message Session"), iNameLen); return 0; @@ -2368,6 +2359,7 @@ int TSAPI GetContainerNameForContact(HANDLE hContact, TCHAR *szName, int iNameLe return dbv.cchVal; } } + if (M->GetTString(hContact, SRMSGMOD_T, "containerW", &dbv)) { _tcsncpy(szName, _T("default"), iNameLen); return 0; @@ -2384,13 +2376,13 @@ int TSAPI GetContainerNameForContact(HANDLE hContact, TCHAR *szName, int iNameLe void TSAPI DeleteContainer(int iIndex) { - DBVARIANT dbv; char szIndex[10], szSetting[CONTAINER_NAMELEN + 30]; char *szKey = "TAB_ContainersW"; char *szSettingP = "CNTW_"; char *szSubKey = "containerW"; _snprintf(szIndex, 8, "%d", iIndex); + DBVARIANT dbv; if (!M->GetTString(NULL, szKey, szIndex, &dbv)) { if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR) { TCHAR *wszContainerName = dbv.ptszVal; @@ -2566,7 +2558,7 @@ HMENU TSAPI BuildMCProtocolMenu(HWND hwndDlg) * iMode == 0: turn off flashing */ -void TSAPI FlashContainer(struct TContainerData *pContainer, int iMode, int iCount) { +void TSAPI FlashContainer(TContainerData *pContainer, int iMode, int iCount) { FLASHWINFO fwi; if (CMimAPI::m_MyFlashWindowEx == NULL) @@ -2594,7 +2586,7 @@ void TSAPI FlashContainer(struct TContainerData *pContainer, int iMode, int iCou CMimAPI::m_MyFlashWindowEx(&fwi); } -void TSAPI ReflashContainer(struct TContainerData *pContainer) +void TSAPI ReflashContainer(TContainerData *pContainer) { DWORD dwStartTime = pContainer->dwFlashingStarted; diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp index 47aa0738fd..38da7faf18 100644 --- a/plugins/TabSRMM/src/containeroptions.cpp +++ b/plugins/TabSRMM/src/containeroptions.cpp @@ -39,18 +39,15 @@ static void MY_CheckDlgButton(HWND hWnd, UINT id, int iCheck) static void ReloadGlobalContainerSettings(bool fForceReconfig) { - struct TContainerData *pC = pFirstContainer; - - while (pC) { - if (!pC->settings->fPrivate) { - Utils::SettingsToContainer(pC); + for (TContainerData *p = pFirstContainer; p; p = p->pNext) { + if (!p->settings->fPrivate) { + Utils::SettingsToContainer(p); if (fForceReconfig) - SendMessage(pC->hwnd, DM_CONFIGURECONTAINER, 0, 0); + SendMessage(p->hwnd, DM_CONFIGURECONTAINER, 0, 0); else - SendMessage(pC->hwnd, WM_SIZE, 0, 1); - BroadCastContainer(pC, DM_SETINFOPANEL, 0, 0); + SendMessage(p->hwnd, WM_SIZE, 0, 1); + BroadCastContainer(p, DM_SETINFOPANEL, 0, 0); } - pC = pC->pNextContainer; } } @@ -78,16 +75,11 @@ void TSAPI ApplyContainerSetting(TContainerData *pContainer, DWORD flags, UINT m if (flags & CNT_INFOPANEL) BroadCastContainer(pContainer, DM_SETINFOPANEL, 0, 0); if (flags & CNT_SIDEBAR) { - struct TContainerData *pC = pFirstContainer; - while (pC) { - if (!pC->settings->fPrivate) { - SendMessage(pC->hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0); - } - pC = pC->pNextContainer; - } + for (TContainerData *p = pFirstContainer; p; p = p->pNext) + if (!p->settings->fPrivate) + SendMessage(p->hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0); } - else - ReloadGlobalContainerSettings(fForceResize); + else ReloadGlobalContainerSettings(fForceResize); } else { if (!isEx) @@ -153,9 +145,9 @@ static void ShowPage(HWND hwndDlg, int iPage, BOOL fShow) INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - struct TContainerData *pContainer = 0; + TContainerData *pContainer = 0; HWND hwndTree = GetDlgItem(hwndDlg, IDC_SECTIONTREE); - pContainer = (struct TContainerData *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + pContainer = (TContainerData *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index 7173c598a9..014f41ba20 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -372,8 +372,6 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa break; case PSN_APPLY: - struct TContainerData *pContainer = pFirstContainer; - TOptionListItem *defaultItems = CTranslator::getTree(CTranslator::TREE_NEN); for (int i=0; defaultItems[i].szName != NULL; i++) { TVITEM item = {0}; @@ -854,7 +852,7 @@ int TSAPI UpdateTrayMenu(const TWindowData *dat, WORD wStatus, const char *szPro } -int tabSRMM_ShowPopup(WPARAM wParam, LPARAM lParam, WORD eventType, int windowOpen, struct TContainerData *pContainer, HWND hwndChild, const char *szProto, struct TWindowData *dat) +int tabSRMM_ShowPopup(WPARAM wParam, LPARAM lParam, WORD eventType, int windowOpen, TContainerData *pContainer, HWND hwndChild, const char *szProto, struct TWindowData *dat) { if (nen_options.iDisable) // no popups at all. Period return 0; diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index c3ea6cb495..39100dd91d 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1990,21 +1990,21 @@ void SI_CheckStatusIconClick(struct TWindowData *dat, HWND hwndFrom, POINT pt, R if ((int)iconNum == list_icons && code != NM_RCLICK) { if (GetKeyState(VK_SHIFT) & 0x8000) { - struct TContainerData *piContainer = pFirstContainer; - - while (piContainer) { - piContainer->dwFlags = ((dat->pContainer->dwFlags & CNT_NOSOUND) ? piContainer->dwFlags | CNT_NOSOUND : piContainer->dwFlags & ~CNT_NOSOUND); + for (TContainerData *p = pFirstContainer; p; p = p->pNext) { + p->dwFlags = ((dat->pContainer->dwFlags & CNT_NOSOUND) ? p->dwFlags | CNT_NOSOUND : p->dwFlags & ~CNT_NOSOUND); InvalidateRect(dat->pContainer->hwndStatus, NULL, TRUE); - piContainer = piContainer->pNextContainer; } - } else { + } + else { dat->pContainer->dwFlags ^= CNT_NOSOUND; InvalidateRect(dat->pContainer->hwndStatus, NULL, TRUE); } - } else if ((int)iconNum == list_icons + 1 && code != NM_RCLICK && dat->bType == SESSIONTYPE_IM) { + } + else if ((int)iconNum == list_icons + 1 && code != NM_RCLICK && dat->bType == SESSIONTYPE_IM) { SendMessage(dat->pContainer->hwndActive, WM_COMMAND, IDC_SELFTYPING, 0); InvalidateRect(dat->pContainer->hwndStatus, NULL, TRUE); - } else if ((int)iconNum == list_icons + 2) { + } + else if ((int)iconNum == list_icons + 2) { if (code == NM_CLICK) PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, WM_LBUTTONUP); else if (code == NM_RCLICK) diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 7a3a1b0bde..4fc0bd95f5 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -146,7 +146,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { static POINT ptLast; static int iMousedown; - + if (msg == WM_TASKBARCREATED) { CreateSystrayIcon(FALSE); if (nen_options.bTraySupport) @@ -154,7 +154,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return 0; } - TContainerData *pContainer = pFirstContainer; + TContainerData *p; int iSelection; switch (msg) { @@ -276,8 +276,8 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; } } - while (--i >= 0); - + while (--i >= 0); + if (uid == 0 && pLastActiveContainer != NULL) { // no session found, restore last active container if (IsIconic(pLastActiveContainer->hwnd) || !IsWindowVisible(pLastActiveContainer->hwnd)) { SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); @@ -339,26 +339,20 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP nen_options.iNoAutoPopup ^= 1; break; case ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS: - while (pContainer) { - ShowWindow(pContainer->hwnd, SW_HIDE); - pContainer = pContainer->pNextContainer; - } + for (p = pFirstContainer; p; p = p->pNext) + ShowWindow(p->hwnd, SW_HIDE); break; case ID_TRAYCONTEXT_RESTOREALLMESSAGECONTAINERS: - while (pContainer) { - ShowWindow(pContainer->hwnd, SW_SHOW); - pContainer = pContainer->pNextContainer; - } + for (p = pFirstContainer; p; p = p->pNext) + ShowWindow(p->hwnd, SW_SHOW); break; case ID_TRAYCONTEXT_BE: nen_options.iDisable = 1; nen_options.iNoSounds = 1; nen_options.iNoAutoPopup = 1; - while (pContainer) { - SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 1); - pContainer = pContainer->pNextContainer; - } + for (p = pFirstContainer; p; p = p->pNext) + SendMessage(p->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 1); break; } } @@ -372,15 +366,15 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; /* - * handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message - * is posted to our invisible hotkey handler which does always run within the main thread. - * wParam is the hContact - * lParam the event handle - */ + * handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message + * is posted to our invisible hotkey handler which does always run within the main thread. + * wParam is the hContact + * lParam the event handle + */ case DM_HANDLECLISTEVENT: /* - * if lParam == NULL, don't consider clist events, just open the message tab - */ + * if lParam == NULL, don't consider clist events, just open the message tab + */ if (lParam == 0) HandleMenuEntryFromhContact((int)wParam); else { @@ -400,7 +394,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { HWND hWnd = M->FindWindow((HANDLE)lParam); if (hWnd && IsWindow(hWnd)) { - pContainer = 0; + TContainerData *pContainer = 0; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS)); @@ -409,7 +403,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP else SendMessage(hWnd, WM_CLOSE, 0, 1); - CreateNewTabForContact((struct TContainerData *)wParam, (HANDLE)lParam, 0, NULL, TRUE, TRUE, FALSE, 0); + CreateNewTabForContact((TContainerData *)wParam, (HANDLE)lParam, 0, NULL, TRUE, TRUE, FALSE, 0); } } } @@ -419,7 +413,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { SESSION_INFO *si = SM_FindSessionByHWND((HWND)lParam); if (si && IsWindow(si->hWnd)) { - pContainer = 0; + TContainerData *pContainer = 0; SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, 1159)); @@ -428,7 +422,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP else SendMessage(si->hWnd, WM_CLOSE, 0, 1); - si->hWnd = CreateNewRoom((struct TContainerData *)wParam, si, TRUE, 0, 0); + si->hWnd = CreateNewRoom((TContainerData *)wParam, si, TRUE, 0, 0); } } } @@ -447,8 +441,8 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return 0; /* - * sent from the popup to "dismiss" the event. we should do this in the main thread - */ + * sent from the popup to "dismiss" the event. we should do this in the main thread + */ case DM_REMOVECLISTEVENT: CallService(MS_CLIST_REMOVEEVENT, wParam, lParam); db_event_markRead((HANDLE)wParam, (HANDLE)lParam); @@ -479,38 +473,37 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } return 0; /* - * react to changes in the desktop composition state - * (enable/disable DWM, change to a non-aero visual style - * or classic Windows theme - */ + * react to changes in the desktop composition state + * (enable/disable DWM, change to a non-aero visual style + * or classic Windows theme + */ case WM_DWMCOMPOSITIONCHANGED: { bool fNewAero = M->getAeroState(); // refresh dwm state SendMessage(hwndDlg, WM_THEMECHANGED, 0, 0); - while (pContainer) { + for (p = pFirstContainer; p; p = p->pNext) { if (fNewAero) - SetAeroMargins(pContainer); + SetAeroMargins(p); else { MARGINS m = {0}; if (M->m_pfnDwmExtendFrameIntoClientArea) - M->m_pfnDwmExtendFrameIntoClientArea(pContainer->hwnd, &m); + M->m_pfnDwmExtendFrameIntoClientArea(p->hwnd, &m); } - if (pContainer->SideBar->isActive()) - RedrawWindow(GetDlgItem(pContainer->hwnd, 5000), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); // the container for the sidebar buttons - RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); - pContainer = pContainer->pNextContainer; + if (p->SideBar->isActive()) + RedrawWindow(GetDlgItem(p->hwnd, 5000), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); // the container for the sidebar buttons + RedrawWindow(p->hwnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); } } M->BroadcastMessage(WM_DWMCOMPOSITIONCHANGED, 0, 0); break; /* - * this message is fired when the user changes desktop color - * settings (Desktop->personalize) - * the handler reconfigures the aero-related skin images for - * tabs and buttons to match the new desktop color theme. - */ + * this message is fired when the user changes desktop color + * settings (Desktop->personalize) + * the handler reconfigures the aero-related skin images for + * tabs and buttons to match the new desktop color theme. + */ case WM_DWMCOLORIZATIONCOLORCHANGED: M->getAeroState(); Skin->setupAeroSkins(); @@ -518,9 +511,9 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; /* - * user has changed the visual style or switched to/from - * classic Windows theme - */ + * user has changed the visual style or switched to/from + * classic Windows theme + */ case WM_THEMECHANGED: M->getAeroState(); Skin->setupTabCloseBitmap(); @@ -529,10 +522,10 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &PluginConfig.m_ncm, 0); FreeTabConfig(); ReloadTabConfig(); - while (pContainer) { - SendMessage(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), EM_THEMECHANGED, 0, 0); - BroadCastContainer(pContainer, EM_THEMECHANGED, 0, 0); - pContainer = pContainer->pNextContainer; + + for (p = pFirstContainer; p; p = p->pNext) { + SendMessage(GetDlgItem(p->hwnd, IDC_MSGTABS), EM_THEMECHANGED, 0, 0); + BroadCastContainer(p, EM_THEMECHANGED, 0, 0); } break; @@ -562,7 +555,6 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case DM_MUCFLASHWORKER: { FLASH_PARAMS *p = reinterpret_cast(lParam); - if (1 == wParam) { CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)p->hContact, 1); p->bActiveTab = TRUE; @@ -582,18 +574,16 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_POWERBROADCAST: case WM_DISPLAYCHANGE: - while (pContainer) { + for (p = pFirstContainer; p; p = p->pNext) if (CSkin::m_skinEnabled) { // invalidate cached background DCs for skinned containers - pContainer->oldDCSize.cx = pContainer->oldDCSize.cy = 0; - SelectObject(pContainer->cachedDC, pContainer->oldHBM); - DeleteObject(pContainer->cachedHBM); - DeleteDC(pContainer->cachedDC); - pContainer->cachedDC = 0; - RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME); + p->oldDCSize.cx = p->oldDCSize.cy = 0; + SelectObject(p->cachedDC, p->oldHBM); + DeleteObject(p->cachedHBM); + DeleteDC(p->cachedDC); + p->cachedDC = 0; + RedrawWindow(p->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME); } - pContainer = pContainer->pNextContainer; - } - break; + break; case WM_ACTIVATE: if (LOWORD(wParam) != WA_ACTIVE) @@ -606,28 +596,27 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_TIMER: if (wParam == TIMERID_SENDLATER) { /* - * send heartbeat to each container, they use this to update - * dynamic content (i.e. local time in the info panel). - */ - while(pContainer) { - SendMessage(pContainer->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0); - pContainer = pContainer->pNextContainer; - } + * send heartbeat to each container, they use this to update + * dynamic content (i.e. local time in the info panel). + */ + for (p = pFirstContainer; p; p = p->pNext) + SendMessage(p->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0); + /* - * process send later contacts and jobs, if enough time has elapsed - */ + * process send later contacts and jobs, if enough time has elapsed + */ if (sendLater->isAvail() && !sendLater->isInteractive() && (time(0) - sendLater->lastProcessed()) > CSendLater::SENDLATER_PROCESS_INTERVAL) { sendLater->setLastProcessed(time(0)); /* - * check the list of contacts that may have new send later jobs - * (added on user's request) - */ + * check the list of contacts that may have new send later jobs + * (added on user's request) + */ sendLater->processContacts(); /* - * start processing the job list - */ + * start processing the job list + */ if (!sendLater->isJobListEmpty()) { KillTimer(hwndDlg, wParam); sendLater->startJobListProcess(); @@ -636,10 +625,10 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } } /* - * process one entry per tick (default: 200ms) - * TODO better timings, possibly slow down when many jobs are in the - * queue. - */ + * process one entry per tick (default: 200ms) + * TODO better timings, possibly slow down when many jobs are in the + * queue. + */ else if (wParam == TIMERID_SENDLATER_TICK) { if ( !sendLater->haveJobs()) { KillTimer(hwndDlg, wParam); diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 065bde4837..7699d1da01 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -702,7 +702,7 @@ int CMimAPI::DispatchNewEvent(WPARAM wParam, LPARAM lParam) int CMimAPI::MessageEventAdded(WPARAM wParam, LPARAM lParam) { BYTE bAutoPopup = FALSE, bAutoCreate = FALSE, bAutoContainer = FALSE, bAllowAutoCreate = 0; - struct TContainerData *pContainer = 0; + TContainerData *pContainer = 0; TCHAR szName[CONTAINER_NAMELEN + 1]; DWORD dwStatusMask = 0; struct TWindowData *mwdat=NULL; @@ -718,7 +718,7 @@ int CMimAPI::MessageEventAdded(WPARAM wParam, LPARAM lParam) CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)1); //MaD: hide on close mod, simulating standard behavior for hidden container if (hwnd) { - struct TContainerData *pTargetContainer = 0; + TContainerData *pTargetContainer = 0; WINDOWPLACEMENT wp={0}; wp.length = sizeof(wp); SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pTargetContainer); diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 1905ab5dcb..c43e6d5685 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2759,7 +2759,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return 0; } case DM_QUERYCONTAINER: { - struct TContainerData **pc = (struct TContainerData **) lParam; + TContainerData **pc = (TContainerData **) lParam; if (pc) *pc = m_pContainer; return 0; diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 868e59513b..f7367f58d6 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -362,10 +362,9 @@ static INT_PTR CALLBACK DlgProcSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L PluginConfig.m_HideOnClose = FALSE; - while(pFirstContainer) { + while(pFirstContainer) if (pFirstContainer->hwnd) SendMessage(pFirstContainer->hwnd, WM_CLOSE, 0, 1); - } PluginConfig.m_HideOnClose = fOldHideSetting; break; diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index f03b130180..63daf44ece 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -205,7 +205,7 @@ static INT_PTR GetWindowAPI(WPARAM,LPARAM) INT_PTR MessageWindowOpened(WPARAM wParam, LPARAM lParam) { HWND hwnd = 0; - struct TContainerData *pContainer = NULL; + TContainerData *pContainer = NULL; if (wParam) hwnd = M->FindWindow((HANDLE)wParam); @@ -253,7 +253,7 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) else { TCHAR szName[CONTAINER_NAMELEN + 1]; GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); - struct TContainerData *pContainer = FindContainerByName(szName); + TContainerData *pContainer = FindContainerByName(szName); if (pContainer == NULL) pContainer = CreateContainer(szName, FALSE, hContact); CreateNewTabForContact(pContainer, hContact, 0, NULL, TRUE, TRUE, FALSE, 0); @@ -312,7 +312,7 @@ INT_PTR SendMessageCommand_W(WPARAM wParam, LPARAM lParam) TCHAR szName[CONTAINER_NAMELEN + 1]; GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); - struct TContainerData *pContainer = FindContainerByName(szName); + TContainerData *pContainer = FindContainerByName(szName); if (pContainer == NULL) pContainer = CreateContainer(szName, FALSE, hContact); CreateNewTabForContact(pContainer, hContact, 1, (const char *)lParam, TRUE, TRUE, FALSE, 0); @@ -368,7 +368,7 @@ INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam) } else { TCHAR szName[CONTAINER_NAMELEN + 1]; GetContainerNameForContact((HANDLE) wParam, szName, CONTAINER_NAMELEN); - struct TContainerData *pContainer = FindContainerByName(szName); + TContainerData *pContainer = FindContainerByName(szName); if (pContainer == NULL) pContainer = CreateContainer(szName, FALSE, hContact); CreateNewTabForContact(pContainer, hContact, 0, (const char *) lParam, TRUE, TRUE, FALSE, 0); @@ -441,12 +441,8 @@ int MyAvatarChanged(WPARAM wParam, LPARAM lParam) if (wParam == 0 || IsBadReadPtr((void*)wParam, 4)) return 0; - struct TContainerData *pContainer = pFirstContainer; - - while (pContainer) { - BroadCastContainer(pContainer, DM_MYAVATARCHANGED, wParam, lParam); - pContainer = pContainer->pNextContainer; - } + for (TContainerData *p = pFirstContainer; p; p = p->pNext) + BroadCastContainer(p, DM_MYAVATARCHANGED, wParam, lParam); return 0; } @@ -662,7 +658,7 @@ int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild) * bPopupContainer: restore container if it was minimized, otherwise flash it... */ -HWND TSAPI CreateNewTabForContact(struct TContainerData *pContainer, HANDLE hContact, int isSend, const char *pszInitialText, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup, HANDLE hdbEvent) +HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, HANDLE hContact, int isSend, const char *pszInitialText, BOOL bActivateTab, BOOL bPopupContainer, BOOL bWantPopup, HANDLE hdbEvent) { TCHAR newcontactname[128], tabtitle[128]; int newItem; @@ -831,32 +827,26 @@ HWND TSAPI CreateNewTabForContact(struct TContainerData *pContainer, HANDLE hCon * a new (cloned) one. */ -struct TContainerData* TSAPI FindMatchingContainer(const TCHAR *szName, HANDLE hContact) +TContainerData* TSAPI FindMatchingContainer(const TCHAR *szName, HANDLE hContact) { - struct TContainerData *pDesired = 0; int iMaxTabs = M->GetDword("maxtabs", 0); - if (iMaxTabs > 0 && M->GetByte("limittabs", 0) && !_tcsncmp(szName, _T("default"), 6)) { - struct TContainerData *pCurrent = pFirstContainer; // search a "default" with less than iMaxTabs opened... - while (pCurrent) { - if (!_tcsncmp(pCurrent->szName, _T("default"), 6) && pCurrent->iChilds < iMaxTabs) { - pDesired = pCurrent; - break; - } - pCurrent = pCurrent->pNextContainer; - } - return(pDesired != NULL ? pDesired : NULL); - } else - return FindContainerByName(szName); + for (TContainerData *p = pFirstContainer; p; p = p->pNext) + if (!_tcsncmp(p->szName, _T("default"), 6) && p->iChilds < iMaxTabs) + return p; + + return NULL; + } + return FindContainerByName(szName); } + /* * load some global icons. */ void TSAPI CreateImageList(BOOL bInitial) { - HICON hIcon; int cxIcon = GetSystemMetrics(SM_CXSMICON); int cyIcon = GetSystemMetrics(SM_CYSMICON); @@ -868,7 +858,7 @@ void TSAPI CreateImageList(BOOL bInitial) if (bInitial) { PluginConfig.g_hImageList = ImageList_Create(16, 16, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 2, 0); - hIcon = CreateIcon(g_hInst, 16, 16, 1, 4, NULL, NULL); + HICON hIcon = CreateIcon(g_hInst, 16, 16, 1, 4, NULL, NULL); ImageList_AddIcon(PluginConfig.g_hImageList, hIcon); DestroyIcon(hIcon); } diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 3486988b96..1815b54228 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -188,7 +188,7 @@ struct TContainerSettings { }; struct TContainerData { - TContainerData *pNextContainer; + TContainerData *pNext; TCHAR szName[CONTAINER_NAMELEN + 4]; // container name HWND hwndActive; // active message window HWND hwnd; // the container handle diff --git a/plugins/TabSRMM/src/nen.h b/plugins/TabSRMM/src/nen.h index 815737feb7..9f51adca01 100644 --- a/plugins/TabSRMM/src/nen.h +++ b/plugins/TabSRMM/src/nen.h @@ -43,7 +43,7 @@ #define MODULE "tabSRMM_NEN" -int tabSRMM_ShowPopup(WPARAM wParam, LPARAM lParam, WORD eventType, int windowOpen, struct TContainerData *pContainer, HWND hwndChild, const char *szProto, struct TWindowData *dat); +int tabSRMM_ShowPopup(WPARAM wParam, LPARAM lParam, WORD eventType, int windowOpen, TContainerData *pContainer, HWND hwndChild, const char *szProto, struct TWindowData *dat); #define DEFAULT_COLBACK RGB(255,255,128) diff --git a/plugins/TabSRMM/src/selectcontainer.cpp b/plugins/TabSRMM/src/selectcontainer.cpp index 6936dc4d1b..269d3380bf 100644 --- a/plugins/TabSRMM/src/selectcontainer.cpp +++ b/plugins/TabSRMM/src/selectcontainer.cpp @@ -42,7 +42,7 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_INITDIALOG: { TCHAR szNewTitle[128]; RECT rc, rcParent; - struct TContainerData *pContainer = 0; + TContainerData *pContainer = 0; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) lParam); hwndMsgDlg = (HWND) lParam; @@ -105,10 +105,7 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L } case IDC_RENAMECONTAINER: { TCHAR szNewName[CONTAINER_NAMELEN], szName[CONTAINER_NAMELEN + 1]; - int iLen, iItem; - struct TContainerData *pCurrent = pFirstContainer; - - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME)); + int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME)); if (iLen) { GetWindowText(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME), szNewName, CONTAINER_NAMELEN); if (!_tcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN) || !_tcsncmp(szNewName, TranslateT("Default container"), CONTAINER_NAMELEN)) { @@ -116,7 +113,7 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L break; } - iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)- 1, (LPARAM)szNewName); + int iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)- 1, (LPARAM)szNewName); if (iItem != LB_ERR) { TCHAR szOldName[CONTAINER_NAMELEN + 1]; SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM)iItem, (LPARAM)szOldName); @@ -134,12 +131,11 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L int iIndex = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETITEMDATA, (WPARAM)iItem, 0); RenameContainer(iIndex, szNewName); SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_RESETCONTENT, 0, 0); - while (pCurrent) { - if (!_tcsncmp(pCurrent->szName, szName, CONTAINER_NAMELEN) && lstrlen(pCurrent->szName) == lstrlen(szName)) { - _tcsncpy(pCurrent->szName, szNewName, CONTAINER_NAMELEN); - SendMessage(pCurrent->hwnd, DM_CONFIGURECONTAINER, 0, 0); + for (TContainerData *p = pFirstContainer; p; p = p->pNext) { + if (!_tcsncmp(p->szName, szName, CONTAINER_NAMELEN) && lstrlen(p->szName) == lstrlen(szName)) { + _tcsncpy(p->szName, szNewName, CONTAINER_NAMELEN); + SendMessage(p->hwnd, DM_CONFIGURECONTAINER, 0, 0); } - pCurrent = pCurrent->pNextContainer; } SendMessage(hwndDlg, DM_SC_BUILDLIST, 0, 0); BuildContainerMenu(); @@ -149,13 +145,12 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L break; } case IDC_CREATENEW: { - int iLen, iItem; TCHAR szNewName[CONTAINER_NAMELEN], szName[CONTAINER_NAMELEN + 1]; - iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINER)); + int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINER)); if (iLen) { GetWindowText(GetDlgItem(hwndDlg, IDC_NEWCONTAINER), szNewName, CONTAINER_NAMELEN); - iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)- 1, (LPARAM)szNewName); + int iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)- 1, (LPARAM)szNewName); if (iItem != LB_ERR || !_tcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN)) { SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM)iItem, (LPARAM)szName); if (lstrlen(szName) == lstrlen(szNewName) || !_tcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN)) { @@ -186,7 +181,7 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L int iCounter = 0, iItemNew; char *szKey = "TAB_ContainersW"; char szValue[10]; - struct TContainerData *pContainer = 0; + TContainerData *pContainer = 0; do { _snprintf(szValue, 8, "%d", iCounter); if (M->GetTString(NULL, szKey, szValue, &dbv)) diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp index c9edabf1f3..e79bbad25c 100644 --- a/plugins/TabSRMM/src/tabctrl.cpp +++ b/plugins/TabSRMM/src/tabctrl.cpp @@ -1472,9 +1472,6 @@ INT_PTR CALLBACK DlgProcTabConfig(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case PSN_APPLY: { BOOL translated; - int fixedWidth; - - struct TContainerData *pContainer = pFirstContainer; M->WriteByte(SRMSGMOD_T, "y-pad", (BYTE)(GetDlgItemInt(hwndDlg, IDC_TABPADDING, NULL, FALSE))); M->WriteByte(SRMSGMOD_T, "x-pad", (BYTE)(GetDlgItemInt(hwndDlg, IDC_HTABPADDING, NULL, FALSE))); @@ -1485,15 +1482,15 @@ INT_PTR CALLBACK DlgProcTabConfig(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM M->WriteByte(SRMSGMOD_T, CSkin::m_skinEnabled ? "S_tborder_outer_bottom" : "tborder_outer_bottom", (BYTE) GetDlgItemInt(hwndDlg, IDC_TABBORDEROUTERBOTTOM, &translated, FALSE)); M->WriteDword(SRMSGMOD_T, "bottomadjust", GetDlgItemInt(hwndDlg, IDC_BOTTOMTABADJUST, &translated, TRUE)); - fixedWidth = GetDlgItemInt(hwndDlg, IDC_TABWIDTH, &translated, FALSE); + int fixedWidth = GetDlgItemInt(hwndDlg, IDC_TABWIDTH, &translated, FALSE); fixedWidth = (fixedWidth < 60 ? 60 : fixedWidth); M->WriteDword(SRMSGMOD_T, "fixedwidth", fixedWidth); FreeTabConfig(); ReloadTabConfig(); - while (pContainer) { - TabCtrl_SetPadding(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), GetDlgItemInt(hwndDlg, IDC_HTABPADDING, NULL, FALSE), GetDlgItemInt(hwndDlg, IDC_TABPADDING, NULL, FALSE)); - RedrawWindow(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), NULL, NULL, RDW_INVALIDATE | RDW_ERASE); - pContainer = pContainer->pNextContainer; + + for (TContainerData *p = pFirstContainer; p; p = p->pNext) { + TabCtrl_SetPadding(GetDlgItem(p->hwnd, IDC_MSGTABS), GetDlgItemInt(hwndDlg, IDC_HTABPADDING, NULL, FALSE), GetDlgItemInt(hwndDlg, IDC_TABPADDING, NULL, FALSE)); + RedrawWindow(GetDlgItem(p->hwnd, IDC_MSGTABS), NULL, NULL, RDW_INVALIDATE | RDW_ERASE); } return TRUE; } diff --git a/plugins/TabSRMM/src/templates.cpp b/plugins/TabSRMM/src/templates.cpp index 215be250c6..5daaf164cb 100644 --- a/plugins/TabSRMM/src/templates.cpp +++ b/plugins/TabSRMM/src/templates.cpp @@ -142,8 +142,8 @@ INT_PTR CALLBACK DlgProcTemplateEditor(HWND hwndDlg, UINT msg, WPARAM wParam, LP dat = (TWindowData*)calloc( sizeof(TWindowData), 1); ZeroMemory((void*) dat, sizeof(struct TWindowData)); - dat->pContainer = (struct TContainerData *)malloc(sizeof(struct TContainerData)); - ZeroMemory((void*)dat->pContainer, sizeof(struct TContainerData)); + dat->pContainer = (TContainerData *)malloc(sizeof(TContainerData)); + ZeroMemory((void*)dat->pContainer, sizeof(TContainerData)); teInfo = (TemplateEditorInfo *)dat->pContainer; ZeroMemory((void*)teInfo, sizeof(TemplateEditorInfo)); teInfo->hContact = teNew->hContact; diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp index 09ed80222b..56defcc5ff 100644 --- a/plugins/TabSRMM/src/themes.cpp +++ b/plugins/TabSRMM/src/themes.cpp @@ -1092,16 +1092,17 @@ void CSkin::Init(bool fStartup) */ bool CSkin::warnToClose() const { - if (::pFirstContainer) { - if (MessageBox(0, TranslateT("All message containers need to close before the skin can be changed\nProceed?"), - TranslateT("Change skin"), MB_YESNO | MB_ICONQUESTION) == IDYES) { - TContainerData *pContainer = ::pFirstContainer; - while (pFirstContainer) - SendMessage(pFirstContainer->hwnd, WM_CLOSE, 0, 1); - return true; - } else - return false; - } + if (::pFirstContainer == NULL) + return true; + + if (MessageBox(0, + TranslateT("All message containers need to close before the skin can be changed\nProceed?"), + TranslateT("Change skin"), MB_YESNO | MB_ICONQUESTION) != IDYES) + return false; + + TContainerData *pContainer = ::pFirstContainer; + while (pFirstContainer) + SendMessage(pFirstContainer->hwnd, WM_CLOSE, 0, 1); return true; } @@ -1911,7 +1912,7 @@ void CSkin::SkinCalcFrameWidth() * @param rcClient RECT *: client rectangle (target area) * @param hdcTarget HDC: device context of the target window */ -void CSkin::SkinDrawBG(HWND hwndClient, HWND hwnd, struct TContainerData *pContainer, RECT *rcClient, HDC hdcTarget) +void CSkin::SkinDrawBG(HWND hwndClient, HWND hwnd, TContainerData *pContainer, RECT *rcClient, HDC hdcTarget) { RECT rcWindow; POINT pt; @@ -2520,14 +2521,11 @@ void CSkin::initAeroEffect() m_BrushBack = ::CreateSolidBrush(0); } - TContainerData *pContainer = pFirstContainer; - - while (pContainer) { - InvalidateRect(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), NULL, TRUE); - InvalidateRect(pContainer->hwnd, NULL, TRUE); - if (IsWindow(GetDlgItem(pContainer->hwnd, 5000))) - InvalidateRect(GetDlgItem(pContainer->hwnd, 5000), NULL, TRUE); - pContainer = pContainer->pNextContainer; + for (TContainerData *p = pFirstContainer; p; p = p->pNext) { + InvalidateRect(GetDlgItem(p->hwnd, IDC_MSGTABS), NULL, TRUE); + InvalidateRect(p->hwnd, NULL, TRUE); + if (IsWindow(GetDlgItem(p->hwnd, 5000))) + InvalidateRect(GetDlgItem(p->hwnd, 5000), NULL, TRUE); } } diff --git a/plugins/TabSRMM/src/themes.h b/plugins/TabSRMM/src/themes.h index 62b8efad81..da939dbbf1 100644 --- a/plugins/TabSRMM/src/themes.h +++ b/plugins/TabSRMM/src/themes.h @@ -299,7 +299,7 @@ public: * static member functions */ static void TSAPI SkinDrawBGFromDC(HWND hwndClient, HWND hwnd, RECT *rcClient, HDC hdcTarget); - static void TSAPI SkinDrawBG(HWND hwndClient, HWND hwnd, struct TContainerData *pContainer, RECT *rcClient, HDC hdcTarget); + static void TSAPI SkinDrawBG(HWND hwndClient, HWND hwnd, TContainerData *pContainer, RECT *rcClient, HDC hdcTarget); static void TSAPI MY_AlphaBlend(HDC hdcDraw, DWORD left, DWORD top, int width, int height, int bmWidth, int bmHeight, HDC hdcMem); static void TSAPI DrawDimmedIcon(HDC hdc, LONG left, LONG top, LONG dx, LONG dy, HICON hIcon, BYTE alpha); static DWORD __fastcall HexStringToLong(const TCHAR *szSource); -- cgit v1.2.3