1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: select.c 897 2007-12-30 23:34:00Z gyoung $
|
---|
5 |
|
---|
6 | Container item selection support routines
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2004, 2007 Steven H. Levine
|
---|
10 |
|
---|
11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
12 | 25 May 05 SHL Rework for ULONGLONG
|
---|
13 | 06 Jun 05 SHL Drop unused code
|
---|
14 | 06 Jul 06 SHL Support compare content (IDM_SELECTSAMECONTENT)
|
---|
15 | 13 Jul 06 SHL Use Runtime_Error
|
---|
16 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
17 | 15 Aug 06 SHL Rework SetMask args and logic
|
---|
18 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
|
---|
19 | 19 Apr 07 SHL Sync with NumItemsToUnhilite mods
|
---|
20 | 12 May 07 SHL Use dcd->ulItemsToUnHilite
|
---|
21 | 14 Jun 07 SHL SelectAll: make odd expression go away
|
---|
22 | 02 Aug 07 SHL Sync with CNRITEM mods
|
---|
23 | 04 Aug 07 SHL Use Runtime_Error
|
---|
24 | 05 Aug 07 SHL Rework SpecialSelect to use CNRITEM_EXISTS and
|
---|
25 | not use pszFileName since CNRITEM_EXISTS set implies
|
---|
26 | pszFileName not null
|
---|
27 | 14 Aug 07 SHL Revert ExpandAll DosSleep to 0
|
---|
28 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
29 | 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
|
---|
30 |
|
---|
31 | ***********************************************************************/
|
---|
32 |
|
---|
33 | #define INCL_DOS
|
---|
34 | #define INCL_WIN
|
---|
35 | #define INCL_LONGLONG
|
---|
36 | #include <os2.h>
|
---|
37 |
|
---|
38 | #include <stdio.h>
|
---|
39 | #include <stdlib.h>
|
---|
40 | #include <string.h>
|
---|
41 | #include <share.h>
|
---|
42 | #include <io.h>
|
---|
43 |
|
---|
44 | #include "fm3dll.h"
|
---|
45 | #include "fm3str.h"
|
---|
46 |
|
---|
47 | static PSZ pszSrcFile = __FILE__;
|
---|
48 |
|
---|
49 | VOID UnHilite(HWND hwndCnr, BOOL all, CHAR *** list, ULONG ulItemsToUnHilite)
|
---|
50 | {
|
---|
51 | PCNRITEM pci;
|
---|
52 | INT numfiles = 0, numalloc = 0, x = 0;
|
---|
53 | INT attribute = CRA_CURSORED;
|
---|
54 |
|
---|
55 | if (all && list && *list) {
|
---|
56 | FreeList(*list);
|
---|
57 | *list = NULL;
|
---|
58 | }
|
---|
59 | pci = (PCNRITEM) CurrentRecord(hwndCnr);
|
---|
60 | if (pci && (INT)pci != -1) {
|
---|
61 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
62 | attribute = CRA_SELECTED;
|
---|
63 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
64 | MPFROMSHORT(attribute));
|
---|
65 | }
|
---|
66 | while (pci && (INT)pci != -1) {
|
---|
67 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
68 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
69 | if (!all)
|
---|
70 | break;
|
---|
71 | // Count is one extra to ensure non-zero elsewhere
|
---|
72 | // x is 0 based index
|
---|
73 | if (x + 2 == ulItemsToUnHilite)
|
---|
74 | break;
|
---|
75 | if (list)
|
---|
76 | AddToList(pci->pszFileName, list, &numfiles, &numalloc);
|
---|
77 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
78 | MPFROMP(pci), MPFROMSHORT(CRA_SELECTED));
|
---|
79 | x++;
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | VOID SelectList(HWND hwndCnr, BOOL partial, BOOL deselect, BOOL clearfirst,
|
---|
85 | PCNRITEM pciParent, PSZ filename, CHAR ** list)
|
---|
86 | {
|
---|
87 |
|
---|
88 | PCNRITEM pci;
|
---|
89 | register INT x;
|
---|
90 | BOOL foundone = FALSE;
|
---|
91 | ULONG errs = 0;
|
---|
92 |
|
---|
93 | if (clearfirst && !deselect)
|
---|
94 | UnHilite(hwndCnr, TRUE, NULL, 0);
|
---|
95 | if (list && list[0]) {
|
---|
96 | for (x = 0; list[x]; x++) {
|
---|
97 | pci = FindCnrRecord(hwndCnr,
|
---|
98 | list[x], pciParent, partial, partial, TRUE);
|
---|
99 | if (pci) {
|
---|
100 | WinSendMsg(hwndCnr,
|
---|
101 | CM_SETRECORDEMPHASIS,
|
---|
102 | MPFROMP(pci),
|
---|
103 | MPFROM2SHORT((SHORT) ((deselect) ? FALSE : TRUE),
|
---|
104 | CRA_SELECTED));
|
---|
105 | foundone = TRUE;
|
---|
106 | }
|
---|
107 | }
|
---|
108 | if (!foundone)
|
---|
109 | Runtime_Error(pszSrcFile, __LINE__, "select failed");
|
---|
110 | }
|
---|
111 | else if (filename && *filename) {
|
---|
112 |
|
---|
113 | FILE *fp;
|
---|
114 | CHAR input[1024], *p;
|
---|
115 |
|
---|
116 | fp = _fsopen(filename, "r", SH_DENYNO);
|
---|
117 | if (fp) {
|
---|
118 | while (!feof(fp)) {
|
---|
119 | if (!xfgets_bstripcr(input, sizeof(input), fp, pszSrcFile, __LINE__))
|
---|
120 | break;
|
---|
121 | if (*input == '\"') {
|
---|
122 | memmove(input, input + 1, strlen(input) + 1);
|
---|
123 | lstrip(input);
|
---|
124 | p = strchr(input, '\"');
|
---|
125 | if (p)
|
---|
126 | *p = 0;
|
---|
127 | rstrip(input);
|
---|
128 | }
|
---|
129 | else {
|
---|
130 | p = strchr(input, ' ');
|
---|
131 | if (p)
|
---|
132 | *p = 0;
|
---|
133 | }
|
---|
134 | /* input now contains name of file to select */
|
---|
135 | pci = FindCnrRecord(hwndCnr,
|
---|
136 | input, pciParent, partial, partial, TRUE);
|
---|
137 | if (pci) /* found it? */
|
---|
138 | WinSendMsg(hwndCnr,
|
---|
139 | CM_SETRECORDEMPHASIS,
|
---|
140 | MPFROMP(pci),
|
---|
141 | MPFROM2SHORT((SHORT) ((deselect) ? FALSE : TRUE),
|
---|
142 | CRA_SELECTED));
|
---|
143 | else
|
---|
144 | errs++;
|
---|
145 | if (errs > 50) { /* prevent runaway on bad file */
|
---|
146 |
|
---|
147 | APIRET ret;
|
---|
148 |
|
---|
149 | ret = saymsg(MB_YESNO,
|
---|
150 | hwndCnr,
|
---|
151 | GetPString(IDS_POSSIBLEERRORTEXT),
|
---|
152 | GetPString(IDS_MAYNOTBELISTTEXT), filename);
|
---|
153 | if (ret == MBID_NO)
|
---|
154 | break;
|
---|
155 | errs = 0;
|
---|
156 | }
|
---|
157 | }
|
---|
158 | fclose(fp);
|
---|
159 | }
|
---|
160 | }
|
---|
161 | }
|
---|
162 |
|
---|
163 | VOID SelectAll(HWND hwndCnr, BOOL files, BOOL dirs, PSZ maskstr,
|
---|
164 | PSZ text, BOOL is_arc)
|
---|
165 | {
|
---|
166 |
|
---|
167 | PCNRITEM pci;
|
---|
168 | BOOL markit;
|
---|
169 | PSZ file;
|
---|
170 | PSZ pszToMatch;
|
---|
171 | MASK Mask;
|
---|
172 | INT x;
|
---|
173 | ULONG textlen = 0;
|
---|
174 |
|
---|
175 | if (text)
|
---|
176 | textlen = strlen(text);
|
---|
177 | memset(&Mask, 0, sizeof(Mask));
|
---|
178 | if (maskstr)
|
---|
179 | SetMask(maskstr, &Mask);
|
---|
180 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
|
---|
181 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
182 | while (pci && (INT)pci != -1) {
|
---|
183 |
|
---|
184 | markit = FALSE;
|
---|
185 |
|
---|
186 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
187 | if (!is_arc) {
|
---|
188 | if (files && ~pci->attrFile & FILE_DIRECTORY)
|
---|
189 | markit = TRUE;
|
---|
190 | if (dirs && pci->attrFile & FILE_DIRECTORY)
|
---|
191 | markit = TRUE;
|
---|
192 | }
|
---|
193 | else
|
---|
194 | markit = TRUE;
|
---|
195 | if (maskstr && *maskstr && markit) {
|
---|
196 | markit = FALSE;
|
---|
197 | // Point a filename part
|
---|
198 | file = strrchr(pci->pszFileName, '\\');
|
---|
199 | if (!file)
|
---|
200 | file = strrchr(pci->pszFileName, ':');
|
---|
201 | if (file)
|
---|
202 | file++;
|
---|
203 | else
|
---|
204 | file = pci->pszFileName;
|
---|
205 | for (x = 0; Mask.pszMasks[x]; x++) {
|
---|
206 | if (*Mask.pszMasks[x]) {
|
---|
207 | if ((strchr(Mask.pszMasks[x], '\\') ||
|
---|
208 | strchr(Mask.pszMasks[x], ':')))
|
---|
209 | pszToMatch = pci->pszFileName;
|
---|
210 | else
|
---|
211 | pszToMatch = file;
|
---|
212 | if (*Mask.pszMasks[x] != '/') {
|
---|
213 | if (wildcard(pszToMatch, Mask.pszMasks[x], FALSE)) {
|
---|
214 | markit = TRUE;
|
---|
215 | }
|
---|
216 | }
|
---|
217 | else {
|
---|
218 | if (wildcard(pszToMatch, Mask.pszMasks[x] + 1, FALSE)) {
|
---|
219 | markit = FALSE;
|
---|
220 | break;
|
---|
221 | }
|
---|
222 | }
|
---|
223 | }
|
---|
224 | } // for
|
---|
225 | }
|
---|
226 | }
|
---|
227 |
|
---|
228 | if (markit && text && *text) {
|
---|
229 | if (~pci->attrFile & FILE_DIRECTORY) {
|
---|
230 | PSZ input;
|
---|
231 | markit = FALSE;
|
---|
232 | input = xmalloc(65537, pszSrcFile, __LINE__);
|
---|
233 | if (input) {
|
---|
234 | ULONG pos;
|
---|
235 | LONG len;
|
---|
236 | FILE *inputFile;
|
---|
237 |
|
---|
238 | if ((inputFile = _fsopen(pci->pszFileName, "rb", SH_DENYNO)) != NULL) {
|
---|
239 | pos = ftell(inputFile);
|
---|
240 | while (!feof(inputFile)) {
|
---|
241 | if (pos)
|
---|
242 | fseek(inputFile, pos - 256, SEEK_SET);
|
---|
243 | len = fread(input, 1, 65536, inputFile);
|
---|
244 | if (len >= 0) {
|
---|
245 | if (findstring(text, textlen, input, len, FALSE)) {
|
---|
246 | markit = TRUE;
|
---|
247 | break;
|
---|
248 | }
|
---|
249 | }
|
---|
250 | else
|
---|
251 | break;
|
---|
252 | } // while
|
---|
253 | fclose(inputFile);
|
---|
254 | }
|
---|
255 | free(input);
|
---|
256 | DosSleep(1);
|
---|
257 | }
|
---|
258 | }
|
---|
259 | else
|
---|
260 | markit = FALSE;
|
---|
261 | }
|
---|
262 |
|
---|
263 | if (markit)
|
---|
264 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
265 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
266 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
267 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
268 | } // while
|
---|
269 | }
|
---|
270 |
|
---|
271 | VOID DeselectAll(HWND hwndCnr, BOOL files, BOOL dirs, PSZ maskstr,
|
---|
272 | PSZ text, BOOL is_arc)
|
---|
273 | {
|
---|
274 | PCNRITEM pci;
|
---|
275 | BOOL unmarkit;
|
---|
276 | PSZ file;
|
---|
277 | PSZ pszToMatch;
|
---|
278 | MASK Mask;
|
---|
279 | register INT x;
|
---|
280 | ULONG textlen = 0;
|
---|
281 |
|
---|
282 | if (text)
|
---|
283 | textlen = strlen(text);
|
---|
284 | memset(&Mask, 0, sizeof(Mask));
|
---|
285 | if (maskstr && *maskstr)
|
---|
286 | SetMask(maskstr, &Mask);
|
---|
287 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
|
---|
288 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
289 | while (pci && (INT)pci != -1) {
|
---|
290 | unmarkit = FALSE;
|
---|
291 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
292 | if (!is_arc) {
|
---|
293 | if (files && ~pci->attrFile & FILE_DIRECTORY)
|
---|
294 | unmarkit = TRUE;
|
---|
295 | if (dirs && (pci->attrFile & FILE_DIRECTORY))
|
---|
296 | unmarkit = TRUE;
|
---|
297 | }
|
---|
298 | else
|
---|
299 | unmarkit = TRUE;
|
---|
300 | if (maskstr && *maskstr && unmarkit) {
|
---|
301 | unmarkit = FALSE;
|
---|
302 | file = strrchr(pci->pszFileName, '\\');
|
---|
303 | if (!file)
|
---|
304 | file = strrchr(pci->pszFileName, ':');
|
---|
305 | if (file)
|
---|
306 | file++;
|
---|
307 | else
|
---|
308 | file = pci->pszFileName;
|
---|
309 | for (x = 0; Mask.pszMasks[x]; x++) {
|
---|
310 | if (*Mask.pszMasks[x]) {
|
---|
311 | if (strchr(Mask.pszMasks[x], '\\') ||
|
---|
312 | strchr(Mask.pszMasks[x], ':'))
|
---|
313 | pszToMatch = pci->pszFileName;
|
---|
314 | else
|
---|
315 | pszToMatch = file;
|
---|
316 | if (*Mask.pszMasks[x] != '/') {
|
---|
317 | if (wildcard(pszToMatch, Mask.pszMasks[x], FALSE))
|
---|
318 | unmarkit = TRUE;
|
---|
319 | }
|
---|
320 | else {
|
---|
321 | if (wildcard(pszToMatch, Mask.pszMasks[x] + 1, FALSE)) {
|
---|
322 | unmarkit = FALSE;
|
---|
323 | break;
|
---|
324 | }
|
---|
325 | }
|
---|
326 | }
|
---|
327 | }
|
---|
328 | }
|
---|
329 | }
|
---|
330 |
|
---|
331 | if (unmarkit && text && *text) {
|
---|
332 | if (~pci->attrFile & FILE_DIRECTORY) {
|
---|
333 | PSZ input;
|
---|
334 | unmarkit = FALSE;
|
---|
335 | input = xmalloc(65537, pszSrcFile, __LINE__);
|
---|
336 | if (input) {
|
---|
337 | ULONG pos;
|
---|
338 | LONG len;
|
---|
339 | FILE *inputFile;
|
---|
340 |
|
---|
341 | if ((inputFile = _fsopen(pci->pszFileName, "rb", SH_DENYNO)) != NULL) {
|
---|
342 | pos = ftell(inputFile);
|
---|
343 | while (!feof(inputFile)) {
|
---|
344 | if (pos)
|
---|
345 | fseek(inputFile, pos - 256, SEEK_SET);
|
---|
346 | len = fread(input, 1, 65536, inputFile);
|
---|
347 | if (len >= 0) {
|
---|
348 | if (findstring(text, textlen, input, len, FALSE)) {
|
---|
349 | unmarkit = TRUE;
|
---|
350 | break;
|
---|
351 | }
|
---|
352 | }
|
---|
353 | else
|
---|
354 | break;
|
---|
355 | } // while
|
---|
356 | fclose(inputFile);
|
---|
357 | }
|
---|
358 | free(input);
|
---|
359 | DosSleep(1);
|
---|
360 | }
|
---|
361 | }
|
---|
362 | else
|
---|
363 | unmarkit = FALSE;
|
---|
364 | }
|
---|
365 |
|
---|
366 | if (unmarkit)
|
---|
367 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, pci,
|
---|
368 | MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED |
|
---|
369 | CRA_INUSE | CRA_SOURCE));
|
---|
370 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
371 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
372 | }
|
---|
373 | }
|
---|
374 |
|
---|
375 | VOID Deselect(HWND hwndCnr)
|
---|
376 | {
|
---|
377 | PCNRITEM pcil;
|
---|
378 |
|
---|
379 | pcil = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
380 | MPFROMLONG(CMA_FIRST),
|
---|
381 | MPFROMSHORT(CRA_SELECTED));
|
---|
382 | while (pcil && (INT)pcil != -1) {
|
---|
383 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pcil),
|
---|
384 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
385 | pcil = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pcil),
|
---|
386 | MPFROMSHORT(CRA_SELECTED));
|
---|
387 | }
|
---|
388 | }
|
---|
389 |
|
---|
390 | //=== HideAll() Hide all selected records ===
|
---|
391 |
|
---|
392 | VOID HideAll(HWND hwndCnr)
|
---|
393 | {
|
---|
394 | PCNRITEM pci, pciH;
|
---|
395 | INT attribute = CRA_CURSORED;
|
---|
396 | CNRINFO cnri;
|
---|
397 | BOOL didone = FALSE;
|
---|
398 |
|
---|
399 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
400 | cnri.cb = sizeof(CNRINFO);
|
---|
401 | WinSendMsg(hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
---|
402 | MPFROMLONG(sizeof(CNRINFO)));
|
---|
403 | pci = (PCNRITEM) CurrentRecord(hwndCnr);
|
---|
404 | if (pci && (INT)pci != -1) {
|
---|
405 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
406 | attribute = CRA_SELECTED;
|
---|
407 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
408 | MPFROMSHORT(attribute));
|
---|
409 | }
|
---|
410 | }
|
---|
411 | while (pci && (INT)pci != -1) {
|
---|
412 | pciH = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
413 | MPFROMSHORT(attribute));
|
---|
414 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
415 | MPFROM2SHORT(FALSE, CRA_CURSORED | CRA_SELECTED |
|
---|
416 | CRA_INUSE | CRA_SOURCE));
|
---|
417 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
418 | didone = TRUE;
|
---|
419 | if (fSyncUpdates) {
|
---|
420 | if (cnri.flWindowAttr & CV_DETAIL)
|
---|
421 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
---|
422 | MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
|
---|
423 | else
|
---|
424 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pci),
|
---|
425 | MPFROM2SHORT(1, CMA_REPOSITION | CMA_ERASE));
|
---|
426 | }
|
---|
427 | pci = pciH;
|
---|
428 | }
|
---|
429 | if (didone && !fSyncUpdates)
|
---|
430 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
---|
431 | MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
432 | }
|
---|
433 |
|
---|
434 | VOID MarkAll(HWND hwndCnr, BOOL quitit, BOOL target, BOOL source)
|
---|
435 | {
|
---|
436 | PCNRITEM pci;
|
---|
437 | INT attribute = CRA_CURSORED;
|
---|
438 |
|
---|
439 | if (quitit)
|
---|
440 | attribute = target ? CRA_TARGET : source ? CRA_SOURCE : CRA_INUSE;
|
---|
441 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
442 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(attribute));
|
---|
443 | if (pci && (INT)pci != -1) {
|
---|
444 | if (attribute == CRA_CURSORED) {
|
---|
445 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
446 | attribute = CRA_SELECTED;
|
---|
447 | pci =
|
---|
448 | WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
449 | MPFROMSHORT(attribute));
|
---|
450 | }
|
---|
451 | }
|
---|
452 | }
|
---|
453 | while (pci && (INT)pci != -1) {
|
---|
454 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
455 | MPFROM2SHORT(!quitit,
|
---|
456 | target ? CRA_TARGET : source ? CRA_SOURCE :
|
---|
457 | CRA_INUSE));
|
---|
458 | pci =
|
---|
459 | WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
460 | MPFROMSHORT(attribute));
|
---|
461 | }
|
---|
462 | }
|
---|
463 |
|
---|
464 | VOID RemoveAll(HWND hwndCnr, ULONGLONG * pullTotalBytes,
|
---|
465 | ULONG * pulTotalFiles)
|
---|
466 | {
|
---|
467 | PCNRITEM pci;
|
---|
468 | INT attribute = CRA_CURSORED;
|
---|
469 | BOOL didone = FALSE;
|
---|
470 |
|
---|
471 | pci = (PCNRITEM) CurrentRecord(hwndCnr);
|
---|
472 | if (pci && (INT)pci != -1) {
|
---|
473 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
474 | attribute = CRA_SELECTED;
|
---|
475 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
476 | MPFROMSHORT(attribute));
|
---|
477 | }
|
---|
478 | }
|
---|
479 | while (pci && (INT)pci != -1) {
|
---|
480 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
481 | didone = TRUE;
|
---|
482 | if (pulTotalFiles)
|
---|
483 | *pulTotalFiles -= 1;
|
---|
484 | if (pullTotalBytes)
|
---|
485 | *pullTotalBytes -= (pci->cbFile + pci->easize);
|
---|
486 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
487 | MPFROM2SHORT(0, CRA_SELECTED));
|
---|
488 | if (fSyncUpdates)
|
---|
489 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
490 | else
|
---|
491 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE);
|
---|
492 | if (attribute == CRA_CURSORED)
|
---|
493 | break;
|
---|
494 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
495 | MPFROMSHORT(attribute));
|
---|
496 | }
|
---|
497 | else
|
---|
498 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
499 | MPFROMSHORT(attribute));
|
---|
500 | }
|
---|
501 | if (didone && !fSyncUpdates)
|
---|
502 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
---|
503 | MPFROM2SHORT(0, CMA_REPOSITION));
|
---|
504 | }
|
---|
505 |
|
---|
506 | //== SetMask() Convert mask string to array of pointers to masks ==
|
---|
507 |
|
---|
508 | VOID SetMask(PSZ maskstr, MASK * mask)
|
---|
509 | {
|
---|
510 | UINT x;
|
---|
511 | PSZ p;
|
---|
512 |
|
---|
513 | if (maskstr)
|
---|
514 | strcpy(mask->szMask, maskstr); // Got new mask string
|
---|
515 | // Build array of pointers
|
---|
516 | p = mask->szMaskCopy;
|
---|
517 | strcpy(p, mask->szMask);
|
---|
518 | // Allow up to 25 masks - ignore extras
|
---|
519 | for (x = 0; *p && x < 25; x++) {
|
---|
520 | mask->pszMasks[x] = p;
|
---|
521 | while (*p && *p != ';')
|
---|
522 | p++; // Find separator
|
---|
523 | if (*p) {
|
---|
524 | *p = 0; // Replace ;
|
---|
525 | p++;
|
---|
526 | }
|
---|
527 | } // for
|
---|
528 | mask->pszMasks[x] = NULL; // Mark end
|
---|
529 | }
|
---|
530 |
|
---|
531 | VOID ExpandAll(HWND hwndCnr, BOOL expand, PCNRITEM pciParent)
|
---|
532 | {
|
---|
533 | PCNRITEM pci;
|
---|
534 |
|
---|
535 | if (!pciParent)
|
---|
536 | pciParent = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(NULL),
|
---|
537 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
538 | if (pciParent) {
|
---|
539 | if (expand && ~pciParent->rc.flRecordAttr & CRA_EXPANDED)
|
---|
540 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciParent), MPVOID);
|
---|
541 | else if (!expand && (pciParent->rc.flRecordAttr & CRA_EXPANDED))
|
---|
542 | WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciParent), MPVOID);
|
---|
543 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
|
---|
544 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
545 | if (pci)
|
---|
546 | DosSleep(0);
|
---|
547 | while (pci && (INT)pci != -1) {
|
---|
548 | ExpandAll(hwndCnr, expand, pci);
|
---|
549 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
550 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
551 | }
|
---|
552 | }
|
---|
553 | DosSleep(0);
|
---|
554 | }
|
---|
555 |
|
---|
556 | VOID InvertAll(HWND hwndCnr)
|
---|
557 | {
|
---|
558 | PCNRITEM pci;
|
---|
559 |
|
---|
560 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPVOID,
|
---|
561 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
562 | while (pci && (INT)pci != -1) {
|
---|
563 | if (~pci->rc.flRecordAttr & CRA_FILTERED) {
|
---|
564 | if (~pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
565 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
566 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
567 | else
|
---|
568 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
569 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
570 | }
|
---|
571 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
|
---|
572 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
573 | }
|
---|
574 | }
|
---|
575 |
|
---|
576 | /**
|
---|
577 | * Do select actions for compare directories containers
|
---|
578 | *
|
---|
579 | */
|
---|
580 |
|
---|
581 | VOID SpecialSelect(HWND hwndCnrS, HWND hwndCnrD, INT action, BOOL reset)
|
---|
582 | {
|
---|
583 | PCNRITEM pciS, pciD, *pciSa = NULL, *pciDa = NULL;
|
---|
584 | CNRINFO cnri;
|
---|
585 | BOOL slow = FALSE;
|
---|
586 | UINT x, numD, numS;
|
---|
587 | INT ret = 0;
|
---|
588 |
|
---|
589 | if (!hwndCnrS || !hwndCnrD) {
|
---|
590 | Runtime_Error(pszSrcFile, __LINE__, "hwndCnrS %p hwndCnrD %p", hwndCnrS, hwndCnrD);
|
---|
591 | return;
|
---|
592 | }
|
---|
593 |
|
---|
594 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
595 | cnri.cb = sizeof(CNRINFO);
|
---|
596 | WinSendMsg(hwndCnrD, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
---|
597 | MPFROMLONG(sizeof(CNRINFO)));
|
---|
598 | numD = cnri.cRecords;
|
---|
599 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
600 | cnri.cb = sizeof(CNRINFO);
|
---|
601 | WinSendMsg(hwndCnrS, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
---|
602 | MPFROMLONG(sizeof(CNRINFO)));
|
---|
603 | numS = cnri.cRecords;
|
---|
604 | if (!numD || numS != numD) {
|
---|
605 | Runtime_Error(pszSrcFile, __LINE__, "numD %u != numS %u", numD, numS);
|
---|
606 | return;
|
---|
607 | }
|
---|
608 | pciDa = xmalloc(sizeof(PCNRITEM) * numD, pszSrcFile, __LINE__);
|
---|
609 | if (!pciDa)
|
---|
610 | return;
|
---|
611 |
|
---|
612 | pciSa = xmalloc(sizeof(PCNRITEM) * numS, pszSrcFile, __LINE__);
|
---|
613 | if (!pciSa) {
|
---|
614 | free(pciDa);
|
---|
615 | return;
|
---|
616 | }
|
---|
617 |
|
---|
618 | Restart:
|
---|
619 |
|
---|
620 | memset(pciDa, 0, sizeof(PCNRITEM) * numD);
|
---|
621 | memset(pciSa, 0, sizeof(PCNRITEM) * numS);
|
---|
622 |
|
---|
623 | pciD = (PCNRITEM)WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
|
---|
624 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
625 | x = 0;
|
---|
626 | while (pciD && (INT)pciD != -1 && x < numD) {
|
---|
627 | if (reset)
|
---|
628 | pciD->flags = 0;
|
---|
629 | pciDa[x] = pciD;
|
---|
630 | x++;
|
---|
631 | if (!slow)
|
---|
632 | pciD = (PCNRITEM) pciD->rc.preccNextRecord;
|
---|
633 | else
|
---|
634 | pciD = (PCNRITEM) WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
|
---|
635 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
636 | if (!(x % 500))
|
---|
637 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
638 | // else if (!(x % 50))
|
---|
639 | // DosSleep(0);
|
---|
640 | } // while
|
---|
641 |
|
---|
642 | if (numD != x) {
|
---|
643 | if (!slow) {
|
---|
644 | slow = TRUE;
|
---|
645 | goto Restart;
|
---|
646 | }
|
---|
647 | free(pciDa);
|
---|
648 | free(pciSa);
|
---|
649 | Runtime_Error(pszSrcFile, __LINE__, "numD %u != x %lu", numD, x);
|
---|
650 | return;
|
---|
651 | }
|
---|
652 |
|
---|
653 | pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
|
---|
654 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
655 | x = 0;
|
---|
656 | while (pciS && (INT)pciS != -1 && x < numS) {
|
---|
657 | if (reset)
|
---|
658 | pciS->flags = 0;
|
---|
659 | pciSa[x] = pciS;
|
---|
660 | x++;
|
---|
661 | if (!slow)
|
---|
662 | pciS = (PCNRITEM) pciS->rc.preccNextRecord;
|
---|
663 | else
|
---|
664 | pciS = (PCNRITEM) WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pciS),
|
---|
665 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
666 | if (!(x % 500))
|
---|
667 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
668 | // else if (!(x % 50))
|
---|
669 | // DosSleep(0);
|
---|
670 | } // while
|
---|
671 |
|
---|
672 | if (numS != x) {
|
---|
673 | if (!slow) {
|
---|
674 | slow = TRUE;
|
---|
675 | goto Restart;
|
---|
676 | }
|
---|
677 | free(pciSa);
|
---|
678 | free(pciDa);
|
---|
679 | Runtime_Error(pszSrcFile, __LINE__, "numS (%lu) != x (%lu)", numS, x);
|
---|
680 | return;
|
---|
681 | }
|
---|
682 |
|
---|
683 | // 05 Aug 07 SHL fixme to know what sets reset
|
---|
684 | if (reset) {
|
---|
685 | // Update flags for files that exist on both sides
|
---|
686 | for (x = 0; x < numS; x++) {
|
---|
687 |
|
---|
688 | // 05 Aug 07 SHL fixme to know if should clear first
|
---|
689 | if (!*pciSa[x]->pszFileName || !*pciDa[x]->pszFileName)
|
---|
690 | continue;
|
---|
691 |
|
---|
692 | pciSa[x]->flags |= CNRITEM_EXISTS; // File exists on both sides
|
---|
693 | pciDa[x]->flags |= CNRITEM_EXISTS;
|
---|
694 | if (pciSa[x]->cbFile + pciSa[x]->easize >
|
---|
695 | pciDa[x]->cbFile + pciDa[x]->easize) {
|
---|
696 | pciSa[x]->flags |= CNRITEM_LARGER;
|
---|
697 | pciDa[x]->flags |= CNRITEM_SMALLER;
|
---|
698 | }
|
---|
699 | else if (pciSa[x]->cbFile + pciSa[x]->easize <
|
---|
700 | pciDa[x]->cbFile + pciDa[x]->easize) {
|
---|
701 | pciSa[x]->flags |= CNRITEM_SMALLER;
|
---|
702 | pciDa[x]->flags |= CNRITEM_LARGER;
|
---|
703 | }
|
---|
704 | ret = TestCDates(&pciDa[x]->date, &pciDa[x]->time,
|
---|
705 | &pciSa[x]->date, &pciSa[x]->time);
|
---|
706 | if (ret == 1)
|
---|
707 | /*((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE :
|
---|
708 | (pciSa[x]->date.year < pciDa[x]->date.year) ? FALSE :
|
---|
709 | (pciSa[x]->date.month > pciDa[x]->date.month) ? TRUE :
|
---|
710 | (pciSa[x]->date.month < pciDa[x]->date.month) ? FALSE :
|
---|
711 | (pciSa[x]->date.day > pciDa[x]->date.day) ? TRUE :
|
---|
712 | (pciSa[x]->date.day < pciDa[x]->date.day) ? FALSE :
|
---|
713 | (pciSa[x]->time.hours > pciDa[x]->time.hours) ? TRUE :
|
---|
714 | (pciSa[x]->time.hours < pciDa[x]->time.hours) ? FALSE :
|
---|
715 | (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? TRUE :
|
---|
716 | (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? FALSE :
|
---|
717 | (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? TRUE :
|
---|
718 | (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? FALSE : FALSE)*/ {
|
---|
719 | pciSa[x]->flags |= CNRITEM_NEWER;
|
---|
720 | pciDa[x]->flags |= CNRITEM_OLDER;
|
---|
721 | }
|
---|
722 | else if (ret == -1)
|
---|
723 | /*((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE :
|
---|
724 | (pciSa[x]->date.year > pciDa[x]->date.year) ? FALSE :
|
---|
725 | (pciSa[x]->date.month < pciDa[x]->date.month) ? TRUE :
|
---|
726 | (pciSa[x]->date.month > pciDa[x]->date.month) ? FALSE :
|
---|
727 | (pciSa[x]->date.day < pciDa[x]->date.day) ? TRUE :
|
---|
728 | (pciSa[x]->date.day > pciDa[x]->date.day) ? FALSE :
|
---|
729 | (pciSa[x]->time.hours < pciDa[x]->time.hours) ? TRUE :
|
---|
730 | (pciSa[x]->time.hours > pciDa[x]->time.hours) ? FALSE :
|
---|
731 | (pciSa[x]->time.minutes < pciDa[x]->time.minutes) ? TRUE :
|
---|
732 | (pciSa[x]->time.minutes > pciDa[x]->time.minutes) ? FALSE :
|
---|
733 | (pciSa[x]->time.seconds < pciDa[x]->time.seconds) ? TRUE :
|
---|
734 | (pciSa[x]->time.seconds > pciDa[x]->time.seconds) ? FALSE :
|
---|
735 | FALSE)*/ {
|
---|
736 | pciSa[x]->flags |= CNRITEM_OLDER;
|
---|
737 | pciDa[x]->flags |= CNRITEM_NEWER;
|
---|
738 | }
|
---|
739 | if (!(x % 500))
|
---|
740 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
741 | // else if (!(x % 50))
|
---|
742 | // DosSleep(0);
|
---|
743 | } // for
|
---|
744 | } // if reset
|
---|
745 |
|
---|
746 | switch (action) {
|
---|
747 | case IDM_SELECTIDENTICAL:
|
---|
748 | for (x = 0; x < numS; x++) {
|
---|
749 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
750 | pciSa[x]->flags & CNRITEM_EXISTS &&
|
---|
751 | ~pciSa[x]->flags & CNRITEM_SMALLER &&
|
---|
752 | ~pciSa[x]->flags & CNRITEM_LARGER &&
|
---|
753 | ~pciSa[x]->flags & CNRITEM_NEWER &&
|
---|
754 | ~pciSa[x]->flags & CNRITEM_OLDER) {
|
---|
755 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
756 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
757 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
758 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
759 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
760 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
761 | }
|
---|
762 | if (!(x % 500))
|
---|
763 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
764 | // else if (!(x % 50))
|
---|
765 | // DosSleep(0);
|
---|
766 | } // for
|
---|
767 | break;
|
---|
768 |
|
---|
769 | case IDM_SELECTSAME:
|
---|
770 | for (x = 0; x < numS; x++) {
|
---|
771 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
772 | pciSa[x]->flags & CNRITEM_EXISTS &&
|
---|
773 | ~pciSa[x]->flags & CNRITEM_SMALLER &&
|
---|
774 | ~pciSa[x]->flags & CNRITEM_LARGER) {
|
---|
775 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
776 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
777 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
778 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
779 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
780 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
781 | }
|
---|
782 | if (!(x % 500))
|
---|
783 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
784 | // else if (!(x % 50))
|
---|
785 | // DosSleep(0);
|
---|
786 | }
|
---|
787 | break;
|
---|
788 |
|
---|
789 | case IDM_SELECTSAMECONTENT:
|
---|
790 | for (x = 0; x < numS; x++) {
|
---|
791 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
792 | pciSa[x]->flags & CNRITEM_EXISTS)
|
---|
793 | {
|
---|
794 | FILE *fp1 = NULL;
|
---|
795 | FILE *fp2 = NULL;
|
---|
796 | BOOL gotMatch = FALSE;
|
---|
797 | UINT errLineNo = 0;
|
---|
798 | UINT compErrno = 0;
|
---|
799 | CHAR buf1[1024];
|
---|
800 | CHAR buf2[1024];
|
---|
801 | HAB hab = WinQueryAnchorBlock(hwndCnrS);
|
---|
802 |
|
---|
803 | if (!*pciSa[x]->pszFileName ||
|
---|
804 | !*pciDa[x]->pszFileName) {
|
---|
805 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
806 | "CNRITEM_EXISTS set with null file name for index %u", x);
|
---|
807 | break;
|
---|
808 | }
|
---|
809 |
|
---|
810 | fp1 = _fsopen(pciSa[x]->pszFileName, "rb", SH_DENYNO);
|
---|
811 | if (!fp1) {
|
---|
812 | errLineNo = __LINE__;
|
---|
813 | compErrno = errno;
|
---|
814 | }
|
---|
815 | else {
|
---|
816 | fp2 = _fsopen(pciDa[x]->pszFileName, "rb", SH_DENYNO);
|
---|
817 | if (!fp2) {
|
---|
818 | errLineNo = __LINE__;
|
---|
819 | compErrno = errno;
|
---|
820 | }
|
---|
821 | else {
|
---|
822 | size_t len1 = filelength(fileno(fp1));
|
---|
823 | size_t len2 = filelength(fileno(fp2));
|
---|
824 |
|
---|
825 | if (len1 == len2) {
|
---|
826 | setbuf(fp1, NULL);
|
---|
827 | setbuf(fp2, NULL);
|
---|
828 | while (WinIsWindow(hab, hwndCnrS)) {
|
---|
829 | size_t numread1 = fread(buf1, 1, 1024, fp1);
|
---|
830 | size_t numread2 = fread(buf2, 1, 1024, fp2);
|
---|
831 |
|
---|
832 | if (!numread1 || !numread2 || numread1 != numread2) {
|
---|
833 | if (ferror(fp1) || ferror(fp2)) {
|
---|
834 | errLineNo = __LINE__;
|
---|
835 | compErrno = errno;
|
---|
836 | }
|
---|
837 | else if (feof(fp1) && feof(fp2))
|
---|
838 | gotMatch = TRUE;
|
---|
839 | break;
|
---|
840 | }
|
---|
841 | else if (memcmp(buf1, buf2, numread1))
|
---|
842 | break;
|
---|
843 | } // while
|
---|
844 | } // same len
|
---|
845 | }
|
---|
846 | }
|
---|
847 |
|
---|
848 | if (fp1)
|
---|
849 | fclose(fp1);
|
---|
850 |
|
---|
851 | if (fp2)
|
---|
852 | fclose(fp2);
|
---|
853 |
|
---|
854 | if (errLineNo) {
|
---|
855 | Runtime_Error(pszSrcFile, errLineNo,
|
---|
856 | "error %d while comparing", compErrno);
|
---|
857 | }
|
---|
858 |
|
---|
859 | if (gotMatch) {
|
---|
860 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
861 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
862 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
863 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
864 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
865 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
866 | }
|
---|
867 | }
|
---|
868 | if (!(x % 500))
|
---|
869 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
870 | // else if (!(x % 50))
|
---|
871 | // DosSleep(0);
|
---|
872 | } // for
|
---|
873 | break;
|
---|
874 |
|
---|
875 | case IDM_SELECTBOTH:
|
---|
876 | for (x = 0; x < numS; x++) {
|
---|
877 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
878 | pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
879 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
880 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
881 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
882 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
883 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
884 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
885 | }
|
---|
886 | if (!(x % 500))
|
---|
887 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
888 | // else if (!(x % 50))
|
---|
889 | // DosSleep(0);
|
---|
890 | }
|
---|
891 | break;
|
---|
892 |
|
---|
893 | case IDM_SELECTONE:
|
---|
894 | for (x = 0; x < numS; x++) {
|
---|
895 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
896 | ~pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
897 | if (*pciSa[x]->pszFileName) {
|
---|
898 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED) {
|
---|
899 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
900 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
901 | }
|
---|
902 | }
|
---|
903 | else if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED) {
|
---|
904 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
905 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
906 | }
|
---|
907 | }
|
---|
908 | if (!(x % 500))
|
---|
909 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
910 | // else if (!(x % 50))
|
---|
911 | // DosSleep(0);
|
---|
912 | }
|
---|
913 | break;
|
---|
914 |
|
---|
915 | case IDM_SELECTBIGGER:
|
---|
916 | for (x = 0; x < numS; x++) {
|
---|
917 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
918 | if (pciSa[x]->flags & CNRITEM_LARGER) {
|
---|
919 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
920 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
921 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
922 | }
|
---|
923 | else if (pciDa[x]->flags & CNRITEM_LARGER) {
|
---|
924 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
925 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
926 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
927 | }
|
---|
928 | }
|
---|
929 | if (!(x % 500))
|
---|
930 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
931 | // else if (!(x % 50))
|
---|
932 | // DosSleep(0);
|
---|
933 | }
|
---|
934 | break;
|
---|
935 |
|
---|
936 | case IDM_SELECTSMALLER:
|
---|
937 | for (x = 0; x < numS; x++) {
|
---|
938 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
939 | if (pciSa[x]->flags & CNRITEM_SMALLER) {
|
---|
940 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
941 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
942 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
943 | }
|
---|
944 | else if (pciDa[x]->flags & CNRITEM_SMALLER) {
|
---|
945 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
946 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
947 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
948 | }
|
---|
949 | }
|
---|
950 | if (!(x % 500))
|
---|
951 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
952 | // else if (!(x % 50))
|
---|
953 | // DosSleep(0);
|
---|
954 | }
|
---|
955 | break;
|
---|
956 |
|
---|
957 | case IDM_SELECTNEWER:
|
---|
958 | for (x = 0; x < numS; x++) {
|
---|
959 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
960 | if (pciSa[x]->flags & CNRITEM_NEWER) {
|
---|
961 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
962 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
963 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
964 | }
|
---|
965 | else if (pciDa[x]->flags & CNRITEM_NEWER) {
|
---|
966 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
967 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
968 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
969 | }
|
---|
970 | }
|
---|
971 | if (!(x % 500))
|
---|
972 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
973 | // else if (!(x % 50))
|
---|
974 | // DosSleep(0);
|
---|
975 | }
|
---|
976 | break;
|
---|
977 |
|
---|
978 | case IDM_SELECTOLDER:
|
---|
979 | for (x = 0; x < numS; x++) {
|
---|
980 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
981 | if (pciSa[x]->flags & CNRITEM_OLDER) {
|
---|
982 | if (~pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
983 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
984 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
985 | }
|
---|
986 | else if (pciDa[x]->flags & CNRITEM_OLDER) {
|
---|
987 | if (~pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
988 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
989 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
990 | }
|
---|
991 | }
|
---|
992 | if (!(x % 500))
|
---|
993 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
994 | // else if (!(x % 50))
|
---|
995 | // DosSleep(0);
|
---|
996 | }
|
---|
997 | break;
|
---|
998 |
|
---|
999 | case IDM_DESELECTBOTH:
|
---|
1000 | for (x = 0; x < numS; x++) {
|
---|
1001 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED &&
|
---|
1002 | pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
1003 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1004 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1005 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1006 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1007 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1008 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1009 | }
|
---|
1010 | if (!(x % 500))
|
---|
1011 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1012 | // else if (!(x % 50))
|
---|
1013 | // DosSleep(0);
|
---|
1014 | }
|
---|
1015 | break;
|
---|
1016 |
|
---|
1017 | case IDM_DESELECTONE:
|
---|
1018 | for (x = 0; x < numS; x++) {
|
---|
1019 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1020 | if (~pciSa[x]->flags & CNRITEM_EXISTS) {
|
---|
1021 | if (*pciSa[x]->pszFileName) {
|
---|
1022 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1023 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1024 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1025 | }
|
---|
1026 | else if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1027 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1028 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1029 | }
|
---|
1030 | }
|
---|
1031 | if (!(x % 500))
|
---|
1032 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1033 | // else if (!(x % 50))
|
---|
1034 | // DosSleep(0);
|
---|
1035 | }
|
---|
1036 | break;
|
---|
1037 |
|
---|
1038 | case IDM_DESELECTBIGGER:
|
---|
1039 | for (x = 0; x < numS; x++) {
|
---|
1040 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1041 | if (pciSa[x]->flags & CNRITEM_LARGER) {
|
---|
1042 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1043 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1044 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1045 | }
|
---|
1046 | else if (pciDa[x]->flags & CNRITEM_LARGER) {
|
---|
1047 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1048 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1049 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1050 | }
|
---|
1051 | }
|
---|
1052 | if (!(x % 500))
|
---|
1053 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1054 | // else if (!(x % 50))
|
---|
1055 | // DosSleep(0);
|
---|
1056 | }
|
---|
1057 | break;
|
---|
1058 |
|
---|
1059 | case IDM_DESELECTSMALLER:
|
---|
1060 | for (x = 0; x < numS; x++) {
|
---|
1061 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1062 | if (pciSa[x]->flags & CNRITEM_SMALLER) {
|
---|
1063 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1064 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1065 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1066 | }
|
---|
1067 | else if (pciDa[x]->flags & CNRITEM_SMALLER) {
|
---|
1068 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1069 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1070 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1071 | }
|
---|
1072 | }
|
---|
1073 | if (!(x % 500))
|
---|
1074 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1075 | // else if (!(x % 50))
|
---|
1076 | // DosSleep(0);
|
---|
1077 | }
|
---|
1078 | break;
|
---|
1079 |
|
---|
1080 | case IDM_DESELECTNEWER:
|
---|
1081 | for (x = 0; x < numS; x++) {
|
---|
1082 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1083 | if (pciSa[x]->flags & CNRITEM_NEWER) {
|
---|
1084 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1085 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1086 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1087 | }
|
---|
1088 | else if (pciDa[x]->flags & CNRITEM_NEWER) {
|
---|
1089 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1090 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1091 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1092 | }
|
---|
1093 | }
|
---|
1094 | if (!(x % 500))
|
---|
1095 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1096 | // else if (!(x % 50))
|
---|
1097 | // DosSleep(0);
|
---|
1098 | }
|
---|
1099 | break;
|
---|
1100 |
|
---|
1101 | case IDM_DESELECTOLDER:
|
---|
1102 | for (x = 0; x < numS; x++) {
|
---|
1103 | if (~pciSa[x]->rc.flRecordAttr & CRA_FILTERED) {
|
---|
1104 | if (pciSa[x]->flags & CNRITEM_OLDER) {
|
---|
1105 | if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1106 | WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciSa[x]),
|
---|
1107 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1108 | }
|
---|
1109 | else if (pciDa[x]->flags & CNRITEM_OLDER) {
|
---|
1110 | if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
|
---|
1111 | WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciDa[x]),
|
---|
1112 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1113 | }
|
---|
1114 | }
|
---|
1115 | if (!(x % 500))
|
---|
1116 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1117 | // else if (!(x % 50))
|
---|
1118 | // DosSleep(0);
|
---|
1119 | }
|
---|
1120 | break;
|
---|
1121 |
|
---|
1122 | default:
|
---|
1123 | break;
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 | if (reset) {
|
---|
1127 | while (numS) {
|
---|
1128 | WinSendMsg(hwndCnrS, CM_INVALIDATERECORD,
|
---|
1129 | MPFROMP(pciSa), MPFROM2SHORT((min(numS, 65535)), 0));
|
---|
1130 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1131 | WinSendMsg(hwndCnrD, CM_INVALIDATERECORD,
|
---|
1132 | MPFROMP(pciDa), MPFROM2SHORT((min(numD, 65535)), 0));
|
---|
1133 | numS -= min(numS, 65535);
|
---|
1134 | if (numS)
|
---|
1135 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1136 | }
|
---|
1137 | }
|
---|
1138 |
|
---|
1139 | free(pciSa);
|
---|
1140 | free(pciDa);
|
---|
1141 | DosPostEventSem(CompactSem);
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | struct SS
|
---|
1145 | {
|
---|
1146 | PCNRITEM pci;
|
---|
1147 | BOOL unique, all, smallest, largest, newest, oldest;
|
---|
1148 | };
|
---|
1149 |
|
---|
1150 | struct Cnr
|
---|
1151 | {
|
---|
1152 | HWND hwndCnr;
|
---|
1153 | ULONG numfiles;
|
---|
1154 | struct SS *ss;
|
---|
1155 | };
|
---|
1156 |
|
---|
1157 | static int CompSSNamesB(const void *s1, const void *s2)
|
---|
1158 | {
|
---|
1159 | struct SS *ss2 = (struct SS *)s2;
|
---|
1160 |
|
---|
1161 | return stricmp((PSZ)s1, ss2->pci->pszFileName);
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 | static int CompSSNames(const void *s1, const void *s2)
|
---|
1165 | {
|
---|
1166 | struct SS *ss1 = (struct SS *)s1;
|
---|
1167 | struct SS *ss2 = (struct SS *)s2;
|
---|
1168 |
|
---|
1169 | return stricmp(ss1->pci->pszFileName, ss2->pci->pszFileName);
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | VOID FreeCnrs(struct Cnr * Cnrs, INT numw)
|
---|
1173 | {
|
---|
1174 | register INT z;
|
---|
1175 |
|
---|
1176 | for (z = 0; z < numw; z++) {
|
---|
1177 | if (Cnrs[z].ss)
|
---|
1178 | free(Cnrs[z].ss);
|
---|
1179 | }
|
---|
1180 | free(Cnrs);
|
---|
1181 | DosPostEventSem(CompactSem);
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | /**
|
---|
1185 | * Do select actions for single container
|
---|
1186 | *
|
---|
1187 | */
|
---|
1188 |
|
---|
1189 | VOID SpecialSelect2(HWND hwndParent, INT action)
|
---|
1190 | {
|
---|
1191 | PCNRITEM pci;
|
---|
1192 | HENUM henum;
|
---|
1193 | HWND hwnd;
|
---|
1194 | INT numwindows = 0, w, x, z, cmp = 0;
|
---|
1195 | struct Cnr *Cnrs = NULL;
|
---|
1196 | struct SS *bsres;
|
---|
1197 |
|
---|
1198 | if (!hwndParent)
|
---|
1199 | return;
|
---|
1200 |
|
---|
1201 | /* count directory containers, build array of hwnds */
|
---|
1202 | henum = WinBeginEnumWindows(hwndParent);
|
---|
1203 | while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
1204 | if (WinWindowFromID(WinWindowFromID(hwnd, FID_CLIENT), DIR_CNR)) {
|
---|
1205 | Cnrs =
|
---|
1206 | xrealloc(Cnrs, (numwindows + 1) * sizeof(struct Cnr), pszSrcFile,
|
---|
1207 | __LINE__);
|
---|
1208 | if (!Cnrs) {
|
---|
1209 | Notify(GetPString(IDS_OUTOFMEMORY));
|
---|
1210 | return;
|
---|
1211 | }
|
---|
1212 | memset(&Cnrs[numwindows], 0, sizeof(struct Cnr));
|
---|
1213 | Cnrs[numwindows].hwndCnr = WinWindowFromID(WinWindowFromID(hwnd,
|
---|
1214 | FID_CLIENT),
|
---|
1215 | DIR_CNR);
|
---|
1216 | numwindows++;
|
---|
1217 | }
|
---|
1218 | }
|
---|
1219 | WinEndEnumWindows(henum);
|
---|
1220 | if (numwindows < 2) {
|
---|
1221 | FreeCnrs(Cnrs, numwindows);
|
---|
1222 | Runtime_Error(pszSrcFile, __LINE__, "expected two windows");
|
---|
1223 | Notify(GetPString(IDS_COMPSEL2ORMORETEXT));
|
---|
1224 | return;
|
---|
1225 | }
|
---|
1226 | if (numwindows > 4) {
|
---|
1227 | WinSendMsg(Cnrs[0].
|
---|
1228 | hwndCnr,
|
---|
1229 | UM_NOTIFY, MPFROMP(GetPString(IDS_BUILDINGLISTSTEXT)), MPVOID);
|
---|
1230 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1231 | }
|
---|
1232 |
|
---|
1233 | /* count records, build array of pointers to records */
|
---|
1234 | for (z = 0; z < numwindows; z++) {
|
---|
1235 | pci = (PCNRITEM) WinSendMsg(Cnrs[z].hwndCnr,
|
---|
1236 | CM_QUERYRECORD,
|
---|
1237 | MPVOID,
|
---|
1238 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
1239 | x = 0;
|
---|
1240 | while (pci && (INT)pci != -1) {
|
---|
1241 | if (~pci->rc.flRecordAttr & CRA_FILTERED &&
|
---|
1242 | ~pci->attrFile & FILE_DIRECTORY) {
|
---|
1243 | Cnrs[z].ss =
|
---|
1244 | xrealloc(Cnrs[z].ss, (x + 1) * sizeof(struct SS), pszSrcFile,
|
---|
1245 | __LINE__);
|
---|
1246 | if (!Cnrs[z].ss) {
|
---|
1247 | FreeCnrs(Cnrs, numwindows);
|
---|
1248 | Notify(GetPString(IDS_OUTOFMEMORY));
|
---|
1249 | return;
|
---|
1250 | }
|
---|
1251 | memset(&Cnrs[z].ss[x], 0, sizeof(struct SS));
|
---|
1252 | Cnrs[z].ss[x].pci = pci;
|
---|
1253 | x++;
|
---|
1254 | }
|
---|
1255 | pci = (PCNRITEM) WinSendMsg(Cnrs[z].hwndCnr,
|
---|
1256 | CM_QUERYRECORD,
|
---|
1257 | MPFROMP(pci),
|
---|
1258 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
1259 | }
|
---|
1260 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1261 | Cnrs[z].numfiles = x;
|
---|
1262 | if (Cnrs[z].numfiles)
|
---|
1263 | qsort(Cnrs[z].ss, Cnrs[z].numfiles, sizeof(struct SS), CompSSNames);
|
---|
1264 | }
|
---|
1265 |
|
---|
1266 | for (z = 0; z < numwindows; z++) {
|
---|
1267 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1268 | Cnrs[z].ss[x].all = Cnrs[z].ss[x].unique = Cnrs[z].ss[x].newest =
|
---|
1269 | Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].smallest =
|
---|
1270 | Cnrs[z].ss[x].largest = TRUE;
|
---|
1271 | for (w = 0; w < numwindows; w++) {
|
---|
1272 | if (w != z && Cnrs[w].numfiles) {
|
---|
1273 | bsres = (struct SS *)bsearch(Cnrs[z].ss[x].pci->pszFileName,
|
---|
1274 | Cnrs[w].ss, Cnrs[w].numfiles,
|
---|
1275 | sizeof(struct SS), CompSSNamesB);
|
---|
1276 | if (bsres) {
|
---|
1277 | Cnrs[z].ss[x].unique = FALSE;
|
---|
1278 | if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize >
|
---|
1279 | bsres->pci->cbFile + bsres->pci->easize)
|
---|
1280 | Cnrs[z].ss[x].smallest = FALSE;
|
---|
1281 | if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize <
|
---|
1282 | bsres->pci->cbFile + bsres->pci->easize)
|
---|
1283 | Cnrs[z].ss[x].largest = FALSE;
|
---|
1284 | cmp = TestCDates(&bsres->pci->date, &bsres->pci->time,
|
---|
1285 | &Cnrs[z].ss[x].pci->date, &Cnrs[z].ss[x].pci->time);
|
---|
1286 | /*(Cnrs[z].ss[x].pci->date.year >
|
---|
1287 | bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year <
|
---|
1288 | bsres->pci->date.
|
---|
1289 | year) ? FALSE : (Cnrs[z].
|
---|
1290 | ss[x].pci->
|
---|
1291 | date.month >
|
---|
1292 | bsres->pci->
|
---|
1293 | date.
|
---|
1294 | month) ? TRUE
|
---|
1295 | : (Cnrs[z].ss[x].pci->date.month <
|
---|
1296 | bsres->pci->date.month) ? FALSE : (Cnrs[z].ss[x].pci->date.
|
---|
1297 | day >
|
---|
1298 | bsres->pci->date.
|
---|
1299 | day) ? TRUE : (Cnrs[z].
|
---|
1300 | ss[x].pci->
|
---|
1301 | date.day <
|
---|
1302 | bsres->
|
---|
1303 | pci->date.
|
---|
1304 | day) ?
|
---|
1305 | FALSE : (Cnrs[z].ss[x].pci->time.hours >
|
---|
1306 | bsres->pci->time.hours) ? TRUE : (Cnrs[z].ss[x].pci->
|
---|
1307 | time.hours <
|
---|
1308 | bsres->pci->time.
|
---|
1309 | hours) ? FALSE
|
---|
1310 | : (Cnrs[z].ss[x].pci->time.minutes >
|
---|
1311 | bsres->pci->time.minutes) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1312 | minutes <
|
---|
1313 | bsres->pci->time.
|
---|
1314 | minutes) ? FALSE
|
---|
1315 | : (Cnrs[z].ss[x].pci->time.seconds >
|
---|
1316 | bsres->pci->time.seconds) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1317 | seconds <
|
---|
1318 | bsres->pci->time.
|
---|
1319 | seconds) ? FALSE : FALSE;*/
|
---|
1320 | if (cmp != 1)
|
---|
1321 | Cnrs[z].ss[x].newest = FALSE;
|
---|
1322 | /*cmp =
|
---|
1323 | (Cnrs[z].ss[x].pci->date.year <
|
---|
1324 | bsres->pci->date.year) ? TRUE : (Cnrs[z].ss[x].pci->date.year >
|
---|
1325 | bsres->pci->date.
|
---|
1326 | year) ? FALSE : (Cnrs[z].
|
---|
1327 | ss[x].pci->
|
---|
1328 | date.month <
|
---|
1329 | bsres->pci->
|
---|
1330 | date.
|
---|
1331 | month) ? TRUE
|
---|
1332 | : (Cnrs[z].ss[x].pci->date.month >
|
---|
1333 | bsres->pci->date.month) ? FALSE : (Cnrs[z].ss[x].pci->date.
|
---|
1334 | day <
|
---|
1335 | bsres->pci->date.
|
---|
1336 | day) ? TRUE : (Cnrs[z].
|
---|
1337 | ss[x].pci->
|
---|
1338 | date.day >
|
---|
1339 | bsres->
|
---|
1340 | pci->date.
|
---|
1341 | day) ?
|
---|
1342 | FALSE : (Cnrs[z].ss[x].pci->time.hours <
|
---|
1343 | bsres->pci->time.hours) ? TRUE : (Cnrs[z].ss[x].pci->
|
---|
1344 | time.hours >
|
---|
1345 | bsres->pci->time.
|
---|
1346 | hours) ? FALSE
|
---|
1347 | : (Cnrs[z].ss[x].pci->time.minutes <
|
---|
1348 | bsres->pci->time.minutes) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1349 | minutes >
|
---|
1350 | bsres->pci->time.
|
---|
1351 | minutes) ? FALSE
|
---|
1352 | : (Cnrs[z].ss[x].pci->time.seconds <
|
---|
1353 | bsres->pci->time.seconds) ? TRUE : (Cnrs[z].ss[x].pci->time.
|
---|
1354 | seconds >
|
---|
1355 | bsres->pci->time.
|
---|
1356 | seconds) ? FALSE : FALSE;*/
|
---|
1357 | if (cmp != -1)
|
---|
1358 | Cnrs[z].ss[x].oldest = FALSE;
|
---|
1359 | cmp = 0;
|
---|
1360 | break;
|
---|
1361 | }
|
---|
1362 | else
|
---|
1363 | Cnrs[z].ss[x].all = FALSE;
|
---|
1364 | }
|
---|
1365 | }
|
---|
1366 | if (Cnrs[z].ss[x].unique)
|
---|
1367 | Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].newest = Cnrs[z].ss[x].all =
|
---|
1368 | Cnrs[z].ss[x].largest = Cnrs[z].ss[x].smallest = FALSE;
|
---|
1369 | DosSleep(1);
|
---|
1370 | }
|
---|
1371 | DosSleep(1);
|
---|
1372 | }
|
---|
1373 |
|
---|
1374 | switch (action) {
|
---|
1375 | case IDM_SELECTBOTH:
|
---|
1376 | for (z = 0; z < numwindows; z++) {
|
---|
1377 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1378 | if (Cnrs[z].ss[x].all)
|
---|
1379 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1380 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1381 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1382 | }
|
---|
1383 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1384 | }
|
---|
1385 | break;
|
---|
1386 | case IDM_SELECTMORE:
|
---|
1387 | for (z = 0; z < numwindows; z++) {
|
---|
1388 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1389 | if (!Cnrs[z].ss[x].unique)
|
---|
1390 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1391 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1392 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1393 | }
|
---|
1394 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1395 | }
|
---|
1396 | break;
|
---|
1397 | case IDM_SELECTONE:
|
---|
1398 | for (z = 0; z < numwindows; z++) {
|
---|
1399 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1400 | if (Cnrs[z].ss[x].unique)
|
---|
1401 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1402 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1403 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1404 | }
|
---|
1405 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1406 | }
|
---|
1407 | break;
|
---|
1408 | case IDM_SELECTNEWER:
|
---|
1409 | for (z = 0; z < numwindows; z++) {
|
---|
1410 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1411 | if (Cnrs[z].ss[x].newest)
|
---|
1412 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1413 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1414 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1415 | }
|
---|
1416 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1417 | }
|
---|
1418 | break;
|
---|
1419 | case IDM_SELECTOLDER:
|
---|
1420 | for (z = 0; z < numwindows; z++) {
|
---|
1421 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1422 | if (Cnrs[z].ss[x].oldest)
|
---|
1423 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1424 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1425 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1426 | }
|
---|
1427 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1428 | }
|
---|
1429 | break;
|
---|
1430 | case IDM_SELECTBIGGER:
|
---|
1431 | for (z = 0; z < numwindows; z++) {
|
---|
1432 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1433 | if (Cnrs[z].ss[x].largest)
|
---|
1434 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1435 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1436 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1437 | }
|
---|
1438 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1439 | }
|
---|
1440 | break;
|
---|
1441 | case IDM_SELECTSMALLER:
|
---|
1442 | for (z = 0; z < numwindows; z++) {
|
---|
1443 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1444 | if (Cnrs[z].ss[x].smallest)
|
---|
1445 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1446 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1447 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1448 | }
|
---|
1449 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1450 | }
|
---|
1451 | break;
|
---|
1452 |
|
---|
1453 | case IDM_DESELECTBOTH:
|
---|
1454 | for (z = 0; z < numwindows; z++) {
|
---|
1455 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1456 | if (Cnrs[z].ss[x].all)
|
---|
1457 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1458 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1459 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1460 | }
|
---|
1461 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1462 | }
|
---|
1463 | break;
|
---|
1464 | case IDM_DESELECTMORE:
|
---|
1465 | for (z = 0; z < numwindows; z++) {
|
---|
1466 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1467 | if (!Cnrs[z].ss[x].unique)
|
---|
1468 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1469 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1470 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1471 | }
|
---|
1472 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1473 | }
|
---|
1474 | break;
|
---|
1475 | case IDM_DESELECTONE:
|
---|
1476 | for (z = 0; z < numwindows; z++) {
|
---|
1477 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1478 | if (Cnrs[z].ss[x].unique)
|
---|
1479 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1480 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1481 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1482 | }
|
---|
1483 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1484 | }
|
---|
1485 | break;
|
---|
1486 | case IDM_DESELECTNEWER:
|
---|
1487 | for (z = 0; z < numwindows; z++) {
|
---|
1488 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1489 | if (Cnrs[z].ss[x].newest)
|
---|
1490 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1491 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1492 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1493 | }
|
---|
1494 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1495 | }
|
---|
1496 | break;
|
---|
1497 | case IDM_DESELECTOLDER:
|
---|
1498 | for (z = 0; z < numwindows; z++) {
|
---|
1499 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1500 | if (Cnrs[z].ss[x].oldest)
|
---|
1501 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1502 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1503 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1504 | }
|
---|
1505 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1506 | }
|
---|
1507 | break;
|
---|
1508 | case IDM_DESELECTBIGGER:
|
---|
1509 | for (z = 0; z < numwindows; z++) {
|
---|
1510 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1511 | if (Cnrs[z].ss[x].largest)
|
---|
1512 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1513 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1514 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1515 | }
|
---|
1516 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1517 | }
|
---|
1518 | break;
|
---|
1519 | case IDM_DESELECTSMALLER:
|
---|
1520 | for (z = 0; z < numwindows; z++) {
|
---|
1521 | for (x = 0; x < Cnrs[z].numfiles; x++) {
|
---|
1522 | if (Cnrs[z].ss[x].smallest)
|
---|
1523 | WinSendMsg(Cnrs[z].hwndCnr, CM_SETRECORDEMPHASIS,
|
---|
1524 | MPFROMP(Cnrs[z].ss[x].pci),
|
---|
1525 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1526 | }
|
---|
1527 | DosSleep(0); //26 Aug 07 GKY 1
|
---|
1528 | }
|
---|
1529 | break;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | FreeCnrs(Cnrs, numwindows);
|
---|
1533 | }
|
---|
1534 |
|
---|
1535 | #pragma alloc_text(SELECT,UnHilite,SelectAll,DeselectAll,MarkAll,SetMask)
|
---|
1536 | #pragma alloc_text(SELECT,SelectList)
|
---|
1537 | #pragma alloc_text(SELECT1,Deselect,HideAll,RemoveAll,ExpandAll,InvertAll)
|
---|
1538 | #pragma alloc_text(SELECT3,SpecialSelect)
|
---|
1539 | #pragma alloc_text(SELECT4,FreeCnrs,SpecialSelect2,CompSSNames,CompSSNamesB)
|
---|