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