diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-14 20:27:44 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-14 20:27:44 +0300 |
commit | 0edc6006e17f896324d4011acdf5e16162572908 (patch) | |
tree | 0894285d03393bbb891a6bac94f2fbda07ea40cc | |
parent | b408d9e8208c426c263c69602edfa8a4978fa3bf (diff) |
tabSRMM:
- fixes #735 (crazy dark magic of Windows);
- common code of window creation moved to CTabBaseDlg::OnInitDialog();
- DM_REFRESHTABINDEX replaced with the call of TContainerData::UpdateTabs();
-rw-r--r-- | plugins/TabSRMM/src/chat_window.cpp | 15 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 15 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 15 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 25 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/version.h | 2 |
7 files changed, 49 insertions, 28 deletions
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 6a23c3f3d1..18ae16fec0 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -1556,7 +1556,7 @@ void CChatRoomDlg::tabClearLog() void CChatRoomDlg::OnInitDialog() { - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); + CTabBaseDlg::OnInitDialog(); m_cache = CContactCache::getContactCache(m_hContact); m_cache->updateNick(); @@ -1579,10 +1579,8 @@ void CChatRoomDlg::OnInitDialog() SetTimer(m_hwnd, TIMERID_TYPE, 1000, nullptr); } - m_pPanel.setActive(false); + m_pPanel.getVisibility(); m_pPanel.Configure(); - M.AddWindow(m_hwnd, m_hContact); - BroadCastContainer(m_pContainer, DM_REFRESHTABINDEX, 0, 0); m_log.SendMsg(EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback); m_log.SendMsg(EM_AUTOURLDETECT, 1, 0); @@ -1601,7 +1599,6 @@ void CChatRoomDlg::OnInitDialog() if (PluginConfig.g_hMenuTrayUnread != 0 && m_hContact != 0 && m_szProto != nullptr) UpdateTrayMenu(0, m_wStatus, m_szProto, m_wszStatus, m_hContact, FALSE); - DM_ThemeChanged(); m_log.SendMsg(EM_HIDESELECTION, TRUE, 0); GetMYUIN(); @@ -1673,7 +1670,7 @@ void CChatRoomDlg::OnDestroy() if (i >= 0) { SendMessage(m_hwndParent, WM_USER + 100, 0, 0); // clean up tooltip TabCtrl_DeleteItem(m_hwndParent, i); - BroadCastContainer(m_pContainer, DM_REFRESHTABINDEX, 0, 0); + m_pContainer->UpdateTabs(); m_iTabID = -1; } if (m_pWnd) { @@ -2954,10 +2951,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } return 0; - case DM_REFRESHTABINDEX: - m_iTabID = GetTabIndexFromHWND(m_hwndParent, m_hwnd); - return 0; - case WM_CBD_UPDATED: if (lParam) CB_ChangeButton((CustomButtonData*)lParam); @@ -3073,7 +3066,7 @@ void ShowRoom(SESSION_INFO *si) TCITEM item = {}; item.pszText = newcontactname; - item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; + item.mask = TCIF_TEXT | TCIF_IMAGE; int iTabId = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &item); SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0); diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 9163fd0e08..3a86d7910c 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -41,6 +41,21 @@ static TContainerData* TSAPI RemoveContainerFromList(TContainerData*); static bool fForceOverlayIcons = false;
+void TContainerData::UpdateTabs()
+{
+ int nTabs = TabCtrl_GetItemCount(hwnd);
+ for (int i = 0; i < nTabs; i++) {
+ TCITEM tci;
+ tci.mask = TCIF_PARAM;
+ if (!TabCtrl_GetItem(hwnd, i, &tci))
+ continue;
+
+ CTabBaseDlg *dat = (CTabBaseDlg*)GetWindowLongPtr((HWND)tci.lParam, GWLP_USERDATA);
+ if (dat)
+ dat->m_iTabID = i;
+ }
+}
+
void TContainerData::UpdateTitle(MCONTACT hContact, CTabBaseDlg *pDlg)
{
if (pDlg) { // lParam != 0 means sent by a chat window
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 7279902229..bc1b473ccd 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -958,19 +958,16 @@ CThumbBase* CSrmmWindow::tabCreateThumb(CProxyWindow *pProxy) const void CSrmmWindow::OnInitDialog()
{
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
+ CTabBaseDlg::OnInitDialog();
if (Utils::rtf_ctable == 0)
Utils::RTF_CTableInit();
- DM_ThemeChanged();
-
m_cache = CContactCache::getContactCache(m_hContact);
m_cache->updateNick();
m_cache->setWindowData(this);
- M.AddWindow(m_hwnd, m_hContact);
- BroadCastContainer(m_pContainer, DM_REFRESHTABINDEX, 0, 0);
- CProxyWindow::add(this);
+
+ //////////////////////////////////////////////////////////////////////////////////////
m_szProto = const_cast<char *>(m_cache->getProto());
m_bIsMeta = m_cache->isMeta();
if (m_bIsMeta)
@@ -1301,7 +1298,7 @@ void CSrmmWindow::OnDestroy() if (i >= 0) {
SendMessage(m_hwndParent, WM_USER + 100, 0, 0); // remove tooltip
TabCtrl_DeleteItem(m_hwndParent, i);
- BroadCastContainer(m_pContainer, DM_REFRESHTABINDEX, 0, 0);
+ m_pContainer->UpdateTabs();
m_iTabID = -1;
}
@@ -2933,10 +2930,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) DM_ThemeChanged();
return 0;
- case DM_REFRESHTABINDEX:
- m_iTabID = GetTabIndexFromHWND(GetParent(m_hwnd), m_hwnd);
- return 0;
-
case DM_STATUSICONCHANGE:
if (m_pContainer->hwndStatus) {
SendMessage(m_pContainer->hwnd, WM_SIZE, 0, 0);
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 368a29f5e7..8fd3b87740 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -90,7 +90,7 @@ void TSAPI RearrangeTab(HWND hwndDlg, const CTabBaseDlg *dat, int iMode, BOOL fS TabCtrl_DeleteItem(hwndTab, dat->m_iTabID);
item.lParam = (LPARAM)hwndDlg;
TabCtrl_InsertItem(hwndTab, newIndex, &item);
- BroadCastContainer(dat->m_pContainer, DM_REFRESHTABINDEX, 0, 0);
+ dat->m_pContainer->UpdateTabs();
ActivateTabFromHWND(hwndTab, hwndDlg);
if (fSavePos)
db_set_dw(dat->m_hContact, SRMSGMOD_T, "tabindex", newIndex * 100);
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index cd5e765b0c..2df17da155 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -147,6 +147,27 @@ CTabBaseDlg::~CTabBaseDlg() if (m_hTaskbarIcon) DestroyIcon(m_hTaskbarIcon);
}
+void CTabBaseDlg::OnInitDialog()
+{
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
+
+ // m_hwnd is valid, pass it to the tab control
+ TCITEM tci;
+ tci.mask = TCIF_PARAM;
+ tci.lParam = (LPARAM)m_hwnd;
+ TabCtrl_SetItem(m_hwndParent, m_iTabID, &tci);
+
+ // update another tab ids
+ m_pContainer->UpdateTabs();
+
+ // add this window to window list & proxy
+ M.AddWindow(m_hwnd, m_hContact);
+ CProxyWindow::add(this);
+
+ // set up Windows themes
+ DM_ThemeChanged();
+}
+
INT_PTR CTabBaseDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -701,7 +722,7 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, TCITEM item = {};
item.pszText = tabtitle;
- item.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
+ item.mask = TCIF_TEXT | TCIF_IMAGE;
item.iImage = 0;
item.cchTextMax = _countof(tabtitle);
int iTabId = TabCtrl_InsertItem(hwndTab, pContainer->iTabIndex, &item);
@@ -725,8 +746,6 @@ HWND TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, pWindow->Create();
HWND hwndNew = pWindow->GetHwnd();
- item.lParam = (LPARAM)hwndNew;
- TabCtrl_SetItem(hwndTab, iTabId, &item);
// switchbar support
if (pContainer->dwFlags & CNT_SIDEBAR)
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 3ce2656ff3..1f97f52581 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -225,6 +225,7 @@ struct TContainerData CMenuBar *MenuBar;
CSideBar *SideBar;
+ void UpdateTabs();
void UpdateTitle(MCONTACT, class CTabBaseDlg* = nullptr);
void ClearMargins()
@@ -362,6 +363,7 @@ public: CTabBaseDlg(int iDialogId, SESSION_INFO* = nullptr);
virtual ~CTabBaseDlg();
+ virtual void OnInitDialog() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
virtual CThumbBase* tabCreateThumb(CProxyWindow*) const = 0;
@@ -724,7 +726,6 @@ struct TIconDescW #define DM_REMOVECLISTEVENT (TM_USER+75)
#define DM_GETWINDOWSTATE (TM_USER+76)
#define DM_DOCREATETAB (TM_USER+77)
-#define DM_REFRESHTABINDEX (TM_USER+83)
#define DM_SMILEYOPTIONSCHANGED (TM_USER+85)
#define DM_MYAVATARCHANGED (TM_USER+86)
#define DM_IEVIEWOPTIONSCHANGED (TM_USER+88)
diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h index 15aa63e569..15cef1d4f9 100644 --- a/plugins/TabSRMM/src/version.h +++ b/plugins/TabSRMM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3
#define __MINOR_VERSION 5
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
|