source: trunk/dll/comp.c@ 366

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

Drop unreachable CN_... code

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