From 9a1b2f988762967da30e6f4d2575dc2dfe99a21a Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 1 Nov 2006 14:58:17 +0000 Subject: git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@25 4f64403b-2f21-0410-a795-97e2b3489a10 --- xframes/common.h | 54 +++ xframes/frames.cpp | 870 +++++++++++++++++++++++++++++++++++++++++++++++++ xframes/frames.h | 35 ++ xframes/icon1.ico | Bin 0 -> 1406 bytes xframes/options.cpp | 209 ++++++++++++ xframes/options.h | 17 + xframes/resource.h | 27 ++ xframes/xframes.cpp | 109 +++++++ xframes/xframes.h | 12 + xframes/xframes.rc | 128 ++++++++ xframes/xframes.sln | 20 ++ xframes/xframes.vcproj | 270 +++++++++++++++ 12 files changed, 1751 insertions(+) create mode 100644 xframes/common.h create mode 100644 xframes/frames.cpp create mode 100644 xframes/frames.h create mode 100644 xframes/icon1.ico create mode 100644 xframes/options.cpp create mode 100644 xframes/options.h create mode 100644 xframes/resource.h create mode 100644 xframes/xframes.cpp create mode 100644 xframes/xframes.h create mode 100644 xframes/xframes.rc create mode 100644 xframes/xframes.sln create mode 100644 xframes/xframes.vcproj diff --git a/xframes/common.h b/xframes/common.h new file mode 100644 index 0000000..73b2ef0 --- /dev/null +++ b/xframes/common.h @@ -0,0 +1,54 @@ +#ifndef _COMMON_INC +#define _COMMON_INC + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows XP or later. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. +#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. +#endif + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define MODULE "XFrames" + +extern HINSTANCE hInst; +extern PLUGINLINK *pluginLink; + +extern HANDLE mainThread; + +extern int code_page; + +#endif diff --git a/xframes/frames.cpp b/xframes/frames.cpp new file mode 100644 index 0000000..7130257 --- /dev/null +++ b/xframes/frames.cpp @@ -0,0 +1,870 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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 "common.h" +#include "resource.h" +#include "frames.h" + +#define WMU_SNAPTO (WM_USER + 0x10) +#define SNAP_THRESH 10 + + +int next_frame_id = 1; +CRITICAL_SECTION cs; + +DWORD id_pos_timer = 0; + +BOOL clist_visible = FALSE; + +HMODULE hUserDll = 0; +BOOL(WINAPI * MyFramesSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD) = 0; +BOOL(WINAPI * MyAnimateWindow) (HWND hWnd, DWORD dwTime, DWORD dwFlags) = 0; + +LRESULT (CALLBACK *oldContactListWndProc)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) = 0; + +struct FrameListNode *frame_list = 0; + +void SetCListVisible(BOOL visible) { + clist_visible = visible; +} + +int height_client_to_frame(int client_height, LONG style, LONG ex_style) { + RECT tr; + tr.top = tr.right = tr.left = 0; + tr.bottom = client_height; + if(AdjustWindowRectEx(&tr, style, FALSE, ex_style)) + return tr.bottom - tr.top; + return 0; +} + +int ReadFrameFlags(char *frame_name, int default_flags) { + char setting[256]; + mir_snprintf(setting, 256, "FrameFlags_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_flags); +} + +int ReadFrameHeight(char *frame_name, int default_height) { + char setting[256]; + mir_snprintf(setting, 256, "FrameHeight_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_height); +} + +int ReadFrameWidth(char *frame_name, int default_width) { + char setting[256]; + mir_snprintf(setting, 256, "FrameWidth_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_width); +} + +bool ReadFrameMoving(char *frame_name, BOOL default_moving) { + char setting[256]; + mir_snprintf(setting, 256, "FrameMove_%s", frame_name); + return DBGetContactSettingByte(0, "SimpleCLUIFrames", setting, default_moving ? 1 : 0) ? true : false; +} + +bool ReadFrameHiding(char *frame_name, bool default_hiding) { + char setting[256]; + mir_snprintf(setting, 256, "FrameHide_%s", frame_name); + return DBGetContactSettingByte(0, "SimpleCLUIFrames", setting, default_hiding ? 1 : 0) ? TRUE : FALSE; +} + +bool ReadFrameIsStyleOverride(char *frame_name, BOOL default_isoverride) { + char setting[256]; + mir_snprintf(setting, 256, "FrameIsStyleOverride_%s", frame_name); + return DBGetContactSettingByte(0, "SimpleCLUIFrames", setting, default_isoverride ? 1 : 0) ? true : false; +} + +LONG ReadFrameStyleOverride(char *frame_name, LONG default_styleoverride) { + char setting[256]; + mir_snprintf(setting, 256, "FrameStyleOverride_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_styleoverride); +} + +LONG ReadFrameStyleExOverride(char *frame_name, LONG default_styleexoverride) { + char setting[256]; + mir_snprintf(setting, 256, "FrameStyleExOverride_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_styleexoverride); +} + +BYTE ReadFrameAlpha(char *frame_name, int default_alpha) { + char setting[256]; + mir_snprintf(setting, 256, "FrameAlpha_%s", frame_name); + return DBGetContactSettingByte(0, "SimpleCLUIFrames", setting, default_alpha); +} + +FrameAlign ReadFrameAlign(char *frame_name, FrameAlign default_align) { + char setting[256]; + mir_snprintf(setting, 256, "FrameAlign_%s", frame_name); + return (FrameAlign)DBGetContactSettingByte(0, "SimpleCLUIFrames", setting, (int)default_align); +} + +int ReadFrameOffX(char *frame_name, int default_off_x) { + char setting[256]; + mir_snprintf(setting, 256, "FrameOffX_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_off_x); +} + +int ReadFrameOffY(char *frame_name, int default_off_y) { + char setting[256]; + mir_snprintf(setting, 256, "FrameOffY_%s", frame_name); + return DBGetContactSettingDword(0, "SimpleCLUIFrames", setting, default_off_y); +} + +void StoreFrameFlags(char *frame_name, int flags) { + char setting[256]; + mir_snprintf(setting, 256, "FrameFlags_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, flags); +} + +void StoreFrameHeight(char *frame_name, int height) { + char setting[256]; + mir_snprintf(setting, 256, "FrameHeight_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, height); +} + +void StoreFrameWidth(char *frame_name, int width) { + char setting[256]; + mir_snprintf(setting, 256, "FrameWidth_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, width); +} + +void StoreFrameMoving(char *frame_name, BOOL moving) { + char setting[256]; + mir_snprintf(setting, 256, "FrameMove_%s", frame_name); + DBWriteContactSettingByte(0, "SimpleCLUIFrames", setting, moving ? 1 : 0); +} + +void StoreFrameHiding(char *frame_name, BOOL hiding) { + char setting[256]; + mir_snprintf(setting, 256, "FrameHide_%s", frame_name); + DBWriteContactSettingByte(0, "SimpleCLUIFrames", setting, hiding ? 1 : 0); +} + +void StoreFrameIsStyleOverride(char *frame_name, BOOL isoverride) { + char setting[256]; + mir_snprintf(setting, 256, "FrameIsStyleOverride_%s", frame_name); + DBWriteContactSettingByte(0, "SimpleCLUIFrames", setting, isoverride ? 1 : 0); +} + +void StoreFrameStyleOverride(char *frame_name, LONG styleoverride) { + char setting[256]; + mir_snprintf(setting, 256, "FrameStyleOverride_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, styleoverride); +} + +void StoreFrameStyleExOverride(char *frame_name, LONG exstyleoverride) { + char setting[256]; + mir_snprintf(setting, 256, "FrameStyleExOverride_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, exstyleoverride); +} + +void StoreFrameAlpha(char *frame_name, BYTE alpha) { + char setting[256]; + mir_snprintf(setting, 256, "FrameAlpha_%s", frame_name); + DBWriteContactSettingByte(0, "SimpleCLUIFrames", setting, alpha); +} + +void StoreFrameAlign(char *frame_name, FrameAlign align) { + char setting[256]; + mir_snprintf(setting, 256, "FrameAlign_%s", frame_name); + DBWriteContactSettingByte(0, "SimpleCLUIFrames", setting, (BYTE)align); +} + +void StoreFrameOffX(char *frame_name, int off_x) { + char setting[256]; + mir_snprintf(setting, 256, "FrameOffX_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, off_x); +} + +void StoreFrameOffY(char *frame_name, int off_y) { + char setting[256]; + mir_snprintf(setting, 256, "FrameOffY_%s", frame_name); + DBWriteContactSettingDword(0, "SimpleCLUIFrames", setting, off_y); +} + +struct FrameListNode *GetFrame(int id) { + struct FrameListNode *current, *ret = 0; + EnterCriticalSection(&cs); + current = frame_list; + while(current) { + if(current->id == id) { + ret = current; + break; + } + current = current->next; + } + LeaveCriticalSection(&cs); + return ret; +} + +void PositionFramesNow() { + if(Miranda_Terminated()) return; + + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0), + hwndFrame; + LONG clistStyle = GetWindowLong(hwndClist, GWL_STYLE), + clistExStyle = GetWindowLong(hwndClist, GWL_EXSTYLE); + + RECT r, fr; + int frameHeight, frameWidth; + struct FrameListNode *current; + BOOL hwndVis; + GetWindowRect(hwndClist, &r); + + //PUShowMessage("reposition", SM_NOTIFY); + + EnterCriticalSection(&cs); + current = frame_list; + while(current) { + hwndFrame = current->hwndParent; + frameWidth = current->width; + hwndVis = IsWindowVisible(hwndFrame); + + if(!current->style_override) { + if(GetWindowLong(hwndFrame, GWL_EXSTYLE) != clistExStyle) { + SetWindowLong(hwndFrame, GWL_EXSTYLE, clistExStyle); + if (MyFramesSetLayeredWindowAttributes && (clistExStyle & WS_EX_LAYERED)) + MyFramesSetLayeredWindowAttributes( + hwndFrame, RGB(0, 0, 0), + (BYTE) DBGetContactSettingByte(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), + LWA_ALPHA + ); + } + if((GetWindowLong(hwndFrame, GWL_STYLE)& ~WS_VISIBLE) != (clistStyle & ~WS_VISIBLE)) { + SetWindowLong(hwndFrame, GWL_STYLE, (clistStyle & ~WS_VISIBLE) | (hwndVis ? WS_VISIBLE : 0)); + SetWindowPos(hwndFrame, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE); + } + + } else { + if(GetWindowLong(hwndFrame, GWL_EXSTYLE) != current->overrideExStyle) { + SetWindowLong(hwndFrame, GWL_EXSTYLE, current->overrideExStyle); + if(MyFramesSetLayeredWindowAttributes) { + if((GetWindowLong(hwndFrame, GWL_EXSTYLE) & WS_EX_LAYERED) == 0) + SetWindowLong(hwndFrame, GWL_EXSTYLE, GetWindowLong(hwndFrame, GWL_EXSTYLE) | WS_EX_LAYERED); + MyFramesSetLayeredWindowAttributes( + hwndFrame, RGB(0, 0, 0), + current->alpha, + LWA_ALPHA + ); + } + } + if((GetWindowLong(hwndFrame, GWL_STYLE)& ~WS_VISIBLE) != (current->overrideStyle & ~WS_VISIBLE)) { + SetWindowLong(hwndFrame, GWL_STYLE, (current->overrideStyle & ~WS_VISIBLE) | (hwndVis ? WS_VISIBLE : 0)); + SetWindowPos(hwndFrame, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE); + } + } + + // convert client height to frame height + if(!(current->frame_data.Flags & F_UNCOLLAPSED)) + frameHeight = height_client_to_frame(0, GetWindowLong(hwndFrame, GWL_STYLE) | WS_VISIBLE, GetWindowLong(hwndFrame, GWL_EXSTYLE)); + else + frameHeight = current->height; + + if(frameHeight <= 0) frameHeight = 1; + + if((clist_visible && current->hiding) || (!current->hiding && (current->frame_data.Flags & F_VISIBLE))) { + GetWindowRect(hwndFrame, &fr); + if(current->moving) { + if(fr.left != r.left + current->off_x || fr.top != r.top + current->off_y || fr.right != r.left + current->off_x + frameWidth || fr.bottom != r.top + current->off_y + frameHeight) { + SetWindowPos(hwndFrame, 0, r.left + current->off_x, r.top + current->off_y , frameWidth, frameHeight, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + } + } else { + if(fr.bottom - fr.top != frameHeight || fr.right - fr.left != frameWidth) { + SetWindowPos(hwndFrame, 0, 0, 0, frameWidth, frameHeight, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSENDCHANGING); + } + } + + if(!IsWindowVisible(hwndFrame)) { + ShowWindow(hwndFrame, SW_SHOWNOACTIVATE); + //UpdateWindow(hwndFrame); + RedrawWindow(hwndFrame, 0, 0, RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_ERASE); + } + } else if(IsWindowVisible(hwndFrame) && ((current->hiding && !clist_visible) || (!current->hiding && (current->frame_data.Flags & F_VISIBLE) == 0))) { + current->frame_data.Flags &= ~F_VISIBLE; + ShowWindow(hwndFrame, SW_HIDE); + } + + current = current->next; + } + LeaveCriticalSection(&cs); +} + +//void PosTimerProc(HWND hwnd, UINT msg, UINT_PTR idEvent, DWORD time) { +// PositionFramesNow(); +//} + +// schedule a frame position update +void PositionFrames() { + /* + if(id_pos_timer) { + KillTimer(0, id_pos_timer); + id_pos_timer = 0; + } + id_pos_timer = SetTimer(0, 0, 1000, (TIMERPROC)PosTimerProc); + */ + PositionFramesNow(); +} + + +void SaveFrameState(struct FrameListNode *node) { + //StoreFrameHeight(node->frame_data.name, node->height); + StoreFrameFlags(node->frame_data.name, node->frame_data.Flags); + StoreFrameMoving(node->frame_data.name, node->moving); + StoreFrameHiding(node->frame_data.name, node->hiding); + StoreFrameIsStyleOverride(node->frame_data.name, node->style_override ? TRUE : FALSE); + StoreFrameStyleOverride(node->frame_data.name, node->overrideStyle); + StoreFrameStyleExOverride(node->frame_data.name, node->overrideExStyle); + StoreFrameAlpha(node->frame_data.name, node->alpha); + StoreFrameOffX(node->frame_data.name, node->off_x); + StoreFrameOffY(node->frame_data.name, node->off_y); +} + +int AddFrame(WPARAM wParam, LPARAM lParam) { + CLISTFrame *frame_data = (CLISTFrame *)wParam; + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + + LONG clistStyle = GetWindowLong(hwndClist, GWL_STYLE), + clistExStyle = GetWindowLong(hwndClist, GWL_EXSTYLE), + childStyle; + + struct FrameListNode *node; + TCHAR title[256]; + HWND hwndParent; + RECT r; + + if(frame_data->cbSize != sizeof(CLISTFrame)) + return -1; + + childStyle = GetWindowLong(frame_data->hWnd, GWL_STYLE); + childStyle &= ~(WS_POPUP | WS_BORDER); + childStyle |= (WS_VISIBLE | WS_CHILD);// | WS_CLIPCHILDREN); + + SetWindowLong(frame_data->hWnd, GWL_STYLE, childStyle); + SetWindowPos(frame_data->hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + frame_data->Flags = ReadFrameFlags(frame_data->name, frame_data->Flags | F_UNCOLLAPSED); + StoreFrameFlags(frame_data->name, frame_data->Flags); + +#ifdef _UNICODE + MultiByteToWideChar(CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, frame_data->name, -1, title, 256); +#else + strncpy(title, frame_data->name, 256); +#endif + + node = (struct FrameListNode *)malloc(sizeof(struct FrameListNode)); + memcpy(&node->frame_data, frame_data, sizeof(CLISTFrame)); + node->id = next_frame_id++; + node->origStyle = GetWindowLong(node->frame_data.hWnd, GWL_STYLE); + node->origExStyle = GetWindowLong(node->frame_data.hWnd, GWL_EXSTYLE); + node->frame_data.name = _strdup(frame_data->name); + node->sizing = node->size_move = FALSE; + + node->align = ReadFrameAlign(frame_data->name, AL_TOP); + + node->width = ReadFrameWidth(frame_data->name, 150); + node->moving = ReadFrameMoving(frame_data->name, TRUE); + node->hiding = ReadFrameHiding(frame_data->name, true); + node->off_x = ReadFrameOffX(frame_data->name, 0); + node->off_y = ReadFrameOffY(frame_data->name, 0); + + node->style_override = ReadFrameIsStyleOverride(frame_data->name, FALSE); + node->overrideStyle = ReadFrameStyleOverride(frame_data->name, clistStyle); + node->overrideExStyle = ReadFrameStyleExOverride(frame_data->name, clistExStyle); + + if(node->style_override) + node->height = ReadFrameHeight(frame_data->name, height_client_to_frame(frame_data->height, node->overrideStyle, node->overrideExStyle)); + else + node->height = ReadFrameHeight(frame_data->name, height_client_to_frame(frame_data->height, clistStyle, clistExStyle)); + StoreFrameHeight(frame_data->name, node->height); + + node->alpha = ReadFrameAlpha(frame_data->name, 255); + + GetWindowRect(hwndClist, &r); + //hwndParent = CreateWindowEx(clistExStyle, _T("CListFrameClass"), title, clistStyle, r.left + node->off_x, r.top + node->off_y, node->width, node->height, hwndClist, NULL, g_hInst, NULL); + if(node->style_override) { + hwndParent = CreateWindowEx(node->overrideExStyle, _T("CListFrameClass"), title, (node->overrideStyle & ~WS_VISIBLE), r.left + node->off_x, r.top + node->off_y, 0, 0, hwndClist, NULL, hInst, node); + + if (MyFramesSetLayeredWindowAttributes) + MyFramesSetLayeredWindowAttributes(hwndParent, RGB(0, 0, 0), + (BYTE) node->alpha, + LWA_ALPHA); + } else { + hwndParent = CreateWindowEx(clistExStyle, _T("CListFrameClass"), title, (clistStyle & ~WS_VISIBLE), r.left + node->off_x, r.top + node->off_y, 0, 0, hwndClist, NULL, hInst, node); + + if (MyFramesSetLayeredWindowAttributes && (clistExStyle & WS_EX_LAYERED)) + MyFramesSetLayeredWindowAttributes(hwndParent, RGB(0, 0, 0), + (BYTE) DBGetContactSettingByte(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), + LWA_ALPHA); + } + + node->hwndParent = hwndParent; + SetParent(frame_data->hWnd, hwndParent); + + PostMessage(hwndParent, WM_CHANGEUISTATE, UIS_INITIALIZE, 0); + + EnterCriticalSection(&cs); + node->next = frame_list; + frame_list = node; + LeaveCriticalSection(&cs); + + return node->id; +} + +int ShowHideFrame(WPARAM wParam, LPARAM lParam) { + int id = (int)wParam; + struct FrameListNode *node = GetFrame(id); + if(node) { + node->frame_data.Flags ^= F_VISIBLE; + /* + if(((node->frame_data.Flags & F_VISIBLE) != 0) != clist_visible) { + node->hiding = false; + StoreFrameHiding(node->frame_data.name, node->hiding); + } + */ + StoreFrameFlags(node->frame_data.name, node->frame_data.Flags); + PositionFrames(); + } + return 0; +} + +int ShowAllFrames(WPARAM wParam, LPARAM lParam) { + struct FrameListNode *current; + + EnterCriticalSection(&cs); + current = frame_list; + while(current) { + current->frame_data.Flags |= F_VISIBLE; + /* + if(((current->frame_data.Flags & F_VISIBLE) != 0) != clist_visible) { + current->hiding = false; + StoreFrameHiding(current->frame_data.name, current->hiding); + } + */ + StoreFrameFlags(current->frame_data.name, current->frame_data.Flags); + current = current->next; + } + LeaveCriticalSection(&cs); + PositionFrames(); + return 0; +} + +int UpdateFrame(WPARAM wParam, LPARAM lParam) { + int id = (int)wParam, flags = (int)lParam; + struct FrameListNode *node = GetFrame(id); + if(node) { + if((flags & FU_FMREDRAW) && IsWindowVisible(node->hwndParent)) { + RedrawWindow(node->hwndParent, 0, 0, RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_ERASE); + //RedrawWindow(node->frame_data.hWnd, 0, 0, RDW_FRAME | RDW_INVALIDATE); + //InvalidateRect(node->hwndParent, 0, TRUE); + } + } + return 0; +} + + +int GetFrameOptions(WPARAM wParam, LPARAM lParam) { + //int id = (int)LOWORD(wParam), flags = (int)HIWORD(wParam); // grr - header file wrong! + int id = (int)HIWORD(wParam), flags = (int)LOWORD(wParam); + struct FrameListNode *node = GetFrame(id); + if(node) { + switch(flags) { + case FO_FLAGS: + return node->frame_data.Flags; + case FO_FLOATING: + return TRUE; + case FO_HEIGHT: + return node->frame_data.height; + } + } + + return -1; +} + +int SetFrameOptions(WPARAM wParam, LPARAM lParam) { + //int id = (int)LOWORD(wParam), flags = (int)HIWORD(wParam); // grr - header file wrong! + int id = (int)HIWORD(wParam), flag = (int)LOWORD(wParam); + int value = (int)lParam; + struct FrameListNode *node = GetFrame(id); + if(node) { + switch(flag) { + case FO_HEIGHT: + node->frame_data.height = value; + { + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + if(node->style_override) { + LONG clistStyle = GetWindowLong(hwndClist, GWL_STYLE), + clistExStyle = GetWindowLong(hwndClist, GWL_EXSTYLE); + node->height = height_client_to_frame(value, clistStyle, clistExStyle); + } else { + node->height = height_client_to_frame(value, node->overrideStyle, node->overrideExStyle); + } + StoreFrameHeight(node->frame_data.name, node->height); + } + break; + case FO_FLAGS: + node->frame_data.Flags = value; + StoreFrameFlags(node->frame_data.name, node->frame_data.Flags); + break; + case FO_FLOATING: + // not implemented! + // (fall through) + default: + return -1; + } + + PositionFrames(); + } + + return 0; +} + +void MakeFrameServices() { + CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, AddFrame); + CreateServiceFunction(MS_CLIST_FRAMES_SHFRAME, ShowHideFrame); + CreateServiceFunction(MS_CLIST_FRAMES_UPDATEFRAME, UpdateFrame); + CreateServiceFunction(MS_CLIST_FRAMES_GETFRAMEOPTIONS, GetFrameOptions); + CreateServiceFunction(MS_CLIST_FRAMES_SETFRAMEOPTIONS, SetFrameOptions); + CreateServiceFunction(MS_CLIST_FRAMES_SHOWALLFRAMES, ShowAllFrames); +} + +void AddMainMenuItem() { + CLISTMENUITEM menu; + ZeroMemory(&menu,sizeof(menu)); + menu.cbSize=sizeof(menu); + menu.flags = CMIM_ALL; + + menu.hIcon=LoadIcon(hInst, MAKEINTRESOURCE(IDI_BLANK)); + + menu.pszName = (char *)Translate("Show all frames"); + menu.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES; + menu.position = 500100000; + CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu); +} + +LRESULT CALLBACK ContactListWndSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + switch(msg) { + case WM_MOVE: + case WM_SIZE: + case WM_STYLECHANGED: + PositionFrames(); + break; + case WM_SHOWWINDOW: + SetCListVisible(wParam); + PositionFrames(); + break; + } + + return CallWindowProc(oldContactListWndProc, hwnd, msg, wParam, lParam); + //return oldContactListWndProc(hwnd, msg, wParam, lParam); +} + +void SubclassCListWndProc() { + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + oldContactListWndProc = (LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM))SetWindowLong(hwndClist, GWL_WNDPROC, (LONG)ContactListWndSubclassProc); +} + +void UnsubclassCListWndProc() { + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + SetWindowLong(hwndClist, GWL_WNDPROC, (LONG)oldContactListWndProc); +} + + +int FramesModulesLoaded(WPARAM wParam, LPARAM lParam) { + SubclassCListWndProc(); + SetCListVisible(IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))); + PositionFrames(); + AddMainMenuItem(); + return 0; +} + +LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + switch(msg) { + case WM_CREATE: + { + CREATESTRUCT *cs = (CREATESTRUCT *)lParam; + // set 'node' pointer + SetWindowLong(hwnd, GWL_USERDATA, (LONG)cs->lpCreateParams); + } + return FALSE; + case WM_MOVE: + //PUShowMessage("move", SM_NOTIFY); + if(!IsWindowVisible(hwnd)) break; + + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) { + RECT r, clr; + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + GetWindowRect(hwndClist, &clr); + GetWindowRect(hwnd, &r); + + node->off_x = r.left - clr.left; + node->off_y = r.top - clr.top; + StoreFrameOffX(node->frame_data.name, node->off_x); + StoreFrameOffY(node->frame_data.name, node->off_y); + } + } + break; + case WM_SIZE: + //PUShowMessage("size", SM_NOTIFY); + //if(!IsWindowVisible(hwnd)) break; + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) { + HWND hwndChild = node->frame_data.hWnd; + RECT r, cr; + GetClientRect(hwnd, &r); + GetWindowRect(hwndChild, &cr); + + //SetWindowPos(hwndChild, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE); + if(cr.right - cr.left != r.right - r.left || cr.bottom - cr.top != r.bottom - r.top) { + SetWindowPos(hwndChild, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW); + if(IsWindowVisible(hwnd)) { + cr = r; + // frame_data.height is client height + GetWindowRect(hwnd, &r); + // but node width and height are frame + if(node->frame_data.Flags & F_UNCOLLAPSED) { + node->frame_data.height = cr.bottom - cr.top; + node->height = r.bottom - r.top; + StoreFrameHeight(node->frame_data.name, node->height); + } + node->width = r.right - r.left; + StoreFrameWidth(node->frame_data.name, node->width); + PositionFrames(); + } + } + + if(node->size_move) + node->sizing = TRUE; + UpdateWindow(hwnd); + } + } + break; + case WM_ENTERSIZEMOVE: + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) node->size_move = TRUE; + } + break; + case WM_EXITSIZEMOVE: + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) node->size_move = node->sizing = FALSE; + } + break; + case WM_CLOSE: + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) ShowHideFrame(node->id, 0); + } + return 0; + case WM_NCLBUTTONDBLCLK: + //PUShowMessage("dbl click", SM_NOTIFY); + { + HRESULT hr = DefWindowProc(hwnd, WM_NCHITTEST, 0, lParam); + if(hr == HTCAPTION) { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) { + node->frame_data.Flags ^= F_UNCOLLAPSED; + StoreFrameFlags(node->frame_data.name, node->frame_data.Flags); + PositionFrames(); + } + } + } + break; + case WM_WINDOWPOSCHANGING: + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(node) { + WINDOWPOS *winpos = (WINDOWPOS *)lParam; + HWND hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + struct FrameListNode *current; + + if(IsWindowVisible(hwndClist)) + SendMessage(hwnd, WMU_SNAPTO, (WPARAM)hwndClist, (LPARAM)winpos); + + EnterCriticalSection(&cs); + current = frame_list; + while(current) { + if(IsWindowVisible(current->hwndParent)) + SendMessage(hwnd, WMU_SNAPTO, (WPARAM)current->hwndParent, (LPARAM)winpos); + current = current->next; + } + LeaveCriticalSection(&cs); + + //PositionFrames(); + } + } + return 0; + //break; + case WMU_SNAPTO: + { + BOOL snapped = FALSE; + WINDOWPOS *winpos = (WINDOWPOS *)lParam; + HWND hwndOther = (HWND)wParam; + RECT sr; + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + + if(node && GetWindowRect(hwndOther,&sr)) { + if((winpos->x <= (sr.right + SNAP_THRESH)) && (winpos->x >= (sr.right - SNAP_THRESH))) { + if ((winpos->y + winpos->cy >= sr.top) && (winpos->y <= sr.bottom)) { + snapped = TRUE; + if(node->sizing) winpos->cx += winpos->x - sr.right; + winpos->x = sr.right; + } + } + + if((winpos->x + winpos->cx <= (sr.left + SNAP_THRESH)) && (winpos->x + winpos->cx >= (sr.left - SNAP_THRESH))) { + if ((winpos->y + winpos->cy >= sr.top) && (winpos->y <= sr.bottom)) { + snapped = TRUE; + + if(node->sizing) winpos->cx = sr.left - winpos->x; + else winpos->x = sr.left - winpos->cx; + } + } + + if((winpos->y <= (sr.bottom + SNAP_THRESH)) && (winpos->y >= (sr.bottom - SNAP_THRESH))) { + if ((winpos->x + winpos->cx >= sr.left) && (winpos->x <= sr.right)) { + snapped = TRUE; + if(node->sizing) winpos->cy += winpos->y - sr.bottom; + winpos->y = sr.bottom; + } + } + + if((winpos->y + winpos->cy <= (sr.top + SNAP_THRESH)) && (winpos->y + winpos->cy >= (sr.top - SNAP_THRESH))) { + if ((winpos->x + winpos->cx >= sr.left) && (winpos->x <= sr.right)) { + snapped = TRUE; + + if(node->sizing) winpos->cy = sr.top - winpos->y; + else winpos->y = sr.top - winpos->cy; + } + } + + if((winpos->x <= (sr.left + SNAP_THRESH)) && (winpos->x >= (sr.left - SNAP_THRESH))) { + if ((winpos->y + winpos->cy == sr.top) || (winpos->y == sr.bottom)) { + snapped = TRUE; + if(node->sizing) winpos->cx += winpos->x - sr.left; + winpos->x = sr.left; + } + } + + if((winpos->x + winpos->cx <= (sr.right + SNAP_THRESH)) && (winpos->x + winpos->cx >= (sr.right - SNAP_THRESH))) { + if ((winpos->y + winpos->cy == sr.top) || (winpos->y == sr.bottom)) { + snapped = TRUE; + if(node->sizing) winpos->cx = sr.right - winpos->x; + else winpos->x = sr.right - winpos->cx; + } + } + + if((winpos->y <= (sr.top + SNAP_THRESH)) && (winpos->y >= (sr.top - SNAP_THRESH))) { + if ((winpos->x + winpos->cx == sr.left) || (winpos->x == sr.right)) { + snapped = TRUE; + if(node->sizing) winpos->cy += winpos->y - sr.top; + winpos->y = sr.top; + } + } + + if((winpos->y + winpos->cy <= (sr.bottom + SNAP_THRESH)) && (winpos->y + winpos->cy >= (sr.bottom - SNAP_THRESH))) { + if ((winpos->x + winpos->cx == sr.left) || (winpos->x == sr.right)) { + snapped = TRUE; + if(node->sizing) winpos->cy = sr.bottom - winpos->y; + else winpos->y = sr.bottom - winpos->cy; + } + } + } + return snapped; + } + /* + case WM_SHOWWINDOW: + { + struct FrameListNode *node = (struct FrameListNode *)GetWindowLong(hwnd, GWL_USERDATA); + if(!node) break; + if (lParam) + break; + if (!DBGetContactSettingByte(NULL, "CLUI", "FadeInOut", 0) || !IsWinVer2000Plus()) + break; + if(!(node->frame_data.Flags & F_VISIBLE)) + break; + if (wParam) + SetForegroundWindow(hwnd); + if(MyAnimateWindow) + MyAnimateWindow(hwnd, 200, AW_BLEND | (wParam ? 0 : AW_HIDE)); + //SetWindowPos(cli.hwndContactTree, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + } + break; + */ + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +void InitFrames() { + WNDCLASS wndclass; + + hUserDll = LoadLibraryA("user32.dll"); + if (hUserDll) { + MyFramesSetLayeredWindowAttributes = (BOOL(WINAPI *) (HWND, COLORREF, BYTE, DWORD)) GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); + MyAnimateWindow = (BOOL(WINAPI *) (HWND, DWORD, DWORD)) GetProcAddress(hUserDll, "AnimateWindow"); + } + + wndclass.style = CS_VREDRAW | CS_HREDRAW | CS_GLOBALCLASS; + wndclass.lpfnWndProc = FrameWindowProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInst; + wndclass.hIcon = 0; + wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = _T("CListFrameClass"); + RegisterClass(&wndclass); + + InitializeCriticalSection(&cs); + + MakeFrameServices(); + + HookEvent(ME_SYSTEM_MODULESLOADED, FramesModulesLoaded); +} + +void DeinitFrames() { + struct FrameListNode *current; + + UnsubclassCListWndProc(); + + EnterCriticalSection(&cs); + current = frame_list; + while(current) { + DestroyWindow(current->hwndParent); + + frame_list = current->next; + free(current->frame_data.name); + free(current); + current = frame_list; + } + LeaveCriticalSection(&cs); + DeleteCriticalSection(&cs); + + UnregisterClass(_T("CListFrameClass"), hInst); + + if(hUserDll) + FreeLibrary(hUserDll); +} \ No newline at end of file diff --git a/xframes/frames.h b/xframes/frames.h new file mode 100644 index 0000000..4f765ea --- /dev/null +++ b/xframes/frames.h @@ -0,0 +1,35 @@ +#ifndef _FRAMES_INC +#define _FRAMES_INC + +void PositionFrames(); +void SetCListVisible(BOOL visible); + +void InitFrames(); +void DeinitFrames(); + +// my own alignment enum +typedef enum {AL_TOP, AL_BOTTOM, AL_LEFT, AL_RIGHT} FrameAlign; + +struct FrameListNode { + CLISTFrame frame_data; + HWND hwndParent; + int id; + struct FrameListNode *next; + LONG origStyle, origExStyle; + bool moving, hiding, style_override; + LONG overrideStyle, overrideExStyle; + char alpha; + FrameAlign align; + int width, height; // for frame (frame_data->height is client - which is only used as input from API [addframe, set frame options]) + + int off_x, off_y; // offsets from clist location for non-floating mode + + bool sizing, size_move; +}; + +extern struct FrameListNode *frame_list; + +void SaveFrameState(struct FrameListNode *node); +extern CRITICAL_SECTION cs; + +#endif diff --git a/xframes/icon1.ico b/xframes/icon1.ico new file mode 100644 index 0000000..1868f45 Binary files /dev/null and b/xframes/icon1.ico differ diff --git a/xframes/options.cpp b/xframes/options.cpp new file mode 100644 index 0000000..dc7043d --- /dev/null +++ b/xframes/options.cpp @@ -0,0 +1,209 @@ +#include "common.h" +#include "options.h" +#include "frames.h" + +Options options; + +#define WMU_SETFRAMEDATA (WM_USER + 0x100) + +struct FrameListNode *temp_frame_list = 0; + +static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + + switch ( msg ) { + case WM_INITDIALOG: + TranslateDialogDefault( hwndDlg ); + + // copy original frame list + { + EnterCriticalSection(&cs); + struct FrameListNode *current = frame_list, *newnode; + while(current) { + newnode = (struct FrameListNode *)malloc(sizeof(struct FrameListNode)); + *newnode = *current; + newnode->next = temp_frame_list; + temp_frame_list = newnode; + + // fill list with frame names while we're here + int index = SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_ADDSTRING, 0, (LPARAM)newnode->frame_data.name); + SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_SETITEMDATA, (WPARAM)index, (LPARAM)newnode); + + current = current->next; + } + LeaveCriticalSection(&cs); + } + + if(temp_frame_list) { + SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_SETCURSEL, 0, 0); + SendMessage(hwndDlg, WMU_SETFRAMEDATA, 0, 0); + } + + return FALSE; + case WMU_SETFRAMEDATA: + { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_GETCURSEL, 0, 0); + if(sel >= 0) { + struct FrameListNode *node = (struct FrameListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_GETITEMDATA, (WPARAM)sel, 0); + if(node) { + CheckDlgButton(hwndDlg, IDC_CHK_VIS, (node->frame_data.Flags & F_VISIBLE) != 0); + CheckDlgButton(hwndDlg, IDC_CHK_MOVE, node->moving ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_HIDE, node->hiding ? TRUE : FALSE); + + int rad; + if(!node->style_override) rad = 0; + else if(node->overrideExStyle & WS_EX_TOOLWINDOW) rad = 1; + else if((node->overrideStyle & WS_CAPTION) == WS_CAPTION) rad = 2; + else if(node->overrideStyle & WS_BORDER) rad = 3; + else rad = 4; + + CheckDlgButton(hwndDlg, IDC_RAD_BCOPY, rad == 0 ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_RAD_BTOOL, rad == 1 ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_RAD_BNORM, rad == 2 ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_RAD_BTHIN, rad == 3 ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_RAD_BNONE, rad == 4 ? TRUE : FALSE); + } + } + } + return TRUE; + case WM_COMMAND: + if ( HIWORD( wParam ) == LBN_SELCHANGE ) { + SendMessage(hwndDlg, WMU_SETFRAMEDATA, 0, 0); + } else if ( HIWORD( wParam ) == BN_CLICKED ) { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_GETCURSEL, 0, 0); + if(sel >= 0) { + struct FrameListNode *node = (struct FrameListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_FRAMES, LB_GETITEMDATA, (WPARAM)sel, 0); + + switch( LOWORD( wParam )) { + case IDC_CHK_VIS: + if(IsDlgButtonChecked(hwndDlg, IDC_CHK_VIS)) + node->frame_data.Flags |= F_VISIBLE; + else + node->frame_data.Flags &= ~F_VISIBLE; + break; + case IDC_CHK_MOVE: + node->moving = (IsDlgButtonChecked(hwndDlg, IDC_CHK_MOVE) ? true : false); + break; + case IDC_CHK_HIDE: + node->hiding = (IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDE) ? true : false); + break; + + case IDC_RAD_BCOPY: + node->style_override = false; + break; + case IDC_RAD_BTOOL: + node->style_override = true; + node->overrideStyle = WS_CAPTION | WS_SYSMENU | WS_THICKFRAME; + node->overrideExStyle = WS_EX_TOOLWINDOW | WS_EX_LAYERED; + break; + case IDC_RAD_BNORM: + node->style_override = true; + node->overrideStyle = WS_CAPTION | WS_SYSMENU | WS_THICKFRAME; + node->overrideExStyle = WS_EX_LAYERED; + break; + case IDC_RAD_BTHIN: + node->style_override = true; + node->overrideStyle = WS_BORDER; + node->overrideExStyle = WS_EX_LAYERED; + break; + case IDC_RAD_BNONE: + node->style_override = true; + node->overrideStyle = 0; + node->overrideExStyle = WS_EX_LAYERED; + break; + } + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + return TRUE; + } + } + break; + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == PSN_APPLY ) { + + EnterCriticalSection(&cs); + // save old frame list + struct FrameListNode *old_frame_list = frame_list; + + frame_list = 0; + // copy temp frame list to real frame list + if(temp_frame_list) { + struct FrameListNode *current = temp_frame_list, *newnode, *oldnode; + while(current) { + newnode = (struct FrameListNode *)malloc(sizeof(struct FrameListNode)); + *newnode = *current; + newnode->next = frame_list; + frame_list = newnode; + + // keep old frame size info + oldnode = (struct FrameListNode *)GetWindowLong(frame_list->hwndParent, GWL_USERDATA); + newnode->height = oldnode->height; + newnode->width = oldnode->width; + newnode->frame_data.height = oldnode->frame_data.height; + newnode->off_x = oldnode->off_x; + newnode->off_y = oldnode->off_y; + + SetWindowLong(frame_list->hwndParent, GWL_USERDATA, (LONG)newnode); + SaveFrameState(newnode); + + current = current->next; + } + } + + // delete old frame list + if(old_frame_list) { + struct FrameListNode *current; + while(old_frame_list) { + current = old_frame_list; + old_frame_list = old_frame_list->next; + free(current); + } + } + + LeaveCriticalSection(&cs); + + PositionFrames(); + + return TRUE; + } + break; + case WM_DESTROY: + if(temp_frame_list) { + struct FrameListNode *current; + while(temp_frame_list) { + current = temp_frame_list; + temp_frame_list = temp_frame_list->next; + free(current); + } + } + + break; + } + return FALSE; + +} + + +int OptInit(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.position = -790000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT); + odp.pszTitle = Translate(MODULE); + odp.pszGroup = Translate("Plugins"); // Services? Customize? + odp.flags = ODPF_BOLDGROUPS; + odp.nIDBottomSimpleControl = 0; + odp.pfnDlgProc = DlgProcOpts; + + CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp ); + + return 0; +} + +void LoadOptions() { +} + +void SaveOptions() { +} + + diff --git a/xframes/options.h b/xframes/options.h new file mode 100644 index 0000000..9a72d50 --- /dev/null +++ b/xframes/options.h @@ -0,0 +1,17 @@ +#ifndef _OPTIONS_INC +#define _OPTIONS_INC + +#include "resource.h" + +typedef struct Options_tag { + int dummy; +} Options; + +extern Options options; + +int OptInit(WPARAM wParam, LPARAM lParam); + +void LoadOptions(); +void SaveOptions(); + +#endif diff --git a/xframes/resource.h b/xframes/resource.h new file mode 100644 index 0000000..056e46b --- /dev/null +++ b/xframes/resource.h @@ -0,0 +1,27 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by xframes.rc +// +#define IDD_OPT 101 +#define IDI_BLANK 102 +#define IDC_LST_FRAMES 1001 +#define IDC_CHK_VIS 1002 +#define IDC_CHK_MOVE 1003 +#define IDC_RAD_BCOPY 1004 +#define IDC_RAD_BNORM 1005 +#define IDC_RAD_BTOOL 1006 +#define IDC_RAD_BTHIN 1007 +#define IDC_RADIO5 1008 +#define IDC_RAD_BNONE 1008 +#define IDC_CHK_HIDE 1009 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1005 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/xframes/xframes.cpp b/xframes/xframes.cpp new file mode 100644 index 0000000..fae3cef --- /dev/null +++ b/xframes/xframes.cpp @@ -0,0 +1,109 @@ +// xframes.cpp : Defines the entry point for the DLL application. +// + +#include "common.h" +#include "xframes.h" +#include "options.h" +#include "frames.h" + +HINSTANCE hInst; +PLUGINLINK *pluginLink; + +HANDLE mainThread; + +bool metacontacts_installed; +bool unicode_system; + +int code_page = CP_ACP; + +HANDLE popupWindowList; + +DWORD focusTimerId = 0; + +PLUGININFO pluginInfo={ + sizeof(PLUGININFO), + "XFrames", + PLUGIN_MAKE_VERSION(0,0,1,2), + "External frames support", + "Scott Ellis", + "mail@scottellis.com.au", + "© 2005 Scott Ellis", + "http://www.scottellis.com.au/", + 0, //not transient + 0 //doesn't replace anything built-in +}; + + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + DisableThreadLibraryCalls(hInst); + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { + if(ServiceExists(MS_UPDATE_REGISTER)) { + // register with updater + Update update = {0}; + char szVersion[16]; + + update.cbSize = sizeof(Update); + + update.szComponentName = pluginInfo.shortName; + update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion); + update.cpbVersion = strlen((char *)update.pbVersion); + + update.szUpdateURL = UPDATER_AUTOREGISTER; + + update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/xframes.zip"; + update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_xframes.html"; + update.pbBetaVersionPrefix = (BYTE *)"XFrames version "; + update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix); + + CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); + } + + return 0; +} + +int OnPreShutdown(WPARAM wParam, LPARAM lParam) { + return 0; +} + +extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) +{ + if(GetModuleHandle(_T("clist_modern")) || GetModuleHandle(_T("clist_nicer")) || GetModuleHandle(_T("clist_mw"))) + return 1; + + pluginLink = link; + DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 ); + + char szVer[128]; + unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode")); + if(ServiceExists(MS_LANGPACK_GETCODEPAGE)) code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); + + // Ensure that the common control DLL is loaded (for listview) + INITCOMMONCONTROLSEX icex; + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_LISTVIEW_CLASSES; + InitCommonControlsEx(&icex); + + LoadOptions(); + InitFrames(); + + HookEvent(ME_OPT_INITIALISE, OptInit); + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + DeinitFrames(); + return 0; +} diff --git a/xframes/xframes.h b/xframes/xframes.h new file mode 100644 index 0000000..90bd3e0 --- /dev/null +++ b/xframes/xframes.h @@ -0,0 +1,12 @@ +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the XFRAMES_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// XFRAMES_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#ifdef XFRAMES_EXPORTS +#define XFRAMES_API __declspec(dllexport) +#else +#define XFRAMES_API __declspec(dllimport) +#endif + diff --git a/xframes/xframes.rc b/xframes/xframes.rc new file mode 100644 index 0000000..40e579c --- /dev/null +++ b/xframes/xframes.rc @@ -0,0 +1,128 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT DIALOGEX 0, 0, 299, 159 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LISTBOX IDC_LST_FRAMES,15,19,90,126,LBS_SORT | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Frames",IDC_STATIC,7,7,106,145 + GROUPBOX "Properties",IDC_STATIC,119,7,173,55 + CONTROL "Visible",IDC_CHK_VIS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,19,146,10 + CONTROL "Move with contact list",IDC_CHK_MOVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,33,146,10 + CONTROL "Copy contact list",IDC_RAD_BCOPY,"Button",BS_AUTORADIOBUTTON,130,79,117,10 + GROUPBOX "Border",IDC_STATIC,119,64,173,88 + CONTROL "Normal window",IDC_RAD_BNORM,"Button",BS_AUTORADIOBUTTON,130,93,117,10 + CONTROL "Tool window",IDC_RAD_BTOOL,"Button",BS_AUTORADIOBUTTON,130,107,117,10 + CONTROL "Thin",IDC_RAD_BTHIN,"Button",BS_AUTORADIOBUTTON,130,121,117,10 + CONTROL "None",IDC_RAD_BNONE,"Button",BS_AUTORADIOBUTTON,130,136,117,10 + CONTROL "Hide/show with contact list",IDC_CHK_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,47,146,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 292 + VERTGUIDE, 130 + TOPMARGIN, 7 + BOTTOMMARGIN, 152 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_BLANK ICON "icon1.ico" +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/xframes/xframes.sln b/xframes/xframes.sln new file mode 100644 index 0000000..d85933d --- /dev/null +++ b/xframes/xframes.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xframes", "xframes.vcproj", "{192288C4-718D-44A0-B34E-1E0F3BD5944E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {192288C4-718D-44A0-B34E-1E0F3BD5944E}.Debug|Win32.ActiveCfg = Debug|Win32 + {192288C4-718D-44A0-B34E-1E0F3BD5944E}.Debug|Win32.Build.0 = Debug|Win32 + {192288C4-718D-44A0-B34E-1E0F3BD5944E}.Release|Win32.ActiveCfg = Release|Win32 + {192288C4-718D-44A0-B34E-1E0F3BD5944E}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xframes/xframes.vcproj b/xframes/xframes.vcproj new file mode 100644 index 0000000..9175d03 --- /dev/null +++ b/xframes/xframes.vcproj @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3