source: trunk/dll/comp.c@ 448

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

Turn off hide not selected on dir change

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