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