source: trunk/dll/comp.c@ 731

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

Correct ticket 24 pointer errors for Gregg

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