|
|
| version 1.1, 2003/10/16 17:58:44 | version 1.2, 2003/10/31 04:11:40 |
|---|---|
| Line 1 | Line 1 |
| #include <windows.h> | #include "compiler.h" |
| #include "winloc.h" | |
| #define SNAPDOTPULL 12 | |
| #define SNAPDOTREL 16 | |
| static int wingx; | enum { |
| static int wingy; | SNAPDOTPULL = 12, |
| static int winflg; | SNAPDOTREL = 16 |
| }; | |
| void winloc_movingstart(void) { | |
| wingx = 0; | void winloc_movingstart(WINLOC *wl) { |
| wingy = 0; | |
| winflg = 0; | ZeroMemory(wl, sizeof(WINLOC)); |
| } | } |
| void winloc_movingproc(RECT *prc) { | void winloc_movingproc(WINLOC *wl, RECT *rect) { |
| RECT workrc; | RECT workrc; |
| int winlx, winly; | int winlx; |
| int mv1, mv2; | int winly; |
| int d; | |
| SystemParametersInfo(SPI_GETWORKAREA, 0, &workrc, 0); | SystemParametersInfo(SPI_GETWORKAREA, 0, &workrc, 0); |
| winlx = prc->right - prc->left; | winlx = rect->right - rect->left; |
| winly = prc->bottom - prc->top; | winly = rect->bottom - rect->top; |
| if ((winlx > (workrc.right - workrc.left)) || | if ((winlx > (workrc.right - workrc.left)) || |
| (winly > (workrc.bottom - workrc.top))) { | (winly > (workrc.bottom - workrc.top))) { |
| return; | return; |
| } | } |
| mv1 = prc->left - workrc.left; | |
| mv2 = prc->right - workrc.right; | |
| if (winflg & 1) { | |
| wingx += mv1; | |
| prc->left = workrc.left; | |
| } | |
| else if (winflg & 2) { | |
| wingx += mv2; | |
| prc->left = workrc.right - winlx; | |
| } | |
| else if ((mv1 < SNAPDOTPULL) && (mv1 > -SNAPDOTPULL)) { | |
| wingx += mv1; | |
| prc->left = workrc.left; | |
| winflg |= 1; | |
| } | |
| else if ((mv2 < SNAPDOTPULL) && (mv2 > -SNAPDOTPULL)) { | |
| wingx += mv2; | |
| prc->left = workrc.right - winlx; | |
| winflg |= 2; | |
| } | |
| if ((wingx >= SNAPDOTREL) || (wingx <= -SNAPDOTREL)) { | |
| prc->left += wingx; | |
| wingx = 0; | |
| winflg &= (~3); | |
| } | |
| prc->right = prc->left + winlx; | |
| mv1 = prc->top - workrc.top; | if (wl->flag & 1) { |
| mv2 = prc->bottom - workrc.bottom; | wl->gx += rect->left - wl->tx; |
| if (winflg & 4) { | rect->left = wl->tx; |
| wingy += mv1; | if ((wl->gx >= SNAPDOTREL) || (wl->gx <= -SNAPDOTREL)) { |
| prc->top = workrc.top; | wl->flag &= ~1; |
| } | rect->left += wl->gx; |
| else if (winflg & 8) { | wl->gx = 0; |
| wingy += mv2; | } |
| prc->top = workrc.bottom - winly; | rect->right = rect->left + winlx; |
| } | } |
| else if ((mv1 < SNAPDOTPULL) && (mv1 > -SNAPDOTPULL)) { | if (wl->flag & 2) { |
| wingy += mv1; | wl->gy += rect->top - wl->ty; |
| prc->top = workrc.top; | rect->top = wl->ty; |
| winflg |= 4; | if ((wl->gy >= SNAPDOTREL) || (wl->gy <= -SNAPDOTREL)) { |
| } | wl->flag &= ~2; |
| else if ((mv2 < SNAPDOTPULL) && (mv2 > -SNAPDOTPULL)) { | rect->top += wl->gy; |
| wingy += mv2; | wl->gy = 0; |
| prc->top = workrc.bottom - winly; | } |
| winflg |= 8; | rect->bottom = rect->top + winly; |
| } | } |
| if ((wingy >= SNAPDOTREL) || (wingy <= -SNAPDOTREL)) { | |
| prc->top += wingy; | if (!(wl->flag & 1)) { |
| wingy = 0; | do { |
| winflg &= (~0xc); | d = rect->left - workrc.left; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - workrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| rect->left -= d; | |
| rect->right = rect->left + winlx; | |
| wl->flag |= 1; | |
| wl->gx = d; | |
| wl->tx = rect->left; | |
| } | |
| } | |
| if (!(wl->flag & 2)) { | |
| do { | |
| d = rect->top - workrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->bottom - workrc.bottom; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| rect->top -= d; | |
| rect->bottom = rect->top + winly; | |
| wl->flag |= 2; | |
| wl->gy = d; | |
| wl->ty = rect->top; | |
| } | |
| } | } |
| prc->bottom = prc->top + winly; | |
| } | } |