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
RevLine 
[76]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
[907]9 Copyright (c) 2003, 2008 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
[907]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
[76]45
46***********************************************************************/
47
[907]48#include <stdlib.h>
49#include <string.h>
50#include <share.h>
51#include <io.h>
52#include <process.h> // _beginthread
53
[2]54#define INCL_DOS
55#define INCL_WIN
[783]56#define INCL_DOSERRORS
[2]57#define INCL_GPI
[157]58#define INCL_LONGLONG
[2]59
60#include "fm3dlg.h"
61#include "fm3str.h"
[907]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"
[2]70
[551]71typedef struct
72{
73 CHAR filename[CCHMAXPATH];
74 CHAR dirname[CCHMAXPATH];
75 BOOL recurse;
76}
77SNAPSTUFF;
[2]78
[362]79static PSZ pszSrcFile = __FILE__;
80
[316]81//=== SnapShot() Write directory tree to file and recurse if requested ===
[2]82
[783]83static VOID SnapShot(char *path, FILE *fp, BOOL recurse)
[157]84{
[841]85 PFILEFINDBUF4L pffb;
[551]86 char *mask, *enddir;
87 HDIR hdir = HDIR_CREATE;
[783]88 ULONG ulFindCnt;
[2]89
[783]90 // 13 Aug 07 SHL fimxe to use FileToGet
[841]91 pffb = xmalloc(sizeof(FILEFINDBUF4L), pszSrcFile, __LINE__);
[783]92 if (pffb) {
[551]93 mask = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
94 if (mask) {
[783]95 BldFullPathName(mask, path, "*");
96 // sprintf(mask,
97 // "%s%s*",
98 // path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
[551]99 enddir = strrchr(mask, '\\');
[2]100 enddir++;
[783]101 ulFindCnt = 1;
102 // 13 Aug 07 SHL fixme to report errors
[838]103 if (!xDosFindFirst(mask,
[907]104 &hdir,
[838]105 FILE_NORMAL | FILE_DIRECTORY |
106 FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN |
107 FILE_SYSTEM,
[841]108 pffb, sizeof(FILEFINDBUF4L), &ulFindCnt, FIL_QUERYEASIZEL)) {
[551]109 do {
[783]110 strcpy(enddir, pffb->achName);
111 if (!(pffb->attrFile & FILE_DIRECTORY))
[846]112 // 27 Sep 07 SHL fixme to use CommaFmtULL
[551]113 fprintf(fp,
[846]114 "\"%s\",%u,%llu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",
[551]115 mask,
116 enddir - mask,
[783]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,
[846]124 pffb->attrFile,
125 pffb->cbList > 4 ? pffb->cbList / 2 : 0);
[517]126 // Skip . and ..
[551]127 else if (recurse &&
[783]128 (pffb->achName[0] != '.' ||
129 (pffb->achName[1] &&
130 (pffb->achName[1] != '.' || pffb->achName[2])))) {
[551]131 SnapShot(mask, fp, recurse);
132 }
[783]133 ulFindCnt = 1;
[850]134 } while (!xDosFindNext(hdir, pffb, sizeof(FILEFINDBUF4L), &ulFindCnt, FIL_QUERYEASIZEL));
[551]135 DosFindClose(hdir);
[2]136 }
137 free(mask);
138 }
[783]139 free(pffb);
[2]140 }
141}
142
[316]143//=== StartSnap() Write directory tree to snapshot file ===
[2]144
[551]145static VOID StartSnap(VOID * dummy)
[316]146{
[551]147 SNAPSTUFF *sf = (SNAPSTUFF *) dummy;
148 FILE *fp;
149 CHAR *p;
[2]150
[551]151 if (sf) {
152 if (*sf->dirname && *sf->filename) {
[2]153 priority_normal();
154 p = sf->dirname;
[551]155 while (*p) {
156 if (*p == '/')
157 *p = '\\';
158 p++;
[2]159 }
[551]160 if (*(p - 1) != '\\') {
161 *p = '\\';
162 p++;
[2]163 }
[551]164 fp = xfopen(sf->filename, "w", pszSrcFile, __LINE__);
[362]165 if (fp) {
[551]166 fprintf(fp, "\"%s\"\n", sf->dirname);
167 SnapShot(sf->dirname, fp, sf->recurse);
168 fclose(fp);
[2]169 }
170 }
171 free(sf);
172 }
173}
174
[316]175//=== CompareFilesThread() Compare files and update container select flags ===
[2]176
[551]177static VOID CompareFilesThread(VOID * args)
[316]178{
[2]179 FCOMPARE fc;
[551]180 HAB hab2;
181 HMQ hmq2;
182 FILE *fp1, *fp2;
[847]183 ULONG len1, len2;
[841]184 ULONG offset = 0;
[551]185 LONG numread1, numread2;
186 CHAR s[1024], ss[1024], *p1, *p2;
[2]187
[551]188 if (args) {
189 fc = *(FCOMPARE *) args;
[2]190 hab2 = WinInitialize(0);
[551]191 if (hab2) {
192 hmq2 = WinCreateMsgQueue(hab2, 0);
193 if (hmq2) {
194 WinCancelShutdown(hmq2, TRUE);
[535]195 IncrThreadUsage();
[551]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 }
[362]203 }
[551]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 }
[362]222 else {
[551]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));
[362]228 }
229 else {
[847]230 len1 = filelength(fileno(fp1));
231 len2 = filelength(fileno(fp2));
[551]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 }
[535]299 DecrThreadUsage();
[551]300 WinDestroyMsgQueue(hmq2);
[2]301 }
302 WinTerminate(hab2);
303 }
304 }
305}
306
[316]307//=== CFileDlgProc() Select directories to compare dialog procedure ===
[2]308
[551]309MRESULT EXPENTRY CFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[316]310{
[2]311 FCOMPARE *fc;
312
[551]313 switch (msg) {
314 case WM_INITDLG:
315 if (!mp2)
316 WinDismissDlg(hwnd, 0);
317 else {
[574]318 WinSetWindowPtr(hwnd, QWL_USER, mp2);
[551]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;
[2]326 }
[551]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;
[2]343
[551]344 case WM_ADJUSTWINDOWPOS:
345 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
346 break;
[2]347
[551]348 case UM_SETDIR:
349 PaintRecessedWindow(WinWindowFromID(hwnd, FCMP_HELP),
350 (HPS) 0, FALSE, TRUE);
351 return 0;
[2]352
[551]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;
[2]363
[551]364 case WM_DESTROY:
[846]365 DosSleep(50); // 05 Aug 07 GKY 100
[551]366 break;
[2]367 }
[551]368 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]369}
370
[316]371//=== ActionCnrThread() Do requested action on container contents ===
[2]372
[731]373static VOID ActionCnrThread(VOID *args)
[316]374{
[731]375 COMPARE *cmp = (COMPARE *)args;
[551]376 HAB hab;
377 HMQ hmq;
378 HWND hwndCnrS, hwndCnrD;
[748]379 PCNRITEM pci, pciD, pciNextS, pciNextD;
[769]380 CHAR szNewName[CCHMAXPATH], szDirName[CCHMAXPATH], *p;
[551]381 APIRET rc;
[2]382
[748]383 if (!cmp) {
[773]384 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]385 return;
[748]386 }
[2]387
388 DosError(FERR_DISABLEHARDERR);
389
390 hab = WinInitialize(0);
[551]391 if (hab) {
392 hmq = WinCreateMsgQueue(hab, 0);
393 if (hmq) {
394 WinCancelShutdown(hmq, TRUE);
[535]395 IncrThreadUsage();
[2]396 priority_normal();
[551]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;
[2]431 }
432
[551]433 pci = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPVOID,
434 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
[748]435 pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
[551]436 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
[316]437
[907]438 WinStartTimer(hab, cmp->hwnd, ID_TIMER, 2000);
439
[748]440 while (pci && (INT)pci != -1 && pciD && (INT)pciD != -1) {
441
442 pciNextS = WinSendMsg(hwndCnrS, CM_QUERYRECORD, MPFROMP(pci),
[551]443 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
[748]444 pciNextD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPFROMP(pciD),
[551]445 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
[748]446
447 if (*pci->pszFileName && pci->rc.flRecordAttr & CRA_SELECTED) {
448
449 // Source name not blank
[551]450 switch (cmp->action) {
451 case IDM_DELETE:
[730]452 if (!unlinkf("%s", pci->pszFileName)) {
[551]453 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
454 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]455
456 if (!*pciD->pszFileName) {
[751]457 // Other side is blank - remove from both sides
458 RemoveCnrItems(hwndCnrS, pci, 1, CMA_FREE | CMA_INVALIDATE);
[748]459 if (pciD->rc.flRecordAttr & CRA_SELECTED)
460 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
[551]461 MPFROM2SHORT(FALSE, CRA_SELECTED));
[751]462 RemoveCnrItems(hwndCnrD, pciD, 1, CMA_FREE | CMA_INVALIDATE);
[551]463 }
[742]464 else {
[751]465 // Other side is not blank - update just this side
[748]466 FreeCnrItemData(pci);
[751]467 pci->pszDisplayName = pci->pszFileName;
468 pci->rc.pszIcon = pci->pszFileName;
[551]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--;
[846]477 DosSleep(0); // 8-26-07 GKY 1
[551]478 }
479 break;
[2]480
[551]481 case IDM_MOVE:
482 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
[769]483 BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName);
484 //sprintf(szNewName, "%s%s%s",
[763]485 // cmp->leftdir,
486 // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
[769]487 // NullStr : "\\",
488 // pci->pszDisplayName);
489 else
490 BldFullPathName(szNewName, cmp->rightdir, pci->pszDisplayName);
491 //sprintf(szNewName, "%s%s%s",
[763]492 // cmp->rightdir,
[765]493 // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
[769]494 // NullStr : "\\",
[765]495 // pci->pszDisplayName);
[748]496 // Make directory if required
[769]497 strcpy(szDirName, szNewName);
498 p = strrchr(szDirName, '\\');
[551]499 if (p) {
[769]500 if (p > szDirName + 2)
[551]501 p++;
502 *p = 0;
[769]503 if (IsFile(szDirName) == -1)
504 MassMkdir(hwndMain, szDirName);
[551]505 }
[769]506 rc = docopyf(MOVE, pci->pszFileName, "%s", szNewName);
507 if (!rc && stricmp(pci->pszFileName, szNewName)) {
[551]508 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
509 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]510 if (pciD->rc.flRecordAttr & CRA_SELECTED)
511 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
[551]512 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]513 FreeCnrItemData(pciD);
[769]514 pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
[551]515 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
[748]516 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
[551]517 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
[751]518 pciD->pszDisplayName++;
[551]519 }
520 else {
[748]521 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
[551]522 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
[751]523 pciD->pszDisplayName++;
[742]524 }
[769]525 // 02 Aug 07 SHL fixme to know if LongName transfer is correct?
[762]526 pciD->pszLongName = pci->pszLongName;
[751]527 if (pciD->pszSubject != NullStr) {
528 xfree(pciD->pszSubject);
529 pciD->pszSubject = NullStr;
530 }
[748]531 pciD->attrFile = pci->attrFile;
[751]532 pciD->pszDispAttr = pci->pszDispAttr;
[769]533 pciD->flags = 0; // Just on one side
[748]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;
[751]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 }
[551]553 pci->flags = 0;
[751]554
[551]555 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
556 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
[748]557 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
[551]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),
[769]567 pci->pszFileName, szNewName);
[748]568 if (rc == MBID_CANCEL) // Cause loop to break
569 pciNextS = NULL;
[551]570 }
571 break;
[2]572
[551]573 case IDM_COPY:
[769]574 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR))
575 BldFullPathName(szNewName, cmp->leftdir, pci->pszDisplayName);
576 //sprintf(szNewName, "%s%s%s",
[763]577 // cmp->leftdir,
578 // cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
[769]579 // NullStr : "\\",
[765]580 // pci->pszDisplayName);
[769]581 else
582 BldFullPathName(szNewName, cmp->rightdir, pci->pszDisplayName);
583 //sprintf(szNewName, "%s%s%s",
[763]584 // cmp->rightdir,
585 // cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
[769]586 // NullStr : "\\",
[763]587 // pci->pszDisplayName);
[748]588 // Make directory if required
[769]589 strcpy(szDirName, szNewName);
590 p = strrchr(szDirName, '\\');
[551]591 if (p) {
[769]592 if (p > szDirName + 2)
[551]593 p++;
594 *p = 0;
[769]595 if (IsFile(szDirName) == -1)
596 MassMkdir(hwndMain, szDirName);
[551]597 }
[769]598 rc = docopyf(COPY, pci->pszFileName, "%s", szNewName);
[551]599 if (rc) {
600 rc = Dos_Error(MB_ENTERCANCEL,
601 rc,
602 HWND_DESKTOP,
603 pszSrcFile,
604 __LINE__,
605 GetPString(IDS_COMPCOPYFAILEDTEXT),
[769]606 pci->pszFileName, szNewName);
[551]607 if (rc == MBID_CANCEL)
[748]608 pciNextS = NULL; // Cause loop to break
[551]609 }
610 else {
611 WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pci),
612 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]613 if (pciD->rc.flRecordAttr & CRA_SELECTED)
614 WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
[551]615 MPFROM2SHORT(FALSE, CRA_SELECTED));
[748]616 FreeCnrItemData(pciD);
[769]617 pciD->pszFileName = xstrdup(szNewName, pszSrcFile, __LINE__);
[551]618 if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
[748]619 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
[551]620 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
[751]621 pciD->pszDisplayName++;
[362]622 }
623 else {
[748]624 pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->rightdir);
[551]625 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
[751]626 pciD->pszDisplayName++;
[742]627 }
[748]628 pciD->attrFile = pci->attrFile;
[751]629 pciD->pszDispAttr = pci->pszDispAttr;
[769]630 pciD->flags = CNRITEM_EXISTS; // Now on both sides
[748]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;
[751]639
[769]640 // Forget status until we regenerate it
[751]641 if (pci->pszSubject != NullStr) {
642 xfree(pci->pszSubject);
643 pci->pszSubject = NullStr;
644 }
[769]645 pci->flags = CNRITEM_EXISTS;
[751]646
[551]647 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
648 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
[748]649 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
[551]650 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
651 }
652 break;
[2]653
[551]654 default:
655 break;
[748]656 } // switch
657
658 } // if have name
659
660 pci = pciNextS;
661 pciD = pciNextD;
662
663 } // while
[551]664 Abort:
[907]665 WinStopTimer(hab, cmp->hwnd, ID_TIMER);
[2]666 WinDestroyMsgQueue(hmq);
667 }
[907]668 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
669 PostMsg(cmp->hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DESELECTALL, 0), MPVOID);
[535]670 DecrThreadUsage();
[2]671 WinTerminate(hab);
672 }
673 free(cmp);
674}
675
[316]676//=== SelectCnrsThread() Update container selection flags thread ===
[2]677
[551]678static VOID SelectCnrsThread(VOID * args)
[316]679{
[551]680 COMPARE *cmp = (COMPARE *) args;
681 HAB hab;
682 HMQ hmq;
[2]683
[783]684 if (!cmp) {
685 Runtime_Error(pszSrcFile, __LINE__, "no data");
[2]686 return;
[783]687 }
[2]688
689 DosError(FERR_DISABLEHARDERR);
690
691 hab = WinInitialize(0);
[551]692 if (hab) {
693 hmq = WinCreateMsgQueue(hab, 0);
694 if (hmq) {
695 WinCancelShutdown(hmq, TRUE);
[535]696 IncrThreadUsage();
[2]697 priority_normal();
[907]698 WinStartTimer(hab, cmp->hwnd, ID_TIMER, 2000);
[551]699 switch (cmp->action) {
700 case IDM_INVERT:
701 InvertAll(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
702 InvertAll(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
703 break;
[2]704
[551]705 case IDM_DESELECTALL:
706 Deselect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR));
707 Deselect(WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR));
708 break;
[2]709
[551]710 default:
711 SpecialSelect(WinWindowFromID(cmp->hwnd, COMP_LEFTDIR),
712 WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR),
713 cmp->action, cmp->reset);
714 break;
[2]715 }
[907]716 WinStopTimer(hab, cmp->hwnd, ID_TIMER);
[551]717 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID))
718 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPFROMLONG(1L), MPVOID);
[2]719 WinDestroyMsgQueue(hmq);
720 }
[535]721 DecrThreadUsage();
[2]722 WinTerminate(hab);
723 }
724 free(cmp);
725}
726
[748]727/**
728 * Build FILELIST given pathname
729 */
730
[907]731static VOID FillDirList(CHAR *str, UINT skiplen, BOOL recurse,
732 FILELIST ***list, UINT *pnumfiles, UINT *pnumalloc)
[551]733{
[748]734 CHAR *enddir;
735 ULONG x;
[551]736 CHAR *maskstr;
[841]737 PFILEFINDBUF4L pffbArray;
738 PFILEFINDBUF4L pffbFile;
[551]739 HDIR hDir;
[783]740 ULONG ulFindCnt;
[841]741 ULONG ulBufBytes = sizeof(FILEFINDBUF4L) * FilesToGet;
[551]742 APIRET rc;
[2]743
[748]744 if (!str || !*str) {
[773]745 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]746 return;
[748]747 }
748
[846]749 // DbgMsg(pszSrcFile, __LINE__, "FillDirList start %s", str);
750
[551]751 maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
752 if (!maskstr)
[2]753 return;
[783]754 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
755 if (!pffbArray) {
[2]756 free(maskstr);
757 return;
758 }
759 x = strlen(str);
[551]760 memcpy(maskstr, str, x + 1);
[2]761 enddir = maskstr + x;
[551]762 if (*(enddir - 1) != '\\') {
[2]763 *enddir = '\\';
764 enddir++;
765 *enddir = 0;
766 }
767 *enddir = '*';
768 *(enddir + 1) = 0;
769 hDir = HDIR_CREATE;
770 DosError(FERR_DISABLEHARDERR);
[783]771 ulFindCnt = FilesToGet;
[838]772 rc = xDosFindFirst(maskstr, &hDir,
[907]773 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
[838]774 FILE_SYSTEM | FILE_HIDDEN |
775 (recurse ? FILE_DIRECTORY : 0),
[841]776 pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
[551]777 if (!rc) {
[783]778 do {
779 pffbFile = pffbArray;
780 for (x = 0; x < ulFindCnt; x++) {
781 if (pffbFile->attrFile & FILE_DIRECTORY) {
[517]782 // Skip . and ..
[551]783 if (recurse &&
[783]784 (pffbFile->achName[0] != '.' ||
785 (pffbFile->achName[1] &&
786 (pffbFile->achName[1] != '.' || pffbFile->achName[2])))) {
[551]787 if (fForceUpper)
[783]788 strupr(pffbFile->achName);
[551]789 else if (fForceLower)
[783]790 strlwr(pffbFile->achName);
791 memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1);
[907]792 FillDirList(maskstr, skiplen, recurse, list, pnumfiles, pnumalloc);
[551]793 }
794 }
795 else {
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);
801 if (AddToFileList(maskstr + skiplen,
[907]802 pffbFile, list, pnumfiles, pnumalloc)) {
[551]803 goto Abort;
[783]804 }
[551]805 }
[841]806 pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
[783]807 } // for
[2]808 DosError(FERR_DISABLEHARDERR);
[783]809 ulFindCnt = FilesToGet;
[850]810 rc = xDosFindNext(hDir, pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
[783]811 } while (!rc);
812
813Abort:
814
[2]815 DosFindClose(hDir);
[846]816 DosSleep(0);
[2]817 }
[783]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
[2]824 free(maskstr);
[783]825 free(pffbArray);
[846]826
827 // DbgMsg(pszSrcFile, __LINE__, "FillDirList finish %s", str);
[2]828}
829
[316]830//=== CompNames() Compare names for qsort ===
[2]831
[551]832static int CompNames(const void *n1, const void *n2)
[316]833{
[551]834 FILELIST *fl1 = *(FILELIST **) n1;
835 FILELIST *fl2 = *(FILELIST **) n2;
[2]836
[551]837 return stricmp(fl1->fname, fl2->fname);
[2]838}
839
[316]840//=== FillCnrsThread() Fill left and right containers ===
[2]841
[751]842static VOID FillCnrsThread(VOID *args)
[316]843{
[551]844 COMPARE *cmp = (COMPARE *) args;
845 HAB hab;
846 HMQ hmq;
847 BOOL notified = FALSE;
[907]848 ITIMER_DESC itdSleep = { 0 };
[751]849
[551]850 HWND hwndLeft, hwndRight;
[748]851 CHAR szBuf[CCHMAXPATH];
852 CNRINFO cnri;
[2]853
[748]854 if (!cmp) {
[773]855 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]856 _endthread();
[748]857 }
[2]858
[846]859 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread enter");
860
[2]861 DosError(FERR_DISABLEHARDERR);
862
[907]863 InitITimer(&itdSleep, 500); // Sleep every 500 mSec
864
[2]865 hab = WinInitialize(0);
[551]866 if (!hab)
867 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__, "WinInitialize");
[362]868 else {
[551]869 hmq = WinCreateMsgQueue(hab, 0);
870 if (!hmq)
871 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
872 "WinCreateMsgQueue");
[362]873 else {
[551]874 INT x;
[907]875 UINT l;
876 UINT r;
[846]877 UINT cntr;
[551]878 FILELIST **filesl = NULL;
879 FILELIST **filesr = NULL;
[917]880 // UINT numfilesl = 0; // 08 Jan 08 SHL fixme
881 // UINT numfilesr = 0;
[907]882 UINT numallocl = 0;
883 UINT numallocr = 0;
[897]884 INT ret = 0;
[769]885 UINT lenl; // Directory prefix length
886 UINT lenr;
[748]887 UINT recsNeeded;
[907]888 UINT recsGotten;
889 UINT filesSeenL;
890 UINT filesSeenR;
[551]891 PCNRITEM pcilFirst;
892 PCNRITEM pcirFirst;
[907]893 PCNRITEM pcilLast;
894 PCNRITEM pcirLast;
[551]895 PCNRITEM pcil;
896 PCNRITEM pcir;
897 RECORDINSERT ri;
898 CHAR *pch;
[2]899
[551]900 WinCancelShutdown(hmq, TRUE);
[535]901 IncrThreadUsage();
[907]902 WinStartTimer(hab, cmp->hwnd, ID_TIMER, 2000);
903
[551]904 hwndLeft = WinWindowFromID(cmp->hwnd, COMP_LEFTDIR);
905 hwndRight = WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR);
[2]906 lenl = strlen(cmp->leftdir);
[551]907 if (cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
908 lenl++;
[2]909 lenr = strlen(cmp->rightdir);
[551]910 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
911 lenr++;
[2]912 priority_normal();
[748]913 // Clear containers
[751]914 RemoveCnrItems(hwndRight, NULL, 0, CMA_FREE | CMA_INVALIDATE);
915 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
[917]916 cmp->cmp->totalleft = 0;
917 cmp->cmp->totalright = 0;
[2]918
[748]919 // Build list of all files in left directory
[551]920 if (fForceLower)
921 strlwr(cmp->leftdir);
922 else if (fForceUpper)
923 strupr(cmp->leftdir);
924 FillDirList(cmp->leftdir, lenl, cmp->includesubdirs,
[907]925 &filesl, &cmp->cmp->totalleft, &numallocl);
[917]926 // numfilesl = cmp->cmp->totalleft; // 08 Jan 08 SHL fixme
[2]927
[551]928 if (filesl)
[917]929 qsort(filesl, cmp->cmp->totalleft, sizeof(CHAR *), CompNames);
[748]930
[846]931 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesl");
932
[748]933 // Build list of all files in right directory
[551]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,
[907]940 &filesr, &cmp->cmp->totalright, &numallocr);
[917]941 // numfilesr = cmp->cmp->totalright;
[2]942 }
[551]943 else {
[748]944 // Use snapshot file
[551]945 FILE *fp;
[841]946 FILEFINDBUF4L fb4;
[551]947 CHAR str[CCHMAXPATH * 2], *p;
[2]948
[551]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);
[362]954 else {
[551]955 while (!feof(fp)) {
[748]956 // First get name of directory
[551]957 if (!xfgets_bstripcr(str, sizeof(str), fp, pszSrcFile, __LINE__))
958 break; // EOF
959 p = str;
960 if (*p == '\"') {
[748]961 // Quoted
[551]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 }
[748]981 } // while !EOF
[2]982
[748]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");
[551]989 }
[748]990
[551]991 if (*cmp->rightdir) {
[769]992 lenr = strlen(cmp->rightdir);
993 if (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
994 lenr++;
[551]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++;
[846]1014 // 27 Sep 07 SHL fixme to do ULONGLONG conversion
[551]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,
[917]1055 &cmp->cmp->totalright,
[551]1056 &numallocr))
1057 break;
1058 }
1059 }
1060 }
1061 }
1062 }
1063 }
1064 }
1065 }
1066 }
1067 }
1068 }
1069 }
1070 }
[748]1071 } // while
1072 } // if have rightdir
[551]1073 fclose(fp);
1074 }
[748]1075 } // if snapshot file
[316]1076
[551]1077 if (filesr)
[917]1078 qsort(filesr, cmp->cmp->totalright, sizeof(CHAR *), CompNames);
[2]1079
[846]1080 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread sorted filesr");
1081
[748]1082 // We now have two lists of files, both sorted.
1083 // Count total number of container entries required on each side
[2]1084 l = r = 0;
[316]1085 recsNeeded = 0;
[551]1086 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
[748]1087
1088 if (filesl && filesl[l]) {
1089 if (filesr && filesr[r])
1090 x = stricmp(filesl[l]->fname, filesr[r]->fname);
[551]1091 else
[748]1092 x = -1; // Left side list longer
[551]1093 }
[748]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
[907]1106 // Say building list - fixme to post?
[551]1107 WinSendMsg(cmp->hwnd, UM_CONTAINERHWND, MPVOID, MPVOID);
[748]1108
1109 // Now insert records into the containers
[2]1110 cntr = 0;
1111 l = r = 0;
[551]1112 if (recsNeeded) {
1113 pcilFirst = WinSendMsg(hwndLeft,
1114 CM_ALLOCRECORD,
[751]1115 MPFROMLONG(EXTRA_RECORD_BYTES),
[551]1116 MPFROMLONG(recsNeeded));
1117 if (!pcilFirst) {
[742]1118 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1119 recsNeeded);
[551]1120 recsNeeded = 0;
1121 }
[316]1122 }
[362]1123 if (recsNeeded) {
[551]1124 pcirFirst = WinSendMsg(hwndRight, CM_ALLOCRECORD,
[751]1125 MPFROMLONG(EXTRA_RECORD_BYTES),
[551]1126 MPFROMLONG(recsNeeded));
1127 if (!pcirFirst) {
[742]1128 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
1129 recsNeeded);
[551]1130 recsNeeded = 0;
[751]1131 FreeCnrItemList(hwndLeft, pcilFirst);
[551]1132 }
[2]1133 }
[748]1134
[362]1135 if (recsNeeded) {
[748]1136
[846]1137 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filling");
1138
[551]1139 pcil = pcilFirst;
1140 pcir = pcirFirst;
[907]1141 pcilLast = 0;
1142 pcirLast = 0;
1143
1144 recsGotten = 0;
1145 filesSeenL = 0;
1146 filesSeenR = 0;
1147
[551]1148 while ((filesl && filesl[l]) || (filesr && filesr[r])) {
[907]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++;
[551]1164 pcir->hwndCnr = hwndRight;
[748]1165 pcir->rc.hptrIcon = (HPOINTER) 0;
[551]1166 pcil->hwndCnr = hwndLeft;
1167 pcil->rc.hptrIcon = (HPOINTER) 0;
[748]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) {
[769]1179 // File appears on left side
[907]1180 filesSeenL++;
[917]1181 cmp->cmp->totalleft = filesSeenL;
[769]1182 BldFullPathName(szBuf, cmp->leftdir, filesl[l]->fname);
1183 pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
[748]1184 pcil->pszDisplayName = pcil->pszFileName + lenl;
1185 pcil->attrFile = filesl[l]->attrFile;
[751]1186 pcil->pszDispAttr = FileAttrToString(pcil->attrFile);
[748]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) {
[769]1216 // File appears on right side
[907]1217 filesSeenR++;
[917]1218 cmp->cmp->totalright = filesSeenR;
[773]1219 BldFullPathName(szBuf, cmp->rightdir, filesr[r]->fname);
[769]1220 pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL
[748]1221 pcir->pszDisplayName = pcir->pszFileName + lenr;
1222 pcir->attrFile = filesr[r]->attrFile;
1223 // pcir->rc.hptrIcon = hptrFile;
[751]1224 pcir->pszDispAttr = FileAttrToString(pcir->attrFile);
[748]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;
[790]1245 // Bypass check if already filtered on left side
1246 if (~pcir->rc.flRecordAttr & CRA_FILTERED &&
[748]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
[769]1257 pcil->flags |= CNRITEM_EXISTS;
1258 pcir->flags |= CNRITEM_EXISTS;
1259 pch = szBuf;
[748]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;
[907]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 :
[748]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 :
[897]1289 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE)*/ {
[748]1290 pcil->flags |= CNRITEM_NEWER;
1291 pcir->flags |= CNRITEM_OLDER;
[769]1292 if (pch != szBuf) {
[748]1293 strcpy(pch, ", ");
1294 pch += 2;
1295 }
1296 strcpy(pch, GetPString(IDS_NEWERTEXT));
1297 pch += 5;
1298 }
[907]1299 else if (ret == -1)
1300 /*((pcil->date.year < pcir->date.year) ? TRUE :
[748]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 :
[897]1312 FALSE)*/ {
[748]1313 pcil->flags |= CNRITEM_OLDER;
1314 pcir->flags |= CNRITEM_NEWER;
[769]1315 if (pch != szBuf) {
[748]1316 strcpy(pch, ", ");
1317 pch += 2;
1318 }
1319 strcpy(pch, GetPString(IDS_OLDERTEXT));
1320 pch += 5;
1321 }
[769]1322 pcil->pszSubject = *szBuf ?
1323 xstrdup(szBuf, pszSrcFile, __LINE__) :
[751]1324 NullStr;
[748]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
[751]1349 pcil->rc.pszIcon = pcil->pszDisplayName;
1350 pcir->rc.pszIcon = pcir->pszDisplayName;
[748]1351
[762]1352 pcil->pszLongName = NullStr;
1353 pcir->pszLongName = NullStr;
[751]1354
[748]1355 if (!pcil->pszSubject)
1356 pcil->pszSubject = NullStr;
1357 if (!pcir->pszSubject)
[790]1358 pcir->pszSubject = NullStr;
[748]1359
[751]1360 if (!pcil->pszDispAttr)
1361 pcil->pszDispAttr = NullStr;
1362 if (!pcir->pszDispAttr)
[790]1363 pcir->pszDispAttr = NullStr;
[751]1364
[907]1365 // Avoid hogging systems
1366 SleepIfNeeded(&itdSleep, 0);
[748]1367
[907]1368 pcilLast = pcil;
1369 pcirLast = pcir;
[551]1370 pcil = (PCNRITEM) pcil->rc.preccNextRecord;
1371 pcir = (PCNRITEM) pcir->rc.preccNextRecord;
[748]1372
1373 } // while filling left or right
1374
[907]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 }
[917]1399 // Reduce count to match what is in containers
[907]1400 recsNeeded = recsGotten;
1401 } // if insufficient resources
1402
[551]1403 if (filesl)
1404 free(filesl); // Free header - have already freed elements
1405 filesl = NULL;
1406 if (filesr)
1407 free(filesr);
1408 filesr = NULL;
[907]1409
1410 // Say inserting
[551]1411 WinSendMsg(cmp->hwnd, UM_CONTAINERDIR, MPVOID, MPVOID);
[748]1412
[907]1413 // Insert left side
[551]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))) {
[742]1423 Win_Error(hwndLeft, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
[751]1424 FreeCnrItemList(hwndLeft, pcilFirst);
[917]1425 // numfilesl = 0; // 08 Jan 08 SHL fixme
1426 cmp->cmp->totalleft = 0;
[551]1427 }
[748]1428
[907]1429 // Insert right side
[551]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;
[751]1437
[551]1438 if (!WinSendMsg(hwndRight, CM_INSERTRECORD,
1439 MPFROMP(pcirFirst), MPFROMP(&ri))) {
[751]1440 Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
1441 RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1442 FreeCnrItemList(hwndRight, pcirFirst);
[917]1443 // numfilesr = 0;
1444 cmp->cmp->totalright = 0;
[551]1445 }
[748]1446
[846]1447 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread filled");
1448
[748]1449 } // if recsNeeded
1450
[907]1451 WinStopTimer(hab, cmp->hwnd, ID_TIMER);
1452
[2]1453 Deselect(hwndLeft);
1454 Deselect(hwndRight);
[748]1455
[846]1456 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread deselected");
1457
[907]1458 // Request window update
[551]1459 if (!PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID))
1460 WinSendMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
[2]1461 notified = TRUE;
[748]1462
[846]1463 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread FILLED posted");
1464
[362]1465 if (filesl)
[748]1466 FreeList((CHAR **)filesl); // Must have failed to create container
[362]1467 if (filesr)
[748]1468 FreeList((CHAR **)filesr);
1469
[2]1470 WinDestroyMsgQueue(hmq);
[907]1471 } // if have queue
1472 if (!notified)
1473 PostMsg(cmp->hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
[535]1474 DecrThreadUsage();
[2]1475 WinTerminate(hab);
1476 }
1477 free(cmp);
1478 DosPostEventSem(CompactSem);
[846]1479
1480 // DbgMsg(pszSrcFile, __LINE__, "FillCnrsThread exit");
[2]1481}
1482
[773]1483// fixme to be gone - use variable
1484#define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR))
1485#define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
[2]1486
[316]1487//=== CompareDlgProc() Compare directories dialog procedure ===
[2]1488
[551]1489MRESULT EXPENTRY CompareDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[316]1490{
[551]1491 COMPARE *cmp;
[773]1492 BOOL temp;
[907]1493 CHAR s[81];
[362]1494
[773]1495 static HPOINTER hptr;
[2]1496
[551]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,
[751]1517 COMP_TOTALRIGHT, COMP_SELLEFT, COMP_SELRIGHT,
1518 0
1519 };
1520 INT x;
[2]1521
[551]1522 for (x = 0; ids[x]; x++)
1523 SetPresParams(WinWindowFromID(hwnd, ids[x]),
1524 &RGBGREY,
1525 &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVTEXT));
[2]1526 }
[551]1527 }
1528 break;
[2]1529
[551]1530 case UM_STRETCH:
1531 {
1532 SWP swp, swpC;
1533 LONG titl, szbx, szby, sz;
1534 HWND hwndActive;
[2]1535
[551]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);
[2]1602 }
[551]1603 }
1604 return 0;
[2]1605
[551]1606 case WM_ADJUSTWINDOWPOS:
1607 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
1608 break;
[2]1609
[551]1610 case UM_SETUP:
1611 {
1612 CNRINFO cnri;
1613 BOOL tempsubj;
[2]1614
[551]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;
[748]1625 cmp->dcd.detailsicon = FALSE; // TRUE;
[2]1626 }
[551]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;
[2]1664
[551]1665 case WM_DRAWITEM:
1666 if (mp2) {
[748]1667 POWNERITEM pown = (POWNERITEM)mp2;
[551]1668 PCNRDRAWITEMINFO pcown;
1669 PCNRITEM pci;
[2]1670
[748]1671 pcown = (PCNRDRAWITEMINFO)pown->hItem;
[551]1672 if (pcown) {
1673 pci = (PCNRITEM) pcown->pRecord;
[748]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)
[551]1677 return MRFROMLONG(TRUE);
[2]1678 }
[551]1679 }
1680 return 0;
[2]1681
[551]1682 case UM_CONTAINERHWND:
[907]1683 // Building list
[551]1684 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDBLDLISTTEXT));
1685 return 0;
[2]1686
[551]1687 case UM_CONTAINERDIR:
[907]1688 // Filling container
[551]1689 WinSetDlgItemText(hwnd, COMP_NOTE, GetPString(IDS_COMPHOLDFILLCNRTEXT));
1690 return 0;
[2]1691
[907]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
[551]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
[846]1720 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED enter");
1721
[551]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);
[362]1764 }
[551]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));
[846]1771
1772 // DbgMsg(pszSrcFile, __LINE__, "CompareDlgProc UM_CONTAINER_FILLED exit");
1773
[551]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;
[2]1784 }
[551]1785 }
1786 break;
[2]1787
[551]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;
[2]1796 }
[551]1797 }
1798 break;
[2]1799
[551]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;
[2]1811 }
1812 break;
[551]1813 case COMP_HIDENOTSELECTED:
1814 switch (SHORT2FROMMP(mp1)) {
1815 case BN_CLICKED:
1816 WinSendMsg(hwnd, UM_HIDENOTSELECTED, MPVOID, MPVOID);
1817 break;
1818 }
1819 break;
[2]1820
[551]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;
[2]1828
[551]1829 case CN_SETFOCUS:
1830 PaintRecessedWindow(WinWindowFromID(hwnd, SHORT1FROMMP(mp1)),
1831 (HPS) 0, TRUE, TRUE);
1832 break;
[2]1833
[551]1834 case CN_ENTER:
1835 if (mp2) {
[2]1836
[551]1837 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1838 HWND hwndCnr = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
[2]1839
[551]1840 SetShiftState();
1841 if (pci) {
[748]1842 if (pci->rc.flRecordAttr & CRA_INUSE || !pci || !*pci->pszFileName)
[551]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))
[730]1848 OpenObject(pci->pszFileName, Settings, hwnd);
[551]1849 else
[730]1850 OpenObject(pci->pszFileName, Default, hwnd);
[551]1851 }
1852 else
1853 DefaultViewKeys(hwnd, hwnd, HWND_DESKTOP, NULL,
[730]1854 pci->pszFileName);
[551]1855 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS,
1856 MPFROMP(pci),
1857 MPFROM2SHORT(FALSE, CRA_INUSE |
1858 ((fUnHilite) ? CRA_SELECTED : 0)));
1859 }
1860 }
1861 break;
[2]1862
[551]1863 case CN_CONTEXTMENU:
1864 cmp = INSTDATA(hwnd);
1865 if (cmp) {
[2]1866
[551]1867 PCNRITEM pci = (PCNRITEM) mp2;
1868 USHORT id = COMP_CNRMENU;
[2]1869
[551]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) {
[748]1875 if (!pci || !*pci->pszFileName || *cmp->rightlist)
[551]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;
[2]1899
[551]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;
[2]1907
[551]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;
[2]1914
[551]1915 case CN_EMPHASIS:
1916 {
1917 PNOTIFYRECORDEMPHASIS pre = mp2;
1918 PCNRITEM pci;
[2]1919
[551]1920 if (pre->fEmphasisMask & CRA_SELECTED) {
1921 pci = (PCNRITEM) pre->pRecord;
1922 if (pci) {
[748]1923 if (!pci || !*pci->pszFileName) {
[551]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 {
[2]1931
[551]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;
[2]1954
[551]1955 case CN_SCROLL:
1956 cmp = INSTDATA(hwnd);
1957 if (!cmp->forcescroll) {
[2]1958
[551]1959 PNOTIFYSCROLL pns = mp2;
[2]1960
[551]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;
[2]1971 }
[551]1972 break; // COMP_RIGHTDIR
1973 }
1974 return 0; // WM_CONTROL
[2]1975
[551]1976 case UM_SETDIR:
1977 cmp = INSTDATA(hwnd);
1978 if (cmp) {
[2]1979
[551]1980 COMPARE *forthread;
1981 CNRINFO cnri;
[2]1982
[551]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 |
[751]1989 CA_CONTAINERTITLE | CA_TITLESEPARATOR |
1990 CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
[551]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 }
[362]2011 else {
[551]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 }
[2]2054 }
[551]2055 }
2056 return 0;
[2]2057
[551]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();
[2]2065 }
[551]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;
[2]2079
[551]2080 case UM_HIDENOTSELECTED:
2081 cmp = INSTDATA(hwnd);
2082 if (cmp) {
2083 USHORT wantHide = WinQueryButtonCheckstate(hwnd,
2084 COMP_HIDENOTSELECTED);
[316]2085
[551]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;
[316]2102 }
[551]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));
[748]2107 } // while
[551]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));
[316]2113 }
2114 }
[551]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;
[316]2129
[551]2130 case WM_COMMAND:
2131 switch (SHORT1FROMMP(mp1)) {
2132 case IDM_COMPARE:
2133 cmp = INSTDATA(hwnd);
2134 if (cmp) {
[2]2135
[551]2136 PCNRITEM pci;
2137 CHAR ofile[CCHMAXPATH];
[2]2138
[551]2139 pci = (PCNRITEM) WinSendMsg(cmp->hwndCalling,
2140 CM_QUERYRECORDEMPHASIS,
2141 MPFROMLONG(CMA_FIRST),
2142 MPFROMSHORT(CRA_CURSORED));
[748]2143 // 01 Aug 07 SHL
2144 if (pci && *pci->pszFileName) {
[551]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, "\\");
[751]2151 strcat(ofile, pci->pszDisplayName);
[551]2152 if (*compare) {
2153 CHAR *fakelist[3];
[730]2154 fakelist[0] = pci->pszFileName;
[551]2155 fakelist[1] = ofile;
2156 fakelist[2] = NULL;
2157 ExecOnList(hwnd, compare,
[907]2158 WINDOWED | SEPARATEKEEP, NULL, fakelist, NULL,
2159 pszSrcFile, __LINE__);
[551]2160 }
2161 else {
2162 FCOMPARE fc;
2163 memset(&fc, 0, sizeof(fc));
2164 fc.size = sizeof(fc);
2165 fc.hwndParent = hwnd;
[730]2166 strcpy(fc.file1, pci->pszFileName);
[551]2167 strcpy(fc.file2, ofile);
2168 WinDlgBox(HWND_DESKTOP, hwnd,
2169 CFileDlgProc, FM3ModHandle, FCMP_FRAME, (PVOID) & fc);
2170 }
2171 }
2172 }
2173 break;
[2]2174
[551]2175 case COMP_FILTER:
2176 case IDM_FILTER:
2177 cmp = INSTDATA(hwnd);
2178 if (cmp) {
[2]2179
[551]2180 BOOL empty = FALSE;
2181 PCNRITEM pci;
2182 CHAR *p;
2183 BOOL temp;
[2]2184
[551]2185 if (!*cmp->dcd.mask.szMask) {
2186 empty = TRUE;
2187 temp = fSelectedAlways;
2188 fSelectedAlways = TRUE;
[748]2189 pci = (PCNRITEM)CurrentRecord(hwnd);
[551]2190 fSelectedAlways = temp;
[748]2191 // 01 Aug 07 SHL
2192 if (pci && ~pci->attrFile & FILE_DIRECTORY) {
[730]2193 p = strrchr(pci->pszFileName, '\\');
[551]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;
[2]2216
[551]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) {
[2]2229
[551]2230 DIRCNRDATA dcd1;
2231 BOOL tempsubj;
[2]2232
[551]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;
[2]2246
[551]2247 case IDM_LOADLISTFILE:
2248 cmp = INSTDATA(hwnd);
2249 if (cmp) {
[2]2250
[551]2251 CHAR fullname[CCHMAXPATH];
[2]2252
[551]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;
[2]2262
[551]2263 case IDM_SAVELISTFILE:
2264 cmp = INSTDATA(hwnd);
2265 if (cmp) {
[2]2266
[551]2267 SNAPSTUFF *sf;
2268 CHAR fullname[CCHMAXPATH];
[2]2269
[551]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;
[2]2290
[551]2291 case COMP_SETDIRS:
2292 cmp = INSTDATA(hwnd);
2293 if (cmp) {
[2]2294
[551]2295 WALK2 wa;
[2]2296
[551]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)) &&
[769]2304 !IsFile(wa.szCurrentPath1) &&
2305 !IsFile(wa.szCurrentPath2)) {
[551]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;
[2]2314
[551]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) {
[2]2323
[551]2324 COMPARE *forthread;
[2]2325
[551]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;
[2]2401
[551]2402 case DID_OK:
2403 WinDismissDlg(hwnd, 0);
2404 break;
2405 case DID_CANCEL:
2406 WinDismissDlg(hwnd, 1);
2407 break;
[2]2408
[551]2409 case IDM_HELP:
2410 if (hwndHelp)
2411 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
2412 MPFROM2SHORT(HELP_COMPARE, 0), MPFROMSHORT(HM_RESOURCEID));
2413 break;
[2]2414
[551]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:
[748]2429 case IDM_SELECTIDENTICAL: // Name, size and time
2430 case IDM_SELECTSAME: // Name and size
[551]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 }
[362]2450 else {
[551]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;
[2]2512
[551]2513 case COMP_COLLECT:
2514 cmp = INSTDATA(hwnd);
[773]2515 if (!cmp)
2516 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2517 else {
2518 CHAR **listl;
2519 CHAR **listr = NULL;
[551]2520 if (!Collector) {
2521 SWP swp;
2522 HWND hwndC;
[773]2523 if (!fAutoTile &&
2524 !ParentIsDesktop(hwnd, cmp->hwndParent) &&
2525 !fExternalCollector &&
2526 !strcmp(realappname, FM3Str)) {
[551]2527 GetNextWindowPos(cmp->hwndParent, &swp, NULL, NULL);
[773]2528 }
2529 hwndC = StartCollector(fExternalCollector ||
2530 strcmp(realappname, FM3Str) ?
2531 HWND_DESKTOP :
2532 cmp->hwndParent,
2533 4);
[551]2534 if (hwndC) {
[773]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)) {
[551]2546 TileChildren(cmp->hwndParent, TRUE);
[773]2547 }
[790]2548 DosSleep(32); // 05 Aug 07 GKY 64
[551]2549 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(COMP_COLLECT, 0), MPVOID);
2550 break;
2551 }
2552 }
2553 else
2554 StartCollector(cmp->hwndParent, 4);
[2]2555
[773]2556 temp = fSelectedAlways;
2557 fSelectedAlways = TRUE;
2558 listl = BuildList(hwndLeft);
2559 if (!*cmp->rightlist)
2560 listr = BuildList(hwndRight);
2561 fSelectedAlways = temp;
2562
[551]2563 if (listl || listr) {
2564 if (Collector) {
[773]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
[551]2570 }
[773]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
[551]2575 }
2576 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2577 QW_PARENT),
[773]2578 QW_PARENT),
2579 HWND_TOP, 0, 0, 0, 0,
[551]2580 SWP_ACTIVATE);
2581 }
[773]2582 FreeList(listl);
2583 FreeList(listr);
[551]2584 }
[2]2585 }
[551]2586 break;
2587 }
2588 return 0;
[2]2589
[551]2590 case WM_CLOSE:
2591 WinDismissDlg(hwnd, 0);
2592 return 0;
[2]2593
[551]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) {
[574]2600 WinSetWindowPtr(cmp->dcd.hwndObject, QWL_USER, (PVOID) NULL);
[551]2601 if (!PostMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID))
2602 WinSendMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID);
[2]2603 }
[551]2604 free(cmp);
2605 }
2606 EmptyCnr(hwndLeft);
2607 EmptyCnr(hwndRight);
2608 DosPostEventSem(CompactSem);
2609 break;
[2]2610 }
[551]2611 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]2612}
[783]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.