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
RevLine 
[76]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
[574]9 Copyright (c) 2003, 2007 Steven H. Levine
[76]10
[145]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
[157]15 24 May 05 SHL Rework for CNRITEM.szSubject
16 25 May 05 SHL Rework with ULONGLONG
[199]17 06 Jun 05 SHL Drop unused
[362]18 12 Jul 06 SHL Renames and comments
19 13 Jul 06 SHL Use Runtime_Error
[366]20 26 Jul 06 SHL Drop unreachable CN_... code
[406]21 29 Jul 06 SHL Use xfgets_bstripcr
[448]22 15 Aug 06 SHL Turn off hide not selected on dir change
[517]23 19 Oct 06 SHL Correct . and .. detect
[535]24 03 Nov 06 SHL Count thread usage
[574]25 22 Mar 07 GKY Use QWL_USER
[742]26 29 Jul 07 SHL Use Win_Error to report container errors
[748]27 01 Aug 07 SHL Rework to sync with CNRITEM mods
28 01 Aug 07 SHL Rework to remove vast amount of duplicate code
[756]29 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
[773]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
[775]32 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[783]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
[790]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
[846]38 20 Aug 07 SHL A few more speed up tweaks. Some experimental timing code
[814]39 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
[846]40 27 Sep 07 SHL Correct ULONGLONG size formatting
[897]41 30 Dec 07 GKY Use TestCDates for compare by file date/time
[76]42
43***********************************************************************/
44
[2]45#define INCL_DOS
46#define INCL_WIN
[783]47#define INCL_DOSERRORS
[2]48#define INCL_GPI
[157]49#define INCL_LONGLONG
50#include <os2.h>
[2]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>
[689]58#include <process.h> // _beginthread
[157]59
[2]60#include "fm3dll.h"
61#include "fm3dlg.h"
62#include "fm3str.h"
63
[551]64typedef struct
65{
66 CHAR filename[CCHMAXPATH];
67 CHAR dirname[CCHMAXPATH];
68 BOOL recurse;
69}
70SNAPSTUFF;
[2]71
[362]72static PSZ pszSrcFile = __FILE__;
73
[773]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
[316]95//=== SnapShot() Write directory tree to file and recurse if requested ===
[2]96
[783]97static VOID SnapShot(char *path, FILE *fp, BOOL recurse)
[157]98{
[841]99 PFILEFINDBUF4L pffb;
[551]100 char *mask, *enddir;
101 HDIR hdir = HDIR_CREATE;
[783]102 ULONG ulFindCnt;
[2]103
[783]104 // 13 Aug 07 SHL fimxe to use FileToGet
[841]105 pffb = xmalloc(sizeof(FILEFINDBUF4L), pszSrcFile, __LINE__);
[783]106 if (pffb) {
[551]107 mask = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
108 if (mask) {
[783]109 BldFullPathName(mask, path, "*");
110 // sprintf(mask,
111 // "%s%s*",
112 // path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
[551]113 enddir = strrchr(mask, '\\');
[2]114 enddir++;
[783]115 ulFindCnt = 1;
116 // 13 Aug 07 SHL fixme to report errors
[838]117 if (!xDosFindFirst(mask,
118 &hdir,
119 FILE_NORMAL | FILE_DIRECTORY |
120 FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN |
121 FILE_SYSTEM,
[841]122 pffb, sizeof(FILEFINDBUF4L), &ulFindCnt, FIL_QUERYEASIZEL)) {
[551]123 do {
[783]124 strcpy(enddir, pffb->achName);
125 if (!(pffb->attrFile & FILE_DIRECTORY))
[846]126 // 27 Sep 07 SHL fixme to use CommaFmtULL
[551]127 fprintf(fp,
[846]128 "\"%s\",%u,%llu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",
[551]129 mask,
130 enddir - mask,
[783]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,
[846]138 pffb->attrFile,
139 pffb->cbList > 4 ? pffb->cbList / 2 : 0);
[517]140 // Skip . and ..
[551]141 else if (recurse &&
[783]142 (pffb->achName[0] != '.' ||
143 (pffb->achName[1] &&
144 (pffb->achName[1] != '.' || pffb->achName[2])))) {
[551]145 SnapShot(mask, fp, recurse);
146 }
[783]147 ulFindCnt = 1;
[850]148 } while (!xDosFindNext(hdir, pffb, sizeof(FILEFINDBUF4L), &ulFindCnt, FIL_QUERYEASIZEL));
[551]149 DosFindClose(hdir);
[2]150 }
151 free(mask);
152 }
[783]153 free(pffb);
[2]154 }
155}
156
[316]157//=== StartSnap() Write directory tree to snapshot file ===
[2]158
[551]159static VOID StartSnap(VOID * dummy)
[316]160{
[551]161 SNAPSTUFF *sf = (SNAPSTUFF *) dummy;
162 FILE *fp;
163 CHAR *p;
[2]164
[551]165 if (sf) {
166 if (*sf->dirname && *sf->filename) {
[2]167 priority_normal();
168 p = sf->dirname;
[551]169 while (*p) {
170 if (*p == '/')
171 *p = '\\';
172 p++;
[2]173 }
[551]174 if (*(p - 1) != '\\') {
175 *p = '\\';
176 p++;
[2]177 }
[551]178 fp = xfopen(sf->filename, "w", pszSrcFile, __LINE__);
[362]179 if (fp) {
[551]180 fprintf(fp, "\"%s\"\n", sf->dirname);
181 SnapShot(sf->dirname, fp, sf->recurse);
182 fclose(fp);
[2]183 }
184 }
185 free(sf);
186 }
187}
188
[316]189//=== CompareFilesThread() Compare files and update container select flags ===
[2]190
[551]191static VOID CompareFilesThread(VOID * args)
[316]192{
[2]193 FCOMPARE fc;
[551]194 HAB hab2;
195 HMQ hmq2;
196 FILE *fp1, *fp2;
[847]197 ULONG len1, len2;
[841]198 ULONG offset = 0;
[551]199 LONG numread1, numread2;
200 CHAR s[1024], ss[1024], *p1, *p2;
[2]201
[551]202 if (args) {
203 fc = *(FCOMPARE *) args;
[2]204 hab2 = WinInitialize(0);
[551]205 if (hab2) {
206 hmq2 = WinCreateMsgQueue(hab2, 0);
207 if (hmq2) {
208 WinCancelShutdown(hmq2, TRUE);
[535]209 IncrThreadUsage();
[551]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 }
[362]217 }
[551]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 }
[362]236 else {
[551]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));
[362]242 }
243 else {
[847]244 len1 = filelength(fileno(fp1));
245 len2 = filelength(fileno(fp2));
[551]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 }
[535]313 DecrThreadUsage();
[551]314 WinDestroyMsgQueue(hmq2);
[2]315 }
316 WinTerminate(hab2);
317 }
318 }
319}
320
[316]321//=== CFileDlgProc() Select directories to compare dialog procedure ===
[2]322
[551]323MRESULT EXPENTRY CFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[316]324{
[2]325 FCOMPARE *fc;
326
[551]327 switch (msg) {
328 case WM_INITDLG:
329 if (!mp2)
330 WinDismissDlg(hwnd, 0);
331 else {
[574]332 WinSetWindowPtr(hwnd, QWL_USER, mp2);
[551]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;
[2]340 }
[551]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;
[2]357
[551]358 case WM_ADJUSTWINDOWPOS:
359 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
360 break;
[2]361
[551]362 case UM_SETDIR:
363 PaintRecessedWindow(WinWindowFromID(hwnd, FCMP_HELP),
364 (HPS) 0, FALSE, TRUE);
365 return 0;
[2]366
[551]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;
[2]377
[551]378 case WM_DESTROY:
[846]379 DosSleep(50); // 05 Aug 07 GKY 100
[551]380 break;
[2]381 }
[551]382 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]383}
384
[316]385//=== ActionCnrThread() Do requested action on container contents ===
[2]386
[731]387static VOID ActionCnrThread(VOID *args)
[316]388{
[731]389 COMPARE *cmp = (COMPARE *)args;
[551]390 HAB hab;
391 HMQ hmq;
392 HWND hwndCnrS, hwndCnrD;
[748]393 PCNRITEM pci, pciD, pciNextS, pciNextD;
[769]394 CHAR szNewName[CCHMAXPATH], szDirName[CCHMAXPATH], *p;
[551]395 APIRET rc;
[2]396
[748]397 if (!cmp) {
[773]398 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]399 return;
[748]400 }
[2]401
402 DosError(FERR_DISABLEHARDERR);
403
404 hab = WinInitialize(0);
[551]405 if (hab) {
406 hmq = WinCreateMsgQueue(hab, 0);
407 if (hmq) {
408 WinCancelShutdown(hmq, TRUE);
[535]409 IncrThreadUsage();
[2]410 priority_normal();
[551]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;
[2]445 }
446
[551]447 pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
448 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
[748]449 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
[551]450 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
[316]451
[748]452 while (pci && (INT)pci != -1 && pciD && (INT)pciD != -1) {
453
454 pciNextS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci),
[551]455 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
[748]456 pciNextD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
[551]457 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
[748]458
459 if (*pci->pszFileName && pci->rc.flRecordAttr & CRA_SELECTED) {
460
461 // Source name not blank
[551]462 switch (cmp->action) {
463 case IDM_DELETE:
[730]464 if (!unlinkf("%s", pci->pszFileName)) {
[551]465 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
466 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]467
468 if (!*pciD->pszFileName) {
[751]469 // Other side is blank - remove from both sides
470 RemoveCnrItems(hwndCnrS, pci, 1, CMA_FREE | CMA_INVALIDATE);
[748]471 if (pciD->rc.flRecordAttr & CRA_SELECTED)
472 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
[551]473 MPFROM2SHORT(FALSE, CRA_SELECTED));
[751]474 RemoveCnrItems(hwndCnrD, pciD, 1, CMA_FREE | CMA_INVALIDATE);
[551]475 }
[742]476 else {
[751]477 // Other side is not blank - update just this side
[748]478 FreeCnrItemData(pci);
[751]479 pci->pszDisplayName = pci->pszFileName;
480 pci->rc.pszIcon = pci->pszFileName;
[551]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--;
[846]489 DosSleep(0); // 8-26-07 GKY 1
[551]490 }
491 break;
[2]492
[551]493 case IDM_MOVE:
494 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
[769]495 BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName);
496 //sprintf(szNewName, "%s%s%s",
[763]497 // cmp->leftdir,
498 // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
[769]499 // NullStr : "\\",
500 // pci->pszDisplayName);
501 else
502 BldFullPathName(szNewName, cmp->rightdir, pci->pszDisplayName);
503 //sprintf(szNewName, "%s%s%s",
[763]504 // cmp->rightdir,
[765]505 // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
[769]506 // NullStr : "\\",
[765]507 // pci->pszDisplayName);
[748]508 // Make directory if required
[769]509 strcpy(szDirName, szNewName);
510 p = strrchr(szDirName, '\\');
[551]511 if (p) {
[769]512 if (p > szDirName + 2)
[551]513 p++;
514 *p = 0;
[769]515 if (IsFile(szDirName) == -1)
516 MassMkdir(hwndMain, szDirName);
[551]517 }
[769]518 rc = docopyf(MOVE, pci->pszFileName, "%s", szNewName);
519 if (!rc && stricmp(pci->pszFileName, szNewName)) {
[551]520 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
521 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]522 if (pciD->rc.flRecordAttr & CRA_SELECTED)
523 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
[551]524 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]525 FreeCnrItemData(pciD);
[769]526 pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
[551]527 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
[748]528 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
[551]529 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
[751]530 pciD->pszDisplayName++;
[551]531 }
532 else {
[748]533 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
[551]534 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
[751]535 pciD->pszDisplayName++;
[742]536 }
[769]537 // 02 Aug 07 SHL fixme to know if LongName transfer is correct?
[762]538 pciD->pszLongName = pci->pszLongName;
[751]539 if (pciD->pszSubject != NullStr) {
540 xfree(pciD->pszSubject);
541 pciD->pszSubject = NullStr;
542 }
[748]543 pciD->attrFile = pci->attrFile;
[751]544 pciD->pszDispAttr = pci->pszDispAttr;
[769]545 pciD->flags = 0; // Just on one side
[748]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;
[751]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 }
[551]565 pci->flags = 0;
[751]566
[551]567 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
568 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
[748]569 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
[551]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),
[769]579 pci->pszFileName, szNewName);
[748]580 if (rc == MBID_CANCEL) // Cause loop to break
581 pciNextS = NULL;
[551]582 }
583 break;
[2]584
[551]585 case IDM_COPY:
[769]586 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
587 BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName);
588 //sprintf(szNewName, "%s%s%s",
[763]589 // cmp->leftdir,
590 // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
[769]591 // NullStr : "\\",
[765]592 // pci->pszDisplayName);
[769]593 else
594 BldFullPathName(szNewName, cmp->rightdir, pci->pszDisplayName);
595 //sprintf(szNewName, "%s%s%s",
[763]596 // cmp->rightdir,
597 // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
[769]598 // NullStr : "\\",
[763]599 // pci->pszDisplayName);
[748]600 // Make directory if required
[769]601 strcpy(szDirName, szNewName);
602 p = strrchr(szDirName, '\\');
[551]603 if (p) {
[769]604 if (p > szDirName + 2)
[551]605 p++;
606 *p = 0;
[769]607 if (IsFile(szDirName) == -1)
608 MassMkdir(hwndMain, szDirName);
[551]609 }
[769]610 rc = docopyf(COPY, pci->pszFileName, "%s", szNewName);
[551]611 if (rc) {
612 rc = Dos_Error(MB_ENTERCANCEL,
613 rc,
614 HWND_DESKTOP,
615 pszSrcFile,
616 __LINE__,
617 GetPString(IDS_COMPCOPYFAILEDTEXT),
[769]618 pci->pszFileName, szNewName);
[551]619 if (rc == MBID_CANCEL)
[748]620 pciNextS = NULL; // Cause loop to break
[551]621 }
622 else {
623 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
624 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]625 if (pciD->rc.flRecordAttr & CRA_SELECTED)
626 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
[551]627 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]628 FreeCnrItemData(pciD);
[769]629 pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
[551]630 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
[748]631 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
[551]632 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
[751]633 pciD->pszDisplayName++;
[362]634 }
635 else {
[748]636 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
[551]637 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
[751]638 pciD->pszDisplayName++;
[742]639 }
[748]640 pciD->attrFile = pci->attrFile;
[751]641 pciD->pszDispAttr = pci->pszDispAttr;
[769]642 pciD->flags = CNRITEM_EXISTS; // Now on both sides
[748]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;
[751]651
[769]652 // Forget status until we regenerate it
[751]653 if (pci->pszSubject != NullStr) {
654 xfree(pci->pszSubject);
655 pci->pszSubject = NullStr;
656 }
[769]657 pci->flags = CNRITEM_EXISTS;
[751]658
[551]659 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
660 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
[748]661 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
[551]662 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
663 }
664 break;
[2]665
[551]666 default:
667 break;
[748]668 } // switch
669
670 } // if have name
671
672 pci = pciNextS;
673 pciD = pciNextD;
674
675 } // while
[551]676 Abort:
[2]677 WinDestroyMsgQueue(hmq);
678 }
[535]679 DecrThreadUsage();
[2]680 WinTerminate(hab);
681 }
[551]682 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
683 PostMsg(cmp->hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DESELECTALL, 0), MPVOID);
[2]684 free(cmp);
685}
686
[316]687//=== SelectCnrsThread() Update container selection flags thread ===
[2]688
[551]689static VOID SelectCnrsThread(VOID * args)
[316]690{
[551]691 COMPARE *cmp = (COMPARE *) args;
692 HAB hab;
693 HMQ hmq;
[2]694
[783]695 if (!cmp) {
696 Runtime_Error(pszSrcFile, __LINE__, "no data");
[2]697 return;
[783]698 }
[2]699
700 DosError(FERR_DISABLEHARDERR);
701
702 hab = WinInitialize(0);
[551]703 if (hab) {
704 hmq = WinCreateMsgQueue(hab, 0);
705 if (hmq) {
706 WinCancelShutdown(hmq, TRUE);
[535]707 IncrThreadUsage();
[2]708 priority_normal();
[551]709 switch (cmp->action) {
710 case IDM_INVERT:
711 InvertAll(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
712 InvertAll(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
713 break;
[2]714
[551]715 case IDM_DESELECTALL:
716 Deselect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
717 Deselect(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
718 break;
[2]719
[551]720 default:
721 SpecialSelect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR),
722 WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR),
723 cmp->action, cmp->reset);
724 break;
[2]725 }
[551]726 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID))
727 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
[2]728 WinDestroyMsgQueue(hmq);
729 }
[535]730 DecrThreadUsage();
[2]731 WinTerminate(hab);
732 }
733 free(cmp);
734}
735
[748]736/**
737 * Build FILELIST given pathname
738 */
739
740static VOID FillDirList(CHAR *str, INT skiplen, BOOL recurse,
741 FILELIST ***list, INT *numfiles, INT *numalloc)
[551]742{
[748]743 CHAR *enddir;
744 ULONG x;
[551]745 CHAR *maskstr;
[841]746 PFILEFINDBUF4L pffbArray;
747 PFILEFINDBUF4L pffbFile;
[551]748 HDIR hDir;
[783]749 ULONG ulFindCnt;
[841]750 ULONG ulBufBytes = sizeof(FILEFINDBUF4L) * FilesToGet;
[551]751 APIRET rc;
[2]752
[748]753 if (!str || !*str) {
[773]754 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]755 return;
[748]756 }
757
[846]758 // DbgMsg(pszSrcFile, __LINE__, "FillDirList start %s", str);
759
[551]760 maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
761 if (!maskstr)
[2]762 return;
[783]763 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
764 if (!pffbArray) {
[2]765 free(maskstr);
766 return;
767 }
768 x = strlen(str);
[551]769 memcpy(maskstr, str, x + 1);
[2]770 enddir = maskstr + x;
[551]771 if (*(enddir - 1) != '\\') {
[2]772 *enddir = '\\';
773 enddir++;
774 *enddir = 0;
775 }
776 *enddir = '*';
777 *(enddir + 1) = 0;
778 hDir = HDIR_CREATE;
779 DosError(FERR_DISABLEHARDERR);
[783]780 ulFindCnt = FilesToGet;
[838]781 rc = xDosFindFirst(maskstr, &hDir,
782 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
783 FILE_SYSTEM | FILE_HIDDEN |
784 (recurse ? FILE_DIRECTORY : 0),
[841]785 pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
[551]786 if (!rc) {
[783]787 do {
788 pffbFile = pffbArray;
789 for (x = 0; x < ulFindCnt; x++) {
790 if (pffbFile->attrFile & FILE_DIRECTORY) {
[517]791 // Skip . and ..
[551]792 if (recurse &&
[783]793 (pffbFile->achName[0] != '.' ||
794 (pffbFile->achName[1] &&
795 (pffbFile->achName[1] != '.' || pffbFile->achName[2])))) {
[551]796 if (fForceUpper)
[783]797 strupr(pffbFile->achName);
[551]798 else if (fForceLower)
[783]799 strlwr(pffbFile->achName);
800 memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1);
[551]801 FillDirList(maskstr, skiplen, recurse, list, numfiles, numalloc);
802 }
803 }
804 else {
805 if (fForceUpper)
[783]806 strupr(pffbFile->achName);
[551]807 else if (fForceLower)
[783]808 strlwr(pffbFile->achName);
809 memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1);
810 if (AddToFileList(maskstr + skiplen,
811 pffbFile, list, numfiles, numalloc)) {
[551]812 goto Abort;
[783]813 }
[551]814 }
[841]815 pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
[783]816 } // for
[2]817 DosError(FERR_DISABLEHARDERR);
[783]818 ulFindCnt = FilesToGet;
[850]819 rc = xDosFindNext(hDir, pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
[783]820 } while (!rc);
821
822Abort:
823
[2]824 DosFindClose(hDir);
[846]825 DosSleep(0);
[2]826 }
[783]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
[2]833 free(maskstr);
[783]834 free(pffbArray);
[846]835
836 // DbgMsg(pszSrcFile, __LINE__, "FillDirList finish %s", str);
[2]837}
838
[316]839//=== CompNames() Compare names for qsort ===
[2]840
[551]841static int CompNames(const void *n1, const void *n2)
[316]842{
[551]843 FILELIST *fl1 = *(FILELIST **) n1;
844 FILELIST *fl2 = *(FILELIST **) n2;
[2]845
[551]846 return stricmp(fl1->fname, fl2->fname);
[2]847}
848
[846]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
[316]888//=== FillCnrsThread() Fill left and right containers ===
[2]889
[751]890static VOID FillCnrsThread(VOID *args)
[316]891{
[551]892 COMPARE *cmp = (COMPARE *) args;
893 HAB hab;
894 HMQ hmq;
895 BOOL notified = FALSE;
[751]896
[846]897#if 0
[790]898 ULONG lastMSec = GetMSecTimer();
899 ULONG ul;
[846]900#endif
[790]901
[551]902 HWND hwndLeft, hwndRight;
[748]903 CHAR szBuf[CCHMAXPATH];
904 CNRINFO cnri;
[2]905
[748]906 if (!cmp) {
[773]907 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]908 _endthread();
[748]909 }
[2]910
[846]911 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread enter");
912
[2]913 DosError(FERR_DISABLEHARDERR);
914
915 hab = WinInitialize(0);
[551]916 if (!hab)
917 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__, "WinInitialize");
[362]918 else {
[551]919 hmq = WinCreateMsgQueue(hab, 0);
920 if (!hmq)
921 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
922 "WinCreateMsgQueue");
[362]923 else {
[551]924 INT x;
925 INT l;
926 INT r;
[846]927 UINT cntr;
[551]928 FILELIST **filesl = NULL;
929 FILELIST **filesr = NULL;
930 INT numfilesl = 0;
931 INT numfilesr = 0;
932 INT numallocl = 0;
933 INT numallocr = 0;
[897]934 INT ret = 0;
[769]935 UINT lenl; // Directory prefix length
936 UINT lenr;
[748]937 UINT recsNeeded;
[551]938 PCNRITEM pcilFirst;
939 PCNRITEM pcirFirst;
940 PCNRITEM pcil;
941 PCNRITEM pcir;
942 RECORDINSERT ri;
943 CHAR *pch;
[2]944
[551]945 WinCancelShutdown(hmq, TRUE);
[535]946 IncrThreadUsage();
[551]947 hwndLeft = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
948 hwndRight = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
[2]949 lenl = strlen(cmp->leftdir);
[551]950 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
951 lenl++;
[2]952 lenr = strlen(cmp->rightdir);
[551]953 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
954 lenr++;
[2]955 priority_normal();
[748]956 // Clear containers
[751]957 RemoveCnrItems(hwndRight, NULL, 0, CMA_FREE | CMA_INVALIDATE);
958 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
[2]959 cmp->cmp->totalleft = cmp->cmp->totalright = 0;
960
[748]961 // Build list of all files in left directory
[551]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);
[2]968
[551]969 if (filesl)
970 qsort(filesl, numfilesl, sizeof(CHAR *), CompNames);
[748]971
[846]972 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesl");
973
[748]974 // Build list of all files in right directory
[551]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);
[2]982 }
[551]983 else {
[748]984 // Use snapshot file
[551]985 FILE *fp;
[841]986 FILEFINDBUF4L fb4;
[551]987 CHAR str[CCHMAXPATH * 2], *p;
[2]988
[551]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);
[362]994 else {
[551]995 while (!feof(fp)) {
[748]996 // First get name of directory
[551]997 if (!xfgets_bstripcr(str, sizeof(str), fp, pszSrcFile, __LINE__))
998 break; // EOF
999 p = str;
1000 if (*p == '\"') {
[748]1001 // Quoted
[551]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 }
[748]1021 } // while !EOF
[2]1022
[748]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");
[551]1029 }
[748]1030
[551]1031 if (*cmp->rightdir) {
[769]1032 lenr = strlen(cmp->rightdir);
1033 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
1034 lenr++;
[551]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++;
[846]1054 // 27 Sep 07 SHL fixme to do ULONGLONG conversion
[551]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 }
[748]1111 } // while
1112 } // if have rightdir
[551]1113 fclose(fp);
1114 }
[748]1115 } // if snapshot file
[316]1116
[551]1117 if (filesr)
1118 qsort(filesr, numfilesr, sizeof(CHAR *), CompNames);
[2]1119
[846]1120 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesr");
1121
[748]1122 // We now have two lists of files, both sorted.
1123 // Count total number of container entries required on each side
[2]1124 l = r = 0;
[316]1125 recsNeeded = 0;
[551]1126 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
[748]1127
1128 if (filesl && filesl[l]) {
1129 if (filesr && filesr[r])
1130 x = stricmp(filesl[l]->fname, filesr[r]->fname);
[551]1131 else
[748]1132 x = -1; // Left side list longer
[551]1133 }
[748]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
[551]1146 WinSendMsg(cmp->hwnd, UM_CONTAINERHWND, MPVOID, MPVOID);
[748]1147
1148 // Now insert records into the containers
[2]1149 cntr = 0;
1150 l = r = 0;
[551]1151 if (recsNeeded) {
1152 pcilFirst = WinSendMsg(hwndLeft,
1153 CM_ALLOCRECORD,
[751]1154 MPFROMLONG(EXTRA_RECORD_BYTES),
[551]1155 MPFROMLONG(recsNeeded));
1156 if (!pcilFirst) {
[742]1157 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1158 recsNeeded);
[551]1159 recsNeeded = 0;
1160 }
[316]1161 }
[362]1162 if (recsNeeded) {
[551]1163 pcirFirst = WinSendMsg(hwndRight, CM_ALLOCRECORD,
[751]1164 MPFROMLONG(EXTRA_RECORD_BYTES),
[551]1165 MPFROMLONG(recsNeeded));
1166 if (!pcirFirst) {
[742]1167 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1168 recsNeeded);
[551]1169 recsNeeded = 0;
[751]1170 FreeCnrItemList(hwndLeft, pcilFirst);
[551]1171 }
[2]1172 }
[748]1173
[362]1174 if (recsNeeded) {
[748]1175
[846]1176 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filling");
1177
[551]1178 pcil = pcilFirst;
1179 pcir = pcirFirst;
1180 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
1181 pcir->hwndCnr = hwndRight;
[748]1182 pcir->rc.hptrIcon = (HPOINTER) 0;
[551]1183 pcil->hwndCnr = hwndLeft;
1184 pcil->rc.hptrIcon = (HPOINTER) 0;
[748]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) {
[769]1196 // File appears on left side
1197 BldFullPathName(szBuf, cmp->leftdir, filesl[l]->fname);
[763]1198 //sprintf(szBuf, "%s%s%s", cmp->leftdir,
1199 // (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
1200 // NullStr : "\\", filesl[l]->fname);
[769]1201 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
[748]1202 pcil->pszDisplayName = pcil->pszFileName + lenl;
1203 pcil->attrFile = filesl[l]->attrFile;
[751]1204 pcil->pszDispAttr = FileAttrToString(pcil->attrFile);
[748]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) {
[769]1234 // File appears on right side
[773]1235 BldFullPathName(szBuf, cmp->rightdir, filesr[r]->fname);
[769]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
[748]1240 pcir->pszDisplayName = pcir->pszFileName + lenr;
1241 pcir->attrFile = filesr[r]->attrFile;
1242 // pcir->rc.hptrIcon = hptrFile;
[751]1243 pcir->pszDispAttr = FileAttrToString(pcir->attrFile);
[748]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;
[790]1264 // Bypass check if already filtered on left side
1265 if (~pcir->rc.flRecordAttr & CRA_FILTERED &&
[748]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
[769]1276 pcil->flags |= CNRITEM_EXISTS;
1277 pcir->flags |= CNRITEM_EXISTS;
1278 pch = szBuf;
[748]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;
[897]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 :
[748]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 :
[897]1308 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE)*/ {
[748]1309 pcil->flags |= CNRITEM_NEWER;
1310 pcir->flags |= CNRITEM_OLDER;
[769]1311 if (pch != szBuf) {
[748]1312 strcpy(pch, ", ");
1313 pch += 2;
1314 }
1315 strcpy(pch, GetPString(IDS_NEWERTEXT));
1316 pch += 5;
1317 }
[897]1318 else if (ret == -1)
1319 /*((pcil->date.year < pcir->date.year) ? TRUE :
[748]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 :
[897]1331 FALSE)*/ {
[748]1332 pcil->flags |= CNRITEM_OLDER;
1333 pcir->flags |= CNRITEM_NEWER;
[769]1334 if (pch != szBuf) {
[748]1335 strcpy(pch, ", ");
1336 pch += 2;
1337 }
1338 strcpy(pch, GetPString(IDS_OLDERTEXT));
1339 pch += 5;
1340 }
[769]1341 pcil->pszSubject = *szBuf ?
1342 xstrdup(szBuf, pszSrcFile, __LINE__) :
[751]1343 NullStr;
[748]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
[751]1368 pcil->rc.pszIcon = pcil->pszDisplayName;
1369 pcir->rc.pszIcon = pcir->pszDisplayName;
[748]1370
[762]1371 pcil->pszLongName = NullStr;
1372 pcir->pszLongName = NullStr;
[751]1373
[748]1374 if (!pcil->pszSubject)
1375 pcil->pszSubject = NullStr;
1376 if (!pcir->pszSubject)
[790]1377 pcir->pszSubject = NullStr;
[748]1378
[751]1379 if (!pcil->pszDispAttr)
1380 pcil->pszDispAttr = NullStr;
1381 if (!pcir->pszDispAttr)
[790]1382 pcir->pszDispAttr = NullStr;
[751]1383
[790]1384#if 0 // 20 Aug 07 SHL fixme to be gone
[551]1385 if (!(cntr % 500))
[748]1386 DosSleep(1);
[551]1387 else if (!(cntr % 50))
[790]1388 DosSleep(0);
[551]1389 cntr++;
[846]1390#endif
1391#if 0 // 20 Aug 07 SHL
1392 if (cntr++ % 256 == 0) {
[790]1393 ul = GetMSecTimer();
[846]1394 if (ul - lastMSec >= 200) {
[790]1395 lastMSec = ul;
1396 DosSleep(1);
1397 }
1398 }
1399#endif
[846]1400#if 1 // 20 Aug 07 SHL
1401 SleepIfNeeded(0, 500, 1);
1402#endif
[748]1403
[551]1404 pcil = (PCNRITEM) pcil->rc.preccNextRecord;
1405 pcir = (PCNRITEM) pcir->rc.preccNextRecord;
[748]1406
1407 } // while filling left or right
1408
[551]1409 if (filesl)
1410 free(filesl); // Free header - have already freed elements
1411 filesl = NULL;
1412 if (filesr)
1413 free(filesr);
1414 filesr = NULL;
[748]1415 // Insert 'em
[551]1416 WinSendMsg(cmp->hwnd, UM_CONTAINERDIR, MPVOID, MPVOID);
[748]1417
[551]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))) {
[742]1427 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
[751]1428 FreeCnrItemList(hwndLeft, pcilFirst);
[551]1429 numfilesl = 0;
1430 }
[748]1431
[551]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;
[751]1439
[551]1440 if (!WinSendMsg(hwndRight, CM_INSERTRECORD,
1441 MPFROMP(pcirFirst), MPFROMP(&ri))) {
[751]1442 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
1443 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1444 FreeCnrItemList(hwndRight, pcirFirst);
[551]1445 numfilesr = 0;
1446 }
[748]1447
[551]1448 cmp->cmp->totalleft = numfilesl;
1449 cmp->cmp->totalright = numfilesr;
[748]1450
[846]1451 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filled");
1452
[748]1453 } // if recsNeeded
1454
[2]1455 Deselect(hwndLeft);
1456 Deselect(hwndRight);
[748]1457
[846]1458 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread deselected");
1459
[551]1460 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID))
1461 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
[2]1462 notified = TRUE;
[748]1463
[846]1464 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread FILLED posted");
1465
[362]1466 if (filesl)
[748]1467 FreeList((CHAR **)filesl); // Must have failed to create container
[362]1468 if (filesr)
[748]1469 FreeList((CHAR **)filesr);
1470
[2]1471 WinDestroyMsgQueue(hmq);
1472 }
[535]1473 DecrThreadUsage();
[2]1474 WinTerminate(hab);
1475 }
[362]1476 if (!notified)
[551]1477 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
[2]1478 free(cmp);
1479 DosPostEventSem(CompactSem);
[846]1480
1481 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread exit");
[2]1482}
1483
[773]1484// fixme to be gone - use variable
1485#define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR))
1486#define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
[2]1487
[846]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
[316]1517//=== CompareDlgProc() Compare directories dialog procedure ===
[2]1518
[551]1519MRESULT EXPENTRY CompareDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[316]1520{
[551]1521 COMPARE *cmp;
[773]1522 BOOL temp;
[362]1523
[773]1524 static HPOINTER hptr;
[2]1525
[551]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,
[751]1546 COMP_TOTALRIGHT, COMP_SELLEFT, COMP_SELRIGHT,
1547 0
1548 };
1549 INT x;
[2]1550
[551]1551 for (x = 0; ids[x]; x++)
1552 SetPresParams(WinWindowFromID(hwnd, ids[x]),
1553 &RGBGREY,
1554 &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT));
[2]1555 }
[551]1556 }
1557 break;
[2]1558
[551]1559 case UM_STRETCH:
1560 {
1561 SWP swp, swpC;
1562 LONG titl, szbx, szby, sz;
1563 HWND hwndActive;
[2]1564
[551]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);
[2]1631 }
[551]1632 }
1633 return 0;
[2]1634
[551]1635 case WM_ADJUSTWINDOWPOS:
1636 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
1637 break;
[2]1638
[551]1639 case UM_SETUP:
1640 {
1641 CNRINFO cnri;
1642 BOOL tempsubj;
[2]1643
[551]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;
[748]1654 cmp->dcd.detailsicon = FALSE; // TRUE;
[2]1655 }
[551]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;
[2]1693
[551]1694 case WM_DRAWITEM:
1695 if (mp2) {
[748]1696 POWNERITEM pown = (POWNERITEM)mp2;
[551]1697 PCNRDRAWITEMINFO pcown;
1698 PCNRITEM pci;
[2]1699
[748]1700 pcown = (PCNRDRAWITEMINFO)pown->hItem;
[551]1701 if (pcown) {
1702 pci = (PCNRITEM) pcown->pRecord;
[748]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)
[551]1706 return MRFROMLONG(TRUE);
[2]1707 }
[551]1708 }
1709 return 0;
[2]1710
[551]1711 case UM_CONTAINERHWND:
1712 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDBLDLISTTEXT));
1713 return 0;
[2]1714
[551]1715 case UM_CONTAINERDIR:
1716 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDFILLCNRTEXT));
1717 return 0;
[2]1718
[551]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
[846]1728 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED enter");
1729
[551]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);
[362]1772 }
[551]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));
[846]1779
1780 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED exit");
1781
[551]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;
[2]1792 }
[551]1793 }
1794 break;
[2]1795
[551]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;
[2]1804 }
[551]1805 }
1806 break;
[2]1807
[551]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;
[2]1819 }
1820 break;
[551]1821 case COMP_HIDENOTSELECTED:
1822 switch (SHORT2FROMMP(mp1)) {
1823 case BN_CLICKED:
1824 WinSendMsg(hwnd, UM_HIDENOTSELECTED, MPVOID, MPVOID);
1825 break;
1826 }
1827 break;
[2]1828
[551]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;
[2]1836
[551]1837 case CN_SETFOCUS:
1838 PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1839 (HPS) 0, TRUE, TRUE);
1840 break;
[2]1841
[551]1842 case CN_ENTER:
1843 if (mp2) {
[2]1844
[551]1845 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1846 HWND hwndCnr = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
[2]1847
[551]1848 SetShiftState();
1849 if (pci) {
[748]1850 if (pci->rc.flRecordAttr & CRA_INUSE || !pci || !*pci->pszFileName)
[551]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))
[730]1856 OpenObject(pci->pszFileName, Settings, hwnd);
[551]1857 else
[730]1858 OpenObject(pci->pszFileName, Default, hwnd);
[551]1859 }
1860 else
1861 DefaultViewKeys(hwnd, hwnd, HWND_DESKTOP, NULL,
[730]1862 pci->pszFileName);
[551]1863 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS,
1864 MPFROMP(pci),
1865 MPFROM2SHORT(FALSE, CRA_INUSE |
1866 ((fUnHilite) ? CRA_SELECTED : 0)));
1867 }
1868 }
1869 break;
[2]1870
[551]1871 case CN_CONTEXTMENU:
1872 cmp = INSTDATA(hwnd);
1873 if (cmp) {
[2]1874
[551]1875 PCNRITEM pci = (PCNRITEM) mp2;
1876 USHORT id = COMP_CNRMENU;
[2]1877
[551]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) {
[748]1883 if (!pci || !*pci->pszFileName || *cmp->rightlist)
[551]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;
[2]1907
[551]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;
[2]1915
[551]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;
[2]1922
[551]1923 case CN_EMPHASIS:
1924 {
1925 PNOTIFYRECORDEMPHASIS pre = mp2;
1926 PCNRITEM pci;
[2]1927
[551]1928 if (pre->fEmphasisMask & CRA_SELECTED) {
1929 pci = (PCNRITEM) pre->pRecord;
1930 if (pci) {
[748]1931 if (!pci || !*pci->pszFileName) {
[551]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 {
[2]1939
[551]1940 CHAR s[81];
[2]1941
[551]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) {
[846]1960 // if (WinIsWindowEnabled(hwndLeft) || !(cmp->selleft % 50)) {
1961 if (WinIsWindowEnabled(hwndLeft) || NeedGUIUpdate(0)) {
[551]1962 sprintf(s, " %d", cmp->selleft);
1963 WinSetDlgItemText(hwnd, COMP_SELLEFT, s);
1964 }
1965 }
1966 else {
[846]1967 // if (WinIsWindowEnabled(hwndRight) || !(cmp->selright % 50)) {
1968 if (WinIsWindowEnabled(hwndRight) || NeedGUIUpdate(1)) {
[551]1969 sprintf(s, " %d", cmp->selright);
1970 WinSetDlgItemText(hwnd, COMP_SELRIGHT, s);
1971 }
1972 }
1973 }
1974 }
1975 }
1976 }
1977 break;
[2]1978
[551]1979 case CN_SCROLL:
1980 cmp = INSTDATA(hwnd);
1981 if (!cmp->forcescroll) {
[2]1982
[551]1983 PNOTIFYSCROLL pns = mp2;
[2]1984
[551]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;
[2]1995 }
[551]1996 break; // COMP_RIGHTDIR
1997 }
1998 return 0; // WM_CONTROL
[2]1999
[551]2000 case UM_SETDIR:
2001 cmp = INSTDATA(hwnd);
2002 if (cmp) {
[2]2003
[551]2004 COMPARE *forthread;
2005 CNRINFO cnri;
[2]2006
[551]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 |
[751]2013 CA_CONTAINERTITLE | CA_TITLESEPARATOR |
2014 CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
[551]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 }
[362]2035 else {
[551]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 }
[2]2078 }
[551]2079 }
2080 return 0;
[2]2081
[551]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();
[2]2089 }
[551]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;
[2]2103
[551]2104 case UM_HIDENOTSELECTED:
2105 cmp = INSTDATA(hwnd);
2106 if (cmp) {
2107 USHORT wantHide = WinQueryButtonCheckstate(hwnd,
2108 COMP_HIDENOTSELECTED);
[316]2109
[551]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;
[316]2126 }
[551]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));
[748]2131 } // while
[551]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));
[316]2137 }
2138 }
[551]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;
[316]2153
[551]2154 case WM_COMMAND:
2155 switch (SHORT1FROMMP(mp1)) {
2156 case IDM_COMPARE:
2157 cmp = INSTDATA(hwnd);
2158 if (cmp) {
[2]2159
[551]2160 PCNRITEM pci;
2161 CHAR ofile[CCHMAXPATH];
[2]2162
[551]2163 pci = (PCNRITEM) WinSendMsg(cmp->hwndCalling,
2164 CM_QUERYRECORDEMPHASIS,
2165 MPFROMLONG(CMA_FIRST),
2166 MPFROMSHORT(CRA_CURSORED));
[748]2167 // 01 Aug 07 SHL
2168 if (pci && *pci->pszFileName) {
[551]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, "\\");
[751]2175 strcat(ofile, pci->pszDisplayName);
[551]2176 if (*compare) {
2177 CHAR *fakelist[3];
[730]2178 fakelist[0] = pci->pszFileName;
[551]2179 fakelist[1] = ofile;
2180 fakelist[2] = NULL;
2181 ExecOnList(hwnd, compare,
[888]2182 WINDOWED | SEPARATEKEEP, NULL, fakelist, NULL,
2183 pszSrcFile, __LINE__);
[551]2184 }
2185 else {
2186 FCOMPARE fc;
2187 memset(&fc, 0, sizeof(fc));
2188 fc.size = sizeof(fc);
2189 fc.hwndParent = hwnd;
[730]2190 strcpy(fc.file1, pci->pszFileName);
[551]2191 strcpy(fc.file2, ofile);
2192 WinDlgBox(HWND_DESKTOP, hwnd,
2193 CFileDlgProc, FM3ModHandle, FCMP_FRAME, (PVOID) & fc);
2194 }
2195 }
2196 }
2197 break;
[2]2198
[551]2199 case COMP_FILTER:
2200 case IDM_FILTER:
2201 cmp = INSTDATA(hwnd);
2202 if (cmp) {
[2]2203
[551]2204 BOOL empty = FALSE;
2205 PCNRITEM pci;
2206 CHAR *p;
2207 BOOL temp;
[2]2208
[551]2209 if (!*cmp->dcd.mask.szMask) {
2210 empty = TRUE;
2211 temp = fSelectedAlways;
2212 fSelectedAlways = TRUE;
[748]2213 pci = (PCNRITEM)CurrentRecord(hwnd);
[551]2214 fSelectedAlways = temp;
[748]2215 // 01 Aug 07 SHL
2216 if (pci && ~pci->attrFile & FILE_DIRECTORY) {
[730]2217 p = strrchr(pci->pszFileName, '\\');
[551]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;
[2]2240
[551]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) {
[2]2253
[551]2254 DIRCNRDATA dcd1;
2255 BOOL tempsubj;
[2]2256
[551]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;
[2]2270
[551]2271 case IDM_LOADLISTFILE:
2272 cmp = INSTDATA(hwnd);
2273 if (cmp) {
[2]2274
[551]2275 CHAR fullname[CCHMAXPATH];
[2]2276
[551]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;
[2]2286
[551]2287 case IDM_SAVELISTFILE:
2288 cmp = INSTDATA(hwnd);
2289 if (cmp) {
[2]2290
[551]2291 SNAPSTUFF *sf;
2292 CHAR fullname[CCHMAXPATH];
[2]2293
[551]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;
[2]2314
[551]2315 case COMP_SETDIRS:
2316 cmp = INSTDATA(hwnd);
2317 if (cmp) {
[2]2318
[551]2319 WALK2 wa;
[2]2320
[551]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)) &&
[769]2328 !IsFile(wa.szCurrentPath1) &&
2329 !IsFile(wa.szCurrentPath2)) {
[551]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;
[2]2338
[551]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) {
[2]2347
[551]2348 COMPARE *forthread;
[2]2349
[551]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;
[2]2425
[551]2426 case DID_OK:
2427 WinDismissDlg(hwnd, 0);
2428 break;
2429 case DID_CANCEL:
2430 WinDismissDlg(hwnd, 1);
2431 break;
[2]2432
[551]2433 case IDM_HELP:
2434 if (hwndHelp)
2435 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
2436 MPFROM2SHORT(HELP_COMPARE, 0), MPFROMSHORT(HM_RESOURCEID));
2437 break;
[2]2438
[551]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:
[748]2453 case IDM_SELECTIDENTICAL: // Name, size and time
2454 case IDM_SELECTSAME: // Name and size
[551]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 }
[362]2474 else {
[551]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;
[2]2536
[551]2537 case COMP_COLLECT:
2538 cmp = INSTDATA(hwnd);
[773]2539 if (!cmp)
2540 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2541 else {
2542 CHAR **listl;
2543 CHAR **listr = NULL;
[551]2544 if (!Collector) {
2545 SWP swp;
2546 HWND hwndC;
[773]2547 if (!fAutoTile &&
2548 !ParentIsDesktop(hwnd, cmp->hwndParent) &&
2549 !fExternalCollector &&
2550 !strcmp(realappname, FM3Str)) {
[551]2551 GetNextWindowPos(cmp->hwndParent, &swp, NULL, NULL);
[773]2552 }
2553 hwndC = StartCollector(fExternalCollector ||
2554 strcmp(realappname, FM3Str) ?
2555 HWND_DESKTOP :
2556 cmp->hwndParent,
2557 4);
[551]2558 if (hwndC) {
[773]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)) {
[551]2570 TileChildren(cmp->hwndParent, TRUE);
[773]2571 }
[790]2572 DosSleep(32); // 05 Aug 07 GKY 64
[551]2573 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
2574 break;
2575 }
2576 }
2577 else
2578 StartCollector(cmp->hwndParent, 4);
[2]2579
[773]2580 temp = fSelectedAlways;
2581 fSelectedAlways = TRUE;
2582 listl = BuildList(hwndLeft);
2583 if (!*cmp->rightlist)
2584 listr = BuildList(hwndRight);
2585 fSelectedAlways = temp;
2586
[551]2587 if (listl || listr) {
2588 if (Collector) {
[773]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
[551]2594 }
[773]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
[551]2599 }
2600 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2601 QW_PARENT),
[773]2602 QW_PARENT),
2603 HWND_TOP, 0, 0, 0, 0,
[551]2604 SWP_ACTIVATE);
2605 }
[773]2606 FreeList(listl);
2607 FreeList(listr);
[551]2608 }
[2]2609 }
[551]2610 break;
2611 }
2612 return 0;
[2]2613
[551]2614 case WM_CLOSE:
2615 WinDismissDlg(hwnd, 0);
2616 return 0;
[2]2617
[551]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) {
[574]2624 WinSetWindowPtr(cmp->dcd.hwndObject, QWL_USER, (PVOID) NULL);
[551]2625 if (!PostMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID))
2626 WinSendMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID);
[2]2627 }
[551]2628 free(cmp);
2629 }
2630 EmptyCnr(hwndLeft);
2631 EmptyCnr(hwndRight);
2632 DosPostEventSem(CompactSem);
2633 break;
[2]2634 }
[551]2635 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]2636}
[783]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.