diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-28 14:18:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-28 14:18:31 +0300 |
commit | 6a9e3738066370dac38f5f6768b8a6f61fe709e0 (patch) | |
tree | 035d3b553c313505707f236e6c9c973416e1be65 /plugins/Scriver | |
parent | b60c918dbcb16f4da7c35c15b190ee9def957a49 (diff) |
SRMM notifications went to the core with ME_MSG_WINDOWEVENT
Diffstat (limited to 'plugins/Scriver')
-rw-r--r-- | plugins/Scriver/src/chat_window.cpp | 8 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 24 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 54 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/tabs.cpp | 61 | ||||
-rw-r--r-- | plugins/Scriver/src/tabs.h | 3 |
7 files changed, 70 insertions, 84 deletions
diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index d431f6a89b..970d78429a 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -211,7 +211,7 @@ void CChatRoomDlg::OnInitDialog() CSuper::OnInitDialog();
m_si->pDlg = this;
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING);
+ NotifyEvent(MSG_WINDOW_EVT_OPENING);
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA);
@@ -265,12 +265,12 @@ void CChatRoomDlg::OnInitDialog() SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)this, 0);
UpdateNickList();
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPEN);
+ NotifyEvent(MSG_WINDOW_EVT_OPEN);
}
void CChatRoomDlg::OnDestroy()
{
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING);
+ NotifyEvent(MSG_WINDOW_EVT_CLOSING);
m_si->pDlg = nullptr;
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
@@ -284,7 +284,7 @@ void CChatRoomDlg::OnDestroy() CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
}
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE);
+ NotifyEvent(MSG_WINDOW_EVT_CLOSE);
CSuper::OnDestroy();
}
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index e1e2e7525a..a798d00868 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -91,22 +91,6 @@ static wchar_t* GetQuotedTextW(wchar_t *text) return out;
}
-void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type)
-{
- if (hContact == 0 || hwnd == nullptr)
- return;
-
- MessageWindowEventData mwe = { sizeof(mwe) };
- mwe.hContact = hContact;
- mwe.hwndWindow = hwnd;
- mwe.szModule = SRMM_MODULE;
- mwe.uType = type;
- mwe.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
- mwe.hwndInput = GetDlgItem(hwnd, IDC_SRMM_MESSAGE);
- mwe.hwndLog = GetDlgItem(hwnd, IDC_SRMM_LOG);
- NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe);
-}
-
int RTL_Detect(WCHAR *pszwText)
{
size_t iLen = mir_wstrlen(pszwText);
@@ -220,7 +204,7 @@ void CSrmmWindow::OnInitDialog() SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
WindowList_Add(pci->hWindowList, m_hwnd, m_hContact);
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING);
+ NotifyEvent(MSG_WINDOW_EVT_OPENING);
m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA);
m_szProto = GetContactProto(m_hContact);
@@ -413,12 +397,12 @@ void CSrmmWindow::OnInitDialog() if (m_iMessagesInProgress > 0)
SendMessage(m_hwnd, DM_SHOWMESSAGESENDING, 0, 0);
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPEN);
+ NotifyEvent(MSG_WINDOW_EVT_OPEN);
}
void CSrmmWindow::OnDestroy()
{
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING);
+ NotifyEvent(MSG_WINDOW_EVT_CLOSING);
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON)
NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
@@ -459,7 +443,7 @@ void CSrmmWindow::OnDestroy() ieWindow.hwnd = m_hwndIeview;
CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
}
- NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE);
+ NotifyEvent(MSG_WINDOW_EVT_CLOSE);
CSuper::OnDestroy();
}
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 90f5c36252..b6478dc16b 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
HCURSOR hDragCursor;
-HANDLE hHookWinEvt, hHookWinPopup, hHookWinWrite;
+HANDLE hHookWinPopup, hHookWinWrite;
HGENMENU hMsgMenuItem;
HMODULE hMsftEdit;
@@ -376,6 +376,56 @@ void CScriverWindow::LoadSettings() LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG);
}
+void CScriverWindow::Reattach(HWND hwndContainer)
+{
+ MCONTACT hContact = m_hContact;
+
+ POINT pt;
+ GetCursorPos(&pt);
+ HWND hParent = WindowFromPoint(pt);
+ while (GetParent(hParent) != nullptr)
+ hParent = GetParent(hParent);
+
+ hParent = WindowList_Find(g_dat.hParentWindowList, (UINT_PTR)hParent);
+ if ((hParent != nullptr && hParent != hwndContainer) || (hParent == nullptr && m_pParent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
+ if (hParent == nullptr) {
+ hParent = GetParentWindow(hContact, FALSE);
+
+ RECT rc;
+ GetWindowRect(hParent, &rc);
+
+ rc.right = (rc.right - rc.left);
+ rc.bottom = (rc.bottom - rc.top);
+ rc.left = pt.x - rc.right / 2;
+ rc.top = pt.y - rc.bottom / 2;
+ HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
+
+ MONITORINFO mi;
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor, &mi);
+
+ RECT rcDesktop = mi.rcWork;
+ if (rc.left < rcDesktop.left)
+ rc.left = rcDesktop.left;
+ if (rc.top < rcDesktop.top)
+ rc.top = rcDesktop.top;
+ MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE);
+ }
+ NotifyEvent(MSG_WINDOW_EVT_CLOSING);
+ NotifyEvent(MSG_WINDOW_EVT_CLOSE);
+ SetParent(hParent);
+ SendMessage(hwndContainer, CM_REMOVECHILD, 0, (LPARAM)m_hwnd);
+ SendMessage(m_hwnd, DM_SETPARENT, 0, (LPARAM)hParent);
+ SendMessage(hParent, CM_ADDCHILD, (WPARAM)this, 0);
+ SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0);
+ SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)m_hwnd);
+ NotifyEvent(MSG_WINDOW_EVT_OPENING);
+ NotifyEvent(MSG_WINDOW_EVT_OPEN);
+ ShowWindow(hParent, SW_SHOWNA);
+ EnableWindow(hParent, TRUE);
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// status icons processing
@@ -592,7 +642,6 @@ int OnUnloadModule(void) {
DestroyCursor(hDragCursor);
- DestroyHookableEvent(hHookWinEvt);
DestroyHookableEvent(hHookWinPopup);
DestroyHookableEvent(hHookWinWrite);
@@ -639,7 +688,6 @@ int OnLoadModule(void) CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand);
CreateServiceFunction("SRMsg/TypingMessage", TypingMessageCommand);
- hHookWinEvt = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
hHookWinWrite = CreateHookableEvent(ME_MSG_PRECREATEEVENT);
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 58c80d4d6a..935fdaa1dc 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -98,6 +98,8 @@ public: virtual void CloseTab() override;
virtual void LoadSettings() override;
+ void Reattach(HWND hwndContainer);
+
ParentWindowData *m_pParent;
int m_minLogBoxHeight, m_minEditBoxHeight;
HWND m_hwndIeview;
diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 77a01e40a2..09d0124a84 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -91,7 +91,7 @@ extern HWND SM_FindWindowByContact(MCONTACT hContact); extern HINSTANCE g_hInst;
extern HCURSOR hDragCursor;
extern ITaskbarList3 *pTaskbarInterface;
-extern HANDLE hHookWinPopup, hHookWinWrite, hHookWinEvt;
+extern HANDLE hHookWinPopup, hHookWinWrite;
void ChangeStatusIcons();
void LoadInfobarFonts();
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp index 3b164494c6..7dbc4f7c91 100644 --- a/plugins/Scriver/src/tabs.cpp +++ b/plugins/Scriver/src/tabs.cpp @@ -429,55 +429,8 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) tci.mask = TCIF_PARAM;
TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
CScriverWindow *pDlg = (CScriverWindow*)tci.lParam;
- if (pDlg != nullptr) {
- HWND hChild = pDlg->GetHwnd();
- MCONTACT hContact = pDlg->m_hContact;
-
- POINT pt;
- GetCursorPos(&pt);
- HWND hParent = WindowFromPoint(pt);
- while (GetParent(hParent) != nullptr)
- hParent = GetParent(hParent);
-
- hParent = WindowList_Find(g_dat.hParentWindowList, (UINT_PTR)hParent);
- if ((hParent != nullptr && hParent != GetParent(hwnd)) || (hParent == nullptr && pDlg->m_pParent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
- if (hParent == nullptr) {
- hParent = GetParentWindow(hContact, FALSE);
-
- RECT rc;
- GetWindowRect(hParent, &rc);
-
- rc.right = (rc.right - rc.left);
- rc.bottom = (rc.bottom - rc.top);
- rc.left = pt.x - rc.right / 2;
- rc.top = pt.y - rc.bottom / 2;
- HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
-
- MONITORINFO mi;
- mi.cbSize = sizeof(mi);
- GetMonitorInfo(hMonitor, &mi);
-
- RECT rcDesktop = mi.rcWork;
- if (rc.left < rcDesktop.left)
- rc.left = rcDesktop.left;
- if (rc.top < rcDesktop.top)
- rc.top = rcDesktop.top;
- MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE);
- }
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSING);
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSE);
- SetParent(hChild, hParent);
- SendMessage(GetParent(hwnd), CM_REMOVECHILD, 0, (LPARAM)hChild);
- SendMessage(hChild, DM_SETPARENT, 0, (LPARAM)hParent);
- SendMessage(hParent, CM_ADDCHILD, (WPARAM)pDlg, 0);
- SendMessage(hChild, DM_UPDATETABCONTROL, 0, 0);
- SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)hChild);
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPENING);
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPEN);
- ShowWindow(hParent, SW_SHOWNA);
- EnableWindow(hParent, TRUE);
- }
- }
+ if (pDlg != nullptr)
+ pDlg->Reattach(GetParent(hwnd));
}
else {
dat->destTab = -1;
@@ -485,13 +438,13 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
}
else if (dat->srcTab >= 0 && g_dat.flags2 & SMF2_TABCLOSEBUTTON) {
- IMAGEINFO info;
- POINT pt;
- RECT rect;
int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
+
+ RECT rect;
TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
- pt.x = LOWORD(lParam);
- pt.y = HIWORD(lParam);
+
+ POINT pt = { LOWORD(lParam), HIWORD(lParam) };
+ IMAGEINFO info;
ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6;
if (!atTop)
diff --git a/plugins/Scriver/src/tabs.h b/plugins/Scriver/src/tabs.h index bafb7c4518..9af8c6d786 100644 --- a/plugins/Scriver/src/tabs.h +++ b/plugins/Scriver/src/tabs.h @@ -84,7 +84,6 @@ struct TabControlData HICON hIcon;
};
-HWND GetParentWindow(MCONTACT hContact, BOOL bChat);
-void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type);
+HWND GetParentWindow(MCONTACT hContact, BOOL bChat);
#endif
|