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