summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-06-04 11:40:30 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-06-04 11:40:30 +0300
commit4a1f343d8684deaaa67e6ee56f0769b8bab8d6c8 (patch)
treeff6f7ecd735e12f636e6f4eabf842b064ce20327 /plugins/TabSRMM/src
parent622ef660a9e8c08bf24d4ae876cd58cdcb97f6f7 (diff)
tabSRMM:
- duplicate code removed; - code cleaning
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/chat_options.cpp6
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp41
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp34
-rw-r--r--plugins/TabSRMM/src/msgs.cpp88
-rw-r--r--plugins/TabSRMM/src/msgs.h6
-rw-r--r--plugins/TabSRMM/src/stdafx.h1
-rw-r--r--plugins/TabSRMM/src/taskbar.cpp8
7 files changed, 54 insertions, 130 deletions
diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp
index 1ecc58c897..c15aca56c1 100644
--- a/plugins/TabSRMM/src/chat_options.cpp
+++ b/plugins/TabSRMM/src/chat_options.cpp
@@ -255,10 +255,10 @@ static IconItem _logicons[] =
};
// add icons to the skinning module
-void Chat_AddIcons(void)
+void Chat_AddIcons(HINSTANCE hIconDll)
{
- Icon_Register(g_hIconDLL, LPGEN("Message Sessions") "/" LPGEN("Group chat windows"), _icons, _countof(_icons), 0, &g_plugin);
- Icon_Register(g_hIconDLL, LPGEN("Message Sessions") "/" LPGEN("Group chat log"), _logicons, _countof(_logicons), 0, &g_plugin);
+ Icon_Register(hIconDll, LPGEN("Message Sessions") "/" LPGEN("Group chat windows"), _icons, _countof(_icons), 0, &g_plugin);
+ Icon_Register(hIconDll, LPGEN("Message Sessions") "/" LPGEN("Group chat log"), _logicons, _countof(_logicons), 0, &g_plugin);
g_chatApi.MM_IconsChanged();
}
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index 432692a125..70e1b140ca 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -737,47 +737,6 @@ void CChatRoomDlg::AddLog()
CSrmmBaseDialog::AddLog();
}
-void CChatRoomDlg::CloseTab()
-{
- int iTabs = TabCtrl_GetItemCount(m_hwndParent);
- if (iTabs == 1 && CMimAPI::m_shutDown == 0) {
- SendMessage(m_pContainer->m_hwnd, WM_CLOSE, 0, 1);
- return;
- }
-
- m_pContainer->m_iChilds--;
- int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd);
-
- // after closing a tab, we need to activate the tab to the left side of
- // the previously open tab.
- // normally, this tab has the same index after the deletion of the formerly active tab
- // unless, of course, we closed the last (rightmost) tab.
- if (!m_pContainer->m_bDontSmartClose && iTabs > 1) {
- if (i == iTabs - 1)
- i--;
- else
- i++;
- TabCtrl_SetCurSel(m_hwndParent, i);
-
- m_pContainer->m_hwndActive = GetTabWindow(m_hwndParent, i);
-
- RECT rc;
- SendMessage(m_pContainer->m_hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc);
- SetWindowPos(m_pContainer->m_hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW);
- ShowWindow(m_pContainer->m_hwndActive, SW_SHOW);
- SetForegroundWindow(m_pContainer->m_hwndActive);
- SetFocus(m_pContainer->m_hwndActive);
- SendMessage(m_pContainer->m_hwnd, WM_SIZE, 0, 0);
- }
-
- if (iTabs == 1)
- SendMessage(m_pContainer->m_hwnd, WM_CLOSE, 0, 1);
- else {
- PostMessage(m_pContainer->m_hwnd, WM_SIZE, 0, 0);
- DestroyWindow(m_hwnd);
- }
-}
-
void CChatRoomDlg::RedrawLog()
{
m_si->LastTime = 0;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index e4a30f9f95..3d0b6aa4c4 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -2971,39 +2971,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
return TRUE;
}
}
- {
- int iTabs = TabCtrl_GetItemCount(m_hwndParent);
- if (iTabs == 1) {
- PostMessage(m_pContainer->m_hwnd, WM_CLOSE, 0, 1);
- return 1;
- }
-
- m_pContainer->m_iChilds--;
-
- // after closing a tab, we need to activate the tab to the left side of
- // the previously open tab.
- // normally, this tab has the same index after the deletion of the formerly active tab
- // unless, of course, we closed the last (rightmost) tab.
- if (!m_pContainer->m_bDontSmartClose && iTabs > 1 && lParam != 3) {
- int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd);
- if (i == iTabs - 1)
- i--;
- else
- i++;
- TabCtrl_SetCurSel(m_hwndParent, i);
-
- // retrieve dialog hwnd for the now active tab...
- m_pContainer->m_hwndActive = GetTabWindow(m_hwndParent, i);
-
- SendMessage(m_pContainer->m_hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc);
- SetWindowPos(m_pContainer->m_hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW);
- ShowWindow(m_pContainer->m_hwndActive, SW_SHOW);
- SetForegroundWindow(m_pContainer->m_hwndActive);
- SetFocus(m_pContainer->m_hwndActive);
- }
- }
-
- SendMessage(m_pContainer->m_hwnd, WM_SIZE, 0, 0);
+ CloseTab();
break;
case WM_DWMCOMPOSITIONCHANGED:
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index 019ee5f7d3..579eb5b796 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -33,12 +33,12 @@
NEN_OPTIONS nen_options;
static HANDLE hUserPrefsWindowLis = nullptr;
-HMODULE g_hIconDLL = nullptr, g_hMsftedit;
+HMODULE g_hMsftedit;
static void UnloadIcons();
int OptInitialise(WPARAM wParam, LPARAM lParam);
-void Chat_AddIcons();
+void Chat_AddIcons(HINSTANCE);
/////////////////////////////////////////////////////////////////////////////////////////
// fired event when user changes IEView plugin options. Apply them to all open tabs
@@ -86,6 +86,41 @@ CTabBaseDlg::~CTabBaseDlg()
if (m_hTaskbarIcon) DestroyIcon(m_hTaskbarIcon);
}
+void CTabBaseDlg::CloseTab()
+{
+ int iTabs = TabCtrl_GetItemCount(m_hwndParent);
+ if (iTabs == 1) {
+ SendMessage(m_pContainer->m_hwnd, WM_CLOSE, 0, 1);
+ return;
+ }
+
+ m_pContainer->m_iChilds--;
+ int i = GetTabIndexFromHWND(m_hwndParent, m_hwnd);
+
+ // after closing a tab, we need to activate the tab to the left side of
+ // the previously open tab.
+ // normally, this tab has the same index after the deletion of the formerly active tab
+ // unless, of course, we closed the last (rightmost) tab.
+ if (!m_pContainer->m_bDontSmartClose && iTabs > 1) {
+ if (i == iTabs - 1)
+ i--;
+ else
+ i++;
+ TabCtrl_SetCurSel(m_hwndParent, i);
+
+ m_pContainer->m_hwndActive = GetTabWindow(m_hwndParent, i);
+
+ RECT rc;
+ SendMessage(m_pContainer->m_hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)& rc);
+ SetWindowPos(m_pContainer->m_hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW);
+ ShowWindow(m_pContainer->m_hwndActive, SW_SHOW);
+ SetForegroundWindow(m_pContainer->m_hwndActive);
+ SetFocus(m_pContainer->m_hwndActive);
+ }
+
+ SendMessage(m_pContainer->m_hwnd, WM_SIZE, 0, 0);
+}
+
void CTabBaseDlg::LoadSettings()
{
m_clrInputBG = m_pContainer->m_theme.inputbg;
@@ -449,11 +484,6 @@ int SplitmsgShutdown(void)
FreeLibrary(g_hMsftedit);
- if (g_hIconDLL) {
- FreeLibrary(g_hIconDLL);
- g_hIconDLL = nullptr;
- }
-
ImageList_RemoveAll(PluginConfig.g_hImageList);
ImageList_Destroy(PluginConfig.g_hImageList);
@@ -665,7 +695,7 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact,
RedrawWindow(pContainer->m_hwndActive, nullptr, nullptr, RDW_ERASENOW | RDW_UPDATENOW);
}
- if (PluginConfig.m_bHideOnClose&&!IsWindowVisible(pContainer->m_hwnd)) {
+ if (PluginConfig.m_bHideOnClose && !IsWindowVisible(pContainer->m_hwnd)) {
WINDOWPLACEMENT wp = { 0 };
wp.length = sizeof(wp);
GetWindowPlacement(pContainer->m_hwnd, &wp);
@@ -729,11 +759,7 @@ void TSAPI CreateImageList(BOOL bInitial)
PluginConfig.g_IconFileEvent = Skin_LoadIcon(SKINICON_EVENT_FILE);
PluginConfig.g_IconMsgEvent = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
PluginConfig.g_IconMsgEventBig = Skin_LoadIcon(SKINICON_EVENT_MESSAGE, true);
- if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconMsgEventBig)
- PluginConfig.g_IconMsgEventBig = nullptr;
PluginConfig.g_IconTypingEventBig = Skin_LoadIcon(SKINICON_OTHER_TYPING, true);
- if ((HICON)CALLSERVICE_NOTFOUND == PluginConfig.g_IconTypingEventBig)
- PluginConfig.g_IconTypingEventBig = nullptr;
PluginConfig.g_IconSend = PluginConfig.g_buttonBarIcons[9];
PluginConfig.g_IconTypingEvent = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING];
}
@@ -812,48 +838,24 @@ static ICONBLOCKS[] = {
{ LPGEN("Message Sessions") "/" LPGEN("Animated Tray"), _trayIcon, _countof(_trayIcon) }
};
-static int GetIconPackVersion(HMODULE hDLL)
-{
- char szIDString[256];
- int version = 0;
-
- if (LoadStringA(hDLL, IDS_IDENTIFY, szIDString, sizeof(szIDString)) == 0)
- version = 0;
- else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 1.0__"))
- version = 1;
- else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 2.0__"))
- version = 2;
- else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 3.0__"))
- version = 3;
- else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 3.5__"))
- version = 4;
- else if (!mir_strcmp(szIDString, "__tabSRMM_ICONPACK 5.0__"))
- version = 5;
-
- return version;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// setup default icons for the IcoLib service. This needs to be done every time the
// plugin is loaded default icons are taken from the icon pack in either \icons or \plugins
static int TSAPI SetupIconLibConfig()
{
- int j = 2, version = 0;
+ int j = 2;
- wchar_t szFilename[MAX_PATH];
- wcsncpy(szFilename, L"icons\\tabsrmm_icons.dll", MAX_PATH);
- g_hIconDLL = LoadLibrary(szFilename);
- if (g_hIconDLL == nullptr) {
+ HINSTANCE hIconDll = LoadLibraryA("icons\\tabsrmm_icons.dll");
+ if (hIconDll == nullptr) {
CWarning::show(CWarning::WARN_ICONPACKMISSING, CWarning::CWF_NOALLOWHIDE | MB_ICONERROR | MB_OK);
return 0;
}
- GetModuleFileName(g_hIconDLL, szFilename, MAX_PATH);
- Chat_AddIcons();
- version = GetIconPackVersion(g_hIconDLL);
- FreeLibrary(g_hIconDLL);
- g_hIconDLL = nullptr;
+ wchar_t szFilename[MAX_PATH];
+ GetModuleFileName(hIconDll, szFilename, MAX_PATH);
+ Chat_AddIcons(hIconDll);
+ FreeLibrary(hIconDll);
SKINICONDESC sid = {};
sid.defaultFile.w = szFilename;
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 0e498bb327..9a880891c6 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -244,8 +244,9 @@ class CTabBaseDlg : public CSrmmBaseDialog
friend class CInfoPanel;
protected:
- virtual void LoadSettings() override;
- virtual void SetStatusText(const wchar_t*, HICON) override;
+ void CloseTab() override;
+ void LoadSettings() override;
+ void SetStatusText(const wchar_t*, HICON) override;
void DM_AddDivider();
void DM_DismissTip(const POINT& pt);
@@ -539,7 +540,6 @@ public:
int Resizer(UTILRESIZECONTROL *urc) override;
void AddLog() override;
- void CloseTab() override;
void RedrawLog() override;
void ScrollToBottom() override;
void ShowFilterMenu() override;
diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h
index 240ebe05ab..7529b738d6 100644
--- a/plugins/TabSRMM/src/stdafx.h
+++ b/plugins/TabSRMM/src/stdafx.h
@@ -226,7 +226,6 @@ extern BOOL g_bIMGtagButton;
extern char *TemplateNames[];
extern HANDLE hUserPrefsWindowList;
extern TCpTable cpTable[];
-extern HMODULE g_hIconDLL;
extern pfnDoPopup oldDoPopup, oldLogToFile;
extern pfnDoTrayIcon oldDoTrayIcon;
diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp
index 68606e093f..1fe035bc38 100644
--- a/plugins/TabSRMM/src/taskbar.cpp
+++ b/plugins/TabSRMM/src/taskbar.cpp
@@ -518,13 +518,9 @@ LRESULT CALLBACK CProxyWindow::wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA
{
switch (msg) {
case WM_CLOSE:
+ SendMessage(m_dat->GetHwnd(), WM_CLOSE, 1, 2);
{
- TContainerData* pC = m_dat->m_pContainer;
-
- if (m_dat->GetHwnd() != pC->m_hwndActive)
- SendMessage(m_dat->GetHwnd(), WM_CLOSE, 1, 3);
- else
- SendMessage(m_dat->GetHwnd(), WM_CLOSE, 1, 2);
+ TContainerData *pC = m_dat->m_pContainer;
if (!IsIconic(pC->m_hwnd))
SetForegroundWindow(pC->m_hwnd);
}