source: trunk/dll/comp.c@ 362

Last change on this file since 362 was 362, checked in by root, 19 years ago

Use Runtime_Error

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