Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define SIZES_DATA_SIZE 8
- struct SIZES_DATA {
- HWND wnd;
- RECT wndBase;
- RECT bases[SIZES_DATA_SIZE];
- RECT defaults[SIZES_DATA_SIZE];
- HWND handles[SIZES_DATA_SIZE];
- bool moveL[SIZES_DATA_SIZE];
- bool moveR[SIZES_DATA_SIZE];
- bool moveT[SIZES_DATA_SIZE];
- bool moveB[SIZES_DATA_SIZE];
- };
- SIZES_DATA pos_data = { 0 };
- #define COLLECT_MAIN {\
- GetWindowRect(pos_data.wnd, &(pos_data.wndBase));\
- COLLECT_HANDLE(0, IDC_GROUPLIST, false, true, false, false);\
- COLLECT_HANDLE(1, IDC_MAPLIST, false, true, false, true);\
- COLLECT_HANDLE(2, IDC_STATIC, false, true, false, false);\
- COLLECT_HANDLE(3, IDC_STATIC2, false, true, false, true);\
- COLLECT_HANDLE(4, IDC_RESTOREFILE, false, false, true, true);\
- COLLECT_HANDLE(5, IDC_DELETEMAP, true, true, true, true);\
- COLLECT_HANDLE(6, IDC_DELETEGROUP, true, true, false, false);\
- COLLECT_HANDLE(7, IDC_CLEARALL, false, false, false, false);\
- }
- #define COLLECT_HANDLE(index, item, _moveL, _moveR, _moveT, _moveB) {\
- pos_data.moveL[index] = _moveL;\
- pos_data.moveR[index] = _moveR;\
- pos_data.moveT[index] = _moveT;\
- pos_data.moveB[index] = _moveB;\
- pos_data.handles[index] = GetDlgItem(pos_data.wnd, item);\
- GetWindowRect(pos_data.handles[index], &(pos_data.defaults[index]));\
- GetWindowRect(GetParent(pos_data.handles[index]), &(pos_data.bases[index]));\
- pos_data.defaults[index].left -= (pos_data.bases[index].right - pos_data.bases[index].left);\
- pos_data.defaults[index].right -= pos_data.bases[index].right;\
- pos_data.defaults[index].top -= (pos_data.bases[index].bottom - pos_data.bases[index].top);\
- pos_data.defaults[index].bottom -= pos_data.bases[index].bottom;\
- }
- #define MOVE_ALL \
- if (pos_data.wnd == 0) {\
- pos_data.wnd = hDlg;\
- COLLECT_MAIN\
- }\
- MOVE(0);\
- MOVE(1);\
- MOVE(2);\
- MOVE(3);\
- MOVE(4);\
- MOVE(5);\
- MOVE(6);\
- MOVE(7);\
- #define MOVE(index) {\
- RECT currentBase;\
- RECT currentWndBase;\
- GetWindowRect(pos_data.wnd, ¤tWndBase);\
- GetWindowRect(GetParent(pos_data.handles[index]), ¤tBase);\
- RECT rect;\
- int diffX = currentWndBase.left - pos_data.wndBase.left;\
- int diffY = currentWndBase.top - pos_data.wndBase.top;\
- rect.left = pos_data.defaults[index].left + (pos_data.moveL[index] ? (currentBase.right - currentBase.left) + diffX: (pos_data.bases[index].right - pos_data.bases[index].left) + diffX);\
- rect.right = pos_data.defaults[index].right + (pos_data.moveR[index] ? currentBase.right : pos_data.bases[index].right + diffX);\
- rect.top = pos_data.defaults[index].top + (pos_data.moveT[index] ? (currentBase.bottom - currentBase.top) + diffY : (pos_data.bases[index].bottom - pos_data.bases[index].top) + diffY);\
- rect.bottom = pos_data.defaults[index].bottom + (pos_data.moveB[index] ? currentBase.bottom : pos_data.bases[index].bottom + diffY);\
- POINT p;\
- p.x = rect.left;p.y = rect.top;ScreenToClient(GetParent(pos_data.handles[index]), &p);rect.left = p.x;rect.top = p.y;\
- p.x = rect.right;p.y = rect.bottom;ScreenToClient(GetParent(pos_data.handles[index]), &p);rect.right = p.x;rect.bottom = p.y;\
- MoveWindow(pos_data.handles[index], rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, true);\
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement