summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Scriver/scriver_10.vcxproj3
-rw-r--r--plugins/Scriver/scriver_10.vcxproj.filters3
-rw-r--r--plugins/Scriver/scriver_11.vcxproj3
-rw-r--r--plugins/Scriver/scriver_11.vcxproj.filters3
-rw-r--r--plugins/Scriver/scriver_12.vcxproj3
-rw-r--r--plugins/Scriver/scriver_12.vcxproj.filters3
-rw-r--r--plugins/Scriver/src/chat/chat.h13
-rw-r--r--plugins/Scriver/src/chat/log.cpp51
-rw-r--r--plugins/Scriver/src/chat/manager.cpp2
-rw-r--r--plugins/Scriver/src/chat/services.cpp39
-rw-r--r--plugins/Scriver/src/chat/window.cpp89
-rw-r--r--plugins/Scriver/src/msgdialog.cpp10
-rw-r--r--plugins/Scriver/src/msgs.h60
-rw-r--r--plugins/Scriver/src/msgwindow.cpp595
-rw-r--r--plugins/Scriver/src/msgwindow.h21
15 files changed, 401 insertions, 497 deletions
diff --git a/plugins/Scriver/scriver_10.vcxproj b/plugins/Scriver/scriver_10.vcxproj
index 00b4eac9db..980f2de7e9 100644
--- a/plugins/Scriver/scriver_10.vcxproj
+++ b/plugins/Scriver/scriver_10.vcxproj
@@ -229,9 +229,6 @@
<ClCompile Include="src\chat\options.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="src\chat\services.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\tools.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/Scriver/scriver_10.vcxproj.filters b/plugins/Scriver/scriver_10.vcxproj.filters
index d885ad0667..22197102e1 100644
--- a/plugins/Scriver/scriver_10.vcxproj.filters
+++ b/plugins/Scriver/scriver_10.vcxproj.filters
@@ -81,9 +81,6 @@
<ClCompile Include="src\chat\options.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
- <ClCompile Include="src\chat\services.cpp">
- <Filter>Source Files\chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\tools.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
diff --git a/plugins/Scriver/scriver_11.vcxproj b/plugins/Scriver/scriver_11.vcxproj
index 7e1999adea..a73c3054e5 100644
--- a/plugins/Scriver/scriver_11.vcxproj
+++ b/plugins/Scriver/scriver_11.vcxproj
@@ -232,9 +232,6 @@
<ClCompile Include="src\chat\options.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="src\chat\services.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\tools.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/Scriver/scriver_11.vcxproj.filters b/plugins/Scriver/scriver_11.vcxproj.filters
index d885ad0667..22197102e1 100644
--- a/plugins/Scriver/scriver_11.vcxproj.filters
+++ b/plugins/Scriver/scriver_11.vcxproj.filters
@@ -81,9 +81,6 @@
<ClCompile Include="src\chat\options.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
- <ClCompile Include="src\chat\services.cpp">
- <Filter>Source Files\chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\tools.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
diff --git a/plugins/Scriver/scriver_12.vcxproj b/plugins/Scriver/scriver_12.vcxproj
index bb6c401951..c11431345e 100644
--- a/plugins/Scriver/scriver_12.vcxproj
+++ b/plugins/Scriver/scriver_12.vcxproj
@@ -232,9 +232,6 @@
<ClCompile Include="src\chat\options.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
- <ClCompile Include="src\chat\services.cpp">
- <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
- </ClCompile>
<ClCompile Include="src\chat\tools.cpp">
<PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/plugins/Scriver/scriver_12.vcxproj.filters b/plugins/Scriver/scriver_12.vcxproj.filters
index d885ad0667..22197102e1 100644
--- a/plugins/Scriver/scriver_12.vcxproj.filters
+++ b/plugins/Scriver/scriver_12.vcxproj.filters
@@ -81,9 +81,6 @@
<ClCompile Include="src\chat\options.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
- <ClCompile Include="src\chat\services.cpp">
- <Filter>Source Files\chat</Filter>
- </ClCompile>
<ClCompile Include="src\chat\tools.cpp">
<Filter>Source Files\chat</Filter>
</ClCompile>
diff --git a/plugins/Scriver/src/chat/chat.h b/plugins/Scriver/src/chat/chat.h
index 323f8cf9ea..00598c44e1 100644
--- a/plugins/Scriver/src/chat/chat.h
+++ b/plugins/Scriver/src/chat/chat.h
@@ -61,7 +61,6 @@ struct LOGSTREAMDATA : public GCLogStreamDataBase
struct SESSION_INFO : public GCSessionInfoBase
{
- char* pszHeader;
TCHAR szSearch[255];
int desiredInputAreaHeight;
@@ -81,24 +80,22 @@ typedef struct{
}
COLORCHOOSER;
-//main.c
+// main.c
void UpgradeCheck(void);
-//colorchooser.c
+// colorchooser.c
INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-//log.c
+// log.c
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw);
void LoadMsgLogBitmaps(void);
void FreeMsgLogBitmaps(void);
TCHAR* GetChatLogsFilename (HANDLE hContact, time_t tTime);
-char* Log_CreateRtfHeader(MODULEINFO * mi, SESSION_INFO *si);
-//window.c
-INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
+// window.c
int GetTextPixelSize( TCHAR* pszText, HFONT hFont, BOOL bWidth);
-//options.c
+// options.c
int OptionsInit(void);
// services.c
diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp
index 613669777d..f13556a494 100644
--- a/plugins/Scriver/src/chat/log.cpp
+++ b/plugins/Scriver/src/chat/log.cpp
@@ -127,7 +127,7 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
sm.rangeToReplace = bRedraw ? NULL : &newsel;
sm.flags = 0;
sm.disableRedraw = TRUE;
- sm.hContact = si->windowData.hContact;
+ sm.hContact = si->hContact;
CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm);
}
@@ -152,52 +152,3 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
InvalidateRect(hwndRich, NULL, TRUE);
}
}
-
-char* Log_CreateRtfHeader(MODULEINFO *mi, SESSION_INFO *si)
-{
- int bufferAlloced, bufferEnd, i = 0;
- int charset = 0;
- BOOL forceCharset = FALSE;
-
- // guesstimate amount of memory for the RTF header
- bufferEnd = 0;
- bufferAlloced = 4096;
- char *buffer = (char*)mir_realloc(si->pszHeader, bufferAlloced);
- buffer[0] = '\0';
-
- // ### RTF HEADER
-
- // font table
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
- for (i = 0; i < OPTIONS_FONTCOUNT; i++)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, (!forceCharset) ? pci->aFonts[i].lf.lfCharSet : charset, pci->aFonts[i].lf.lfFaceName);
-
- // colour table
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ;");
-
- for (i = 0; i < OPTIONS_FONTCOUNT; i++)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color));
-
- for (i = 0; i < mi->nColorCount; i++)
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
-
- // new paragraph
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "}\\pard");
-
- // set tabs and indents
- int iIndent = 0;
-
- if (g_Settings.dwIconFlags) {
- iIndent += (14 * 1440) / g_dat.logPixelSX;
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
- }
- if (g_Settings.ShowTime) {
- int iSize = (g_Settings.LogTextIndent * 1440) / g_dat.logPixelSX;
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize);
- if (g_Settings.LogIndentEnabled)
- iIndent += iSize;
- }
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
-
- return buffer;
-}
diff --git a/plugins/Scriver/src/chat/manager.cpp b/plugins/Scriver/src/chat/manager.cpp
index 192906fb40..821a82bde6 100644
--- a/plugins/Scriver/src/chat/manager.cpp
+++ b/plugins/Scriver/src/chat/manager.cpp
@@ -26,7 +26,7 @@ HWND SM_FindWindowByContact(HANDLE hContact)
SESSION_INFO *pTemp = pci->wndList;
while (pTemp != NULL) {
- if (pTemp->windowData.hContact == hContact)
+ if (pTemp->hContact == hContact)
return pTemp->hWnd;
pTemp = pTemp->next;
diff --git a/plugins/Scriver/src/chat/services.cpp b/plugins/Scriver/src/chat/services.cpp
deleted file mode 100644
index 9945563c48..0000000000
--- a/plugins/Scriver/src/chat/services.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-Chat module plugin for Miranda IM
-
-Copyright (C) 2003 Jörgen Persson
-Copyright 2003-2009 Miranda ICQ/IM project,
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../commonheaders.h"
-
-void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
-{
- if (!si)
- return;
-
- //Do we need to create a window?
- if (si->hWnd == NULL) {
- HWND hParent = GetParentWindow(si->windowData.hContact, TRUE);
- si->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CHANNEL), hParent, RoomWndProc, (LPARAM)si);
- }
- SendMessage(si->hWnd, DM_UPDATETABCONTROL, -1, (LPARAM)si);
- SendMessage(GetParent(si->hWnd), CM_ACTIVATECHILD, 0, (LPARAM)si->hWnd);
- SendMessage(GetParent(si->hWnd), CM_POPUPWINDOW, 0, (LPARAM)si->hWnd);
- SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
- SetFocus(GetDlgItem(si->hWnd, IDC_CHAT_MESSAGE));
-}
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index 40ae167644..12047a4ab6 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -458,7 +458,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_CONTEXTMENU:
- InputAreaContextMenu(hwnd, wParam, lParam, Parentsi->windowData.hContact);
+ InputAreaContextMenu(hwnd, wParam, lParam, Parentsi->hContact);
return TRUE;
case WM_KEYUP:
@@ -1055,9 +1055,10 @@ static void __cdecl phase2(void *lParam)
PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0);
}
-INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HMENU hToolbarMenu;
+
SESSION_INFO *si = (SESSION_INFO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (!si && uMsg != WM_INITDIALOG)
return FALSE;
@@ -1067,7 +1068,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
TranslateDialogDefault(hwndDlg);
{
SESSION_INFO *psi = (SESSION_INFO*)lParam;
- NotifyLocalWinEvent(psi->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_OPENING);
+ NotifyLocalWinEvent(psi->hContact, hwndDlg, MSG_WINDOW_EVT_OPENING);
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)psi);
@@ -1110,7 +1111,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
IEVIEWEVENT iee = { sizeof(iee) };
iee.iType = IEE_CLEAR_LOG;
iee.hwnd = si->windowData.hwndLog;
- iee.hContact = si->windowData.hContact;
+ iee.hContact = si->hContact;
iee.codepage = si->windowData.codePage;
iee.pszProto = si->pszModule;
CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&iee);
@@ -1124,9 +1125,9 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
SendMessage(hwndDlg, DM_UPDATETITLEBAR, 0, 0);
- SendMessage(GetParent(hwndDlg), CM_ADDCHILD, (WPARAM)hwndDlg, (LPARAM)psi->windowData.hContact);
+ SendMessage(GetParent(hwndDlg), CM_ADDCHILD, (WPARAM)hwndDlg, (LPARAM)psi->hContact);
PostMessage(hwndDlg, GC_UPDATENICKLIST, 0, 0);
- NotifyLocalWinEvent(psi->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_OPEN);
+ NotifyLocalWinEvent(psi->hContact, hwndDlg, MSG_WINDOW_EVT_OPEN);
}
break;
@@ -1229,7 +1230,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
StatusIconData sid = { sizeof(sid) };
sid.szModule = SRMMMOD;
- Srmm_ModifyIcon(si->windowData.hContact, &sid);
+ Srmm_ModifyIcon(si->hContact, &sid);
}
break;
@@ -1239,7 +1240,6 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case DM_SETCODEPAGE:
si->windowData.codePage = (int)lParam;
- si->pszHeader = Log_CreateRtfHeader(pci->MM_FindModule(si->pszModule), si);
SendMessage(hwndDlg, GC_REDRAWLOG2, 0, 0);
break;
@@ -1355,15 +1355,14 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
case DM_ACTIVATE:
if (si->wState & STATE_TALK) {
si->wState &= ~STATE_TALK;
-
- db_set_w(si->windowData.hContact, si->pszModule, "ApparentMode", 0);
+ db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
}
if (si->wState & GC_EVENT_HIGHLIGHT) {
si->wState &= ~GC_EVENT_HIGHLIGHT;
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
+ if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)"chaticon");
}
SendMessage(hwndDlg, GC_FIXTABICONS, 0, 0);
@@ -1406,26 +1405,19 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
if (dis->CtlID == IDC_CHAT_LIST) {
- HFONT hFont, hOldFont;
- HICON hIcon;
- int offset;
- int height;
int index = dis->itemID;
USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
if (ui) {
int x_offset = 2;
- height = dis->rcItem.bottom - dis->rcItem.top;
-
+ int height = dis->rcItem.bottom - dis->rcItem.top;
if (height & 1)
height++;
- if (height == 10)
- offset = 0;
- else
- offset = height / 2 - 5;
- hIcon = pci->SM_GetStatusIcon(si, ui);
- hFont = (ui->iStatusEx == 0) ? g_Settings.UserListFont : g_Settings.UserListHeadingsFont;
- hOldFont = (HFONT)SelectObject(dis->hDC, hFont);
+
+ int offset = (height == 10) ? 0 : height / 2 - 5;
+ HICON hIcon = pci->SM_GetStatusIcon(si, ui);
+ HFONT hFont = (ui->iStatusEx == 0) ? g_Settings.UserListFont : g_Settings.UserListHeadingsFont;
+ HFONT hOldFont = (HFONT)SelectObject(dis->hDC, hFont);
SetBkMode(dis->hDC, TRANSPARENT);
if (dis->itemAction == ODA_FOCUS && dis->itemState & ODS_SELECTED)
@@ -1497,10 +1489,10 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
return TRUE;
case SESSION_TERMINATE:
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
+ if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)"chaticon");
si->wState &= ~STATE_TALK;
- db_set_w(si->windowData.hContact, si->pszModule, "ApparentMode", (LPARAM)0);
+ db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)0);
SendMessage(hwndDlg, GC_CLOSEWINDOW, 0, 0);
return TRUE;
@@ -1634,10 +1626,10 @@ LABEL_SHOWWINDOW:
pci->SetActiveSession(si->ptszID, si->pszModule);
- if (db_get_w(si->windowData.hContact, si->pszModule, "ApparentMode", 0) != 0)
- db_set_w(si->windowData.hContact, si->pszModule, "ApparentMode", (LPARAM)0);
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
+ if (db_get_w(si->hContact, si->pszModule, "ApparentMode", 0) != 0)
+ db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)0);
+ if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)"chaticon");
break;
case WM_NOTIFY:
@@ -1706,7 +1698,7 @@ LABEL_SHOWWINDOW:
break;
case WM_COMMAND:
- if (!lParam && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)si->windowData.hContact))
+ if (!lParam && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)si->hContact))
break;
switch (LOWORD(wParam)) {
@@ -1807,7 +1799,7 @@ LABEL_SHOWWINDOW:
smaddInfo.Direction = 0;
smaddInfo.xPosition = rc.left;
smaddInfo.yPosition = rc.bottom;
- smaddInfo.hContact = si->windowData.hContact;
+ smaddInfo.hContact = si->hContact;
CallService(MS_SMILEYADD_SHOWSELECTION, 0, (LPARAM)&smaddInfo);
}
break;
@@ -1816,7 +1808,7 @@ LABEL_SHOWWINDOW:
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHAT_HISTORY))) {
MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
if (pInfo)
- ShellExecute(hwndDlg, NULL, GetChatLogsFilename(si->windowData.hContact, 0), NULL, NULL, SW_SHOW);
+ ShellExecute(hwndDlg, NULL, GetChatLogsFilename(si->hContact, 0), NULL, NULL, SW_SHOW);
}
break;
@@ -1994,7 +1986,7 @@ LABEL_SHOWWINDOW:
case DM_GETCONTEXTMENU:
{
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)si->windowData.hContact, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)si->hContact, 0);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)hMenu);
}
return TRUE;
@@ -2002,7 +1994,7 @@ LABEL_SHOWWINDOW:
case WM_CONTEXTMENU:
if (GetParent(hwndDlg) == (HWND)wParam) {
POINT pt;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)si->windowData.hContact, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)si->hContact, 0);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
@@ -2018,7 +2010,7 @@ LABEL_SHOWWINDOW:
break;
case WM_DESTROY:
- NotifyLocalWinEvent(si->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_CLOSING);
+ NotifyLocalWinEvent(si->hContact, hwndDlg, MSG_WINDOW_EVT_CLOSING);
si->hWnd = NULL;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_UNSUBCLASSED, 0, 0);
@@ -2032,8 +2024,27 @@ LABEL_SHOWWINDOW:
CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
}
- NotifyLocalWinEvent(si->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_CLOSE);
+ NotifyLocalWinEvent(si->hContact, hwndDlg, MSG_WINDOW_EVT_CLOSE);
break;
}
return FALSE;
}
+
+void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
+{
+ if (si == NULL)
+ return;
+
+ si->windowData.hContact = si->hContact;
+
+ //Do we need to create a window?
+ if (si->hWnd == NULL) {
+ HWND hParent = GetParentWindow(si->hContact, TRUE);
+ si->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CHANNEL), hParent, RoomWndProc, (LPARAM)si);
+ }
+ SendMessage(si->hWnd, DM_UPDATETABCONTROL, -1, (LPARAM)si);
+ SendMessage(GetParent(si->hWnd), CM_ACTIVATECHILD, 0, (LPARAM)si->hWnd);
+ SendMessage(GetParent(si->hWnd), CM_POPUPWINDOW, 0, (LPARAM)si->hWnd);
+ SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
+ SetFocus(GetDlgItem(si->hWnd, IDC_CHAT_MESSAGE));
+}
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 51bf39deb2..dc7281a159 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -143,16 +143,16 @@ static void saveDraftMessage(HWND hwnd, HANDLE hContact, int codepage)
void NotifyLocalWinEvent(HANDLE hContact, HWND hwnd, unsigned int type)
{
- MessageWindowEventData mwe = { 0 };
- BOOL bChat = FALSE;
- if (hContact==NULL || hwnd==NULL) return;
- mwe.cbSize = sizeof(mwe);
+ if (hContact == NULL || hwnd == NULL)
+ return;
+
+ MessageWindowEventData mwe = { sizeof(mwe) };
mwe.hContact = hContact;
mwe.hwndWindow = hwnd;
mwe.szModule = SRMMMOD;
mwe.uType = type;
mwe.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
- bChat = (WindowList_Find(g_dat.hMessageWindowList, hContact) == NULL);
+ BOOL bChat = (WindowList_Find(g_dat.hMessageWindowList, hContact) == NULL);
mwe.hwndInput = GetDlgItem(hwnd, bChat ? IDC_CHAT_MESSAGE : IDC_MESSAGE);
mwe.hwndLog = GetDlgItem(hwnd, bChat ? IDC_CHAT_LOG : IDC_LOG);
NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe);
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index 7e593ec9a4..03bacc17be 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -27,25 +27,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MSGERROR_RETRY 1
#define MSGERROR_DONE 2
-typedef struct ToolbarButtonStruct
+struct ToolbarButton
{
TCHAR *name;
UINT controlId;
int alignment;
int spacing;
int width;
-}ToolbarButton;
+};
-typedef struct ErrorWindowDataStruct
+struct ErrorWindowData
{
TCHAR* szName;
TCHAR* szDescription;
TCHAR* szText;
MessageSendQueueItem* queueItem;
HWND hwndParent;
-} ErrorWindowData;
+};
-typedef struct TabCtrlDataStruct
+struct TabCtrlData
{
int lastClickTime;
WPARAM clickWParam;
@@ -56,14 +56,12 @@ typedef struct TabCtrlDataStruct
int bDragged;
int destTab;
int srcTab;
-} TabCtrlData;
+};
-typedef struct ParentWindowDataStruct
+struct ParentWindowData
{
HWND hwnd;
HANDLE hContact;
- struct ParentWindowDataStruct *prev;
- struct ParentWindowDataStruct *next;
int childrenCount;
HWND hwndActive;
HWND hwndStatus;
@@ -80,40 +78,40 @@ typedef struct ParentWindowDataStruct
int windowWasCascaded;
TabCtrlData *tabCtrlDat;
BOOL isChat;
-}ParentWindowData;
+ ParentWindowData *prev, *next;
+};
-typedef struct MessageWindowTabDataStruct
+struct MessageWindowTabData
{
- HWND hwnd;
- HANDLE hContact;
- char *szProto;
+ HWND hwnd;
+ HANDLE hContact;
+ char *szProto;
ParentWindowData *parent;
HICON hIcon;
-}MessageWindowTabData;
+};
#define NMWLP_INCOMING 1
-typedef struct NewMessageWindowLParamStruct
+struct NewMessageWindowLParam
{
- HANDLE hContact;
- BOOL isChat;
- int isWchar;
- const char *szInitialText;
- int flags;
-} NewMessageWindowLParam;
+ HANDLE hContact;
+ BOOL isChat;
+ int isWchar;
+ LPCSTR szInitialText;
+ int flags;
+};
#define CWDF_RTF_INPUT 1
-typedef struct CommonWindowDataStruct {
+struct CommonWindowData
+{
HANDLE hContact;
- TCmdList *cmdList;
- TCmdList *cmdListCurrent;
- int codePage;
- DWORD flags;
- HWND hwndLog;
- int minLogBoxHeight;
- int minEditBoxHeight;
-}CommonWindowData;
+ int codePage;
+ DWORD flags;
+ HWND hwndLog;
+ int minLogBoxHeight, minEditBoxHeight;
+ TCmdList *cmdList, *cmdListCurrent;
+};
struct SrmmWindowData
{
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp
index 18706d3c9b..1c691acadd 100644
--- a/plugins/Scriver/src/msgwindow.cpp
+++ b/plugins/Scriver/src/msgwindow.cpp
@@ -30,20 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TIMEOUT_FLASHWND 900
static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lParam);
-LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-extern TCHAR *GetNickname(HANDLE hContact, const char* szProto);
-
-void SubclassTabCtrl(HWND hwnd)
-{
- mir_subclassWindow(hwnd, TabCtrlProc);
- SendMessage(hwnd, EM_SUBCLASSED, 0, 0);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
-void UnsubclassTabCtrl(HWND hwnd)
-{
- SendMessage(hwnd, EM_UNSUBCLASSED, 0, 0);
-}
+extern TCHAR *GetNickname(HANDLE hContact, const char* szProto);
static const TCHAR *titleTokenNames[] = {_T("%name%"), _T("%status%"), _T("%statusmsg%"), _T("%account%")};
@@ -441,6 +431,304 @@ static void SetContainerWindowStyle(ParentWindowData *dat)
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ TabCtrlData *dat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+ TCHITTESTINFO thinfo;
+ int tabId;
+
+ switch (msg) {
+ case EM_SUBCLASSED:
+ dat = (TabCtrlData*)mir_alloc(sizeof(TabCtrlData));
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
+ dat->bDragging = FALSE;
+ dat->bDragged = FALSE;
+ dat->srcTab = -1;
+ dat->destTab = -1;
+ return 0;
+
+ case WM_MBUTTONDOWN:
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ tabId = TabCtrl_HitTest(hwnd, &thinfo);
+ if (tabId >= 0) {
+ TCITEM tci;
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwnd, tabId, &tci);
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
+ if (mwtd != NULL) {
+ SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
+ dat->srcTab = -1;
+ }
+ }
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ tabId = TabCtrl_HitTest(hwnd, &thinfo);
+ if (tabId >= 0 && tabId == dat->srcTab) {
+ SendMessage(GetChildFromTab(hwnd, tabId)->hwnd, WM_CLOSE, 0, 0);
+ dat->srcTab = -1;
+ }
+ dat->destTab = -1;
+ break;
+
+ case WM_LBUTTONDOWN:
+ if (!dat->bDragging) {
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo);
+
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ if (dat->srcTab >= 0) {
+ dat->bDragging = TRUE;
+ dat->bDragged = FALSE;
+ dat->clickLParam = lParam;
+ dat->clickWParam = wParam;
+ dat->lastClickTime = ft.dwLowDateTime;
+ dat->mouseLBDownPos.x = thinfo.pt.x;
+ dat->mouseLBDownPos.y = thinfo.pt.y;
+ SetCapture(hwnd);
+ }
+ return 0;
+ }
+ break;
+
+ case WM_CAPTURECHANGED:
+ case WM_LBUTTONUP:
+ if (dat->bDragging) {
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ if (dat->bDragged) {
+ ImageList_DragLeave(GetDesktopWindow());
+ ImageList_EndDrag();
+ ImageList_Destroy(dat->hDragImageList);
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
+ dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
+ if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) {
+ NMHDR nmh;
+ TCHAR sBuffer[501];
+ TCITEM item;
+ int curSel;
+ curSel = TabCtrl_GetCurSel(hwnd);
+ item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT;
+ item.pszText = sBuffer;
+ item.cchTextMax = SIZEOF(sBuffer);
+ TabCtrl_GetItem(hwnd, dat->srcTab, &item);
+ sBuffer[SIZEOF(sBuffer) - 1] = '\0';
+
+ if (curSel == dat->srcTab)
+ curSel = dat->destTab;
+ else if (curSel > dat->srcTab && curSel <= dat->destTab)
+ curSel--;
+ else if (curSel < dat->srcTab && curSel >= dat->destTab)
+ curSel++;
+
+ TabCtrl_DeleteItem(hwnd, dat->srcTab);
+ TabCtrl_InsertItem(hwnd, dat->destTab, &item);
+ TabCtrl_SetCurSel(hwnd, curSel);
+ dat->destTab = -1;
+ nmh.hwndFrom = hwnd;
+ nmh.idFrom = GetDlgCtrlID(hwnd);
+ nmh.code = TCN_SELCHANGE;
+ SendMessage(GetParent(hwnd), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh);
+ UpdateWindow(hwnd);
+ }
+ else if (thinfo.flags == TCHT_NOWHERE) {
+ TCITEM tci;
+ POINT pt;
+ NewMessageWindowLParam newData = { 0 };
+ dat->destTab = -1;
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
+ MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
+ if (mwtd != NULL) {
+ HWND hChild = mwtd->hwnd;
+ HANDLE hContact = mwtd->hContact;
+ GetCursorPos(&pt);
+ HWND hParent = WindowFromPoint(pt);
+ while (GetParent(hParent) != NULL)
+ hParent = GetParent(hParent);
+
+ hParent = WindowList_Find(g_dat.hParentWindowList, hParent);
+ if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
+ if (hParent == NULL) {
+ RECT rc, rcDesktop;
+ newData.hContact = hContact;
+ hParent = (HWND)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData);
+ 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);
+ 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)hChild, (LPARAM)hContact);
+ 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);
+ }
+ }
+ }
+ else {
+ dat->destTab = -1;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+ }
+ }
+ 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;
+ TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
+ pt.x = LOWORD(lParam);
+ pt.y = HIWORD(lParam);
+ ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
+ rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6;
+ if (!atTop)
+ rect.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top);
+
+ if (pt.x >= rect.left && pt.x < rect.left + (info.rcImage.right - info.rcImage.left) && pt.y >= rect.top && pt.y < rect.top + (info.rcImage.bottom - info.rcImage.top)) {
+ HBITMAP hOldBitmap, hBmp;
+ HDC hdc = GetDC(NULL);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ pt.x -= rect.left;
+ pt.y -= rect.top;
+ hBmp = CreateCompatibleBitmap(hdc, info.rcImage.right - info.rcImage.left + 1, info.rcImage.bottom - info.rcImage.top + 1);
+ hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmp);
+ SetPixel(hdcMem, pt.x, pt.y, 0x000000);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ COLORREF color1 = GetPixel(hdcMem, pt.x, pt.y);
+ SetPixel(hdcMem, pt.x, pt.y, 0xFFFFFF);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ COLORREF color2 = GetPixel(hdcMem, pt.x, pt.y);
+ SelectObject(hdcMem, hOldBitmap);
+ DeleteDC(hdcMem);
+ DeleteObject(hBmp);
+ ReleaseDC(NULL, hdc);
+ if (color1 != 0x000000 || color2 != 0xFFFFFF) {
+ SendMessage(GetChildFromTab(hwnd, dat->srcTab)->hwnd, WM_CLOSE, 0, 0);
+ dat->srcTab = -1;
+ }
+ }
+ else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
+ }
+ else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
+
+ dat->bDragged = FALSE;
+ dat->bDragging = FALSE;
+ dat->destTab = -1;
+ ReleaseCapture();
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ if (wParam & MK_LBUTTON) {
+ if (dat->bDragging) {
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ if (!dat->bDragged) {
+ if ((abs(thinfo.pt.x - dat->mouseLBDownPos.x) < 3 && abs(thinfo.pt.y - dat->mouseLBDownPos.y) < 3)
+ || (ft.dwLowDateTime - dat->lastClickTime) < 10 * 1000 * 150)
+ break;
+ }
+ if (!dat->bDragged) {
+ POINT pt;
+ RECT rect;
+ RECT rect2;
+ HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 254));
+ GetCursorPos(&pt);
+ TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
+ rect.right -= rect.left - 1;
+ rect.bottom -= rect.top - 1;
+ rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom;
+ dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1);
+ HDC hDC = GetDC(hwnd);
+ HDC hMemDC = CreateCompatibleDC(hDC);
+ HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
+ HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
+ FillRect(hMemDC, &rect2, hBrush);
+ SetWindowOrgEx(hMemDC, rect.left, rect.top, NULL);
+ SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT);
+ SelectObject(hMemDC, hOldBitmap);
+ ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255, 0, 254));
+ DeleteObject(hBitmap);
+ DeleteObject(hBrush);
+ ReleaseDC(hwnd, hDC);
+ DeleteDC(hMemDC);
+ ImageList_BeginDrag(dat->hDragImageList, 0, dat->mouseLBDownPos.x - rect.left, dat->mouseLBDownPos.y - rect.top);
+ ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
+ SetCursor(hDragCursor);
+ dat->mouseLBDownPos.x = thinfo.pt.x;
+ dat->mouseLBDownPos.y = thinfo.pt.y;
+ }
+ else {
+ POINT pt;
+ GetCursorPos(&pt);
+ thinfo.pt = pt;
+ ScreenToClient(hwnd, &thinfo.pt);
+ int newDest = TabCtrl_HitTest(hwnd, &thinfo);
+ if (thinfo.flags == TCHT_NOWHERE)
+ newDest = -1;
+
+ if (newDest != dat->destTab) {
+ dat->destTab = newDest;
+ ImageList_DragLeave(GetDesktopWindow());
+ RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
+ ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
+ }
+ else ImageList_DragMove(pt.x, pt.y);
+ }
+ dat->bDragged = TRUE;
+ return 0;
+ }
+ }
+ break;
+
+ case EM_UNSUBCLASSED:
+ mir_free(dat);
+ return 0;
+ }
+ return mir_callNextSubclass(hwnd, TabCtrlProc, msg, wParam, lParam);
+}
+
+__forceinline void SubclassTabCtrl(HWND hwnd)
+{
+ mir_subclassWindow(hwnd, TabCtrlProc);
+ SendMessage(hwnd, EM_SUBCLASSED, 0, 0);
+}
+
+__forceinline void UnsubclassTabCtrl(HWND hwnd)
+{
+ SendMessage(hwnd, EM_UNSUBCLASSED, 0, 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DWORD ws;
@@ -1219,289 +1507,6 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar
}
}
-LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- TabCtrlData *dat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
-
- TCHITTESTINFO thinfo;
- int tabId;
-
- switch(msg) {
- case EM_SUBCLASSED:
- dat = (TabCtrlData*)mir_alloc(sizeof(TabCtrlData));
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
- dat->bDragging = FALSE;
- dat->bDragged = FALSE;
- dat->srcTab = -1;
- dat->destTab = -1;
- return 0;
-
- case WM_MBUTTONDOWN:
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- tabId = TabCtrl_HitTest(hwnd, &thinfo);
- if (tabId >= 0) {
- TCITEM tci;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwnd, tabId, &tci);
- MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
- if (mwtd != NULL) {
- SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
- dat->srcTab = -1;
- }
- }
- return 0;
-
- case WM_LBUTTONDBLCLK:
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- tabId = TabCtrl_HitTest(hwnd, &thinfo);
- if (tabId >= 0 && tabId == dat->srcTab) {
- SendMessage(GetChildFromTab(hwnd, tabId)->hwnd, WM_CLOSE, 0, 0);
- dat->srcTab = -1;
- }
- dat->destTab = -1;
- break;
-
- case WM_LBUTTONDOWN:
- if (!dat->bDragging) {
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo);
-
- FILETIME ft;
- GetSystemTimeAsFileTime(&ft);
- if (dat->srcTab >= 0) {
- dat->bDragging = TRUE;
- dat->bDragged = FALSE;
- dat->clickLParam = lParam;
- dat->clickWParam = wParam;
- dat->lastClickTime = ft.dwLowDateTime;
- dat->mouseLBDownPos.x = thinfo.pt.x;
- dat->mouseLBDownPos.y = thinfo.pt.y;
- SetCapture(hwnd);
- }
- return 0;
- }
- break;
-
- case WM_CAPTURECHANGED:
- case WM_LBUTTONUP:
- if (dat->bDragging) {
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- if (dat->bDragged) {
- ImageList_DragLeave(GetDesktopWindow());
- ImageList_EndDrag();
- ImageList_Destroy(dat->hDragImageList);
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
- if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) {
- NMHDR nmh;
- TCHAR sBuffer[501];
- TCITEM item;
- int curSel;
- curSel = TabCtrl_GetCurSel(hwnd);
- item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT;
- item.pszText = sBuffer;
- item.cchTextMax = SIZEOF(sBuffer);
- TabCtrl_GetItem(hwnd, dat->srcTab, &item);
- sBuffer[SIZEOF(sBuffer) - 1] = '\0';
-
- if (curSel == dat->srcTab)
- curSel = dat->destTab;
- else if (curSel > dat->srcTab && curSel <= dat->destTab)
- curSel--;
- else if (curSel < dat->srcTab && curSel >= dat->destTab)
- curSel++;
-
- TabCtrl_DeleteItem(hwnd, dat->srcTab);
- TabCtrl_InsertItem(hwnd, dat->destTab, &item);
- TabCtrl_SetCurSel(hwnd, curSel);
- dat->destTab = -1;
- nmh.hwndFrom = hwnd;
- nmh.idFrom = GetDlgCtrlID(hwnd);
- nmh.code = TCN_SELCHANGE;
- SendMessage(GetParent(hwnd), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh);
- UpdateWindow(hwnd);
- }
- else if (thinfo.flags == TCHT_NOWHERE) {
- TCITEM tci;
- POINT pt;
- NewMessageWindowLParam newData = { 0 };
- dat->destTab = -1;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
- MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
- if (mwtd != NULL) {
- HWND hChild = mwtd->hwnd;
- HANDLE hContact = mwtd->hContact;
- GetCursorPos(&pt);
- HWND hParent = WindowFromPoint(pt);
- while (GetParent(hParent) != NULL)
- hParent = GetParent(hParent);
-
- hParent = WindowList_Find(g_dat.hParentWindowList, hParent);
- if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
- if (hParent == NULL) {
- RECT rc, rcDesktop;
- newData.hContact = hContact;
- hParent = (HWND)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData);
- 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);
- 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)hChild, (LPARAM)hContact);
- 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);
- }
- }
- }
- else {
- dat->destTab = -1;
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
- }
- }
- 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;
- TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
- pt.x = LOWORD(lParam);
- pt.y = HIWORD(lParam);
- ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
- rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6;
- if (!atTop)
- rect.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top);
-
- if (pt.x >= rect.left && pt.x < rect.left + (info.rcImage.right - info.rcImage.left) && pt.y >= rect.top && pt.y < rect.top + (info.rcImage.bottom - info.rcImage.top)) {
- HBITMAP hOldBitmap, hBmp;
- HDC hdc = GetDC(NULL);
- HDC hdcMem = CreateCompatibleDC(hdc);
- pt.x -= rect.left;
- pt.y -= rect.top;
- hBmp = CreateCompatibleBitmap(hdc, info.rcImage.right - info.rcImage.left + 1, info.rcImage.bottom - info.rcImage.top + 1);
- hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmp);
- SetPixel(hdcMem, pt.x, pt.y, 0x000000);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- COLORREF color1 = GetPixel(hdcMem, pt.x, pt.y);
- SetPixel(hdcMem, pt.x, pt.y, 0xFFFFFF);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- COLORREF color2 = GetPixel(hdcMem, pt.x, pt.y);
- SelectObject(hdcMem, hOldBitmap);
- DeleteDC(hdcMem);
- DeleteObject(hBmp);
- ReleaseDC(NULL, hdc);
- if (color1 != 0x000000 || color2 != 0xFFFFFF) {
- SendMessage(GetChildFromTab(hwnd, dat->srcTab)->hwnd, WM_CLOSE, 0, 0);
- dat->srcTab = -1;
- }
- }
- else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
- }
- else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
-
- dat->bDragged = FALSE;
- dat->bDragging = FALSE;
- dat->destTab = -1;
- ReleaseCapture();
- }
- break;
-
- case WM_MOUSEMOVE:
- if (wParam & MK_LBUTTON) {
- if (dat->bDragging) {
- FILETIME ft;
- GetSystemTimeAsFileTime(&ft);
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- if (!dat->bDragged) {
- if ((abs(thinfo.pt.x - dat->mouseLBDownPos.x) < 3 && abs(thinfo.pt.y - dat->mouseLBDownPos.y) < 3)
- || (ft.dwLowDateTime - dat->lastClickTime) < 10 * 1000 * 150)
- break;
- }
- if (!dat->bDragged) {
- POINT pt;
- RECT rect;
- RECT rect2;
- HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 254));
- GetCursorPos(&pt);
- TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
- rect.right -= rect.left - 1;
- rect.bottom -= rect.top - 1;
- rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom;
- dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1);
- HDC hDC = GetDC(hwnd);
- HDC hMemDC = CreateCompatibleDC(hDC);
- HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
- HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
- FillRect(hMemDC, &rect2, hBrush);
- SetWindowOrgEx(hMemDC, rect.left, rect.top, NULL);
- SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT);
- SelectObject(hMemDC, hOldBitmap);
- ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255, 0, 254));
- DeleteObject(hBitmap);
- DeleteObject(hBrush);
- ReleaseDC(hwnd, hDC);
- DeleteDC(hMemDC);
- ImageList_BeginDrag(dat->hDragImageList, 0, dat->mouseLBDownPos.x - rect.left, dat->mouseLBDownPos.y - rect.top);
- ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
- SetCursor(hDragCursor);
- dat->mouseLBDownPos.x = thinfo.pt.x;
- dat->mouseLBDownPos.y = thinfo.pt.y;
- }
- else {
- POINT pt;
- GetCursorPos(&pt);
- thinfo.pt = pt;
- ScreenToClient(hwnd, &thinfo.pt);
- int newDest = TabCtrl_HitTest(hwnd, &thinfo);
- if (thinfo.flags == TCHT_NOWHERE)
- newDest = -1;
-
- if (newDest != dat->destTab) {
- dat->destTab = newDest;
- ImageList_DragLeave(GetDesktopWindow());
- RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
- ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
- }
- else ImageList_DragMove(pt.x, pt.y);
- }
- dat->bDragged = TRUE;
- return 0;
- }
- }
- break;
-
- case EM_UNSUBCLASSED:
- mir_free(dat);
- return 0;
- }
- return mir_callNextSubclass(hwnd, TabCtrlProc, msg, wParam, lParam);
-}
-
int ScriverRestoreWindowPosition(HWND hwnd, HANDLE hContact, const char *szModule,const char *szNamePrefix, int flags, int showCmd)
{
WINDOWPLACEMENT wp;
diff --git a/plugins/Scriver/src/msgwindow.h b/plugins/Scriver/src/msgwindow.h
index d0c861bcfc..ea71f2977c 100644
--- a/plugins/Scriver/src/msgwindow.h
+++ b/plugins/Scriver/src/msgwindow.h
@@ -58,40 +58,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SBDF_TEXT 1
#define SBDF_ICON 2
-typedef struct StatusBarDataStruct
+struct StatusBarData
{
int iItem;
int iFlags;
TCHAR *pszText;
HICON hIcon;
-} StatusBarData;
+};
#define TBDF_TEXT 1
#define TBDF_ICON 2
-typedef struct TitleBarDataStruct
+struct TitleBarData
{
int iFlags;
TCHAR *pszText;
HICON hIcon;
HICON hIconBig;
HICON hIconNot;
-} TitleBarData;
+};
#define TCDF_TEXT 1
#define TCDF_ICON 2
-typedef struct TabControlDataStruct
+struct TabControlData
{
int iFlags;
TCHAR *pszText;
-// int iconIdx;
HICON hIcon;
-} TabControlData;
+};
-extern TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto);
-extern TCHAR* GetTabName(HANDLE *hContact);
-extern HWND GetParentWindow(HANDLE hContact, BOOL bChat);
-extern void NotifyLocalWinEvent(HANDLE hContact, HWND hwnd, unsigned int type);
+TCHAR* GetWindowTitle(HANDLE *hContact, const char *szProto);
+TCHAR* GetTabName(HANDLE *hContact);
+HWND GetParentWindow(HANDLE hContact, BOOL bChat);
+void NotifyLocalWinEvent(HANDLE hContact, HWND hwnd, unsigned int type);
#endif