00033 {
00034
PBWL pbwl;
00035
PSMWP psmwp;
00036
PWND pwndTest, pwndSort, pwndSwitch;
00037 HWND *phwnd, *phwndSort;
00038
CHECKPOINT *pcp, *pcpSort;
00039 POINT ptSort, ptSrc;
00040 WORD nIcons = 0;
00041 RECT rc;
00042 POINT ptMin;
00043
int xOrg, yOrg;
00044
int dx, dy;
00045
int dxSlot, dySlot;
00046
int cIconsPerPass, iIconPass;
00047
BOOL fHorizontal, fBreak;
00048
TL tlpwndTest;
00049
BOOL fHideMe;
00050
00051
CheckLock(pwnd);
00052
00053
00054
00055
00056
if ((pbwl =
BuildHwndList(pwnd->
spwndChild, BWL_ENUMLIST, NULL)) ==
NULL)
00057
return 0;
00058
00059 fHideMe =
IsTrayWindow(pwnd->
spwndChild);
00060
00061
00062
00063
00064 dxSlot =
SYSMET(CXMINSPACING);
00065 dySlot =
SYSMET(CYMINSPACING);
00066
00067
00068
00069
00070
GetRealClientRect(pwnd, &rc, GRC_SCROLLS, NULL);
00071
00072
00073
00074
00075 pwndSwitch =
RevalidateHwnd(ghwndSwitch);
00076
for (phwnd = pbwl->
rghwnd; *phwnd != (HWND)1; phwnd++) {
00077
if (((pwndTest =
RevalidateHwnd(*phwnd)) ==
NULL) ||
00078 !
TestWF(pwndTest , WFVISIBLE) ||
00079 pwndTest == pwndSwitch ||
00080 (pcp = (
CHECKPOINT *)
_GetProp(pwndTest, PROP_CHECKPOINT,
00081 PROPF_INTERNAL)) ==
NULL) {
00082 *phwnd =
NULL;
00083
continue;
00084 }
00085
00086
if (!
TestWF(pwndTest, WFMINIMIZED)) {
00087 pcp->
fMinInitialized =
FALSE;
00088 pcp->
ptMin.x = pcp->
ptMin.y = -1;
00089 *phwnd =
NULL;
00090
continue;
00091 }
00092
00093
00094
00095
00096 nIcons++;
00097
00098
00099
00100
00101 pcp->
fDragged =
FALSE;
00102
00103
00104
00105
00106 pcp->
ptMin.x = pwndTest->
rcWindow.left;
00107 pcp->
ptMin.y = pwndTest->
rcWindow.top;
00108
_ScreenToClient(pwnd, &pcp->
ptMin);
00109
00110
00111
switch (
SYSMET(ARRANGE) & ~ARW_HIDE) {
00112
case ARW_TOPLEFT | ARW_RIGHT:
00113
case ARW_TOPRIGHT | ARW_LEFT:
00114
00115 pcp->
ptMin.y += dySlot / 2;
00116 pcp->
ptMin.y -= pcp->
ptMin.y % dySlot;
00117
break;
00118
00119
case ARW_TOPLEFT | ARW_DOWN:
00120
case ARW_BOTTOMLEFT | ARW_UP:
00121
00122 pcp->
ptMin.x += dxSlot / 2;
00123 pcp->
ptMin.x -= pcp->
ptMin.x % dxSlot;
00124
break;
00125
00126
case ARW_BOTTOMLEFT | ARW_RIGHT:
00127
case ARW_BOTTOMRIGHT | ARW_LEFT:
00128
00129 pcp->
ptMin.y = rc.bottom - pcp->
ptMin.y;
00130 pcp->
ptMin.y += dySlot / 2;
00131 pcp->
ptMin.y -= pcp->
ptMin.y % dySlot;
00132 pcp->
ptMin.y = rc.bottom - pcp->
ptMin.y;
00133
break;
00134
00135
case ARW_BOTTOMRIGHT | ARW_UP:
00136
case ARW_TOPRIGHT | ARW_DOWN:
00137
00138 pcp->
ptMin.x = rc.right - pcp->
ptMin.x;
00139 pcp->
ptMin.x += dxSlot / 2;
00140 pcp->
ptMin.x -= pcp->
ptMin.x % dxSlot;
00141 pcp->
ptMin.x = rc.right - pcp->
ptMin.x;
00142
break;
00143 }
00144 }
00145
00146
if (nIcons == 0) {
00147
00148
00149
00150
00151
FreeHwndList(pbwl);
00152
return 0;
00153 }
00154
00155
if (fHideMe) {
00156 ptMin.x =
WHERE_NOONE_CAN_SEE_ME;
00157 ptMin.y =
WHERE_NOONE_CAN_SEE_ME;
00158
goto JustParkEm;
00159 }
00160
00161
00162
00163
00164
if (
SYSMET(ARRANGE) & ARW_STARTRIGHT) {
00165
00166 ptMin.x = xOrg = rc.right - dxSlot;
00167 dx = -dxSlot;
00168 }
else {
00169
00170 ptMin.x = xOrg = rc.left +
DX_GAP;
00171 dx = dxSlot;
00172 }
00173
00174
if (
SYSMET(ARRANGE) & ARW_STARTTOP) {
00175
00176 ptMin.y = yOrg = rc.top +
DY_GAP;
00177 dy = dySlot;
00178 }
else {
00179
00180 ptMin.y = yOrg = rc.bottom - dySlot;
00181 dy = -dySlot;
00182 }
00183
00184
00185
00186
00187 fHorizontal = ( (
SYSMET(ARRANGE) & ARW_DOWN) ?
FALSE :
TRUE );
00188
00189 iIconPass = fHorizontal ? (rc.right / dxSlot) : (rc.bottom / dySlot);
00190 cIconsPerPass = iIconPass =
max(1, iIconPass);
00191
00192
00193
00194
00195
for (phwnd = pbwl->
rghwnd; *phwnd != (HWND)1; phwnd++) {
00196
00197
00198
00199
00200
00201
if (*phwnd ==
NULL || (pwndTest =
RevalidateHwnd(*phwnd)) ==
NULL)
00202
continue;
00203
00204 pcp = (
CHECKPOINT *)
_GetProp(pwndTest, PROP_CHECKPOINT,
00205 PROPF_INTERNAL);
00206 ptSrc = pcp->
ptMin;
00207
00208 fBreak =
FALSE;
00209
for (phwndSort = pbwl->
rghwnd; phwndSort < phwnd; phwndSort++) {
00210
if (*phwndSort ==
NULL ||
00211 (pwndSort =
RevalidateHwnd(*phwndSort)) ==
NULL)
00212
continue;
00213
00214 pcpSort = (
CHECKPOINT*)
_GetProp(pwndSort, PROP_CHECKPOINT,
00215 PROPF_INTERNAL);
00216
00217 ptSort = pcpSort->
ptMin;
00218
00219
00220
00221
00222
switch (
SYSMET(ARRANGE) & ~ARW_HIDE) {
00223
case ARW_BOTTOMLEFT | ARW_RIGHT:
00224
00225
if (((ptSort.y == ptSrc.y) && (ptSort.x > ptSrc.x)) ||
00226 (ptSort.y < ptSrc.y))
00227 fBreak =
TRUE;
00228
break;
00229
00230
case ARW_BOTTOMLEFT | ARW_UP:
00231
00232
if (((ptSort.x == ptSrc.x) && (ptSort.y < ptSrc.y)) ||
00233 (ptSort.x > ptSrc.x))
00234 fBreak =
TRUE;
00235
break;
00236
00237
case ARW_BOTTOMRIGHT | ARW_LEFT:
00238
00239
if (((ptSort.y == ptSrc.y) && (ptSort.x < ptSrc.x)) ||
00240 (ptSort.y < ptSrc.y))
00241 fBreak =
TRUE;
00242
break;
00243
00244
case ARW_BOTTOMRIGHT | ARW_UP:
00245
00246
if (((ptSort.x == ptSrc.x) && (ptSort.y < ptSrc.y)) ||
00247 (ptSort.x < ptSrc.x))
00248 fBreak =
TRUE;
00249
break;
00250
00251
case ARW_TOPLEFT | ARW_RIGHT:
00252
00253
if (((ptSort.y == ptSrc.y) && (ptSort.x > ptSrc.x)) ||
00254 (ptSort.y > ptSrc.y))
00255 fBreak =
TRUE;
00256
break;
00257
00258
case ARW_TOPLEFT | ARW_DOWN:
00259
00260
if (((ptSort.x == ptSrc.x) && (ptSort.y > ptSrc.y)) ||
00261 (ptSort.x > ptSrc.x))
00262 fBreak =
TRUE;
00263
break;
00264
00265
case ARW_TOPRIGHT | ARW_LEFT:
00266
00267
if (((ptSort.y == ptSrc.y) && (ptSort.x < ptSrc.x)) ||
00268 (ptSort.y > ptSrc.y))
00269 fBreak =
TRUE;
00270
break;
00271
00272
case ARW_TOPRIGHT | ARW_DOWN:
00273
00274
if (((ptSort.x == ptSrc.x) && (ptSort.y > ptSrc.y)) ||
00275 (ptSort.x < ptSrc.x))
00276 fBreak =
TRUE;
00277
break;
00278 }
00279
00280
if (fBreak)
00281
break;
00282 }
00283
00284
00285
00286
00287
00288
while (phwndSort < phwnd) {
00289 pwndSort =
PW(*phwndSort);
00290 *phwndSort =
HW(pwndTest);
00291 pwndTest = pwndSort;
00292 phwndSort++;
00293 }
00294
00295
00296
00297
00298 *phwnd =
HW(pwndTest);
00299 }
00300
00301
00302
00303
00304
00305 JustParkEm:
00306
00307
for (phwnd = pbwl->
rghwnd; *phwnd != (HWND)1; phwnd++) {
00308
if (*phwnd ==
NULL || (pwndTest =
RevalidateHwnd(*phwnd)) ==
NULL)
00309
continue;
00310
00311 pcp = (
CHECKPOINT *)
_GetProp(pwndTest, PROP_CHECKPOINT,
00312 PROPF_INTERNAL);
00313
if (pcp !=
NULL) {
00314 pcp->
fMinInitialized =
TRUE;
00315 pcp->
ptMin = ptMin;
00316 }
00317
00318
if (fHideMe) {
00319
continue;
00320 }
00321
00322
00323
if (--iIconPass <= 0) {
00324
00325 iIconPass = cIconsPerPass;
00326
00327
if (fHorizontal) {
00328 ptMin.x = xOrg;
00329 ptMin.y += dy;
00330 }
else {
00331 ptMin.x += dx;
00332 ptMin.y = yOrg;
00333 }
00334 }
else {
00335
00336
if (fHorizontal)
00337 ptMin.x += dx;
00338
else
00339 ptMin.y += dy;
00340 }
00341 }
00342
00343 psmwp =
InternalBeginDeferWindowPos(2 * nIcons);
00344
if (psmwp ==
NULL)
00345
goto ParkExit;
00346
00347
for (phwnd = pbwl->
rghwnd; *phwnd != (HWND)1; phwnd++) {
00348
00349
00350
00351
00352
if (*phwnd ==
NULL || (pwndTest =
RevalidateHwnd(*phwnd)) ==
NULL)
00353
continue;
00354
00355 pcp = (
CHECKPOINT *)
_GetProp(pwndTest, PROP_CHECKPOINT,
00356 PROPF_INTERNAL);
00357
00358
00359
ThreadLockAlways(pwndTest, &tlpwndTest);
00360
00361 psmwp =
_DeferWindowPos(
00362 psmwp,
00363 pwndTest,
00364 NULL,
00365 pcp->
ptMin.x,
00366 pcp->
ptMin.y,
00367
SYSMET(CXMINIMIZED),
00368
SYSMET(CYMINIMIZED),
00369 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
00370
00371
ThreadUnlock(&tlpwndTest);
00372
00373
if (psmwp ==
NULL)
00374
break;
00375 }
00376
if (psmwp !=
NULL) {
00377
00378
00379
00380
xxxEndDeferWindowPosEx(psmwp, TRUE);
00381 }
00382
00383 ParkExit:
00384
FreeHwndList(pbwl);
00385
return nIcons;
00386 }