diff options
author | Goraf <goraf@miranda-ng.org> | 2013-10-11 20:53:23 +0000 |
---|---|---|
committer | Goraf <goraf@miranda-ng.org> | 2013-10-11 20:53:23 +0000 |
commit | 9b8ec8aeeb593644b053dc491818f37587293eae (patch) | |
tree | 0df68d63848d85b513db8a0f925e0b0e9fcf0ad2 /plugins/MagneticWindows/src/SnapToListService.cpp | |
parent | b4b33a756d9c5469007f3b4466a1cc21c6d2ddce (diff) |
* adopted
* compilable version
git-svn-id: http://svn.miranda-ng.org/main/trunk@6450 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MagneticWindows/src/SnapToListService.cpp')
-rw-r--r-- | plugins/MagneticWindows/src/SnapToListService.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/MagneticWindows/src/SnapToListService.cpp b/plugins/MagneticWindows/src/SnapToListService.cpp new file mode 100644 index 0000000000..5fc9f66268 --- /dev/null +++ b/plugins/MagneticWindows/src/SnapToListService.cpp @@ -0,0 +1,64 @@ +#include "MagneticWindowsCore.h"
+
+
+HANDLE hSnapToListService;
+
+
+int SnapToList(WPARAM wParam, LPARAM Align) {
+ HWND hWnd, hWndList;
+ RECT WndRect, ListRect;
+ RECT AlignRect;
+ RECT ResultRect;
+
+ hWnd = (HWND)wParam;
+
+ hWndList = (HWND)CallService(MS_CLUI_GETHWND,0,0);
+ GetWindowRect(hWnd, &WndRect);
+ GetWindowRect(hWndList, &ListRect);
+
+ AlignRect = ListRect;
+ if ((!(MS_MW_STL_List_Left & Align)) && (MS_MW_STL_List_Right & Align)) {
+ AlignRect.left = AlignRect.right;
+ } else
+ if ((MS_MW_STL_List_Left & Align) && (!(MS_MW_STL_List_Right & Align))) {
+ AlignRect.right = AlignRect.left;
+ }
+
+ if ((!(MS_MW_STL_List_Top & Align)) && (MS_MW_STL_List_Bottom & Align)) {
+ AlignRect.top = AlignRect.bottom;
+ } else
+ if ((MS_MW_STL_List_Top & Align) && (!(MS_MW_STL_List_Bottom & Align))) {
+ AlignRect.bottom = AlignRect.top;
+ }
+
+ ResultRect = WndRect;
+ if ((MS_MW_STL_Wnd_Left & Align) && (MS_MW_STL_Wnd_Right & Align)) {
+ ResultRect.left = AlignRect.left;
+ ResultRect.right = AlignRect.right;
+ } else
+ if ((!(MS_MW_STL_Wnd_Left & Align)) && (MS_MW_STL_Wnd_Right & Align)) {
+ ResultRect.left = AlignRect.right - (WndRect.right - WndRect.left);
+ ResultRect.right = AlignRect.right;
+ } else
+ if ((MS_MW_STL_Wnd_Left & Align) && (!(MS_MW_STL_Wnd_Right & Align))) {
+ ResultRect.left = AlignRect.left;
+ ResultRect.right = AlignRect.left + (WndRect.right - WndRect.left);
+ }
+
+ if ((MS_MW_STL_Wnd_Top & Align) && (MS_MW_STL_Wnd_Bottom & Align)) {
+ ResultRect.top = AlignRect.top;
+ ResultRect.bottom = AlignRect.bottom;
+ } else
+ if ((!(MS_MW_STL_Wnd_Top & Align)) && (MS_MW_STL_Wnd_Bottom & Align)) {
+ ResultRect.top = AlignRect.bottom - (WndRect.bottom - WndRect.top);
+ ResultRect.bottom = AlignRect.bottom;
+ } else
+ if ((MS_MW_STL_Wnd_Top & Align) && (!(MS_MW_STL_Wnd_Bottom & Align))) {
+ ResultRect.top = AlignRect.top;
+ ResultRect.bottom = AlignRect.top + (WndRect.bottom - WndRect.top);
+ }
+
+ MoveWindow(hWnd, ResultRect.left, ResultRect.top, ResultRect.right-ResultRect.left, ResultRect.bottom-ResultRect.top, true);
+
+ return 0;
+}
\ No newline at end of file |