source: trunk/dll/comp.c@ 838

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

Remainder of changes for xDosFindFirst/Next wrapper performance test

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