source: trunk/dll/comp.c@ 406

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

Use xfgets_bstripcr

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