source: trunk/dll/comp.c@ 917

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

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 78.2 KB
Line 
1
2/***********************************************************************
3
4 $Id: comp.c 917 2008-01-11 21:41:56Z 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; // 08 Jan 08 SHL fixme
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 = 0;
917 cmp->cmp->totalright = 0;
918
919 // Build list of all files in left directory
920 if (fForceLower)
921 strlwr(cmp->leftdir);
922 else if (fForceUpper)
923 strupr(cmp->leftdir);
924 FillDirList(cmp->leftdir, lenl, cmp->includesubdirs,
925 &filesl, &cmp->cmp->totalleft, &numallocl);
926 // numfilesl = cmp->cmp->totalleft; // 08 Jan 08 SHL fixme
927
928 if (filesl)
929 qsort(filesl, cmp->cmp->totalleft, sizeof(CHAR *), CompNames);
930
931 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesl");
932
933 // Build list of all files in right directory
934 if (!*cmp->rightlist) {
935 if (fForceLower)
936 strlwr(cmp->rightdir);
937 else if (fForceUpper)
938 strupr(cmp->rightdir);
939 FillDirList(cmp->rightdir, lenr, cmp->includesubdirs,
940 &filesr, &cmp->cmp->totalright, &numallocr);
941 // numfilesr = cmp->cmp->totalright;
942 }
943 else {
944 // Use snapshot file
945 FILE *fp;
946 FILEFINDBUF4L fb4;
947 CHAR str[CCHMAXPATH * 2], *p;
948
949 memset(&fb4, 0, sizeof(fb4));
950 fp = fopen(cmp->rightlist, "r");
951 if (!fp)
952 Runtime_Error(pszSrcFile, __LINE__, "can not open %s (%d)",
953 cmp->rightlist, errno);
954 else {
955 while (!feof(fp)) {
956 // First get name of directory
957 if (!xfgets_bstripcr(str, sizeof(str), fp, pszSrcFile, __LINE__))
958 break; // EOF
959 p = str;
960 if (*p == '\"') {
961 // Quoted
962 p++;
963 if (*p && *p != '\"') {
964 p = strchr(p, '\"');
965 if (p) {
966 *p = 0;
967 if (*(str + 1)) {
968 strcpy(cmp->rightdir, str + 1);
969 if (fForceUpper)
970 strupr(cmp->rightdir);
971 else if (fForceLower)
972 strlwr(cmp->rightdir);
973 p = cmp->rightdir + (strlen(cmp->rightdir) - 1);
974 if (p - cmp->rightdir > 3 && *p == '\\')
975 *p = 0; // Chop trailing slash
976 break;
977 }
978 }
979 }
980 }
981 } // while !EOF
982
983 memset(&cnri, 0, sizeof(cnri));
984 cnri.cb = sizeof(cnri);
985 cnri.pszCnrTitle = cmp->rightdir;
986 if (!WinSendMsg(hwndRight, CM_SETCNRINFO,
987 MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE))) {
988 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_SETCNRINFO");
989 }
990
991 if (*cmp->rightdir) {
992 lenr = strlen(cmp->rightdir);
993 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
994 lenr++;
995 while (!feof(fp)) {
996 if (!xfgets_bstripcr
997 (str, sizeof(str), fp, pszSrcFile, __LINE__))
998 break;
999 p = str;
1000 if (*p == '\"') {
1001 p++;
1002 if (*p && *p != '\"') {
1003 p = strchr(p, '\"');
1004 if (p) {
1005 *p = 0;
1006 p++;
1007 if (*p == ',') {
1008 p++;
1009 if (!cmp->includesubdirs && atol(p) > lenr)
1010 continue;
1011 p = strchr(p, ',');
1012 if (p) {
1013 p++;
1014 // 27 Sep 07 SHL fixme to do ULONGLONG conversion
1015 fb4.cbFile = atol(p);
1016 p = strchr(p, ',');
1017 if (p) {
1018 p++;
1019 fb4.fdateLastWrite.year = atol(p) - 1980;
1020 p = strchr(p, '/');
1021 if (p) {
1022 p++;
1023 fb4.fdateLastWrite.month = atol(p);
1024 p = strchr(p, '/');
1025 if (p) {
1026 p++;
1027 fb4.fdateLastWrite.day = atol(p);
1028 p = strchr(p, ',');
1029 if (p) {
1030 p++;
1031 fb4.ftimeLastWrite.hours = atol(p);
1032 p = strchr(p, ':');
1033 if (p) {
1034 p++;
1035 fb4.ftimeLastWrite.minutes = atol(p);
1036 p = strchr(p, ':');
1037 if (p) {
1038 p++;
1039 fb4.ftimeLastWrite.twosecs = atol(p);
1040 p = strchr(p, ',');
1041 if (p) {
1042 p++;
1043 fb4.attrFile = atol(p);
1044 p = strchr(p, ',');
1045 if (p) {
1046 p++;
1047 fb4.cbList = atol(p) * 2;
1048 if (fForceUpper)
1049 strupr(str + 1);
1050 else if (fForceLower)
1051 strlwr(str + 1);
1052 if (AddToFileList((str + 1) + lenr,
1053 &fb4,
1054 &filesr,
1055 &cmp->cmp->totalright,
1056 &numallocr))
1057 break;
1058 }
1059 }
1060 }
1061 }
1062 }
1063 }
1064 }
1065 }
1066 }
1067 }
1068 }
1069 }
1070 }
1071 } // while
1072 } // if have rightdir
1073 fclose(fp);
1074 }
1075 } // if snapshot file
1076
1077 if (filesr)
1078 qsort(filesr, cmp->cmp->totalright, sizeof(CHAR *), CompNames);
1079
1080 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesr");
1081
1082 // We now have two lists of files, both sorted.
1083 // Count total number of container entries required on each side
1084 l = r = 0;
1085 recsNeeded = 0;
1086 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
1087
1088 if (filesl && filesl[l]) {
1089 if (filesr && filesr[r])
1090 x = stricmp(filesl[l]->fname, filesr[r]->fname);
1091 else
1092 x = -1; // Left side list longer
1093 }
1094 else
1095 x = +1; // Right side list longer
1096
1097 if (x <= 0)
1098 l++; // On left side
1099 if (x >= 0)
1100 r++; // On right side
1101
1102 recsNeeded++; // Keep count of how many entries req'd
1103
1104 } // while
1105
1106 // Say building list - fixme to post?
1107 WinSendMsg(cmp->hwnd, UM_CONTAINERHWND, MPVOID, MPVOID);
1108
1109 // Now insert records into the containers
1110 cntr = 0;
1111 l = r = 0;
1112 if (recsNeeded) {
1113 pcilFirst = WinSendMsg(hwndLeft,
1114 CM_ALLOCRECORD,
1115 MPFROMLONG(EXTRA_RECORD_BYTES),
1116 MPFROMLONG(recsNeeded));
1117 if (!pcilFirst) {
1118 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1119 recsNeeded);
1120 recsNeeded = 0;
1121 }
1122 }
1123 if (recsNeeded) {
1124 pcirFirst = WinSendMsg(hwndRight, CM_ALLOCRECORD,
1125 MPFROMLONG(EXTRA_RECORD_BYTES),
1126 MPFROMLONG(recsNeeded));
1127 if (!pcirFirst) {
1128 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1129 recsNeeded);
1130 recsNeeded = 0;
1131 FreeCnrItemList(hwndLeft, pcilFirst);
1132 }
1133 }
1134
1135 if (recsNeeded) {
1136
1137 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filling");
1138
1139 pcil = pcilFirst;
1140 pcir = pcirFirst;
1141 pcilLast = 0;
1142 pcirLast = 0;
1143
1144 recsGotten = 0;
1145 filesSeenL = 0;
1146 filesSeenR = 0;
1147
1148 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
1149
1150 // 03 Jan 08 SHL fixme to have user friendly message
1151 if (!pcil) {
1152 Runtime_Error(pszSrcFile, __LINE__, "pcil short %u/%u",
1153 recsGotten, recsNeeded);
1154 break;
1155 }
1156
1157 // 03 Jan 08 SHL fixme to have user friendly message
1158 if (!pcir) {
1159 Runtime_Error(pszSrcFile, __LINE__, "pcir short %u/%u",
1160 recsGotten, recsNeeded);
1161 break;
1162 }
1163 recsGotten++;
1164 pcir->hwndCnr = hwndRight;
1165 pcir->rc.hptrIcon = (HPOINTER) 0;
1166 pcil->hwndCnr = hwndLeft;
1167 pcil->rc.hptrIcon = (HPOINTER) 0;
1168
1169 if (filesl && filesl[l]) {
1170 if (filesr && filesr[r])
1171 x = stricmp(filesl[l]->fname, filesr[r]->fname);
1172 else
1173 x = -1; // Left side list longer
1174 }
1175 else
1176 x = +1; // Right side list longer
1177
1178 if (x <= 0) {
1179 // File appears on left side
1180 filesSeenL++;
1181 cmp->cmp->totalleft = filesSeenL;
1182 BldFullPathName(szBuf, cmp->leftdir, filesl[l]->fname);
1183 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
1184 pcil->pszDisplayName = pcil->pszFileName + lenl;
1185 pcil->attrFile = filesl[l]->attrFile;
1186 pcil->pszDispAttr = FileAttrToString(pcil->attrFile);
1187 pcil->cbFile = filesl[l]->cbFile;
1188 pcil->easize = filesl[l]->easize;
1189 pcil->date.day = filesl[l]->date.day;
1190 pcil->date.month = filesl[l]->date.month;
1191 pcil->date.year = filesl[l]->date.year + 1980;
1192 pcil->time.seconds = filesl[l]->time.twosecs * 2;
1193 pcil->time.minutes = filesl[l]->time.minutes;
1194 pcil->time.hours = filesl[l]->time.hours;
1195 pcil->ladate.day = filesl[l]->ladate.day;
1196 pcil->ladate.month = filesl[l]->ladate.month;
1197 pcil->ladate.year = filesl[l]->ladate.year + 1980;
1198 pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
1199 pcil->latime.minutes = filesl[l]->latime.minutes;
1200 pcil->latime.hours = filesl[l]->latime.hours;
1201 pcil->crdate.day = filesl[l]->crdate.day;
1202 pcil->crdate.month = filesl[l]->crdate.month;
1203 pcil->crdate.year = filesl[l]->crdate.year + 1980;
1204 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
1205 pcil->crtime.minutes = filesl[l]->crtime.minutes;
1206 pcil->crtime.hours = filesl[l]->crtime.hours;
1207 if (*cmp->dcd.mask.szMask) {
1208 if (!Filter((PMINIRECORDCORE) pcil, (PVOID)&cmp->dcd.mask)) {
1209 pcil->rc.flRecordAttr |= CRA_FILTERED;
1210 pcir->rc.flRecordAttr |= CRA_FILTERED;
1211 }
1212 }
1213 } // if on left
1214
1215 if (x >= 0) {
1216 // File appears on right side
1217 filesSeenR++;
1218 cmp->cmp->totalright = filesSeenR;
1219 BldFullPathName(szBuf, cmp->rightdir, filesr[r]->fname);
1220 pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL
1221 pcir->pszDisplayName = pcir->pszFileName + lenr;
1222 pcir->attrFile = filesr[r]->attrFile;
1223 // pcir->rc.hptrIcon = hptrFile;
1224 pcir->pszDispAttr = FileAttrToString(pcir->attrFile);
1225 pcir->cbFile = filesr[r]->cbFile;
1226 pcir->easize = filesr[r]->easize;
1227 pcir->date.day = filesr[r]->date.day;
1228 pcir->date.month = filesr[r]->date.month;
1229 pcir->date.year = filesr[r]->date.year + 1980;
1230 pcir->time.seconds = filesr[r]->time.twosecs * 2;
1231 pcir->time.minutes = filesr[r]->time.minutes;
1232 pcir->time.hours = filesr[r]->time.hours;
1233 pcir->ladate.day = filesr[r]->ladate.day;
1234 pcir->ladate.month = filesr[r]->ladate.month;
1235 pcir->ladate.year = filesr[r]->ladate.year + 1980;
1236 pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
1237 pcir->latime.minutes = filesr[r]->latime.minutes;
1238 pcir->latime.hours = filesr[r]->latime.hours;
1239 pcir->crdate.day = filesr[r]->crdate.day;
1240 pcir->crdate.month = filesr[r]->crdate.month;
1241 pcir->crdate.year = filesr[r]->crdate.year + 1980;
1242 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
1243 pcir->crtime.minutes = filesr[r]->crtime.minutes;
1244 pcir->crtime.hours = filesr[r]->crtime.hours;
1245 // Bypass check if already filtered on left side
1246 if (~pcir->rc.flRecordAttr & CRA_FILTERED &&
1247 *cmp->dcd.mask.szMask) {
1248 if (!Filter((PMINIRECORDCORE)pcir, (PVOID)&cmp->dcd.mask)) {
1249 pcil->rc.flRecordAttr |= CRA_FILTERED;
1250 pcir->rc.flRecordAttr |= CRA_FILTERED;
1251 }
1252 }
1253 } // if on right
1254
1255 if (x == 0) {
1256 // File appears on both sides
1257 pcil->flags |= CNRITEM_EXISTS;
1258 pcir->flags |= CNRITEM_EXISTS;
1259 pch = szBuf;
1260 // Subject field holds status messages
1261 *pch = 0;
1262 if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) {
1263 pcil->flags |= CNRITEM_LARGER;
1264 pcir->flags |= CNRITEM_SMALLER;
1265 strcpy(pch, GetPString(IDS_LARGERTEXT));
1266 pch += 6;
1267 }
1268 else if (pcil->cbFile + pcil->easize <
1269 pcir->cbFile + pcir->easize) {
1270 pcil->flags |= CNRITEM_SMALLER;
1271 pcir->flags |= CNRITEM_LARGER;
1272 strcpy(pch, GetPString(IDS_SMALLERTEXT));
1273 pch += 7;
1274 }
1275 ret = TestCDates(&pcir->date, &pcir->time,
1276 &pcil->date, &pcil->time);
1277 if (ret == 1)
1278 /*((pcil->date.year > pcir->date.year) ? TRUE :
1279 (pcil->date.year < pcir->date.year) ? FALSE :
1280 (pcil->date.month > pcir->date.month) ? TRUE :
1281 (pcil->date.month < pcir->date.month) ? FALSE :
1282 (pcil->date.day > pcir->date.day) ? TRUE :
1283 (pcil->date.day < pcir->date.day) ? FALSE :
1284 (pcil->time.hours > pcir->time.hours) ? TRUE :
1285 (pcil->time.hours < pcir->time.hours) ? FALSE :
1286 (pcil->time.minutes > pcir->time.minutes) ? TRUE :
1287 (pcil->time.minutes < pcir->time.minutes) ? FALSE :
1288 (pcil->time.seconds > pcir->time.seconds) ? TRUE :
1289 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE)*/ {
1290 pcil->flags |= CNRITEM_NEWER;
1291 pcir->flags |= CNRITEM_OLDER;
1292 if (pch != szBuf) {
1293 strcpy(pch, ", ");
1294 pch += 2;
1295 }
1296 strcpy(pch, GetPString(IDS_NEWERTEXT));
1297 pch += 5;
1298 }
1299 else if (ret == -1)
1300 /*((pcil->date.year < pcir->date.year) ? TRUE :
1301 (pcil->date.year > pcir->date.year) ? FALSE :
1302 (pcil->date.month < pcir->date.month) ? TRUE :
1303 (pcil->date.month > pcir->date.month) ? FALSE :
1304 (pcil->date.day < pcir->date.day) ? TRUE :
1305 (pcil->date.day > pcir->date.day) ? FALSE :
1306 (pcil->time.hours < pcir->time.hours) ? TRUE :
1307 (pcil->time.hours > pcir->time.hours) ? FALSE :
1308 (pcil->time.minutes < pcir->time.minutes) ? TRUE :
1309 (pcil->time.minutes > pcir->time.minutes) ? FALSE :
1310 (pcil->time.seconds < pcir->time.seconds) ? TRUE :
1311 (pcil->time.seconds > pcir->time.seconds) ? FALSE :
1312 FALSE)*/ {
1313 pcil->flags |= CNRITEM_OLDER;
1314 pcir->flags |= CNRITEM_NEWER;
1315 if (pch != szBuf) {
1316 strcpy(pch, ", ");
1317 pch += 2;
1318 }
1319 strcpy(pch, GetPString(IDS_OLDERTEXT));
1320 pch += 5;
1321 }
1322 pcil->pszSubject = *szBuf ?
1323 xstrdup(szBuf, pszSrcFile, __LINE__) :
1324 NullStr;
1325
1326 } // if on both sides
1327
1328 if (x <= 0) {
1329 free(filesl[l]);
1330 l++;
1331 }
1332
1333 if (x >= 0) {
1334 free(filesr[r]);
1335 r++;
1336 }
1337
1338 // Ensure empty buffers point somewhere
1339 if (!pcil->pszFileName) {
1340 pcil->pszFileName = NullStr;
1341 pcil->pszDisplayName = pcil->pszFileName;
1342 }
1343
1344 if (!pcir->pszFileName) {
1345 pcir->pszFileName = NullStr;
1346 pcir->pszDisplayName = pcir->pszFileName;
1347 }
1348
1349 pcil->rc.pszIcon = pcil->pszDisplayName;
1350 pcir->rc.pszIcon = pcir->pszDisplayName;
1351
1352 pcil->pszLongName = NullStr;
1353 pcir->pszLongName = NullStr;
1354
1355 if (!pcil->pszSubject)
1356 pcil->pszSubject = NullStr;
1357 if (!pcir->pszSubject)
1358 pcir->pszSubject = NullStr;
1359
1360 if (!pcil->pszDispAttr)
1361 pcil->pszDispAttr = NullStr;
1362 if (!pcir->pszDispAttr)
1363 pcir->pszDispAttr = NullStr;
1364
1365 // Avoid hogging systems
1366 SleepIfNeeded(&itdSleep, 0);
1367
1368 pcilLast = pcil;
1369 pcirLast = pcir;
1370 pcil = (PCNRITEM) pcil->rc.preccNextRecord;
1371 pcir = (PCNRITEM) pcir->rc.preccNextRecord;
1372
1373 } // while filling left or right
1374
1375 // If stopped early CM_ALLOCATERECORD partially failed
1376 // Free up container records we did not use on other side
1377 // Free up filesl/filer entries we skipped
1378 if (recsGotten < recsNeeded) {
1379 if (pcil) {
1380 pcilLast->rc.preccNextRecord = NULL;
1381 FreeCnrItemList(hwndLeft, pcil);
1382 }
1383 if (filesl) {
1384 while (filesl[l]) {
1385 free(filesl[l]);
1386 l++;
1387 }
1388 }
1389 if (pcir) {
1390 pcirLast->rc.preccNextRecord = NULL;
1391 FreeCnrItemList(hwndRight, pcir);
1392 }
1393 if (filesr) {
1394 while (filesr[r]) {
1395 free(filesr[r]);
1396 r++;
1397 }
1398 }
1399 // Reduce count to match what is in containers
1400 recsNeeded = recsGotten;
1401 } // if insufficient resources
1402
1403 if (filesl)
1404 free(filesl); // Free header - have already freed elements
1405 filesl = NULL;
1406 if (filesr)
1407 free(filesr);
1408 filesr = NULL;
1409
1410 // Say inserting
1411 WinSendMsg(cmp->hwnd, UM_CONTAINERDIR, MPVOID, MPVOID);
1412
1413 // Insert left side
1414 memset(&ri, 0, sizeof(RECORDINSERT));
1415 ri.cb = sizeof(RECORDINSERT);
1416 ri.pRecordOrder = (PRECORDCORE) CMA_END;
1417 ri.pRecordParent = (PRECORDCORE) NULL;
1418 ri.zOrder = (ULONG) CMA_TOP;
1419 ri.cRecordsInsert = recsNeeded;
1420 ri.fInvalidateRecord = FALSE;
1421 if (!WinSendMsg(hwndLeft, CM_INSERTRECORD,
1422 MPFROMP(pcilFirst), MPFROMP(&ri))) {
1423 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
1424 FreeCnrItemList(hwndLeft, pcilFirst);
1425 // numfilesl = 0; // 08 Jan 08 SHL fixme
1426 cmp->cmp->totalleft = 0;
1427 }
1428
1429 // Insert right side
1430 memset(&ri, 0, sizeof(RECORDINSERT));
1431 ri.cb = sizeof(RECORDINSERT);
1432 ri.pRecordOrder = (PRECORDCORE) CMA_END;
1433 ri.pRecordParent = (PRECORDCORE) NULL;
1434 ri.zOrder = (ULONG) CMA_TOP;
1435 ri.cRecordsInsert = recsNeeded;
1436 ri.fInvalidateRecord = FALSE;
1437
1438 if (!WinSendMsg(hwndRight, CM_INSERTRECORD,
1439 MPFROMP(pcirFirst), MPFROMP(&ri))) {
1440 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
1441 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1442 FreeCnrItemList(hwndRight, pcirFirst);
1443 // numfilesr = 0;
1444 cmp->cmp->totalright = 0;
1445 }
1446
1447 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filled");
1448
1449 } // if recsNeeded
1450
1451 WinStopTimer(hab, cmp->hwnd, ID_TIMER);
1452
1453 Deselect(hwndLeft);
1454 Deselect(hwndRight);
1455
1456 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread deselected");
1457
1458 // Request window update
1459 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID))
1460 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
1461 notified = TRUE;
1462
1463 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread FILLED posted");
1464
1465 if (filesl)
1466 FreeList((CHAR **)filesl); // Must have failed to create container
1467 if (filesr)
1468 FreeList((CHAR **)filesr);
1469
1470 WinDestroyMsgQueue(hmq);
1471 } // if have queue
1472 if (!notified)
1473 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
1474 DecrThreadUsage();
1475 WinTerminate(hab);
1476 }
1477 free(cmp);
1478 DosPostEventSem(CompactSem);
1479
1480 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread exit");
1481}
1482
1483// fixme to be gone - use variable
1484#define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR))
1485#define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
1486
1487//=== CompareDlgProc() Compare directories dialog procedure ===
1488
1489MRESULT EXPENTRY CompareDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1490{
1491 COMPARE *cmp;
1492 BOOL temp;
1493 CHAR s[81];
1494
1495 static HPOINTER hptr;
1496
1497 switch (msg) {
1498 case WM_INITDLG:
1499 cmp = (COMPARE *) mp2;
1500 if (!cmp) {
1501 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1502 WinDismissDlg(hwnd, 0);
1503 }
1504 else {
1505 if (!hptr)
1506 hptr = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, COMPARE_ICON);
1507 WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptr), MPVOID);
1508 cmp->hwnd = hwnd;
1509 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) cmp);
1510 SetCnrCols(hwndLeft, TRUE);
1511 SetCnrCols(hwndRight, TRUE);
1512 WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
1513 WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
1514 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
1515 {
1516 USHORT ids[] = { COMP_LEFTDIR, COMP_RIGHTDIR, COMP_TOTALLEFT,
1517 COMP_TOTALRIGHT, COMP_SELLEFT, COMP_SELRIGHT,
1518 0
1519 };
1520 INT x;
1521
1522 for (x = 0; ids[x]; x++)
1523 SetPresParams(WinWindowFromID(hwnd, ids[x]),
1524 &RGBGREY,
1525 &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT));
1526 }
1527 }
1528 break;
1529
1530 case UM_STRETCH:
1531 {
1532 SWP swp, swpC;
1533 LONG titl, szbx, szby, sz;
1534 HWND hwndActive;
1535
1536 WinQueryWindowPos(hwnd, &swp);
1537 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
1538 hwndActive = WinQueryFocus(HWND_DESKTOP);
1539 szbx = SysVal(SV_CXSIZEBORDER);
1540 szby = SysVal(SV_CYSIZEBORDER);
1541 titl = SysVal(SV_CYTITLEBAR);
1542 titl += 26;
1543 swp.cx -= (szbx * 2);
1544 sz = (swp.cx / 8);
1545 WinQueryWindowPos(WinWindowFromID(hwnd, COMP_LEFTDIR), &swpC);
1546 WinSetWindowPos(WinWindowFromID(hwnd, COMP_LEFTDIR), HWND_TOP,
1547 szbx + 6,
1548 swpC.y,
1549 (swp.cx / 2) - (szbx + 6),
1550 ((swp.cy - swpC.y) - titl) - szby,
1551 SWP_MOVE | SWP_SIZE);
1552 WinSetWindowPos(WinWindowFromID(hwnd, COMP_RIGHTDIR), HWND_TOP,
1553 (swp.cx / 2) + (szbx + 6),
1554 swpC.y,
1555 (swp.cx / 2) - (szbx + 6),
1556 ((swp.cy - swpC.y) - titl) - szby,
1557 SWP_MOVE | SWP_SIZE);
1558 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALLEFTHDR), HWND_TOP,
1559 szbx + 6,
1560 ((swp.cy - titl) - szby) + 4,
1561 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1562 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALLEFT), HWND_TOP,
1563 sz + (szbx + 6),
1564 ((swp.cy - titl) - szby) + 4,
1565 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1566 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELLEFTHDR), HWND_TOP,
1567 (sz * 2) + (szbx + 6),
1568 ((swp.cy - titl) - szby) + 4,
1569 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1570 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELLEFT), HWND_TOP,
1571 (sz * 3) + (szbx + 6),
1572 ((swp.cy - titl) - szby) + 4,
1573 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1574 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALRIGHTHDR), HWND_TOP,
1575 (sz * 4) + (szbx + 6),
1576 ((swp.cy - titl) - szby) + 4,
1577 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1578 WinSetWindowPos(WinWindowFromID(hwnd, COMP_TOTALRIGHT), HWND_TOP,
1579 (sz * 5) + (szbx + 6),
1580 ((swp.cy - titl) - szby) + 4,
1581 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1582 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELRIGHTHDR), HWND_TOP,
1583 (sz * 6) + (szbx + 6),
1584 ((swp.cy - titl) - szby) + 4,
1585 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1586 WinSetWindowPos(WinWindowFromID(hwnd, COMP_SELRIGHT), HWND_TOP,
1587 (sz * 7) + (szbx + 6),
1588 ((swp.cy - titl) - szby) + 4,
1589 sz - (szbx + 6), 20, SWP_MOVE | SWP_SIZE);
1590 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_TOTALLEFT),
1591 (HPS) 0, FALSE, FALSE);
1592 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_SELLEFT),
1593 (HPS) 0, FALSE, FALSE);
1594 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_TOTALRIGHT),
1595 (HPS) 0, FALSE, FALSE);
1596 PaintRecessedWindow(WinWindowFromID(hwnd, COMP_SELRIGHT),
1597 (HPS) 0, FALSE, FALSE);
1598 PaintRecessedWindow(hwndLeft, (HPS) 0,
1599 (hwndActive == hwndLeft), TRUE);
1600 PaintRecessedWindow(hwndRight, (HPS) 0,
1601 (hwndActive == hwndRight), TRUE);
1602 }
1603 }
1604 return 0;
1605
1606 case WM_ADJUSTWINDOWPOS:
1607 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
1608 break;
1609
1610 case UM_SETUP:
1611 {
1612 CNRINFO cnri;
1613 BOOL tempsubj;
1614
1615 cmp = INSTDATA(hwnd);
1616 if (cmp) {
1617 cmp->dcd.size = sizeof(DIRCNRDATA);
1618 cmp->dcd.type = DIR_FRAME;
1619 cmp->dcd.hwndFrame = hwnd;
1620 cmp->dcd.hwndClient = hwnd;
1621 cmp->dcd.mask.attrFile = (FILE_DIRECTORY | FILE_ARCHIVED |
1622 FILE_READONLY | FILE_SYSTEM | FILE_HIDDEN);
1623 LoadDetailsSwitches("DirCmp", &cmp->dcd);
1624 cmp->dcd.detailslongname = FALSE;
1625 cmp->dcd.detailsicon = FALSE; // TRUE;
1626 }
1627 memset(&cnri, 0, sizeof(CNRINFO));
1628 cnri.cb = sizeof(CNRINFO);
1629 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_QUERYCNRINFO,
1630 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1631 cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
1632 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 68;
1633 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1634 MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
1635 memset(&cnri, 0, sizeof(CNRINFO));
1636 cnri.cb = sizeof(CNRINFO);
1637 WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_QUERYCNRINFO,
1638 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1639 cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
1640 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 54;
1641 WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1642 MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
1643 AdjustCnrColRO(hwndLeft, GetPString(IDS_FILENAMECOLTEXT), TRUE, FALSE);
1644 AdjustCnrColRO(hwndLeft, GetPString(IDS_LONGNAMECOLTEXT), TRUE, FALSE);
1645 AdjustCnrColRO(hwndRight, GetPString(IDS_FILENAMECOLTEXT), TRUE, FALSE);
1646 AdjustCnrColRO(hwndRight, GetPString(IDS_LONGNAMECOLTEXT), TRUE, FALSE);
1647 AdjustCnrColsForPref(hwndLeft, cmp->leftdir, &cmp->dcd, TRUE);
1648 tempsubj = cmp->dcd.detailssubject;
1649 cmp->dcd.detailssubject = FALSE;
1650 AdjustCnrColsForPref(hwndRight, cmp->rightdir, &cmp->dcd, TRUE);
1651 if (*cmp->rightlist) {
1652 AdjustCnrColVis(hwndRight, GetPString(IDS_LADATECOLTEXT), FALSE,
1653 FALSE);
1654 AdjustCnrColVis(hwndRight, GetPString(IDS_LATIMECOLTEXT), FALSE,
1655 FALSE);
1656 AdjustCnrColVis(hwndRight, GetPString(IDS_CRDATECOLTEXT), FALSE,
1657 FALSE);
1658 AdjustCnrColVis(hwndRight, GetPString(IDS_CRTIMECOLTEXT), FALSE,
1659 FALSE);
1660 }
1661 cmp->dcd.detailssubject = tempsubj;
1662 }
1663 return 0;
1664
1665 case WM_DRAWITEM:
1666 if (mp2) {
1667 POWNERITEM pown = (POWNERITEM)mp2;
1668 PCNRDRAWITEMINFO pcown;
1669 PCNRITEM pci;
1670
1671 pcown = (PCNRDRAWITEMINFO)pown->hItem;
1672 if (pcown) {
1673 pci = (PCNRITEM) pcown->pRecord;
1674 // 01 Aug 07 SHL if field null or blank, we draw
1675 // fixme to know why - probably to optimize and bypass draw?
1676 if (pci && (INT)pci != -1 && !*pci->pszFileName)
1677 return MRFROMLONG(TRUE);
1678 }
1679 }
1680 return 0;
1681
1682 case UM_CONTAINERHWND:
1683 // Building list
1684 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDBLDLISTTEXT));
1685 return 0;
1686
1687 case UM_CONTAINERDIR:
1688 // Filling container
1689 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDFILLCNRTEXT));
1690 return 0;
1691
1692 case WM_TIMER:
1693 // Show current totals
1694 cmp = INSTDATA(hwnd);
1695 if (!cmp) {
1696 Runtime_Error(pszSrcFile, __LINE__, "pCompare NULL");
1697 WinDismissDlg(hwnd, 0);
1698 }
1699 else {
1700 // 05 Jan 08 SHL fixme to use timer id to optimize output
1701 sprintf(s, " %d", cmp->totalleft);
1702 WinSetDlgItemText(hwnd, COMP_TOTALLEFT, s);
1703 sprintf(s, " %d", cmp->totalright);
1704 WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, s);
1705 sprintf(s, " %d", cmp->selleft);
1706 WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
1707 sprintf(s, " %d", cmp->selright);
1708 WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
1709 }
1710 break;
1711
1712 case UM_CONTAINER_FILLED:
1713 cmp = INSTDATA(hwnd);
1714 if (!cmp) {
1715 Runtime_Error(pszSrcFile, __LINE__, "pCompare NULL");
1716 WinDismissDlg(hwnd, 0);
1717 }
1718 else {
1719
1720 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED enter");
1721
1722 cmp->filling = FALSE;
1723 WinEnableWindow(hwndLeft, TRUE);
1724 WinEnableWindow(hwndRight, TRUE);
1725 WinEnableWindowUpdate(hwndLeft, TRUE);
1726 WinEnableWindowUpdate(hwndRight, TRUE);
1727 sprintf(s, " %d", cmp->totalleft);
1728 WinSetDlgItemText(hwnd, COMP_TOTALLEFT, s);
1729 sprintf(s, " %d", cmp->totalright);
1730 WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, s);
1731 sprintf(s, " %d", cmp->selleft);
1732 WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
1733 sprintf(s, " %d", cmp->selright);
1734 WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
1735 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), TRUE);
1736 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), TRUE);
1737 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), TRUE);
1738 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), TRUE);
1739 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), TRUE);
1740 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), TRUE);
1741 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), TRUE);
1742 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), TRUE);
1743 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), TRUE);
1744 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), TRUE);
1745 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), TRUE);
1746 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), TRUE);
1747 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), TRUE);
1748 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), TRUE);
1749 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER), TRUE);
1750 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), TRUE);
1751 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT), TRUE);
1752 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL), TRUE);
1753 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), TRUE);
1754 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), TRUE);
1755 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), TRUE);
1756 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), TRUE);
1757 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), TRUE);
1758 if (!*cmp->rightlist) {
1759 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), TRUE);
1760 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), TRUE);
1761 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), TRUE);
1762 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), TRUE);
1763 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), TRUE);
1764 }
1765 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), TRUE);
1766 if (*cmp->dcd.mask.szMask)
1767 WinSetDlgItemText(hwnd, COMP_NOTE,
1768 GetPString(IDS_COMPREADYFILTEREDTEXT));
1769 else
1770 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
1771
1772 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED exit");
1773
1774 }
1775 break;
1776
1777 case WM_INITMENU:
1778 cmp = INSTDATA(hwnd);
1779 if (cmp) {
1780 switch (SHORT1FROMMP(mp1)) {
1781 case IDM_COMMANDSMENU:
1782 SetupCommandMenu(cmp->dcd.hwndLastMenu, hwnd);
1783 break;
1784 }
1785 }
1786 break;
1787
1788 case WM_MENUEND:
1789 cmp = INSTDATA(hwnd);
1790 if (cmp) {
1791 if ((HWND) mp2 == cmp->dcd.hwndLastMenu) {
1792 MarkAll(hwndLeft, TRUE, FALSE, TRUE);
1793 MarkAll(hwndRight, TRUE, FALSE, TRUE);
1794 WinDestroyWindow(cmp->dcd.hwndLastMenu);
1795 cmp->dcd.hwndLastMenu = (HWND) 0;
1796 }
1797 }
1798 break;
1799
1800 case WM_CONTROL:
1801 switch (SHORT1FROMMP(mp1)) {
1802 case COMP_INCLUDESUBDIRS:
1803 switch (SHORT2FROMMP(mp1)) {
1804 case BN_CLICKED:
1805 cmp = INSTDATA(hwnd);
1806 if (cmp)
1807 *cmp->rightlist = 0;
1808 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
1809 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
1810 break;
1811 }
1812 break;
1813 case COMP_HIDENOTSELECTED:
1814 switch (SHORT2FROMMP(mp1)) {
1815 case BN_CLICKED:
1816 WinSendMsg(hwnd, UM_HIDENOTSELECTED, MPVOID, MPVOID);
1817 break;
1818 }
1819 break;
1820
1821 case COMP_LEFTDIR:
1822 case COMP_RIGHTDIR:
1823 switch (SHORT2FROMMP(mp1)) {
1824 case CN_KILLFOCUS:
1825 PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1826 (HPS) 0, FALSE, TRUE);
1827 break;
1828
1829 case CN_SETFOCUS:
1830 PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1831 (HPS) 0, TRUE, TRUE);
1832 break;
1833
1834 case CN_ENTER:
1835 if (mp2) {
1836
1837 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1838 HWND hwndCnr = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
1839
1840 SetShiftState();
1841 if (pci) {
1842 if (pci->rc.flRecordAttr & CRA_INUSE || !pci || !*pci->pszFileName)
1843 break;
1844 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1845 MPFROM2SHORT(TRUE, CRA_INUSE));
1846 if (pci->attrFile & FILE_DIRECTORY) {
1847 if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT))
1848 OpenObject(pci->pszFileName, Settings, hwnd);
1849 else
1850 OpenObject(pci->pszFileName, Default, hwnd);
1851 }
1852 else
1853 DefaultViewKeys(hwnd, hwnd, HWND_DESKTOP, NULL,
1854 pci->pszFileName);
1855 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS,
1856 MPFROMP(pci),
1857 MPFROM2SHORT(FALSE, CRA_INUSE |
1858 ((fUnHilite) ? CRA_SELECTED : 0)));
1859 }
1860 }
1861 break;
1862
1863 case CN_CONTEXTMENU:
1864 cmp = INSTDATA(hwnd);
1865 if (cmp) {
1866
1867 PCNRITEM pci = (PCNRITEM) mp2;
1868 USHORT id = COMP_CNRMENU;
1869
1870 if (cmp->dcd.hwndLastMenu)
1871 WinDestroyWindow(cmp->dcd.hwndLastMenu);
1872 cmp->dcd.hwndLastMenu = (HWND) 0;
1873 cmp->hwndCalling = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
1874 if (pci) {
1875 if (!pci || !*pci->pszFileName || *cmp->rightlist)
1876 break;
1877 id = COMP_MENU;
1878 WinSendMsg(cmp->hwndCalling, CM_SETRECORDEMPHASIS,
1879 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
1880 }
1881 cmp->dcd.hwndLastMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
1882 if (cmp->dcd.hwndLastMenu) {
1883 if (id == COMP_CNRMENU) {
1884 if (SHORT1FROMMP(mp1) == COMP_RIGHTDIR)
1885 WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
1886 MPFROM2SHORT(IDM_SHOWSUBJECT, FALSE), MPVOID);
1887 SetDetailsSwitches(cmp->dcd.hwndLastMenu, &cmp->dcd);
1888 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
1889 WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
1890 MPFROM2SHORT(IDM_LOADLISTFILE, 0), MPVOID);
1891 else if (*cmp->rightlist)
1892 WinSendMsg(cmp->dcd.hwndLastMenu, MM_DELETEITEM,
1893 MPFROM2SHORT(IDM_SAVELISTFILE, 0), MPVOID);
1894 }
1895 PopupMenu(hwnd, hwnd, cmp->dcd.hwndLastMenu);
1896 }
1897 }
1898 break;
1899
1900 case CN_INITDRAG:
1901 cmp = INSTDATA(hwnd);
1902 if (*cmp->rightlist && SHORT1FROMMP(mp1) == COMP_RIGHTDIR)
1903 break;
1904 DoFileDrag(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1905 (HWND) 0, mp2, NULL, NULL, TRUE);
1906 break;
1907
1908 case CN_BEGINEDIT:
1909 case CN_REALLOCPSZ:
1910 // fixme to be gone - field edits not allowed
1911 Runtime_Error(pszSrcFile, __LINE__,
1912 "CN_BEGINEDIT/CN_REALLOCPSZ unexpected");
1913 break;
1914
1915 case CN_EMPHASIS:
1916 {
1917 PNOTIFYRECORDEMPHASIS pre = mp2;
1918 PCNRITEM pci;
1919
1920 if (pre->fEmphasisMask & CRA_SELECTED) {
1921 pci = (PCNRITEM) pre->pRecord;
1922 if (pci) {
1923 if (!pci || !*pci->pszFileName) {
1924 if (pci->rc.flRecordAttr & CRA_SELECTED)
1925 WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1),
1926 CM_SETRECORDEMPHASIS,
1927 MPFROMP(pci),
1928 MPFROM2SHORT(FALSE, CRA_SELECTED));
1929 }
1930 else {
1931
1932 cmp = INSTDATA(hwnd);
1933 if (pci->rc.flRecordAttr & CRA_SELECTED) {
1934 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
1935 cmp->selleft++;
1936 else
1937 cmp->selright++;
1938 }
1939 else {
1940 if (SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
1941 if (cmp->selleft)
1942 cmp->selleft--;
1943 }
1944 else {
1945 if (cmp->selright)
1946 cmp->selright--;
1947 }
1948 }
1949 }
1950 }
1951 }
1952 }
1953 break;
1954
1955 case CN_SCROLL:
1956 cmp = INSTDATA(hwnd);
1957 if (!cmp->forcescroll) {
1958
1959 PNOTIFYSCROLL pns = mp2;
1960
1961 if (pns->fScroll & CMA_VERTICAL) {
1962 cmp->forcescroll = TRUE;
1963 WinSendDlgItemMsg(hwnd, (SHORT1FROMMP(mp1) == COMP_LEFTDIR) ?
1964 COMP_RIGHTDIR : COMP_LEFTDIR,
1965 CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL),
1966 MPFROMLONG(pns->lScrollInc));
1967 cmp->forcescroll = FALSE;
1968 }
1969 }
1970 break;
1971 }
1972 break; // COMP_RIGHTDIR
1973 }
1974 return 0; // WM_CONTROL
1975
1976 case UM_SETDIR:
1977 cmp = INSTDATA(hwnd);
1978 if (cmp) {
1979
1980 COMPARE *forthread;
1981 CNRINFO cnri;
1982
1983 cmp->includesubdirs = WinQueryButtonCheckstate(hwnd,
1984 COMP_INCLUDESUBDIRS);
1985 memset(&cnri, 0, sizeof(CNRINFO));
1986 cnri.cb = sizeof(CNRINFO);
1987 cnri.pszCnrTitle = cmp->leftdir;
1988 cnri.flWindowAttr = CV_DETAIL | CV_MINI |
1989 CA_CONTAINERTITLE | CA_TITLESEPARATOR |
1990 CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
1991 WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1992 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
1993 cnri.pszCnrTitle = cmp->rightdir;
1994 WinSendDlgItemMsg(hwnd, COMP_RIGHTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
1995 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
1996 WinCheckButton(hwnd, COMP_HIDENOTSELECTED, 0);
1997 cmp->filling = TRUE;
1998 forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
1999 if (!forthread)
2000 WinDismissDlg(hwnd, 0);
2001 else {
2002 *forthread = *cmp;
2003 forthread->cmp = cmp;
2004 if (_beginthread(FillCnrsThread, NULL, 122880, (PVOID) forthread) ==
2005 -1) {
2006 Runtime_Error(pszSrcFile, __LINE__,
2007 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2008 WinDismissDlg(hwnd, 0);
2009 free(forthread);
2010 }
2011 else {
2012 WinEnableWindowUpdate(hwndLeft, FALSE);
2013 WinEnableWindowUpdate(hwndRight, FALSE);
2014 cmp->selleft = cmp->selright = 0;
2015 WinSetDlgItemText(hwnd, COMP_SELLEFT, "0");
2016 WinSetDlgItemText(hwnd, COMP_SELRIGHT, "0");
2017 WinSetDlgItemText(hwnd, COMP_TOTALLEFT, "0");
2018 WinSetDlgItemText(hwnd, COMP_TOTALRIGHT, "0");
2019 WinSetDlgItemText(hwnd, COMP_NOTE,
2020 GetPString(IDS_COMPHOLDREADDISKTEXT));
2021 WinEnableWindow(hwndRight, FALSE);
2022 WinEnableWindow(hwndLeft, FALSE);
2023 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
2024 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
2025 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
2026 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
2027 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
2028 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
2029 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
2030 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
2031 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
2032 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
2033 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
2034 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
2035 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
2036 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
2037 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER), FALSE);
2038 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
2039 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), FALSE);
2040 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
2041 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
2042 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
2043 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
2044 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
2045 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
2046 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
2047 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
2048 FALSE);
2049 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL), FALSE);
2050 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
2051 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
2052 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
2053 }
2054 }
2055 }
2056 return 0;
2057
2058 case UM_FILTER:
2059 cmp = INSTDATA(hwnd);
2060 if (cmp) {
2061 if (mp1) {
2062 DosEnterCritSec();
2063 SetMask((CHAR *) mp1, &cmp->dcd.mask);
2064 DosExitCritSec();
2065 }
2066 cmp->dcd.suspendview = 1;
2067 WinSendMsg(hwndLeft, CM_FILTER, MPFROMP(Filter),
2068 MPFROMP(&cmp->dcd.mask));
2069 WinSendMsg(hwndRight, CM_FILTER, MPFROMP(Filter),
2070 MPFROMP(&cmp->dcd.mask));
2071 cmp->dcd.suspendview = 0;
2072 if (*cmp->dcd.mask.szMask)
2073 WinSetDlgItemText(hwnd, COMP_NOTE,
2074 GetPString(IDS_COMPREADYFILTEREDTEXT));
2075 else
2076 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
2077 }
2078 return 0;
2079
2080 case UM_HIDENOTSELECTED:
2081 cmp = INSTDATA(hwnd);
2082 if (cmp) {
2083 USHORT wantHide = WinQueryButtonCheckstate(hwnd,
2084 COMP_HIDENOTSELECTED);
2085
2086 cmp->dcd.suspendview = 1;
2087 if (wantHide) {
2088 BOOL needRefresh = FALSE;
2089 HWND hwndl = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
2090 HWND hwndr = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
2091 PCNRITEM pcil = WinSendMsg(hwndl, CM_QUERYRECORD, MPVOID,
2092 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
2093 PCNRITEM pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPVOID,
2094 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
2095
2096 while (pcil && (INT) pcil != -1 && pcir && (INT) pcir != -1) {
2097 if (~pcil->rc.flRecordAttr & CRA_SELECTED &&
2098 ~pcir->rc.flRecordAttr & CRA_SELECTED) {
2099 pcil->rc.flRecordAttr |= CRA_FILTERED;
2100 pcir->rc.flRecordAttr |= CRA_FILTERED;
2101 needRefresh = TRUE;
2102 }
2103 pcil = WinSendMsg(hwndl, CM_QUERYRECORD, MPFROMP(pcil),
2104 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
2105 pcir = WinSendMsg(hwndr, CM_QUERYRECORD, MPFROMP(pcir),
2106 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
2107 } // while
2108 if (needRefresh) {
2109 WinSendMsg(hwndl, CM_INVALIDATERECORD,
2110 MPVOID, MPFROM2SHORT(0, CMA_REPOSITION));
2111 WinSendMsg(hwndr, CM_INVALIDATERECORD,
2112 MPVOID, MPFROM2SHORT(0, CMA_REPOSITION));
2113 }
2114 }
2115 else {
2116 WinSendMsg(hwndLeft, CM_FILTER, MPFROMP(Filter),
2117 MPFROMP(&cmp->dcd.mask));
2118 WinSendMsg(hwndRight, CM_FILTER, MPFROMP(Filter),
2119 MPFROMP(&cmp->dcd.mask));
2120 }
2121 cmp->dcd.suspendview = 0;
2122 if (*cmp->dcd.mask.szMask)
2123 WinSetDlgItemText(hwnd, COMP_NOTE,
2124 GetPString(IDS_COMPREADYFILTEREDTEXT));
2125 else
2126 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPREADYTEXT));
2127 }
2128 return 0;
2129
2130 case WM_COMMAND:
2131 switch (SHORT1FROMMP(mp1)) {
2132 case IDM_COMPARE:
2133 cmp = INSTDATA(hwnd);
2134 if (cmp) {
2135
2136 PCNRITEM pci;
2137 CHAR ofile[CCHMAXPATH];
2138
2139 pci = (PCNRITEM) WinSendMsg(cmp->hwndCalling,
2140 CM_QUERYRECORDEMPHASIS,
2141 MPFROMLONG(CMA_FIRST),
2142 MPFROMSHORT(CRA_CURSORED));
2143 // 01 Aug 07 SHL
2144 if (pci && *pci->pszFileName) {
2145 if (cmp->hwndCalling == hwndLeft)
2146 strcpy(ofile, cmp->rightdir);
2147 else
2148 strcpy(ofile, cmp->leftdir);
2149 if (ofile[strlen(ofile) - 1] != '\\')
2150 strcat(ofile, "\\");
2151 strcat(ofile, pci->pszDisplayName);
2152 if (*compare) {
2153 CHAR *fakelist[3];
2154 fakelist[0] = pci->pszFileName;
2155 fakelist[1] = ofile;
2156 fakelist[2] = NULL;
2157 ExecOnList(hwnd, compare,
2158 WINDOWED | SEPARATEKEEP, NULL, fakelist, NULL,
2159 pszSrcFile, __LINE__);
2160 }
2161 else {
2162 FCOMPARE fc;
2163 memset(&fc, 0, sizeof(fc));
2164 fc.size = sizeof(fc);
2165 fc.hwndParent = hwnd;
2166 strcpy(fc.file1, pci->pszFileName);
2167 strcpy(fc.file2, ofile);
2168 WinDlgBox(HWND_DESKTOP, hwnd,
2169 CFileDlgProc, FM3ModHandle, FCMP_FRAME, (PVOID) & fc);
2170 }
2171 }
2172 }
2173 break;
2174
2175 case COMP_FILTER:
2176 case IDM_FILTER:
2177 cmp = INSTDATA(hwnd);
2178 if (cmp) {
2179
2180 BOOL empty = FALSE;
2181 PCNRITEM pci;
2182 CHAR *p;
2183 BOOL temp;
2184
2185 if (!*cmp->dcd.mask.szMask) {
2186 empty = TRUE;
2187 temp = fSelectedAlways;
2188 fSelectedAlways = TRUE;
2189 pci = (PCNRITEM)CurrentRecord(hwnd);
2190 fSelectedAlways = temp;
2191 // 01 Aug 07 SHL
2192 if (pci && ~pci->attrFile & FILE_DIRECTORY) {
2193 p = strrchr(pci->pszFileName, '\\');
2194 if (p) {
2195 p++;
2196 strcpy(cmp->dcd.mask.szMask, p);
2197 }
2198 }
2199 }
2200 cmp->dcd.mask.fNoAttribs = TRUE;
2201 cmp->dcd.mask.attrFile = ALLATTRS;
2202 cmp->dcd.mask.antiattr = 0;
2203 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2204 FM3ModHandle, MSK_FRAME, MPFROMP(&cmp->dcd.mask))) {
2205 cmp->dcd.mask.attrFile = ALLATTRS;
2206 cmp->dcd.mask.antiattr = 0;
2207 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2208 }
2209 else if (empty) {
2210 *cmp->dcd.mask.szMask = 0;
2211 cmp->dcd.mask.attrFile = ALLATTRS;
2212 cmp->dcd.mask.antiattr = 0;
2213 }
2214 }
2215 break;
2216
2217 case IDM_SHOWSUBJECT:
2218 case IDM_SHOWEAS:
2219 case IDM_SHOWSIZE:
2220 case IDM_SHOWLWDATE:
2221 case IDM_SHOWLWTIME:
2222 case IDM_SHOWLADATE:
2223 case IDM_SHOWLATIME:
2224 case IDM_SHOWCRDATE:
2225 case IDM_SHOWCRTIME:
2226 case IDM_SHOWATTR:
2227 cmp = INSTDATA(hwnd);
2228 if (cmp) {
2229
2230 DIRCNRDATA dcd1;
2231 BOOL tempsubj;
2232
2233 dcd1 = cmp->dcd;
2234 AdjustDetailsSwitches(hwndLeft,
2235 (HWND) 0, SHORT1FROMMP(mp1),
2236 cmp->leftdir, "DirCmp", &cmp->dcd, TRUE);
2237 tempsubj = cmp->dcd.detailssubject;
2238 cmp->dcd = dcd1;
2239 cmp->dcd.detailssubject = FALSE;
2240 AdjustDetailsSwitches(hwndRight,
2241 cmp->dcd.hwndLastMenu, SHORT1FROMMP(mp1),
2242 cmp->rightdir, "DirCmp", &cmp->dcd, TRUE);
2243 cmp->dcd.detailssubject = tempsubj;
2244 }
2245 break;
2246
2247 case IDM_LOADLISTFILE:
2248 cmp = INSTDATA(hwnd);
2249 if (cmp) {
2250
2251 CHAR fullname[CCHMAXPATH];
2252
2253 strcpy(fullname, "*.PMD");
2254 if (insert_filename(HWND_DESKTOP, fullname, TRUE, FALSE) &&
2255 *fullname && !strchr(fullname, '*') && !strchr(fullname, '?')) {
2256 strcpy(cmp->rightlist, fullname);
2257 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
2258 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
2259 }
2260 }
2261 break;
2262
2263 case IDM_SAVELISTFILE:
2264 cmp = INSTDATA(hwnd);
2265 if (cmp) {
2266
2267 SNAPSTUFF *sf;
2268 CHAR fullname[CCHMAXPATH];
2269
2270 strcpy(fullname, "*.PMD");
2271 if (export_filename(HWND_DESKTOP, fullname, 1) && *fullname &&
2272 !strchr(fullname, '*') && !strchr(fullname, '?')) {
2273 sf = xmallocz(sizeof(SNAPSTUFF), pszSrcFile, __LINE__);
2274 if (sf) {
2275 strcpy(sf->filename, fullname);
2276 if (hwndLeft == cmp->hwndCalling)
2277 strcpy(sf->dirname, cmp->leftdir);
2278 else
2279 strcpy(sf->dirname, cmp->rightdir);
2280 sf->recurse = cmp->includesubdirs;
2281 if (_beginthread(StartSnap, NULL, 65536, (PVOID) sf) == -1) {
2282 Runtime_Error(pszSrcFile, __LINE__,
2283 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2284 free(sf);
2285 }
2286 }
2287 }
2288 }
2289 break;
2290
2291 case COMP_SETDIRS:
2292 cmp = INSTDATA(hwnd);
2293 if (cmp) {
2294
2295 WALK2 wa;
2296
2297 memset(&wa, 0, sizeof(wa));
2298 wa.size = sizeof(wa);
2299 strcpy(wa.szCurrentPath1, cmp->leftdir);
2300 strcpy(wa.szCurrentPath2, cmp->rightdir);
2301 if (WinDlgBox(HWND_DESKTOP, hwnd, WalkTwoCmpDlgProc,
2302 FM3ModHandle, WALK2_FRAME,
2303 MPFROMP(&wa)) &&
2304 !IsFile(wa.szCurrentPath1) &&
2305 !IsFile(wa.szCurrentPath2)) {
2306 strcpy(cmp->leftdir, wa.szCurrentPath1);
2307 strcpy(cmp->rightdir, wa.szCurrentPath2);
2308 *cmp->rightlist = 0;
2309 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
2310 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
2311 }
2312 }
2313 break;
2314
2315 case COMP_COPYLEFT:
2316 case COMP_MOVELEFT:
2317 case COMP_COPYRIGHT:
2318 case COMP_MOVERIGHT:
2319 case COMP_DELETELEFT:
2320 case COMP_DELETERIGHT:
2321 cmp = INSTDATA(hwnd);
2322 if (cmp) {
2323
2324 COMPARE *forthread;
2325
2326 cmp->filling = TRUE;
2327 forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
2328 if (forthread) {
2329 *forthread = *cmp;
2330 forthread->cmp = cmp;
2331 forthread->action = SHORT1FROMMP(mp1);
2332 if (_beginthread(ActionCnrThread, NULL, 122880, (PVOID) forthread)
2333 == -1) {
2334 Runtime_Error(pszSrcFile, __LINE__,
2335 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2336 free(forthread);
2337 }
2338 else {
2339 WinEnableWindowUpdate(hwndLeft, FALSE);
2340 WinEnableWindowUpdate(hwndRight, FALSE);
2341 switch (SHORT1FROMMP(mp1)) {
2342 case COMP_DELETELEFT:
2343 case COMP_DELETERIGHT:
2344 WinSetDlgItemText(hwnd, COMP_NOTE,
2345 GetPString(IDS_COMPHOLDDELETINGTEXT));
2346 break;
2347 case COMP_MOVELEFT:
2348 case COMP_MOVERIGHT:
2349 WinSetDlgItemText(hwnd, COMP_NOTE,
2350 GetPString(IDS_COMPHOLDMOVINGTEXT));
2351 break;
2352 case COMP_COPYLEFT:
2353 case COMP_COPYRIGHT:
2354 WinSetDlgItemText(hwnd, COMP_NOTE,
2355 GetPString(IDS_COMPHOLDCOPYINGTEXT));
2356 break;
2357 default:
2358 WinSetDlgItemText(hwnd, COMP_NOTE,
2359 GetPString(IDS_COMPHOLDDUNNOTEXT));
2360 break;
2361 }
2362 WinEnableWindow(hwndRight, FALSE);
2363 WinEnableWindow(hwndLeft, FALSE);
2364 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
2365 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
2366 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
2367 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
2368 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
2369 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
2370 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
2371 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
2372 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
2373 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
2374 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
2375 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
2376 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
2377 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
2378 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER),
2379 FALSE);
2380 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
2381 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS),
2382 FALSE);
2383 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
2384 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
2385 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
2386 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
2387 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
2388 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
2389 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
2390 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
2391 FALSE);
2392 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL),
2393 FALSE);
2394 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
2395 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
2396 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
2397 }
2398 }
2399 }
2400 break;
2401
2402 case DID_OK:
2403 WinDismissDlg(hwnd, 0);
2404 break;
2405 case DID_CANCEL:
2406 WinDismissDlg(hwnd, 1);
2407 break;
2408
2409 case IDM_HELP:
2410 if (hwndHelp)
2411 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
2412 MPFROM2SHORT(HELP_COMPARE, 0), MPFROMSHORT(HM_RESOURCEID));
2413 break;
2414
2415 case IDM_DESELECTALL:
2416 case IDM_SELECTNEWER:
2417 case IDM_SELECTOLDER:
2418 case IDM_SELECTBIGGER:
2419 case IDM_SELECTSMALLER:
2420 case IDM_DESELECTNEWER:
2421 case IDM_DESELECTOLDER:
2422 case IDM_DESELECTBIGGER:
2423 case IDM_DESELECTSMALLER:
2424 case IDM_DESELECTONE:
2425 case IDM_DESELECTBOTH:
2426 case IDM_SELECTBOTH:
2427 case IDM_SELECTONE:
2428 case IDM_SELECTSAMECONTENT:
2429 case IDM_SELECTIDENTICAL: // Name, size and time
2430 case IDM_SELECTSAME: // Name and size
2431 case IDM_INVERT:
2432 cmp = INSTDATA(hwnd);
2433 if (!cmp)
2434 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2435 else {
2436 COMPARE *forthread;
2437
2438 cmp->filling = TRUE;
2439 forthread = xmalloc(sizeof(COMPARE), pszSrcFile, __LINE__);
2440 if (forthread) {
2441 *forthread = *cmp;
2442 forthread->cmp = cmp;
2443 forthread->action = SHORT1FROMMP(mp1);
2444 if (_beginthread(SelectCnrsThread, NULL, 65536, (PVOID) forthread)
2445 == -1) {
2446 Runtime_Error(pszSrcFile, __LINE__,
2447 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2448 free(forthread);
2449 }
2450 else {
2451 WinEnableWindowUpdate(hwndLeft, FALSE);
2452 WinEnableWindowUpdate(hwndRight, FALSE);
2453 switch (SHORT1FROMMP(mp1)) {
2454 case IDM_DESELECTALL:
2455 case IDM_DESELECTNEWER:
2456 case IDM_DESELECTOLDER:
2457 case IDM_DESELECTBIGGER:
2458 case IDM_DESELECTSMALLER:
2459 case IDM_DESELECTONE:
2460 case IDM_DESELECTBOTH:
2461 WinSetDlgItemText(hwnd, COMP_NOTE,
2462 GetPString(IDS_COMPHOLDDESELTEXT));
2463 break;
2464 case IDM_INVERT:
2465 WinSetDlgItemText(hwnd, COMP_NOTE,
2466 GetPString(IDS_COMPHOLDINVERTTEXT));
2467 break;
2468 default:
2469 WinSetDlgItemText(hwnd, COMP_NOTE,
2470 GetPString(IDS_COMPHOLDSELTEXT));
2471 break;
2472 }
2473 WinEnableWindow(hwndRight, FALSE);
2474 WinEnableWindow(hwndLeft, FALSE);
2475 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
2476 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
2477 WinEnableWindow(WinWindowFromID(hwnd, COMP_COLLECT), FALSE);
2478 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBOTH), FALSE);
2479 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), FALSE);
2480 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), FALSE);
2481 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), FALSE);
2482 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), FALSE);
2483 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSMALLER), FALSE);
2484 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBOTH), FALSE);
2485 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), FALSE);
2486 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), FALSE);
2487 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), FALSE);
2488 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), FALSE);
2489 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTSMALLER),
2490 FALSE);
2491 WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTALL), FALSE);
2492 WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS),
2493 FALSE);
2494 WinEnableWindow(WinWindowFromID(hwnd, COMP_SETDIRS), FALSE);
2495 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETELEFT), FALSE);
2496 WinEnableWindow(WinWindowFromID(hwnd, COMP_DELETERIGHT), FALSE);
2497 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYLEFT), FALSE);
2498 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVELEFT), FALSE);
2499 WinEnableWindow(WinWindowFromID(hwnd, COMP_COPYRIGHT), FALSE);
2500 WinEnableWindow(WinWindowFromID(hwnd, COMP_MOVERIGHT), FALSE);
2501 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAMECONTENT),
2502 FALSE);
2503 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTIDENTICAL),
2504 FALSE);
2505 WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTSAME), FALSE);
2506 WinEnableWindow(WinWindowFromID(hwnd, IDM_INVERT), FALSE);
2507 WinEnableWindow(WinWindowFromID(hwnd, COMP_FILTER), FALSE);
2508 }
2509 }
2510 }
2511 break;
2512
2513 case COMP_COLLECT:
2514 cmp = INSTDATA(hwnd);
2515 if (!cmp)
2516 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2517 else {
2518 CHAR **listl;
2519 CHAR **listr = NULL;
2520 if (!Collector) {
2521 SWP swp;
2522 HWND hwndC;
2523 if (!fAutoTile &&
2524 !ParentIsDesktop(hwnd, cmp->hwndParent) &&
2525 !fExternalCollector &&
2526 !strcmp(realappname, FM3Str)) {
2527 GetNextWindowPos(cmp->hwndParent, &swp, NULL, NULL);
2528 }
2529 hwndC = StartCollector(fExternalCollector ||
2530 strcmp(realappname, FM3Str) ?
2531 HWND_DESKTOP :
2532 cmp->hwndParent,
2533 4);
2534 if (hwndC) {
2535 if (!fAutoTile &&
2536 !ParentIsDesktop(hwnd, cmp->hwndParent) &&
2537 !fExternalCollector &&
2538 !strcmp(realappname, FM3Str)) {
2539 WinSetWindowPos(hwndC, HWND_TOP,
2540 swp.x, swp.y, swp.cx, swp.cy,
2541 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
2542 }
2543 else if (!ParentIsDesktop(hwnd, cmp->hwndParent) &&
2544 fAutoTile &&
2545 !strcmp(realappname, FM3Str)) {
2546 TileChildren(cmp->hwndParent, TRUE);
2547 }
2548 DosSleep(32); // 05 Aug 07 GKY 64
2549 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
2550 break;
2551 }
2552 }
2553 else
2554 StartCollector(cmp->hwndParent, 4);
2555
2556 temp = fSelectedAlways;
2557 fSelectedAlways = TRUE;
2558 listl = BuildList(hwndLeft);
2559 if (!*cmp->rightlist)
2560 listr = BuildList(hwndRight);
2561 fSelectedAlways = temp;
2562
2563 if (listl || listr) {
2564 if (Collector) {
2565 // 07 Aug 07 SHL Avoid collected from empty list
2566 if (listl && listl[0] && *listl[0]) {
2567 if (PostMsg(Collector, WM_COMMAND,
2568 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listl)))
2569 listl = NULL; // Collector will free
2570 }
2571 if (listr && listr[0] && *listr[0]) {
2572 if (PostMsg(Collector, WM_COMMAND,
2573 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(listr)))
2574 listr = NULL; // Collector will free
2575 }
2576 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2577 QW_PARENT),
2578 QW_PARENT),
2579 HWND_TOP, 0, 0, 0, 0,
2580 SWP_ACTIVATE);
2581 }
2582 FreeList(listl);
2583 FreeList(listr);
2584 }
2585 }
2586 break;
2587 }
2588 return 0;
2589
2590 case WM_CLOSE:
2591 WinDismissDlg(hwnd, 0);
2592 return 0;
2593
2594 case WM_DESTROY:
2595 cmp = INSTDATA(hwnd);
2596 if (cmp) {
2597 if (cmp->dcd.hwndLastMenu)
2598 WinDestroyWindow(cmp->dcd.hwndLastMenu);
2599 if (cmp->dcd.hwndObject) {
2600 WinSetWindowPtr(cmp->dcd.hwndObject, QWL_USER, (PVOID) NULL);
2601 if (!PostMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID))
2602 WinSendMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID);
2603 }
2604 free(cmp);
2605 }
2606 EmptyCnr(hwndLeft);
2607 EmptyCnr(hwndRight);
2608 DosPostEventSem(CompactSem);
2609 break;
2610 }
2611 return WinDefDlgProc(hwnd, msg, mp1, mp2);
2612}
2613
2614#pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames,BldFullPathName)
2615#pragma alloc_text(COMPAREDIR1,CompareDlgProc)
2616#pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
2617#pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
2618#pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
2619
Note: See TracBrowser for help on using the repository browser.