source: trunk/dll/comp.c@ 907

Last change on this file since 907 was 907, checked in by Steven Levine, 18 years ago

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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