source: trunk/dll/comp.c@ 746

Last change on this file since 746 was 746, checked in by Gregg Young, 18 years ago

Fixed most of the display problems still shows 0 for size eas and date on nonexistant file. names are now correct.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 78.7 KB
Line 
1
2/***********************************************************************
3
4 $Id: comp.c 746 2007-07-31 00:49:52Z gyoung $
5
6 Compare directories
7
8 Copyright (c) 1993-02 M. Kimes
9 Copyright (c) 2003, 2007 Steven H. Levine
10
11 16 Oct 02 MK Baseline
12 04 Nov 03 SHL Force window refresh after subdir toggle
13 01 Aug 04 SHL Rework lstrip/rstrip usage
14 24 May 05 SHL Rework Win_Error usage
15 24 May 05 SHL Rework for CNRITEM.szSubject
16 25 May 05 SHL Rework with ULONGLONG
17 06 Jun 05 SHL Drop unused
18 12 Jul 06 SHL Renames and comments
19 13 Jul 06 SHL Use Runtime_Error
20 26 Jul 06 SHL Drop unreachable CN_... code
21 29 Jul 06 SHL Use xfgets_bstripcr
22 15 Aug 06 SHL Turn off hide not selected on dir change
23 19 Oct 06 SHL Correct . and .. detect
24 03 Nov 06 SHL Count thread usage
25 22 Mar 07 GKY Use QWL_USER
26 29 Jul 07 SHL Use Win_Error to report container errors
27
28***********************************************************************/
29
30#define INCL_DOS
31#define INCL_WIN
32#define INCL_GPI
33#define INCL_LONGLONG
34#include <os2.h>
35
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <ctype.h>
40#include <share.h>
41#include <io.h>
42#include <process.h> // _beginthread
43
44#include "fm3dll.h"
45#include "fm3dlg.h"
46#include "fm3str.h"
47
48#pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames)
49#pragma alloc_text(COMPAREDIR1,CompareDlgProc)
50#pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
51#pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
52#pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
53
54typedef struct
55{
56 CHAR filename[CCHMAXPATH];
57 CHAR dirname[CCHMAXPATH];
58 BOOL recurse;
59}
60SNAPSTUFF;
61
62static PSZ pszSrcFile = __FILE__;
63
64//=== SnapShot() Write directory tree to file and recurse if requested ===
65
66static VOID SnapShot(char *path, FILE * fp, BOOL recurse)
67{
68 FILEFINDBUF4 *fb;
69 char *mask, *enddir;
70 HDIR hdir = HDIR_CREATE;
71 ULONG nm = 1L;
72
73 fb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);
74 if (fb) {
75 mask = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
76 if (mask) {
77 sprintf(mask,
78 "%s%s*",
79 path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
80 enddir = strrchr(mask, '\\');
81 enddir++;
82 if (!DosFindFirst(mask,
83 &hdir,
84 FILE_NORMAL | FILE_DIRECTORY |
85 FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN |
86 FILE_SYSTEM,
87 fb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE)) {
88 do {
89 strcpy(enddir, fb->achName);
90 if (!(fb->attrFile & FILE_DIRECTORY))
91 fprintf(fp,
92 "\"%s\",%u,%lu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",
93 mask,
94 enddir - mask,
95 fb->cbFile,
96 (fb->fdateLastWrite.year + 1980),
97 fb->fdateLastWrite.month,
98 fb->fdateLastWrite.day,
99 fb->ftimeLastWrite.hours,
100 fb->ftimeLastWrite.minutes,
101 fb->ftimeLastWrite.twosecs,
102 fb->attrFile, (fb->cbList > 4L) ? (fb->cbList / 2L) : 0L);
103 // Skip . and ..
104 else if (recurse &&
105 (fb->achName[0] != '.' ||
106 (fb->achName[1] &&
107 (fb->achName[1] != '.' || fb->achName[2])))) {
108 SnapShot(mask, fp, recurse);
109 }
110 nm = 1L;
111 } while (!DosFindNext(hdir, fb, sizeof(FILEFINDBUF4), &nm));
112 DosFindClose(hdir);
113 }
114 free(mask);
115 }
116 free(fb);
117 }
118}
119
120//=== StartSnap() Write directory tree to snapshot file ===
121
122static VOID StartSnap(VOID * dummy)
123{
124 SNAPSTUFF *sf = (SNAPSTUFF *) dummy;
125 FILE *fp;
126 CHAR *p;
127
128 if (sf) {
129 if (*sf->dirname && *sf->filename) {
130 priority_normal();
131 p = sf->dirname;
132 while (*p) {
133 if (*p == '/')
134 *p = '\\';
135 p++;
136 }
137 if (*(p - 1) != '\\') {
138 *p = '\\';
139 p++;
140 }
141 fp = xfopen(sf->filename, "w", pszSrcFile, __LINE__);
142 if (fp) {
143 fprintf(fp, "\"%s\"\n", sf->dirname);
144 SnapShot(sf->dirname, fp, sf->recurse);
145 fclose(fp);
146 }
147 }
148 free(sf);
149 }
150}
151
152//=== CompareFilesThread() Compare files and update container select flags ===
153
154static VOID CompareFilesThread(VOID * args)
155{
156 FCOMPARE fc;
157 HAB hab2;
158 HMQ hmq2;
159 FILE *fp1, *fp2;
160 ULONG len1, len2, offset = 0L;
161 LONG numread1, numread2;
162 CHAR s[1024], ss[1024], *p1, *p2;
163
164 if (args) {
165 fc = *(FCOMPARE *) args;
166 hab2 = WinInitialize(0);
167 if (hab2) {
168 hmq2 = WinCreateMsgQueue(hab2, 0);
169 if (hmq2) {
170 WinCancelShutdown(hmq2, TRUE);
171 IncrThreadUsage();
172 if (!IsFile(fc.file1) || IsRoot(fc.file1)) {
173 p1 = strrchr(fc.file2, '\\');
174 if (p1) {
175 if (fc.file1[strlen(fc.file1) - 1] == '\\')
176 p1++;
177 strcat(fc.file1, p1);
178 }
179 }
180 else if (!IsFile(fc.file2) || IsRoot(fc.file2)) {
181 p1 = strrchr(fc.file1, '\\');
182 if (p1) {
183 if (fc.file2[strlen(fc.file2) - 1] == '\\')
184 p1++;
185 strcat(fc.file2, p1);
186 }
187 }
188 sprintf(s, GetPString(IDS_COMPCOMPARETEXT), fc.file1);
189 AddToListboxBottom(fc.hwndList, s);
190 sprintf(s, GetPString(IDS_COMPTOTEXT), fc.file2);
191 AddToListboxBottom(fc.hwndList, s);
192 fp1 = _fsopen(fc.file1, "rb", SH_DENYNO);
193 if (!fp1) {
194 sprintf(s, GetPString(IDS_COMPCANTOPENTEXT), fc.file1);
195 AddToListboxBottom(fc.hwndList, s);
196 WinSetWindowText(fc.hwndHelp, GetPString(IDS_ERRORTEXT));
197 }
198 else {
199 fp2 = _fsopen(fc.file2, "rb", SH_DENYNO);
200 if (!fp2) {
201 sprintf(s, GetPString(IDS_COMPCANTOPENTEXT), fc.file2);
202 AddToListboxBottom(fc.hwndList, s);
203 WinSetWindowText(fc.hwndHelp, GetPString(IDS_ERRORTEXT));
204 }
205 else {
206 len1 = filelength(fileno(fp1));
207 len2 = filelength(fileno(fp2));
208 if (len1 != len2) {
209 strcpy(s, GetPString(IDS_COMPDIFSIZESTEXT));
210 AddToListboxBottom(fc.hwndList, s);
211 sprintf(s, GetPString(IDS_COMPVSBYTESTEXT), len1, len2);
212 AddToListboxBottom(fc.hwndList, s);
213 WinSetWindowText(fc.hwndHelp,
214 GetPString(IDS_COMPDONTMATCHTEXT));
215 }
216 else {
217 WinSetWindowText(fc.hwndHelp,
218 GetPString(IDS_COMPCOMPARINGTEXT));
219 while (WinIsWindow(hab2, fc.hwndList)) {
220 numread1 = fread(s, 1, 1024, fp1);
221 numread2 = fread(ss, 1, 1024, fp2);
222 if (numread1 != numread2 || feof(fp1) != feof(fp2)) {
223 sprintf(s, GetPString(IDS_COMPREADERRORTEXT),
224 offset, offset);
225 AddToListboxBottom(fc.hwndList, s);
226 WinSetWindowText(fc.hwndHelp, GetPString(IDS_ERRORTEXT));
227 break;
228 }
229 else if (!numread1 && feof(fp1) && feof(fp2)) {
230 AddToListboxBottom(fc.hwndList,
231 GetPString(IDS_COMPFILESMATCHTEXT));
232 if (!stricmp(fc.file1, fc.file2))
233 AddToListboxBottom(fc.hwndList,
234 GetPString(IDS_COMPWONDERWHYTEXT));
235 WinSetWindowText(fc.hwndHelp,
236 GetPString(IDS_COMPCOMPLETETEXT));
237 break;
238 }
239 else if (numread1 <= 0 || numread2 <= 0) {
240 if (offset == len1)
241 break;
242 else {
243 sprintf(s, GetPString(IDS_COMPMATCHREADERRORTEXT),
244 offset, offset);
245 WinSetWindowText(fc.hwndHelp,
246 GetPString(IDS_COMPODDERRORTEXT));
247 AddToListboxBottom(fc.hwndList, s);
248 break;
249 }
250 }
251 else if (memcmp(s, ss, numread1)) {
252 p1 = s;
253 p2 = ss;
254 while (p1 < s + numread1) {
255 if (*p1 != *p2) {
256 sprintf(s, GetPString(IDS_COMPMISMATCHERRORTEXT),
257 offset + (p1 - s), offset + (p1 - s));
258 AddToListboxBottom(fc.hwndList, s);
259 WinSetWindowText(fc.hwndHelp,
260 GetPString(IDS_COMPDONTMATCHTEXT));
261 break;
262 }
263 p1++;
264 p2++;
265 }
266 break;
267 }
268 offset += numread1;
269 }
270 }
271 fclose(fp2);
272 }
273 fclose(fp1);
274 }
275 DecrThreadUsage();
276 WinDestroyMsgQueue(hmq2);
277 }
278 WinTerminate(hab2);
279 }
280 }
281}
282
283//=== CFileDlgProc() Select directories to compare dialog procedure ===
284
285MRESULT EXPENTRY CFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
286{
287 FCOMPARE *fc;
288
289 switch (msg) {
290 case WM_INITDLG:
291 if (!mp2)
292 WinDismissDlg(hwnd, 0);
293 else {
294 WinSetWindowPtr(hwnd, QWL_USER, mp2);
295 fc = (FCOMPARE *) mp2;
296 fc->hwndReport = hwnd;
297 fc->hwndList = WinWindowFromID(hwnd, FCMP_LISTBOX);
298 fc->hwndHelp = WinWindowFromID(hwnd, FCMP_HELP);
299 if (!*fc->file1 || !fc->file2) {
300 WinDismissDlg(hwnd, 0);
301 break;
302 }
303 MakeFullName(fc->file1);
304 MakeFullName(fc->file2);
305 if (!stricmp(fc->file1, fc->file2)) {
306 saymsg(MB_CANCEL, hwnd,
307 GetPString(IDS_COMPSILLYALERTTEXT),
308 GetPString(IDS_COMPTOITSELFTEXT));
309 WinDismissDlg(hwnd, 0);
310 break;
311 }
312 if (_beginthread(CompareFilesThread, NULL, 65536, (PVOID) fc) == -1) {
313 Runtime_Error(pszSrcFile, __LINE__,
314 GetPString(IDS_COULDNTSTARTTHREADTEXT));
315 WinDismissDlg(hwnd, 0);
316 }
317 }
318 break;
319
320 case WM_ADJUSTWINDOWPOS:
321 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
322 break;
323
324 case UM_SETDIR:
325 PaintRecessedWindow(WinWindowFromID(hwnd, FCMP_HELP),
326 (HPS) 0, FALSE, TRUE);
327 return 0;
328
329 case WM_COMMAND:
330 switch (SHORT1FROMMP(mp1)) {
331 case DID_OK:
332 WinDismissDlg(hwnd, 0);
333 break;
334 case DID_CANCEL:
335 WinDismissDlg(hwnd, 1);
336 break;
337 }
338 return 0;
339
340 case WM_DESTROY:
341 DosSleep(100);
342 break;
343 }
344 return WinDefDlgProc(hwnd, msg, mp1, mp2);
345}
346
347//=== ActionCnrThread() Do requested action on container contents ===
348
349static VOID ActionCnrThread(VOID *args)
350{
351 COMPARE *cmp = (COMPARE *)args;
352 HAB hab;
353 HMQ hmq;
354 HWND hwndCnrS, hwndCnrD;
355 PCNRITEM pci, pciO, pcin, pciOn;
356 CHAR newname[CCHMAXPATH], dirname[CCHMAXPATH], *p;
357 APIRET rc;
358
359 if (!cmp)
360 return;
361
362 DosError(FERR_DISABLEHARDERR);
363
364 hab = WinInitialize(0);
365 if (hab) {
366 hmq = WinCreateMsgQueue(hab, 0);
367 if (hmq) {
368 WinCancelShutdown(hmq, TRUE);
369 IncrThreadUsage();
370 priority_normal();
371 switch (cmp->action) {
372 case COMP_DELETELEFT:
373 hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
374 hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
375 cmp->action = IDM_DELETE;
376 break;
377 case COMP_DELETERIGHT:
378 hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
379 hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
380 cmp->action = IDM_DELETE;
381 break;
382 case COMP_MOVELEFT:
383 cmp->action = IDM_MOVE;
384 hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
385 hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
386 break;
387 case COMP_MOVERIGHT:
388 cmp->action = IDM_MOVE;
389 hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
390 hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
391 break;
392 case COMP_COPYLEFT:
393 cmp->action = IDM_COPY;
394 hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
395 hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
396 break;
397 case COMP_COPYRIGHT:
398 cmp->action = IDM_COPY;
399 hwndCnrS = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
400 hwndCnrD = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
401 break;
402 default:
403 Runtime_Error(pszSrcFile, __LINE__, "bad case %u", cmp->action);
404 goto Abort;
405 }
406
407 pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
408 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
409 pciO = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
410 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
411 while (pci && (INT) pci != -1 && pciO && (INT) pciO != -1) {
412
413 pcin = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci),
414 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
415 pciOn = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciO),
416 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
417 if (*pci->pszFileName && (pci->rc.flRecordAttr & CRA_SELECTED)) {
418 switch (cmp->action) {
419 case IDM_DELETE:
420 if (!unlinkf("%s", pci->pszFileName)) {
421 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
422 MPFROM2SHORT(FALSE, CRA_SELECTED));
423 if (!*pciO->pszFileName) {
424 WinSendMsg(hwndCnrS, CM_REMOVERECORD, MPFROMP(&pci),
425 MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
426 if (pciO->rc.flRecordAttr & CRA_SELECTED)
427 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciO),
428 MPFROM2SHORT(FALSE, CRA_SELECTED));
429 WinSendMsg(hwndCnrD, CM_REMOVERECORD, MPFROMP(&pciO),
430 MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
431 }
432 else {
433 pci->pszFileName = xstrdup(NullStr, pszSrcFile, __LINE__);
434 //pci->pszFileName = pci->szFileName;
435 pci->flags = 0;
436 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
437 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
438 }
439 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
440 cmp->cmp->totalleft--;
441 else
442 cmp->cmp->totalright--;
443 DosSleep(0L);
444 }
445 break;
446
447 case IDM_MOVE:
448 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
449 sprintf(newname, "%s%s%s", cmp->leftdir,
450 cmp->leftdir[strlen(cmp->leftdir) - 1] ==
451 '\\' ? NullStr : "\\", pci->pszFileName);
452 else
453 sprintf(newname, "%s%s%s", cmp->rightdir,
454 cmp->rightdir[strlen(cmp->rightdir) - 1] ==
455 '\\' ? NullStr : "\\", pci->pszFileName);
456 /* make directory if required */
457 strcpy(dirname, newname);
458 p = strrchr(dirname, '\\');
459 if (p) {
460 if (p > dirname + 2)
461 p++;
462 *p = 0;
463 if (IsFile(dirname) == -1)
464 MassMkdir(hwndMain, dirname);
465 }
466 rc = docopyf(MOVE, pci->pszFileName, "%s", newname);
467 if (!rc && stricmp(pci->pszFileName, newname)) {
468 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
469 MPFROM2SHORT(FALSE, CRA_SELECTED));
470 if (pciO->rc.flRecordAttr & CRA_SELECTED)
471 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciO),
472 MPFROM2SHORT(FALSE, CRA_SELECTED));
473 pciO->pszFileName = xstrdup(newname, pszSrcFile, __LINE__);
474 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
475 pciO->pszDisplayName = pciO->pszFileName + strlen(cmp->leftdir);
476 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
477 pciO->pszFileName++;
478 }
479 else {
480 pciO->pszDisplayName = pciO->pszFileName + strlen(cmp->rightdir);
481 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
482 pciO->pszFileName++;
483 }
484 strcpy(pciO->szDispAttr, pci->szDispAttr);
485 pciO->attrFile = pci->attrFile;
486 pciO->flags = 0;
487 pciO->date = pci->date;
488 pciO->time = pci->time;
489 pciO->ladate = pci->ladate;
490 pciO->latime = pci->latime;
491 pciO->crdate = pci->crdate;
492 pciO->crtime = pci->crtime;
493 pciO->cbFile = pci->cbFile;
494 pciO->easize = pci->easize;
495 pciO->pszSubject = xstrdup(NullStr, pszSrcFile, __LINE__);
496 pci->pszFileName = xstrdup(NullStr, pszSrcFile, __LINE__);
497 //pci->pszFileName = pci->szFileName;
498 pci->flags = 0;
499 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
500 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
501 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciO),
502 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
503 }
504 else if (rc) {
505 rc = Dos_Error(MB_ENTERCANCEL,
506 rc,
507 HWND_DESKTOP,
508 pszSrcFile,
509 __LINE__,
510 GetPString(IDS_COMPMOVEFAILEDTEXT),
511 pci->pszFileName, newname);
512 if (rc == MBID_CANCEL) /* cause loop to break */
513 pcin = NULL;
514 }
515 break;
516
517 case IDM_COPY:
518 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
519 sprintf(newname, "%s%s%s", cmp->leftdir,
520 cmp->leftdir[strlen(cmp->leftdir) - 1] ==
521 '\\' ? NullStr : "\\", pci->pszFileName);
522 else
523 sprintf(newname, "%s%s%s", cmp->rightdir,
524 cmp->rightdir[strlen(cmp->rightdir) - 1] ==
525 '\\' ? NullStr : "\\", pci->pszFileName);
526 /* make directory if required */
527 strcpy(dirname, newname);
528 p = strrchr(dirname, '\\');
529 if (p) {
530 if (p > dirname + 2)
531 p++;
532 *p = 0;
533 if (IsFile(dirname) == -1)
534 MassMkdir(hwndMain, dirname);
535 }
536 rc = docopyf(COPY, pci->pszFileName, "%s", newname);
537 if (rc) {
538 rc = Dos_Error(MB_ENTERCANCEL,
539 rc,
540 HWND_DESKTOP,
541 pszSrcFile,
542 __LINE__,
543 GetPString(IDS_COMPCOPYFAILEDTEXT),
544 pci->pszFileName, newname);
545 if (rc == MBID_CANCEL)
546 pcin = NULL; /* cause loop to break */
547 }
548 else {
549 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
550 MPFROM2SHORT(FALSE, CRA_SELECTED));
551 if (pciO->rc.flRecordAttr & CRA_SELECTED)
552 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciO),
553 MPFROM2SHORT(FALSE, CRA_SELECTED));
554 pciO->pszFileName = xstrdup(newname, pszSrcFile, __LINE__);
555 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
556 pciO->pszDisplayName = pciO->pszFileName + strlen(cmp->leftdir);
557 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
558 pciO->pszFileName++;
559 }
560 else {
561 pciO->pszDisplayName = pciO->pszFileName + strlen(cmp->rightdir);
562 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
563 pciO->pszFileName++;
564 }
565 strcpy(pciO->szDispAttr, pci->szDispAttr);
566 pciO->attrFile = pci->attrFile;
567 pciO->flags = CNRITEM_EXISTS;
568 pciO->date = pci->date;
569 pciO->time = pci->time;
570 pciO->ladate = pci->ladate;
571 pciO->latime = pci->latime;
572 pciO->crdate = pci->crdate;
573 pciO->crtime = pci->crtime;
574 pciO->cbFile = pci->cbFile;
575 pciO->easize = pci->easize;
576 pci->pszSubject = xstrdup(NullStr, pszSrcFile, __LINE__);
577 pci->flags = CNRITEM_EXISTS;
578 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
579 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
580 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciO),
581 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
582 }
583 break;
584
585 default:
586 break;
587 } // switch
588 }
589 pci = pcin;
590 pciO = pciOn;
591 } // while
592 Abort:
593 WinDestroyMsgQueue(hmq);
594 }
595 DecrThreadUsage();
596 WinTerminate(hab);
597 }
598 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
599 PostMsg(cmp->hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DESELECTALL, 0), MPVOID);
600 free(cmp);
601}
602
603//=== SelectCnrsThread() Update container selection flags thread ===
604
605static VOID SelectCnrsThread(VOID * args)
606{
607 COMPARE *cmp = (COMPARE *) args;
608 HAB hab;
609 HMQ hmq;
610
611 if (!cmp)
612 return;
613
614 DosError(FERR_DISABLEHARDERR);
615
616 hab = WinInitialize(0);
617 if (hab) {
618 hmq = WinCreateMsgQueue(hab, 0);
619 if (hmq) {
620 WinCancelShutdown(hmq, TRUE);
621 IncrThreadUsage();
622 priority_normal();
623 switch (cmp->action) {
624 case IDM_INVERT:
625 InvertAll(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
626 InvertAll(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
627 break;
628
629 case IDM_DESELECTALL:
630 Deselect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
631 Deselect(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
632 break;
633
634 default:
635 SpecialSelect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR),
636 WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR),
637 cmp->action, cmp->reset);
638 break;
639 }
640 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID))
641 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
642 WinDestroyMsgQueue(hmq);
643 }
644 DecrThreadUsage();
645 WinTerminate(hab);
646 }
647 free(cmp);
648}
649
650static VOID FillDirList(CHAR * str, INT skiplen, BOOL recurse,
651 FILELIST *** list, INT * numfiles, INT * numalloc)
652{
653
654 register BYTE *fb;
655 register CHAR *enddir;
656 register ULONG x;
657 CHAR *maskstr;
658 FILEFINDBUF4 *ffb4, *pffb;
659 HDIR hDir;
660 ULONG nm, fl = 0, ulM = 64;
661 APIRET rc;
662
663 if (!str || !*str)
664 return;
665 if (!recurse)
666 ulM = 128;
667 maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
668 if (!maskstr)
669 return;
670 ffb4 = xmalloc(sizeof(FILEFINDBUF4) * ulM, pszSrcFile, __LINE__);
671 if (!ffb4) {
672 free(maskstr);
673 return;
674 }
675 x = strlen(str);
676 memcpy(maskstr, str, x + 1);
677 enddir = maskstr + x;
678 if (*(enddir - 1) != '\\') {
679 *enddir = '\\';
680 enddir++;
681 *enddir = 0;
682 }
683 *enddir = '*';
684 *(enddir + 1) = 0;
685 hDir = HDIR_CREATE;
686 nm = ulM;
687 if (recurse)
688 fl = FILE_DIRECTORY;
689 DosError(FERR_DISABLEHARDERR);
690 rc = DosFindFirst(maskstr, &hDir,
691 (FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
692 FILE_SYSTEM | FILE_HIDDEN) | fl,
693 ffb4, sizeof(FILEFINDBUF4) * nm, &nm, FIL_QUERYEASIZE);
694 if (!rc) {
695 while (!rc) {
696 fb = (BYTE *) ffb4;
697 x = 0;
698 while (x < nm) {
699 pffb = (FILEFINDBUF4 *) fb;
700 if (pffb->attrFile & FILE_DIRECTORY) {
701 // Skip . and ..
702 if (recurse &&
703 (pffb->achName[0] != '.' ||
704 (pffb->achName[1] &&
705 (pffb->achName[1] != '.' || pffb->achName[2])))) {
706 if (fForceUpper)
707 strupr(pffb->achName);
708 else if (fForceLower)
709 strlwr(pffb->achName);
710 memcpy(enddir, pffb->achName, pffb->cchName + 1);
711 FillDirList(maskstr, skiplen, recurse, list, numfiles, numalloc);
712 }
713 }
714 else {
715 if (fForceUpper)
716 strupr(pffb->achName);
717 else if (fForceLower)
718 strlwr(pffb->achName);
719 memcpy(enddir, pffb->achName, pffb->cchName + 1);
720 if (AddToFileList
721 (maskstr + skiplen, pffb, list, numfiles, numalloc))
722 goto Abort;
723 }
724 fb += pffb->oNextEntryOffset;
725 x++;
726 }
727 nm = ulM;
728 DosError(FERR_DISABLEHARDERR);
729 rc = DosFindNext(hDir, ffb4, sizeof(FILEFINDBUF4) * nm, &nm);
730 }
731 Abort:
732 DosFindClose(hDir);
733 DosSleep(0L);
734 }
735 free(maskstr);
736 free(ffb4);
737}
738
739//=== CompNames() Compare names for qsort ===
740
741static int CompNames(const void *n1, const void *n2)
742{
743 FILELIST *fl1 = *(FILELIST **) n1;
744 FILELIST *fl2 = *(FILELIST **) n2;
745
746 return stricmp(fl1->fname, fl2->fname);
747}
748
749//=== FillCnrsThread() Fill left and right containers ===
750
751static VOID FillCnrsThread(VOID * args)
752{
753 COMPARE *cmp = (COMPARE *) args;
754 HAB hab;
755 HMQ hmq;
756 BOOL notified = FALSE;
757 static CHAR attrstring[] = "RHS\0DA";
758 HWND hwndLeft, hwndRight;
759
760 if (!cmp)
761 _endthread();
762
763 DosError(FERR_DISABLEHARDERR);
764
765 hab = WinInitialize(0);
766 if (!hab)
767 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__, "WinInitialize");
768 else {
769 hmq = WinCreateMsgQueue(hab, 0);
770 if (!hmq)
771 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
772 "WinCreateMsgQueue");
773 else {
774 INT x;
775 INT l;
776 INT r;
777 INT y;
778 ULONG cntr;
779 FILELIST **filesl = NULL;
780 FILELIST **filesr = NULL;
781 INT numfilesl = 0;
782 INT numfilesr = 0;
783 INT numallocl = 0;
784 INT numallocr = 0;
785 INT lenl; // Directory prefix length
786 INT lenr;
787 UINT recsNeeded; // fixme to check ovf
788 PCNRITEM pcilFirst;
789 PCNRITEM pcirFirst;
790 PCNRITEM pcil;
791 PCNRITEM pcir;
792 PCNRITEM pcit;
793 RECORDINSERT ri;
794 CHAR *pch;
795
796 WinCancelShutdown(hmq, TRUE);
797 IncrThreadUsage();
798 hwndLeft = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
799 hwndRight = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
800 lenl = strlen(cmp->leftdir);
801 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
802 lenl++;
803 lenr = strlen(cmp->rightdir);
804 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
805 lenr++;
806 priority_normal();
807 /* clear containers */
808 WinSendMsg(hwndRight, CM_REMOVERECORD,
809 MPVOID, MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE));
810 WinSendMsg(hwndLeft, CM_REMOVERECORD,
811 MPVOID, MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE));
812 cmp->cmp->totalleft = cmp->cmp->totalright = 0;
813
814 /* build list of all files in left directory */
815 if (fForceLower)
816 strlwr(cmp->leftdir);
817 else if (fForceUpper)
818 strupr(cmp->leftdir);
819 FillDirList(cmp->leftdir, lenl, cmp->includesubdirs,
820 &filesl, &numfilesl, &numallocl);
821
822 if (filesl)
823 qsort(filesl, numfilesl, sizeof(CHAR *), CompNames);
824 /* build list of all files in right directory */
825 if (!*cmp->rightlist) {
826 if (fForceLower)
827 strlwr(cmp->rightdir);
828 else if (fForceUpper)
829 strupr(cmp->rightdir);
830 FillDirList(cmp->rightdir, lenr, cmp->includesubdirs,
831 &filesr, &numfilesr, &numallocr);
832 }
833 else {
834 /* use snapshot file */
835 FILE *fp;
836 FILEFINDBUF4 fb4;
837 CHAR str[CCHMAXPATH * 2], *p;
838
839 memset(&fb4, 0, sizeof(fb4));
840 fp = fopen(cmp->rightlist, "r");
841 if (!fp)
842 Runtime_Error(pszSrcFile, __LINE__, "can not open %s (%d)",
843 cmp->rightlist, errno);
844 else {
845 while (!feof(fp)) {
846 /* first get name of directory */
847 if (!xfgets_bstripcr(str, sizeof(str), fp, pszSrcFile, __LINE__))
848 break; // EOF
849 p = str;
850 if (*p == '\"') {
851 /* Quoted */
852 p++;
853 if (*p && *p != '\"') {
854 p = strchr(p, '\"');
855 if (p) {
856 *p = 0;
857 if (*(str + 1)) {
858 strcpy(cmp->rightdir, str + 1);
859 if (fForceUpper)
860 strupr(cmp->rightdir);
861 else if (fForceLower)
862 strlwr(cmp->rightdir);
863 p = cmp->rightdir + (strlen(cmp->rightdir) - 1);
864 if (p - cmp->rightdir > 3 && *p == '\\')
865 *p = 0; // Chop trailing slash
866 break;
867 }
868 }
869 }
870 }
871 } // while !EOF
872 {
873 CNRINFO cnri;
874
875 memset(&cnri, 0, sizeof(cnri));
876 cnri.cb = sizeof(cnri);
877 cnri.pszCnrTitle = cmp->rightdir;
878 WinSendMsg(hwndRight, CM_SETCNRINFO,
879 MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
880 }
881 if (*cmp->rightdir) {
882 lenr = strlen(cmp->rightdir) +
883 (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\');
884 while (!feof(fp)) {
885 if (!xfgets_bstripcr
886 (str, sizeof(str), fp, pszSrcFile, __LINE__))
887 break;
888 p = str;
889 if (*p == '\"') {
890 p++;
891 if (*p && *p != '\"') {
892 p = strchr(p, '\"');
893 if (p) {
894 *p = 0;
895 p++;
896 if (*p == ',') {
897 p++;
898 if (!cmp->includesubdirs && atol(p) > lenr)
899 continue;
900 p = strchr(p, ',');
901 if (p) {
902 p++;
903 fb4.cbFile = atol(p);
904 p = strchr(p, ',');
905 if (p) {
906 p++;
907 fb4.fdateLastWrite.year = atol(p) - 1980;
908 p = strchr(p, '/');
909 if (p) {
910 p++;
911 fb4.fdateLastWrite.month = atol(p);
912 p = strchr(p, '/');
913 if (p) {
914 p++;
915 fb4.fdateLastWrite.day = atol(p);
916 p = strchr(p, ',');
917 if (p) {
918 p++;
919 fb4.ftimeLastWrite.hours = atol(p);
920 p = strchr(p, ':');
921 if (p) {
922 p++;
923 fb4.ftimeLastWrite.minutes = atol(p);
924 p = strchr(p, ':');
925 if (p) {
926 p++;
927 fb4.ftimeLastWrite.twosecs = atol(p);
928 p = strchr(p, ',');
929 if (p) {
930 p++;
931 fb4.attrFile = atol(p);
932 p = strchr(p, ',');
933 if (p) {
934 p++;
935 fb4.cbList = atol(p) * 2;
936 if (fForceUpper)
937 strupr(str + 1);
938 else if (fForceLower)
939 strlwr(str + 1);
940 if (AddToFileList((str + 1) + lenr,
941 &fb4,
942 &filesr,
943 &numfilesr,
944 &numallocr))
945 break;
946 }
947 }
948 }
949 }
950 }
951 }
952 }
953 }
954 }
955 }
956 }
957 }
958 }
959 } // while
960 } // if have rightdir
961 fclose(fp);
962 }
963 } // if snapshot file
964
965 if (filesr)
966 qsort(filesr, numfilesr, sizeof(CHAR *), CompNames);
967
968 /* we now have two lists of files, both sorted. */
969 /* first, count total number of container entries required */
970 l = r = 0;
971 recsNeeded = 0;
972 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
973 if ((filesl && filesl[l]) && (filesr && filesr[r])) {
974 x = stricmp(filesl[l]->fname, filesr[r]->fname);
975 if (!x) {
976 l++; // In both
977 r++;
978 }
979 else if (x < 0)
980 l++; // In left only
981 else
982 r++; // In right only
983 }
984 else if (filesl && filesl[l])
985 l++; // In left only
986 else /* filesr && filesr[r] */
987 r++; // In right only
988 recsNeeded++; /* keep count of how many entries req'd */
989 }
990 WinSendMsg(cmp->hwnd, UM_CONTAINERHWND, MPVOID, MPVOID);
991 /* now insert records into the containers */
992 cntr = 0;
993 l = r = 0;
994 if (recsNeeded) {
995 pcilFirst = WinSendMsg(hwndLeft,
996 CM_ALLOCRECORD,
997 MPFROMLONG(EXTRA_RECORD_BYTES2),
998 MPFROMLONG(recsNeeded));
999 if (!pcilFirst) {
1000 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1001 recsNeeded);
1002 recsNeeded = 0;
1003 }
1004 }
1005 if (recsNeeded) {
1006 pcirFirst = WinSendMsg(hwndRight, CM_ALLOCRECORD,
1007 MPFROMLONG(EXTRA_RECORD_BYTES2),
1008 MPFROMLONG(recsNeeded));
1009 if (!pcirFirst) {
1010 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1011 recsNeeded);
1012 recsNeeded = 0;
1013 pcil = pcilFirst;
1014 while (pcil) {
1015 pcit = (PCNRITEM) pcil->rc.preccNextRecord;
1016 WinSendMsg(hwndLeft, CM_FREERECORD,
1017 MPFROMP(&pcil), MPFROMSHORT(1));
1018 pcil = pcit;
1019 }
1020 }
1021 }
1022 if (recsNeeded) {
1023 pcil = pcilFirst;
1024 pcir = pcirFirst;
1025 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
1026 pcir->hwndCnr = hwndRight;
1027 //pcir->pszFileName = pcir->szFileName;
1028 // 23 Jul 07 SHL fixme to set pszIcon after pszFileName allocated
1029 // 23 Jul 07 SHL fixme to set pszLongName after pszFileName allocated
1030 pcir->pszFileName = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);//29 Jul 07 GKY Temp fix to crash
1031 pcir->rc.pszIcon = pcir->pszFileName;
1032 pcir->rc.hptrIcon = (HPOINTER) 0;
1033 pcir->pszDisplayName = NULL; // Not used here
1034 pcir->pszSubject = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
1035 //pcir->pszLongname = pcir->pszFileName;
1036 pcir->pszDispAttr = pcir->szDispAttr;
1037 pcil->hwndCnr = hwndLeft;
1038 //pcil->pszFileName = pcil->szFileName;
1039 pcil->pszFileName = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);//29 Jul 07 GKY Temp fix to crash
1040 pcil->rc.pszIcon = pcil->pszFileName;
1041 pcil->rc.hptrIcon = (HPOINTER) 0;
1042 pcil->pszDispAttr = pcil->szDispAttr;
1043 pcil->pszDisplayName = NULL; // Not used here
1044 pcil->pszSubject = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__) ;
1045 //pcil->pszLongname = pcil->pszFileName;
1046 if ((filesl && filesl[l]) && (filesr && filesr[r])) {
1047 x = stricmp(filesl[l]->fname, filesr[r]->fname);
1048 if (!x) {
1049 // Same
1050 sprintf(pcil->pszFileName, "%s%s%s", cmp->leftdir,
1051 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
1052 NullStr : "\\", filesl[l]->fname);
1053 // pcil->rc.hptrIcon = hptrFile;
1054 pcil->pszDisplayName = pcil->pszFileName + lenl;
1055 pcil->attrFile = filesl[l]->attrFile;
1056 y = 0;
1057 for (x = 0; x < 6; x++) {
1058 if (attrstring[x])
1059 pcil->szDispAttr[y++] =
1060 (CHAR) ((pcil->
1061 attrFile & (1 << x)) ? attrstring[x] : '-');
1062 }
1063 pcil->szDispAttr[5] = 0;
1064 pcil->cbFile = filesl[l]->cbFile;
1065 pcil->easize = filesl[l]->easize;
1066 pcil->date.day = filesl[l]->date.day;
1067 pcil->date.month = filesl[l]->date.month;
1068 pcil->date.year = filesl[l]->date.year + 1980;
1069 pcil->time.seconds = filesl[l]->time.twosecs * 2;
1070 pcil->time.minutes = filesl[l]->time.minutes;
1071 pcil->time.hours = filesl[l]->time.hours;
1072 pcil->ladate.day = filesl[l]->ladate.day;
1073 pcil->ladate.month = filesl[l]->ladate.month;
1074 pcil->ladate.year = filesl[l]->ladate.year + 1980;
1075 pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
1076 pcil->latime.minutes = filesl[l]->latime.minutes;
1077 pcil->latime.hours = filesl[l]->latime.hours;
1078 pcil->crdate.day = filesl[l]->crdate.day;
1079 pcil->crdate.month = filesl[l]->crdate.month;
1080 pcil->crdate.year = filesl[l]->crdate.year + 1980;
1081 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
1082 pcil->crtime.minutes = filesl[l]->crtime.minutes;
1083 pcil->crtime.hours = filesl[l]->crtime.hours;
1084 if (*cmp->dcd.mask.szMask) {
1085 if (!Filter((PMINIRECORDCORE) pcil, (PVOID) & cmp->dcd.mask)) {
1086 pcil->rc.flRecordAttr |= CRA_FILTERED;
1087 pcir->rc.flRecordAttr |= CRA_FILTERED;
1088 }
1089 }
1090 sprintf(pcir->pszFileName, "%s%s%s", cmp->rightdir,
1091 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
1092 NullStr : "\\", filesr[r]->fname);
1093 pcir->pszDisplayName = pcir->pszFileName + lenr;
1094 pcir->attrFile = filesr[r]->attrFile;
1095 // pcir->rc.hptrIcon = hptrFile;
1096 y = 0;
1097 for (x = 0; x < 6; x++)
1098 if (attrstring[x])
1099 pcir->szDispAttr[y++] =
1100 (CHAR) ((pcir->
1101 attrFile & (1 << x)) ? attrstring[x] : '-');
1102 pcir->szDispAttr[5] = 0;
1103 pcir->cbFile = filesr[r]->cbFile;
1104 pcir->easize = filesr[r]->easize;
1105 pcir->date.day = filesr[r]->date.day;
1106 pcir->date.month = filesr[r]->date.month;
1107 pcir->date.year = filesr[r]->date.year + 1980;
1108 pcir->time.seconds = filesr[r]->time.twosecs * 2;
1109 pcir->time.minutes = filesr[r]->time.minutes;
1110 pcir->time.hours = filesr[r]->time.hours;
1111 pcir->ladate.day = filesr[r]->ladate.day;
1112 pcir->ladate.month = filesr[r]->ladate.month;
1113 pcir->ladate.year = filesr[r]->ladate.year + 1980;
1114 pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
1115 pcir->latime.minutes = filesr[r]->latime.minutes;
1116 pcir->latime.hours = filesr[r]->latime.hours;
1117 pcir->crdate.day = filesr[r]->crdate.day;
1118 pcir->crdate.month = filesr[r]->crdate.month;
1119 pcir->crdate.year = filesr[r]->crdate.year + 1980;
1120 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
1121 pcir->crtime.minutes = filesr[r]->crtime.minutes;
1122 pcir->crtime.hours = filesr[r]->crtime.hours;
1123 pcil->flags |= CNRITEM_EXISTS;
1124 pcir->flags |= CNRITEM_EXISTS;
1125 pch = pcil->pszSubject;
1126 if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) {
1127 pcil->flags |= CNRITEM_LARGER;
1128 pcir->flags |= CNRITEM_SMALLER;
1129 strcpy(pch, GetPString(IDS_LARGERTEXT));
1130 pch += 6;
1131 }
1132 else if (pcil->cbFile + pcil->easize <
1133 pcir->cbFile + pcir->easize) {
1134 pcil->flags |= CNRITEM_SMALLER;
1135 pcir->flags |= CNRITEM_LARGER;
1136 strcpy(pch, GetPString(IDS_SMALLERTEXT));
1137 pch += 7;
1138 }
1139 if ((pcil->date.year > pcir->date.year) ? TRUE :
1140 (pcil->date.year < pcir->date.year) ? FALSE :
1141 (pcil->date.month > pcir->date.month) ? TRUE :
1142 (pcil->date.month < pcir->date.month) ? FALSE :
1143 (pcil->date.day > pcir->date.day) ? TRUE :
1144 (pcil->date.day < pcir->date.day) ? FALSE :
1145 (pcil->time.hours > pcir->time.hours) ? TRUE :
1146 (pcil->time.hours < pcir->time.hours) ? FALSE :
1147 (pcil->time.minutes > pcir->time.minutes) ? TRUE :
1148 (pcil->time.minutes < pcir->time.minutes) ? FALSE :
1149 (pcil->time.seconds > pcir->time.seconds) ? TRUE :
1150 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) {
1151 pcil->flags |= CNRITEM_NEWER;
1152 pcir->flags |= CNRITEM_OLDER;
1153 if (pch != pcil->pszSubject) {
1154 strcpy(pch, ", ");
1155 pch += 2;
1156 }
1157 strcpy(pch, GetPString(IDS_NEWERTEXT));
1158 pch += 5;
1159 }
1160 else if ((pcil->date.year < pcir->date.year) ? TRUE :
1161 (pcil->date.year > pcir->date.year) ? FALSE :
1162 (pcil->date.month < pcir->date.month) ? TRUE :
1163 (pcil->date.month > pcir->date.month) ? FALSE :
1164 (pcil->date.day < pcir->date.day) ? TRUE :
1165 (pcil->date.day > pcir->date.day) ? FALSE :
1166 (pcil->time.hours < pcir->time.hours) ? TRUE :
1167 (pcil->time.hours > pcir->time.hours) ? FALSE :
1168 (pcil->time.minutes < pcir->time.minutes) ? TRUE :
1169 (pcil->time.minutes > pcir->time.minutes) ? FALSE :
1170 (pcil->time.seconds < pcir->time.seconds) ? TRUE :
1171 (pcil->time.seconds > pcir->time.seconds) ? FALSE :
1172 FALSE) {
1173 pcil->flags |= CNRITEM_OLDER;
1174 pcir->flags |= CNRITEM_NEWER;
1175 if (pch != pcil->pszSubject) {
1176 strcpy(pch, ", ");
1177 pch += 2;
1178 }
1179 strcpy(pch, GetPString(IDS_OLDERTEXT));
1180 pch += 5;
1181 }
1182 *pch = 0;
1183 r++;
1184 l++;
1185 }
1186 else if (x < 0) {
1187 // Just on left
1188 sprintf(pcil->pszFileName, "%s%s%s", cmp->leftdir,
1189 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
1190 NullStr : "\\", filesl[l]->fname);
1191 pcil->pszDisplayName = pcil->pszFileName + lenl;
1192 pcil->attrFile = filesl[l]->attrFile;
1193 // pcil->rc.hptrIcon = hptrFile;
1194 y = 0;
1195 for (x = 0; x < 6; x++)
1196 if (attrstring[x])
1197 pcil->szDispAttr[y++] =
1198 (CHAR) ((pcil->
1199 attrFile & (1 << x)) ? attrstring[x] : '-');
1200 pcil->szDispAttr[5] = 0;
1201 pcil->cbFile = filesl[l]->cbFile;
1202 pcil->easize = filesl[l]->easize;
1203 pcil->date.day = filesl[l]->date.day;
1204 pcil->date.month = filesl[l]->date.month;
1205 pcil->date.year = filesl[l]->date.year + 1980;
1206 pcil->time.seconds = filesl[l]->time.twosecs * 2;
1207 pcil->time.minutes = filesl[l]->time.minutes;
1208 pcil->time.hours = filesl[l]->time.hours;
1209 pcil->ladate.day = filesl[l]->ladate.day;
1210 pcil->ladate.month = filesl[l]->ladate.month;
1211 pcil->ladate.year = filesl[l]->ladate.year + 1980;
1212 pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
1213 pcil->latime.minutes = filesl[l]->latime.minutes;
1214 pcil->latime.hours = filesl[l]->latime.hours;
1215 pcil->crdate.day = filesl[l]->crdate.day;
1216 pcil->crdate.month = filesl[l]->crdate.month;
1217 pcil->crdate.year = filesl[l]->crdate.year + 1980;
1218 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
1219 pcil->crtime.minutes = filesl[l]->crtime.minutes;
1220 pcil->crtime.hours = filesl[l]->crtime.hours;
1221 if (*cmp->dcd.mask.szMask) {
1222 if (!Filter((PMINIRECORDCORE) pcil, (PVOID) & cmp->dcd.mask)) {
1223 pcil->rc.flRecordAttr |= CRA_FILTERED;
1224 pcir->rc.flRecordAttr |= CRA_FILTERED;
1225 }
1226 }
1227 free(filesl[l]);
1228 l++;
1229 }
1230 else {
1231 // Just on right
1232 sprintf(pcir->pszFileName, "%s%s%s", cmp->rightdir,
1233 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
1234 NullStr : "\\", filesr[r]->fname);
1235 pcir->pszDisplayName = pcir->pszFileName + lenr;
1236 pcir->attrFile = filesr[r]->attrFile;
1237 // pcir->rc.hptrIcon = hptrFile;
1238 y = 0;
1239 for (x = 0; x < 6; x++) {
1240 if (attrstring[x])
1241 pcir->szDispAttr[y++] =
1242 (CHAR) ((pcir->
1243 attrFile & (1 << x)) ? attrstring[x] : '-');
1244 }
1245 pcir->szDispAttr[5] = 0;
1246 pcir->cbFile = filesr[r]->cbFile;
1247 pcir->easize = filesr[r]->easize;
1248 pcir->date.day = filesr[r]->date.day;
1249 pcir->date.month = filesr[r]->date.month;
1250 pcir->date.year = filesr[r]->date.year + 1980;
1251 pcir->time.seconds = filesr[r]->time.twosecs * 2;
1252 pcir->time.minutes = filesr[r]->time.minutes;
1253 pcir->time.hours = filesr[r]->time.hours;
1254 pcir->ladate.day = filesr[r]->ladate.day;
1255 pcir->ladate.month = filesr[r]->ladate.month;
1256 pcir->ladate.year = filesr[r]->ladate.year + 1980;
1257 pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
1258 pcir->latime.minutes = filesr[r]->latime.minutes;
1259 pcir->latime.hours = filesr[r]->latime.hours;
1260 pcir->crdate.day = filesr[r]->crdate.day;
1261 pcir->crdate.month = filesr[r]->crdate.month;
1262 pcir->crdate.year = filesr[r]->crdate.year + 1980;
1263 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
1264 pcir->crtime.minutes = filesr[r]->crtime.minutes;
1265 pcir->crtime.hours = filesr[r]->crtime.hours;
1266 if (*cmp->dcd.mask.szMask) {
1267 if (!Filter((PMINIRECORDCORE) pcir, (PVOID) & cmp->dcd.mask)) {
1268 pcir->rc.flRecordAttr |= CRA_FILTERED;
1269 pcil->rc.flRecordAttr |= CRA_FILTERED;
1270 }
1271 }
1272 free(filesr[r]);
1273 r++;
1274 }
1275 }
1276 else if (filesl && filesl[l]) {
1277 // Just on left
1278 sprintf(pcil->pszFileName, "%s%s%s", cmp->leftdir,
1279 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
1280 NullStr : "\\", filesl[l]->fname);
1281 pcil->pszDisplayName = pcil->pszFileName + lenl;
1282 pcil->attrFile = filesl[l]->attrFile;
1283 // pcil->rc.hptrIcon = hptrFile;
1284 y = 0;
1285 for (x = 0; x < 6; x++)
1286 if (attrstring[x])
1287 pcil->szDispAttr[y++] = (CHAR) ((pcil->attrFile & (1 << x)) ?
1288 attrstring[x] : '-');
1289 pcil->szDispAttr[5] = 0;
1290 pcil->cbFile = filesl[l]->cbFile;
1291 pcil->easize = filesl[l]->easize;
1292 pcil->date.day = filesl[l]->date.day;
1293 pcil->date.month = filesl[l]->date.month;
1294 pcil->date.year = filesl[l]->date.year + 1980;
1295 pcil->time.seconds = filesl[l]->time.twosecs * 2;
1296 pcil->time.minutes = filesl[l]->time.minutes;
1297 pcil->time.hours = filesl[l]->time.hours;
1298 pcil->ladate.day = filesl[l]->ladate.day;
1299 pcil->ladate.month = filesl[l]->ladate.month;
1300 pcil->ladate.year = filesl[l]->ladate.year + 1980;
1301 pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
1302 pcil->latime.minutes = filesl[l]->latime.minutes;
1303 pcil->latime.hours = filesl[l]->latime.hours;
1304 pcil->crdate.day = filesl[l]->crdate.day;
1305 pcil->crdate.month = filesl[l]->crdate.month;
1306 pcil->crdate.year = filesl[l]->crdate.year + 1980;
1307 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
1308 pcil->crtime.minutes = filesl[l]->crtime.minutes;
1309 pcil->crtime.hours = filesl[l]->crtime.hours;
1310 if (*cmp->dcd.mask.szMask) {
1311 if (!Filter((PMINIRECORDCORE) pcil, (PVOID) & cmp->dcd.mask)) {
1312 pcil->rc.flRecordAttr |= CRA_FILTERED;
1313 pcir->rc.flRecordAttr |= CRA_FILTERED;
1314 }
1315 }
1316 free(filesl[l]);
1317 l++;
1318 }
1319 else {
1320 /* filesr && filesr[r] */
1321 // Just on right
1322 sprintf(pcir->pszFileName, "%s%s%s", cmp->rightdir,
1323 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
1324 NullStr : "\\", filesr[r]->fname);
1325 pcir->pszDisplayName = pcir->pszFileName + lenr;
1326 pcir->attrFile = filesr[r]->attrFile;
1327 // pcir->rc.hptrIcon = hptrFile;
1328 y = 0;
1329 for (x = 0; x < 6; x++) {
1330 if (attrstring[x])
1331 pcir->szDispAttr[y++] = (CHAR) ((pcir->attrFile & (1 << x)) ?
1332 attrstring[x] : '-');
1333 }
1334 pcir->szDispAttr[5] = 0;
1335 pcir->cbFile = filesr[r]->cbFile;
1336 pcir->easize = filesr[r]->easize;
1337 pcir->date.day = filesr[r]->date.day;
1338 pcir->date.month = filesr[r]->date.month;
1339 pcir->date.year = filesr[r]->date.year + 1980;
1340 pcir->time.seconds = filesr[r]->time.twosecs * 2;
1341 pcir->time.minutes = filesr[r]->time.minutes;
1342 pcir->time.hours = filesr[r]->time.hours;
1343 pcir->ladate.day = filesr[r]->ladate.day;
1344 pcir->ladate.month = filesr[r]->ladate.month;
1345 pcir->ladate.year = filesr[r]->ladate.year + 1980;
1346 pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
1347 pcir->latime.minutes = filesr[r]->latime.minutes;
1348 pcir->latime.hours = filesr[r]->latime.hours;
1349 pcir->crdate.day = filesr[r]->crdate.day;
1350 pcir->crdate.month = filesr[r]->crdate.month;
1351 pcir->crdate.year = filesr[r]->crdate.year + 1980;
1352 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
1353 pcir->crtime.minutes = filesr[r]->crtime.minutes;
1354 pcir->crtime.hours = filesr[r]->crtime.hours;
1355 if (*cmp->dcd.mask.szMask) {
1356 if (!Filter((PMINIRECORDCORE) pcir, (PVOID) & cmp->dcd.mask)) {
1357 pcir->rc.flRecordAttr |= CRA_FILTERED;
1358 pcil->rc.flRecordAttr |= CRA_FILTERED;
1359 }
1360 }
1361 free(filesr[r]);
1362 r++;
1363 }
1364 if (!(cntr % 500))
1365 DosSleep(1L);
1366 else if (!(cntr % 50))
1367 DosSleep(0L);
1368 cntr++;
1369 pcil = (PCNRITEM) pcil->rc.preccNextRecord;
1370 pcir = (PCNRITEM) pcir->rc.preccNextRecord;
1371 } // while
1372 if (filesl)
1373 free(filesl); // Free header - have already freed elements
1374 filesl = NULL;
1375 if (filesr)
1376 free(filesr);
1377 filesr = NULL;
1378 /* insert 'em */
1379 WinSendMsg(cmp->hwnd, UM_CONTAINERDIR, MPVOID, MPVOID);
1380 memset(&ri, 0, sizeof(RECORDINSERT));
1381 ri.cb = sizeof(RECORDINSERT);
1382 ri.pRecordOrder = (PRECORDCORE) CMA_END;
1383 ri.pRecordParent = (PRECORDCORE) NULL;
1384 ri.zOrder = (ULONG) CMA_TOP;
1385 ri.cRecordsInsert = recsNeeded;
1386 ri.fInvalidateRecord = FALSE;
1387 if (!WinSendMsg(hwndLeft, CM_INSERTRECORD,
1388 MPFROMP(pcilFirst), MPFROMP(&ri))) {
1389 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
1390 pcil = pcilFirst;
1391 while (pcil) {
1392 pcit = (PCNRITEM) pcil->rc.preccNextRecord;
1393 WinSendMsg(hwndLeft, CM_FREERECORD,
1394 MPFROMP(&pcil), MPFROMSHORT(1));
1395 pcil = pcit;
1396 }
1397 numfilesl = 0;
1398 }
1399 memset(&ri, 0, sizeof(RECORDINSERT));
1400 ri.cb = sizeof(RECORDINSERT);
1401 ri.pRecordOrder = (PRECORDCORE) CMA_END;
1402 ri.pRecordParent = (PRECORDCORE) NULL;
1403 ri.zOrder = (ULONG) CMA_TOP;
1404 ri.cRecordsInsert = recsNeeded;
1405 ri.fInvalidateRecord = FALSE;
1406 if (!WinSendMsg(hwndRight, CM_INSERTRECORD,
1407 MPFROMP(pcirFirst), MPFROMP(&ri))) {
1408 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
1409 WinSendMsg(hwndLeft, CM_REMOVERECORD,
1410 MPVOID, MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE));
1411 pcir = pcirFirst;
1412 while (pcir) {
1413 pcit = (PCNRITEM) pcir->rc.preccNextRecord;
1414 WinSendMsg(hwndRight, CM_FREERECORD,
1415 MPFROMP(&pcir), MPFROMSHORT(1));
1416 pcir = pcit;
1417 }
1418 numfilesr = 0;
1419 }
1420 cmp->cmp->totalleft = numfilesl;
1421 cmp->cmp->totalright = numfilesr;
1422 } // if recsNeeded
1423 Deselect(hwndLeft);
1424 Deselect(hwndRight);
1425 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID))
1426 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
1427 notified = TRUE;
1428 if (filesl)
1429 FreeList((CHAR **) filesl); // Must have failed to create container
1430 if (filesr)
1431 FreeList((CHAR **) filesr);
1432 WinDestroyMsgQueue(hmq);
1433 }
1434 DecrThreadUsage();
1435 WinTerminate(hab);
1436 }
1437 if (!notified)
1438 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
1439 free(cmp);
1440 DosPostEventSem(CompactSem);
1441}
1442
1443#define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR))
1444#define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
1445
1446//=== CompareDlgProc() Compare directories dialog procedure ===
1447
1448MRESULT EXPENTRY CompareDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1449{
1450 COMPARE *cmp;
1451
1452 static HPOINTER hptr = (HPOINTER) 0;
1453
1454 switch (msg) {
1455 case WM_INITDLG:
1456 cmp = (COMPARE *) mp2;
1457 if (!cmp) {
1458 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1459 WinDismissDlg(hwnd, 0);
1460 }
1461 else {
1462 if (!hptr)
1463 hptr = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, COMPARE_ICON);
1464 WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptr), MPVOID);
1465 cmp->hwnd = hwnd;
1466 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) cmp);
1467 SetCnrCols(hwndLeft, TRUE);
1468 SetCnrCols(hwndRight, TRUE);
1469 WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
1470 WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
1471 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
1472 {
1473 USHORT ids[] = { COMP_LEFTDIR, COMP_RIGHTDIR, COMP_TOTALLEFT,
1474 COMP_TOTALRIGHT, COMP_SELLEFT, COMP_SELRIGHT,
1475 0
1476 };
1477 register INT x;
1478
1479 for (x = 0; ids[x]; x++)
1480 SetPresParams(WinWindowFromID(hwnd, ids[x]),
1481 &RGBGREY,
1482 &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT));
1483 }
1484 }
1485 break;
1486
1487 case UM_STRETCH:
1488 {
1489 SWP swp, swpC;
1490 LONG titl, szbx, szby, sz;
1491 HWND hwndActive;
1492
1493 WinQueryWindowPos(hwnd, &swp);
1494 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
1495 hwndActive = WinQueryFocus(HWND_DESKTOP);
1496 szbx = SysVal(SV_CXSIZEBORDER);
1497 szby = SysVal(SV_CYSIZEBORDER);
1498 titl = SysVal(SV_CYTITLEBAR);
1499 titl += 26;
1500 swp.cx -= (szbx * 2);
1501 sz = (swp.cx / 8);
1502 WinQueryWindowPos(WinWindowFromID(hwnd, COMP_LEFTDIR), &swpC);
1503 WinSetWindowPos(WinWindowFromID(hwnd, COMP_LEFTDIR), HWND_TOP,
1504 szbx + 6,
1505 swpC.y,
1506 (swp.cx / 2) - (szbx + 6),
1507 ((swp.cy - swpC.y) - titl) - szby,
1508 SWP_MOVE | SWP_SIZE);
1509 WinSetWindowPos(WinWindowFromID(hwnd, COMP_RIGHTDIR), HWND_TOP,
1510 (swp.cx / 2) + (szbx + 6),
1511 swpC.y,
1512 (swp.cx / 2) - (szbx + 6),
1513 ((swp.cy - swpC.y) - titl) - szby,
1514 SWP_MOVE | SWP_SIZE);
1515 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALLEFTHDR), HWND_TOP,
1516 szbx + 6,
1517 ((swp.cy - titl) - szby) + 4,
1518 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1519 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALLEFT), HWND_TOP,
1520 sz + (szbx + 6),
1521 ((swp.cy - titl) - szby) + 4,
1522 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1523 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELLEFTHDR), HWND_TOP,
1524 (sz * 2) + (szbx + 6),
1525 ((swp.cy - titl) - szby) + 4,
1526 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1527 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELLEFT), HWND_TOP,
1528 (sz * 3) + (szbx + 6),
1529 ((swp.cy - titl) - szby) + 4,
1530 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1531 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALRIGHTHDR), HWND_TOP,
1532 (sz * 4) + (szbx + 6),
1533 ((swp.cy - titl) - szby) + 4,
1534 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1535 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALRIGHT), HWND_TOP,
1536 (sz * 5) + (szbx + 6),
1537 ((swp.cy - titl) - szby) + 4,
1538 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1539 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELRIGHTHDR), HWND_TOP,
1540 (sz * 6) + (szbx + 6),
1541 ((swp.cy - titl) - szby) + 4,
1542 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1543 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELRIGHT), HWND_TOP,
1544 (sz * 7) + (szbx + 6),
1545 ((swp.cy - titl) - szby) + 4,
1546 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1547 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_TOTALLEFT),
1548 (HPS) 0, FALSE, FALSE);
1549 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_SELLEFT),
1550 (HPS) 0, FALSE, FALSE);
1551 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_TOTALRIGHT),
1552 (HPS) 0, FALSE, FALSE);
1553 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_SELRIGHT),
1554 (HPS) 0, FALSE, FALSE);
1555 PaintRecessedWindow(hwndLeft, (HPS) 0,
1556 (hwndActive == hwndLeft), TRUE);
1557 PaintRecessedWindow(hwndRight, (HPS) 0,
1558 (hwndActive == hwndRight), TRUE);
1559 }
1560 }
1561 return 0;
1562
1563 case WM_ADJUSTWINDOWPOS:
1564 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
1565 break;
1566
1567 case UM_SETUP:
1568 {
1569 CNRINFO cnri;
1570 BOOL tempsubj;
1571
1572 cmp = INSTDATA(hwnd);
1573 if (cmp) {
1574 cmp->dcd.size = sizeof(DIRCNRDATA);
1575 cmp->dcd.type = DIR_FRAME;
1576 cmp->dcd.hwndFrame = hwnd;
1577 cmp->dcd.hwndClient = hwnd;
1578 cmp->dcd.mask.attrFile = (FILE_DIRECTORY | FILE_ARCHIVED |
1579 FILE_READONLY | FILE_SYSTEM | FILE_HIDDEN);
1580 LoadDetailsSwitches("DirCmp", &cmp->dcd);
1581 cmp->dcd.detailslongname = FALSE;
1582 cmp->dcd.detailsicon = FALSE; /* TRUE; */
1583 }
1584 memset(&cnri, 0, sizeof(CNRINFO));
1585 cnri.cb = sizeof(CNRINFO);
1586 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_QUERYCNRINFO,
1587 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1588 cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
1589 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 68;
1590 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1591 MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
1592 memset(&cnri, 0, sizeof(CNRINFO));
1593 cnri.cb = sizeof(CNRINFO);
1594 WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_QUERYCNRINFO,
1595 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1596 cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
1597 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 54;
1598 WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1599 MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
1600 AdjustCnrColRO(hwndLeft, GetPString(IDS_FILENAMECOLTEXT), TRUE, FALSE);
1601 AdjustCnrColRO(hwndLeft, GetPString(IDS_LONGNAMECOLTEXT), TRUE, FALSE);
1602 AdjustCnrColRO(hwndRight, GetPString(IDS_FILENAMECOLTEXT), TRUE, FALSE);
1603 AdjustCnrColRO(hwndRight, GetPString(IDS_LONGNAMECOLTEXT), TRUE, FALSE);
1604 AdjustCnrColsForPref(hwndLeft, cmp->leftdir, &cmp->dcd, TRUE);
1605 tempsubj = cmp->dcd.detailssubject;
1606 cmp->dcd.detailssubject = FALSE;
1607 AdjustCnrColsForPref(hwndRight, cmp->rightdir, &cmp->dcd, TRUE);
1608 if (*cmp->rightlist) {
1609 AdjustCnrColVis(hwndRight, GetPString(IDS_LADATECOLTEXT), FALSE,
1610 FALSE);
1611 AdjustCnrColVis(hwndRight, GetPString(IDS_LATIMECOLTEXT), FALSE,
1612 FALSE);
1613 AdjustCnrColVis(hwndRight, GetPString(IDS_CRDATECOLTEXT), FALSE,
1614 FALSE);
1615 AdjustCnrColVis(hwndRight, GetPString(IDS_CRTIMECOLTEXT), FALSE,
1616 FALSE);
1617 }
1618 cmp->dcd.detailssubject = tempsubj;
1619 }
1620 return 0;
1621
1622 case WM_DRAWITEM:
1623 if (mp2) {
1624
1625 POWNERITEM pown = (POWNERITEM) mp2;
1626 PCNRDRAWITEMINFO pcown;
1627 PCNRITEM pci;
1628
1629 pcown = (PCNRDRAWITEMINFO) pown->hItem;
1630 if (pcown) {
1631 pci = (PCNRITEM) pcown->pRecord;
1632 if (pci && (INT) pci != -1 && !*pci->pszFileName)
1633 return MRFROMLONG(TRUE);
1634 }
1635 }
1636 return 0;
1637
1638 case UM_CONTAINERHWND:
1639 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDBLDLISTTEXT));
1640 return 0;
1641
1642 case UM_CONTAINERDIR:
1643 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDFILLCNRTEXT));
1644 return 0;
1645
1646 case UM_CONTAINER_FILLED:
1647 cmp = INSTDATA(hwnd);
1648 if (!cmp) {
1649 Runtime_Error(pszSrcFile, __LINE__, "pCompare NULL");
1650 WinDismissDlg(hwnd, 0);
1651 }
1652 else {
1653 CHAR s[81];
1654
1655 cmp->filling = FALSE;
1656 WinEnableWindow(hwndLeft, TRUE);
1657 WinEnableWindow(hwndRight, TRUE);
1658 WinEnableWindowUpdate(hwndLeft, TRUE);
1659 WinEnableWindowUpdate(hwndRight, TRUE);
1660 sprintf(s, " %d", cmp->totalleft);
1661 WinSetDlgItemText(hwnd, COMP_TOTALLEFT, s);
1662 sprintf(s, " %d", cmp->totalright);
1663 WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, s);
1664 sprintf(s, " %d", cmp->selleft);
1665 WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
1666 sprintf(s, " %d", cmp->selright);
1667 WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
1668 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), TRUE);
1669 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), TRUE);
1670 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), TRUE);
1671 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), TRUE);
1672 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), TRUE);
1673 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), TRUE);
1674 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), TRUE);
1675 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), TRUE);
1676 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), TRUE);
1677 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), TRUE);
1678 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), TRUE);
1679 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), TRUE);
1680 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), TRUE);
1681 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), TRUE);
1682 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER), TRUE);
1683 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), TRUE);
1684 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT), TRUE);
1685 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL), TRUE);
1686 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), TRUE);
1687 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), TRUE);
1688 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), TRUE);
1689 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), TRUE);
1690 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), TRUE);
1691 if (!*cmp->rightlist) {
1692 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), TRUE);
1693 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), TRUE);
1694 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), TRUE);
1695 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), TRUE);
1696 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), TRUE);
1697 }
1698 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), TRUE);
1699 if (*cmp->dcd.mask.szMask)
1700 WinSetDlgItemText(hwnd, COMP_NOTE,
1701 GetPString(IDS_COMPREADYFILTEREDTEXT));
1702 else
1703 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
1704 }
1705 break;
1706
1707 case WM_INITMENU:
1708 cmp = INSTDATA(hwnd);
1709 if (cmp) {
1710 switch (SHORT1FROMMP(mp1)) {
1711 case IDM_COMMANDSMENU:
1712 SetupCommandMenu(cmp->dcd.hwndLastMenu, hwnd);
1713 break;
1714 }
1715 }
1716 break;
1717
1718 case WM_MENUEND:
1719 cmp = INSTDATA(hwnd);
1720 if (cmp) {
1721 if ((HWND) mp2 == cmp->dcd.hwndLastMenu) {
1722 MarkAll(hwndLeft, TRUE, FALSE, TRUE);
1723 MarkAll(hwndRight, TRUE, FALSE, TRUE);
1724 WinDestroyWindow(cmp->dcd.hwndLastMenu);
1725 cmp->dcd.hwndLastMenu = (HWND) 0;
1726 }
1727 }
1728 break;
1729
1730 case WM_CONTROL:
1731 switch (SHORT1FROMMP(mp1)) {
1732 case COMP_INCLUDESUBDIRS:
1733 switch (SHORT2FROMMP(mp1)) {
1734 case BN_CLICKED:
1735 cmp = INSTDATA(hwnd);
1736 if (cmp)
1737 *cmp->rightlist = 0;
1738 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
1739 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
1740 break;
1741 }
1742 break;
1743 case COMP_HIDENOTSELECTED:
1744 switch (SHORT2FROMMP(mp1)) {
1745 case BN_CLICKED:
1746 WinSendMsg(hwnd, UM_HIDENOTSELECTED, MPVOID, MPVOID);
1747 break;
1748 }
1749 break;
1750
1751 case COMP_LEFTDIR:
1752 case COMP_RIGHTDIR:
1753 switch (SHORT2FROMMP(mp1)) {
1754 case CN_KILLFOCUS:
1755 PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1756 (HPS) 0, FALSE, TRUE);
1757 break;
1758
1759 case CN_SETFOCUS:
1760 PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1761 (HPS) 0, TRUE, TRUE);
1762 break;
1763
1764 case CN_ENTER:
1765 if (mp2) {
1766
1767 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1768 HWND hwndCnr = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
1769
1770 SetShiftState();
1771 if (pci) {
1772 if ((pci->rc.flRecordAttr & CRA_INUSE) || !*pci->pszFileName)
1773 break;
1774 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1775 MPFROM2SHORT(TRUE, CRA_INUSE));
1776 if (pci->attrFile & FILE_DIRECTORY) {
1777 if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT))
1778 OpenObject(pci->pszFileName, Settings, hwnd);
1779 else
1780 OpenObject(pci->pszFileName, Default, hwnd);
1781 }
1782 else
1783 DefaultViewKeys(hwnd, hwnd, HWND_DESKTOP, NULL,
1784 pci->pszFileName);
1785 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS,
1786 MPFROMP(pci),
1787 MPFROM2SHORT(FALSE, CRA_INUSE |
1788 ((fUnHilite) ? CRA_SELECTED : 0)));
1789 }
1790 }
1791 break;
1792
1793 case CN_CONTEXTMENU:
1794 cmp = INSTDATA(hwnd);
1795 if (cmp) {
1796
1797 PCNRITEM pci = (PCNRITEM) mp2;
1798 USHORT id = COMP_CNRMENU;
1799
1800 if (cmp->dcd.hwndLastMenu)
1801 WinDestroyWindow(cmp->dcd.hwndLastMenu);
1802 cmp->dcd.hwndLastMenu = (HWND) 0;
1803 cmp->hwndCalling = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
1804 if (pci) {
1805 if (!*pci->pszFileName || *cmp->rightlist)
1806 break;
1807 id = COMP_MENU;
1808 WinSendMsg(cmp->hwndCalling, CM_SETRECORDEMPHASIS,
1809 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
1810 }
1811 cmp->dcd.hwndLastMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
1812 if (cmp->dcd.hwndLastMenu) {
1813 if (id == COMP_CNRMENU) {
1814 if (SHORT1FROMMP(mp1) == COMP_RIGHTDIR)
1815 WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
1816 MPFROM2SHORT(IDM_SHOWSUBJECT, FALSE), MPVOID);
1817 SetDetailsSwitches(cmp->dcd.hwndLastMenu, &cmp->dcd);
1818 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
1819 WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
1820 MPFROM2SHORT(IDM_LOADLISTFILE, 0), MPVOID);
1821 else if (*cmp->rightlist)
1822 WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
1823 MPFROM2SHORT(IDM_SAVELISTFILE, 0), MPVOID);
1824 }
1825 PopupMenu(hwnd, hwnd, cmp->dcd.hwndLastMenu);
1826 }
1827 }
1828 break;
1829
1830 case CN_INITDRAG:
1831 cmp = INSTDATA(hwnd);
1832 if (*cmp->rightlist && SHORT1FROMMP(mp1) == COMP_RIGHTDIR)
1833 break;
1834 DoFileDrag(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1835 (HWND) 0, mp2, NULL, NULL, TRUE);
1836 break;
1837
1838 case CN_BEGINEDIT:
1839 case CN_REALLOCPSZ:
1840 // fixme to be gone - field edits not allowed
1841 Runtime_Error(pszSrcFile, __LINE__,
1842 "CN_BEGINEDIT/CN_REALLOCPSZ unexpected");
1843 break;
1844
1845 case CN_EMPHASIS:
1846 {
1847 PNOTIFYRECORDEMPHASIS pre = mp2;
1848 PCNRITEM pci;
1849
1850 if (pre->fEmphasisMask & CRA_SELECTED) {
1851 pci = (PCNRITEM) pre->pRecord;
1852 if (pci) {
1853 if (!*pci->pszFileName) {
1854 if (pci->rc.flRecordAttr & CRA_SELECTED)
1855 WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1),
1856 CM_SETRECORDEMPHASIS,
1857 MPFROMP(pci),
1858 MPFROM2SHORT(FALSE, CRA_SELECTED));
1859 }
1860 else {
1861
1862 CHAR s[81];
1863
1864 cmp = INSTDATA(hwnd);
1865 if (pci->rc.flRecordAttr & CRA_SELECTED) {
1866 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
1867 cmp->selleft++;
1868 else
1869 cmp->selright++;
1870 }
1871 else {
1872 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
1873 if (cmp->selleft)
1874 cmp->selleft--;
1875 }
1876 else {
1877 if (cmp->selright)
1878 cmp->selright--;
1879 }
1880 }
1881 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
1882 if (WinIsWindowEnabled(hwndLeft) || !(cmp->selleft % 50)) {
1883 sprintf(s, " %d", cmp->selleft);
1884 WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
1885 }
1886 }
1887 else {
1888 if (WinIsWindowEnabled(hwndRight) || !(cmp->selright % 50)) {
1889 sprintf(s, " %d", cmp->selright);
1890 WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
1891 }
1892 }
1893 }
1894 }
1895 }
1896 }
1897 break;
1898
1899 case CN_SCROLL:
1900 cmp = INSTDATA(hwnd);
1901 if (!cmp->forcescroll) {
1902
1903 PNOTIFYSCROLL pns = mp2;
1904
1905 if (pns->fScroll & CMA_VERTICAL) {
1906 cmp->forcescroll = TRUE;
1907 WinSendDlgItemMsg(hwnd, (SHORT1FROMMP(mp1) == COMP_LEFTDIR) ?
1908 COMP_RIGHTDIR : COMP_LEFTDIR,
1909 CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL),
1910 MPFROMLONG(pns->lScrollInc));
1911 cmp->forcescroll = FALSE;
1912 }
1913 }
1914 break;
1915 }
1916 break; // COMP_RIGHTDIR
1917 }
1918 return 0; // WM_CONTROL
1919
1920 case UM_SETDIR:
1921 cmp = INSTDATA(hwnd);
1922 if (cmp) {
1923
1924 COMPARE *forthread;
1925 CNRINFO cnri;
1926
1927 cmp->includesubdirs = WinQueryButtonCheckstate(hwnd,
1928 COMP_INCLUDESUBDIRS);
1929 memset(&cnri, 0, sizeof(CNRINFO));
1930 cnri.cb = sizeof(CNRINFO);
1931 cnri.pszCnrTitle = cmp->leftdir;
1932 cnri.flWindowAttr = CV_DETAIL | CV_MINI |
1933 CA_CONTAINERTITLE | CA_TITLESEPARATOR |
1934 CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
1935 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1936 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
1937 cnri.pszCnrTitle = cmp->rightdir;
1938 WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1939 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
1940 WinCheckButton(hwnd, COMP_HIDENOTSELECTED, 0);
1941 cmp->filling = TRUE;
1942 forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
1943 if (!forthread)
1944 WinDismissDlg(hwnd, 0);
1945 else {
1946 *forthread = *cmp;
1947 forthread->cmp = cmp;
1948 if (_beginthread(FillCnrsThread, NULL, 122880, (PVOID) forthread) ==
1949 -1) {
1950 Runtime_Error(pszSrcFile, __LINE__,
1951 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1952 WinDismissDlg(hwnd, 0);
1953 free(forthread);
1954 }
1955 else {
1956 WinEnableWindowUpdate(hwndLeft, FALSE);
1957 WinEnableWindowUpdate(hwndRight, FALSE);
1958 cmp->selleft = cmp->selright = 0;
1959 WinSetDlgItemText(hwnd, COMP_SELLEFT, "0");
1960 WinSetDlgItemText(hwnd, COMP_SELRIGHT, "0");
1961 WinSetDlgItemText(hwnd, COMP_TOTALLEFT, "0");
1962 WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, "0");
1963 WinSetDlgItemText(hwnd, COMP_NOTE,
1964 GetPString(IDS_COMPHOLDREADDISKTEXT));
1965 WinEnableWindow(hwndRight, FALSE);
1966 WinEnableWindow(hwndLeft, FALSE);
1967 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
1968 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
1969 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
1970 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
1971 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
1972 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
1973 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
1974 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
1975 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
1976 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
1977 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
1978 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
1979 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
1980 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
1981 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER), FALSE);
1982 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
1983 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), FALSE);
1984 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
1985 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
1986 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
1987 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
1988 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
1989 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
1990 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
1991 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
1992 FALSE);
1993 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL), FALSE);
1994 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
1995 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
1996 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
1997 }
1998 }
1999 }
2000 return 0;
2001
2002 case UM_FILTER:
2003 cmp = INSTDATA(hwnd);
2004 if (cmp) {
2005 if (mp1) {
2006 DosEnterCritSec();
2007 SetMask((CHAR *) mp1, &cmp->dcd.mask);
2008 DosExitCritSec();
2009 }
2010 cmp->dcd.suspendview = 1;
2011 WinSendMsg(hwndLeft, CM_FILTER, MPFROMP(Filter),
2012 MPFROMP(&cmp->dcd.mask));
2013 WinSendMsg(hwndRight, CM_FILTER, MPFROMP(Filter),
2014 MPFROMP(&cmp->dcd.mask));
2015 cmp->dcd.suspendview = 0;
2016 if (*cmp->dcd.mask.szMask)
2017 WinSetDlgItemText(hwnd, COMP_NOTE,
2018 GetPString(IDS_COMPREADYFILTEREDTEXT));
2019 else
2020 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
2021 }
2022 return 0;
2023
2024 case UM_HIDENOTSELECTED:
2025 cmp = INSTDATA(hwnd);
2026 if (cmp) {
2027 USHORT wantHide = WinQueryButtonCheckstate(hwnd,
2028 COMP_HIDENOTSELECTED);
2029
2030 cmp->dcd.suspendview = 1;
2031 if (wantHide) {
2032 BOOL needRefresh = FALSE;
2033 HWND hwndl = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
2034 HWND hwndr = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
2035 PCNRITEM pcil = WinSendMsg(hwndl, CM_QUERYRECORD, MPVOID,
2036 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
2037 PCNRITEM pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPVOID,
2038 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
2039
2040 while (pcil && (INT) pcil != -1 && pcir && (INT) pcir != -1) {
2041 if (~pcil->rc.flRecordAttr & CRA_SELECTED &&
2042 ~pcir->rc.flRecordAttr & CRA_SELECTED) {
2043 pcil->rc.flRecordAttr |= CRA_FILTERED;
2044 pcir->rc.flRecordAttr |= CRA_FILTERED;
2045 needRefresh = TRUE;
2046 }
2047 pcil = WinSendMsg(hwndl, CM_QUERYRECORD, MPFROMP(pcil),
2048 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
2049 pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPFROMP(pcir),
2050 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
2051 } // while
2052 if (needRefresh) {
2053 WinSendMsg(hwndl, CM_INVALIDATERECORD,
2054 MPVOID, MPFROM2SHORT(0, CMA_REPOSITION));
2055 WinSendMsg(hwndr, CM_INVALIDATERECORD,
2056 MPVOID, MPFROM2SHORT(0, CMA_REPOSITION));
2057 }
2058 }
2059 else {
2060 WinSendMsg(hwndLeft, CM_FILTER, MPFROMP(Filter),
2061 MPFROMP(&cmp->dcd.mask));
2062 WinSendMsg(hwndRight, CM_FILTER, MPFROMP(Filter),
2063 MPFROMP(&cmp->dcd.mask));
2064 }
2065 cmp->dcd.suspendview = 0;
2066 if (*cmp->dcd.mask.szMask)
2067 WinSetDlgItemText(hwnd, COMP_NOTE,
2068 GetPString(IDS_COMPREADYFILTEREDTEXT));
2069 else
2070 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
2071 }
2072 return 0;
2073
2074 case WM_COMMAND:
2075 switch (SHORT1FROMMP(mp1)) {
2076 case IDM_COMPARE:
2077 cmp = INSTDATA(hwnd);
2078 if (cmp) {
2079
2080 PCNRITEM pci;
2081 CHAR ofile[CCHMAXPATH];
2082
2083 pci = (PCNRITEM) WinSendMsg(cmp->hwndCalling,
2084 CM_QUERYRECORDEMPHASIS,
2085 MPFROMLONG(CMA_FIRST),
2086 MPFROMSHORT(CRA_CURSORED));
2087 if (pci) {
2088 if (cmp->hwndCalling == hwndLeft)
2089 strcpy(ofile, cmp->rightdir);
2090 else
2091 strcpy(ofile, cmp->leftdir);
2092 if (ofile[strlen(ofile) - 1] != '\\')
2093 strcat(ofile, "\\");
2094 strcat(ofile, pci->pszFileName);
2095 if (*compare) {
2096
2097 CHAR *fakelist[3];
2098
2099 fakelist[0] = pci->pszFileName;
2100 fakelist[1] = ofile;
2101 fakelist[2] = NULL;
2102 ExecOnList(hwnd, compare,
2103 WINDOWED | SEPARATEKEEP, NULL, fakelist, NULL);
2104 }
2105 else {
2106
2107 FCOMPARE fc;
2108
2109 memset(&fc, 0, sizeof(fc));
2110 fc.size = sizeof(fc);
2111 fc.hwndParent = hwnd;
2112 strcpy(fc.file1, pci->pszFileName);
2113 strcpy(fc.file2, ofile);
2114 WinDlgBox(HWND_DESKTOP, hwnd,
2115 CFileDlgProc, FM3ModHandle, FCMP_FRAME, (PVOID) & fc);
2116 }
2117 }
2118 }
2119 break;
2120
2121 case COMP_FILTER:
2122 case IDM_FILTER:
2123 cmp = INSTDATA(hwnd);
2124 if (cmp) {
2125
2126 BOOL empty = FALSE;
2127 PCNRITEM pci;
2128 CHAR *p;
2129 BOOL temp;
2130
2131 if (!*cmp->dcd.mask.szMask) {
2132 empty = TRUE;
2133 temp = fSelectedAlways;
2134 fSelectedAlways = TRUE;
2135 pci = (PCNRITEM) CurrentRecord(hwnd);
2136 fSelectedAlways = temp;
2137 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2138 p = strrchr(pci->pszFileName, '\\');
2139 if (p) {
2140 p++;
2141 strcpy(cmp->dcd.mask.szMask, p);
2142 }
2143 }
2144 }
2145 cmp->dcd.mask.fNoAttribs = TRUE;
2146 cmp->dcd.mask.attrFile = ALLATTRS;
2147 cmp->dcd.mask.antiattr = 0;
2148 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2149 FM3ModHandle, MSK_FRAME, MPFROMP(&cmp->dcd.mask))) {
2150 cmp->dcd.mask.attrFile = ALLATTRS;
2151 cmp->dcd.mask.antiattr = 0;
2152 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2153 }
2154 else if (empty) {
2155 *cmp->dcd.mask.szMask = 0;
2156 cmp->dcd.mask.attrFile = ALLATTRS;
2157 cmp->dcd.mask.antiattr = 0;
2158 }
2159 }
2160 break;
2161
2162 case IDM_SHOWSUBJECT:
2163 case IDM_SHOWEAS:
2164 case IDM_SHOWSIZE:
2165 case IDM_SHOWLWDATE:
2166 case IDM_SHOWLWTIME:
2167 case IDM_SHOWLADATE:
2168 case IDM_SHOWLATIME:
2169 case IDM_SHOWCRDATE:
2170 case IDM_SHOWCRTIME:
2171 case IDM_SHOWATTR:
2172 cmp = INSTDATA(hwnd);
2173 if (cmp) {
2174
2175 DIRCNRDATA dcd1;
2176 BOOL tempsubj;
2177
2178 dcd1 = cmp->dcd;
2179 AdjustDetailsSwitches(hwndLeft,
2180 (HWND) 0, SHORT1FROMMP(mp1),
2181 cmp->leftdir, "DirCmp", &cmp->dcd, TRUE);
2182 tempsubj = cmp->dcd.detailssubject;
2183 cmp->dcd = dcd1;
2184 cmp->dcd.detailssubject = FALSE;
2185 AdjustDetailsSwitches(hwndRight,
2186 cmp->dcd.hwndLastMenu, SHORT1FROMMP(mp1),
2187 cmp->rightdir, "DirCmp", &cmp->dcd, TRUE);
2188 cmp->dcd.detailssubject = tempsubj;
2189 }
2190 break;
2191
2192 case IDM_LOADLISTFILE:
2193 cmp = INSTDATA(hwnd);
2194 if (cmp) {
2195
2196 CHAR fullname[CCHMAXPATH];
2197
2198 strcpy(fullname, "*.PMD");
2199 if (insert_filename(HWND_DESKTOP, fullname, TRUE, FALSE) &&
2200 *fullname && !strchr(fullname, '*') && !strchr(fullname, '?')) {
2201 strcpy(cmp->rightlist, fullname);
2202 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
2203 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
2204 }
2205 }
2206 break;
2207
2208 case IDM_SAVELISTFILE:
2209 cmp = INSTDATA(hwnd);
2210 if (cmp) {
2211
2212 SNAPSTUFF *sf;
2213 CHAR fullname[CCHMAXPATH];
2214
2215 strcpy(fullname, "*.PMD");
2216 if (export_filename(HWND_DESKTOP, fullname, 1) && *fullname &&
2217 !strchr(fullname, '*') && !strchr(fullname, '?')) {
2218 sf = xmallocz(sizeof(SNAPSTUFF), pszSrcFile, __LINE__);
2219 if (sf) {
2220 strcpy(sf->filename, fullname);
2221 if (hwndLeft == cmp->hwndCalling)
2222 strcpy(sf->dirname, cmp->leftdir);
2223 else
2224 strcpy(sf->dirname, cmp->rightdir);
2225 sf->recurse = cmp->includesubdirs;
2226 if (_beginthread(StartSnap, NULL, 65536, (PVOID) sf) == -1) {
2227 Runtime_Error(pszSrcFile, __LINE__,
2228 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2229 free(sf);
2230 }
2231 }
2232 }
2233 }
2234 break;
2235
2236 case COMP_SETDIRS:
2237 cmp = INSTDATA(hwnd);
2238 if (cmp) {
2239
2240 WALK2 wa;
2241
2242 memset(&wa, 0, sizeof(wa));
2243 wa.size = sizeof(wa);
2244 strcpy(wa.szCurrentPath1, cmp->leftdir);
2245 strcpy(wa.szCurrentPath2, cmp->rightdir);
2246 if (WinDlgBox(HWND_DESKTOP, hwnd, WalkTwoCmpDlgProc,
2247 FM3ModHandle, WALK2_FRAME,
2248 MPFROMP(&wa)) &&
2249 !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
2250 strcpy(cmp->leftdir, wa.szCurrentPath1);
2251 strcpy(cmp->rightdir, wa.szCurrentPath2);
2252 *cmp->rightlist = 0;
2253 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
2254 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
2255 }
2256 }
2257 break;
2258
2259 case COMP_COPYLEFT:
2260 case COMP_MOVELEFT:
2261 case COMP_COPYRIGHT:
2262 case COMP_MOVERIGHT:
2263 case COMP_DELETELEFT:
2264 case COMP_DELETERIGHT:
2265 cmp = INSTDATA(hwnd);
2266 if (cmp) {
2267
2268 COMPARE *forthread;
2269
2270 cmp->filling = TRUE;
2271 forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
2272 if (forthread) {
2273 *forthread = *cmp;
2274 forthread->cmp = cmp;
2275 forthread->action = SHORT1FROMMP(mp1);
2276 if (_beginthread(ActionCnrThread, NULL, 122880, (PVOID) forthread)
2277 == -1) {
2278 Runtime_Error(pszSrcFile, __LINE__,
2279 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2280 free(forthread);
2281 }
2282 else {
2283 WinEnableWindowUpdate(hwndLeft, FALSE);
2284 WinEnableWindowUpdate(hwndRight, FALSE);
2285 switch (SHORT1FROMMP(mp1)) {
2286 case COMP_DELETELEFT:
2287 case COMP_DELETERIGHT:
2288 WinSetDlgItemText(hwnd, COMP_NOTE,
2289 GetPString(IDS_COMPHOLDDELETINGTEXT));
2290 break;
2291 case COMP_MOVELEFT:
2292 case COMP_MOVERIGHT:
2293 WinSetDlgItemText(hwnd, COMP_NOTE,
2294 GetPString(IDS_COMPHOLDMOVINGTEXT));
2295 break;
2296 case COMP_COPYLEFT:
2297 case COMP_COPYRIGHT:
2298 WinSetDlgItemText(hwnd, COMP_NOTE,
2299 GetPString(IDS_COMPHOLDCOPYINGTEXT));
2300 break;
2301 default:
2302 WinSetDlgItemText(hwnd, COMP_NOTE,
2303 GetPString(IDS_COMPHOLDDUNNOTEXT));
2304 break;
2305 }
2306 WinEnableWindow(hwndRight, FALSE);
2307 WinEnableWindow(hwndLeft, FALSE);
2308 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
2309 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
2310 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
2311 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
2312 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
2313 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
2314 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
2315 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
2316 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
2317 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
2318 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
2319 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
2320 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
2321 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
2322 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER),
2323 FALSE);
2324 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
2325 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS),
2326 FALSE);
2327 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
2328 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
2329 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
2330 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
2331 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
2332 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
2333 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
2334 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
2335 FALSE);
2336 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL),
2337 FALSE);
2338 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
2339 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
2340 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
2341 }
2342 }
2343 }
2344 break;
2345
2346 case DID_OK:
2347 WinDismissDlg(hwnd, 0);
2348 break;
2349 case DID_CANCEL:
2350 WinDismissDlg(hwnd, 1);
2351 break;
2352
2353 case IDM_HELP:
2354 if (hwndHelp)
2355 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
2356 MPFROM2SHORT(HELP_COMPARE, 0), MPFROMSHORT(HM_RESOURCEID));
2357 break;
2358
2359 case IDM_DESELECTALL:
2360 case IDM_SELECTNEWER:
2361 case IDM_SELECTOLDER:
2362 case IDM_SELECTBIGGER:
2363 case IDM_SELECTSMALLER:
2364 case IDM_DESELECTNEWER:
2365 case IDM_DESELECTOLDER:
2366 case IDM_DESELECTBIGGER:
2367 case IDM_DESELECTSMALLER:
2368 case IDM_DESELECTONE:
2369 case IDM_DESELECTBOTH:
2370 case IDM_SELECTBOTH:
2371 case IDM_SELECTONE:
2372 case IDM_SELECTSAMECONTENT:
2373 case IDM_SELECTIDENTICAL: // name, size and time
2374 case IDM_SELECTSAME: // name and size
2375 case IDM_INVERT:
2376 cmp = INSTDATA(hwnd);
2377 if (!cmp)
2378 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2379 else {
2380 COMPARE *forthread;
2381
2382 cmp->filling = TRUE;
2383 forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
2384 if (forthread) {
2385 *forthread = *cmp;
2386 forthread->cmp = cmp;
2387 forthread->action = SHORT1FROMMP(mp1);
2388 if (_beginthread(SelectCnrsThread, NULL, 65536, (PVOID) forthread)
2389 == -1) {
2390 Runtime_Error(pszSrcFile, __LINE__,
2391 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2392 free(forthread);
2393 }
2394 else {
2395 WinEnableWindowUpdate(hwndLeft, FALSE);
2396 WinEnableWindowUpdate(hwndRight, FALSE);
2397 switch (SHORT1FROMMP(mp1)) {
2398 case IDM_DESELECTALL:
2399 case IDM_DESELECTNEWER:
2400 case IDM_DESELECTOLDER:
2401 case IDM_DESELECTBIGGER:
2402 case IDM_DESELECTSMALLER:
2403 case IDM_DESELECTONE:
2404 case IDM_DESELECTBOTH:
2405 WinSetDlgItemText(hwnd, COMP_NOTE,
2406 GetPString(IDS_COMPHOLDDESELTEXT));
2407 break;
2408 case IDM_INVERT:
2409 WinSetDlgItemText(hwnd, COMP_NOTE,
2410 GetPString(IDS_COMPHOLDINVERTTEXT));
2411 break;
2412 default:
2413 WinSetDlgItemText(hwnd, COMP_NOTE,
2414 GetPString(IDS_COMPHOLDSELTEXT));
2415 break;
2416 }
2417 WinEnableWindow(hwndRight, FALSE);
2418 WinEnableWindow(hwndLeft, FALSE);
2419 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
2420 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
2421 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
2422 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
2423 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
2424 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
2425 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
2426 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
2427 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
2428 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
2429 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
2430 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
2431 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
2432 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
2433 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER),
2434 FALSE);
2435 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
2436 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS),
2437 FALSE);
2438 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
2439 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
2440 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
2441 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
2442 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
2443 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
2444 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
2445 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
2446 FALSE);
2447 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL),
2448 FALSE);
2449 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
2450 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
2451 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
2452 }
2453 }
2454 }
2455 break;
2456
2457 case COMP_COLLECT:
2458 cmp = INSTDATA(hwnd);
2459 if (cmp) {
2460
2461 CHAR **listl, **listr = NULL;
2462
2463 if (!Collector) {
2464
2465 SWP swp;
2466 HWND hwndC;
2467
2468 if (!fAutoTile && !ParentIsDesktop(hwnd, cmp->hwndParent) &&
2469 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2470 GetNextWindowPos(cmp->hwndParent, &swp, NULL, NULL);
2471 hwndC = StartCollector((fExternalCollector ||
2472 strcmp(realappname, FM3Str)) ?
2473 HWND_DESKTOP : cmp->hwndParent, 4);
2474 if (hwndC) {
2475 if (!fAutoTile && !ParentIsDesktop(hwnd, cmp->hwndParent) &&
2476 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2477 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2478 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2479 SWP_SHOW | SWP_ZORDER);
2480 else if (!ParentIsDesktop(hwnd, cmp->hwndParent) && fAutoTile &&
2481 !strcmp(realappname, FM3Str))
2482 TileChildren(cmp->hwndParent, TRUE);
2483 DosSleep(64L);
2484 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
2485 break;
2486 }
2487 }
2488 else
2489 StartCollector(cmp->hwndParent, 4);
2490 {
2491 BOOL temp;
2492
2493 temp = fSelectedAlways;
2494 fSelectedAlways = TRUE;
2495 listl = BuildList(hwndLeft);
2496 if (!*cmp->rightlist)
2497 listr = BuildList(hwndRight);
2498 fSelectedAlways = temp;
2499 }
2500 if (listl || listr) {
2501 if (Collector) {
2502 if (listl) {
2503 if (!PostMsg(Collector, WM_COMMAND,
2504 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listl)))
2505 FreeList(listl);
2506 }
2507 if (listr) {
2508 if (!PostMsg(Collector, WM_COMMAND,
2509 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listr)))
2510 FreeList(listr);
2511 }
2512 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2513 QW_PARENT),
2514 QW_PARENT), HWND_TOP, 0, 0, 0, 0,
2515 SWP_ACTIVATE);
2516 }
2517 else {
2518 FreeList(listl);
2519 FreeList(listr);
2520 }
2521 }
2522 }
2523 break;
2524 }
2525 return 0;
2526
2527 case WM_CLOSE:
2528 WinDismissDlg(hwnd, 0);
2529 return 0;
2530
2531 case WM_DESTROY:
2532 cmp = INSTDATA(hwnd);
2533 if (cmp) {
2534 if (cmp->dcd.hwndLastMenu)
2535 WinDestroyWindow(cmp->dcd.hwndLastMenu);
2536 if (cmp->dcd.hwndObject) {
2537 WinSetWindowPtr(cmp->dcd.hwndObject, QWL_USER, (PVOID) NULL);
2538 if (!PostMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID))
2539 WinSendMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID);
2540 }
2541 free(cmp);
2542 }
2543 EmptyCnr(hwndLeft);
2544 EmptyCnr(hwndRight);
2545 DosPostEventSem(CompactSem);
2546 break;
2547 }
2548 return WinDefDlgProc(hwnd, msg, mp1, mp2);
2549}
Note: See TracBrowser for help on using the repository browser.