source: trunk/dll/comp.c@ 897

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

Use CommaFmtULL for additional file, EA etc sizes display; Modify/Create TestFDates & TestCDates for comparing/sorting files or CNRITEMS by date/time.

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