source: trunk/dll/comp.c@ 316

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

Renames and comments

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 99.8 KB
RevLine 
[76]1
2/***********************************************************************
3
4 $Id: comp.c 316 2006-07-13 04:17:43Z 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
[316]18 12 Jul 06 SHL Renames and comments
[76]19
20***********************************************************************/
21
[2]22#define INCL_DOS
23#define INCL_WIN
24#define INCL_GPI
[157]25#define INCL_LONGLONG
26#include <os2.h>
[2]27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <ctype.h>
32#include <share.h>
33#include <io.h>
[157]34
[2]35#include "fm3dll.h"
36#include "fm3dlg.h"
37#include "fm3str.h"
38
[316]39#pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames)
[2]40#pragma alloc_text(COMPAREDIR1,CompareDlgProc)
[316]41#pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
42#pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
[2]43#pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
44
45typedef struct {
46 CHAR filename[CCHMAXPATH];
47 CHAR dirname[CCHMAXPATH];
48 BOOL recurse;
49} SNAPSTUFF;
50
[316]51//=== SnapShot() Write directory tree to file and recurse if requested ===
[2]52
[316]53static VOID SnapShot (char *path,FILE *fp,BOOL recurse)
[157]54{
[2]55 FILEFINDBUF4 *fb;
56 char *mask,*enddir;
57 HDIR hdir = HDIR_CREATE;
58 ULONG nm = 1L;
59
60 fb = malloc(sizeof(FILEFINDBUF4));
61 if(fb) {
62 mask = malloc(CCHMAXPATH);
63 if(mask) {
64 sprintf(mask,
65 "%s%s*",
66 path,
67 (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
68 enddir = strrchr(mask,'\\');
69 enddir++;
70 if(!DosFindFirst(mask,
71 &hdir,
72 FILE_NORMAL | FILE_DIRECTORY |
73 FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN |
74 FILE_SYSTEM,
75 fb,
76 sizeof(FILEFINDBUF4),
77 &nm,
78 FIL_QUERYEASIZE)) {
79 do {
80 strcpy(enddir,fb->achName);
81 if(!(fb->attrFile & FILE_DIRECTORY))
82 fprintf(fp,
83 "\"%s\",%u,%lu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",
84 mask,
85 enddir - mask,
86 fb->cbFile,
87 (fb->fdateLastWrite.year + 1980),
88 fb->fdateLastWrite.month,
89 fb->fdateLastWrite.day,
90 fb->ftimeLastWrite.hours,
91 fb->ftimeLastWrite.minutes,
92 fb->ftimeLastWrite.twosecs,
93 fb->attrFile,
94 (fb->cbList > 4L) ? (fb->cbList / 2L) : 0L);
95 else if(recurse && (*fb->achName != '.' ||
96 (fb->achName[1] && fb->achName[1] != '.')))
97 SnapShot(mask,fp,recurse);
98 nm = 1L;
99 } while(!DosFindNext(hdir,fb,sizeof(FILEFINDBUF4),&nm));
100 DosFindClose(hdir);
101 }
102 free(mask);
103 }
104 free(fb);
105 }
106}
107
[316]108//=== StartSnap() Write directory tree to snapshot file ===
[2]109
[316]110static VOID StartSnap (VOID *dummy)
111{
[2]112 SNAPSTUFF *sf = (SNAPSTUFF *)dummy;
113 FILE *fp;
114 CHAR *p;
115
116 if(sf) {
117 if(*sf->dirname && *sf->filename) {
118 priority_normal();
119 p = sf->dirname;
120 while(*p) {
121 if(*p == '/')
122 *p = '\\';
123 p++;
124 }
125 if(*(p - 1) != '\\') {
126 *p = '\\';
127 p++;
128 }
129 fp = fopen(sf->filename,"w");
130 if(fp) {
131 fprintf(fp,"\"%s\"\n",sf->dirname);
132 SnapShot(sf->dirname,fp,sf->recurse);
133 fclose(fp);
134 }
135 }
136 free(sf);
137 }
138}
139
[316]140//=== CompareFilesThread() Compare files and update container select flags ===
[2]141
[316]142static VOID CompareFilesThread (VOID *args)
143{
[2]144 FCOMPARE fc;
145 HAB hab2;
146 HMQ hmq2;
147 FILE *fp1,*fp2;
148 ULONG len1,len2,offset = 0L;
149 LONG numread1,numread2;
150 CHAR s[1024],ss[1024],*p1,*p2;
151
152 if(args) {
153 fc = *(FCOMPARE *)args;
154 hab2 = WinInitialize(0);
155 if(hab2) {
156 hmq2 = WinCreateMsgQueue(hab2,0);
157 if(hmq2) {
158 WinCancelShutdown(hmq2,TRUE);
159 if(!IsFile(fc.file1) || IsRoot(fc.file1)) {
160 p1 = strrchr(fc.file2,'\\');
161 if(p1) {
162 if(fc.file1[strlen(fc.file1) - 1] == '\\')
163 p1++;
164 strcat(fc.file1,p1);
165 }
166 }
167 else if(!IsFile(fc.file2) || IsRoot(fc.file2)) {
168 p1 = strrchr(fc.file1,'\\');
169 if(p1) {
170 if(fc.file2[strlen(fc.file2) - 1] == '\\')
171 p1++;
172 strcat(fc.file2,p1);
173 }
174 }
175 sprintf(s,GetPString(IDS_COMPCOMPARETEXT),fc.file1);
176 AddToListboxBottom(fc.hwndList,s);
177 sprintf(s,GetPString(IDS_COMPTOTEXT),fc.file2);
178 AddToListboxBottom(fc.hwndList,s);
179 fp1 = _fsopen(fc.file1,"rb",SH_DENYNO);
180 if(fp1) {
181 fp2 = _fsopen(fc.file2,"rb",SH_DENYNO);
182 if(fp2) {
183 len1 = filelength(fileno(fp1));
184 len2 = filelength(fileno(fp2));
185 if(len1 != len2) {
186 strcpy(s,GetPString(IDS_COMPDIFSIZESTEXT));
187 AddToListboxBottom(fc.hwndList,s);
188 sprintf(s,GetPString(IDS_COMPVSBYTESTEXT),len1,len2);
189 AddToListboxBottom(fc.hwndList,s);
190 WinSetWindowText(fc.hwndHelp,GetPString(IDS_COMPDONTMATCHTEXT));
191 }
192 else {
193 WinSetWindowText(fc.hwndHelp,GetPString(IDS_COMPCOMPARINGTEXT));
194 while(WinIsWindow(hab2,fc.hwndList)) {
195 numread1 = fread(s,1,1024,fp1);
196 numread2 = fread(ss,1,1024,fp2);
197 if(numread1 != numread2 || feof(fp1) != feof(fp2)) {
198 sprintf(s,GetPString(IDS_COMPREADERRORTEXT),
199 offset,offset);
200 AddToListboxBottom(fc.hwndList,s);
201 WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
202 break;
203 }
204 else if(!numread1 && feof(fp1) && feof(fp2)) {
205 AddToListboxBottom(fc.hwndList,
206 GetPString(IDS_COMPFILESMATCHTEXT));
207 if(!stricmp(fc.file1,fc.file2))
208 AddToListboxBottom(fc.hwndList,
209 GetPString(IDS_COMPWONDERWHYTEXT));
210 WinSetWindowText(fc.hwndHelp,
211 GetPString(IDS_COMPCOMPLETETEXT));
212 break;
213 }
214 else if(numread1 <= 0 || numread2 <= 0) {
215 if(offset == len1)
216 break;
217 else {
218 sprintf(s,GetPString(IDS_COMPMATCHREADERRORTEXT),
219 offset,offset);
220 WinSetWindowText(fc.hwndHelp,
221 GetPString(IDS_COMPODDERRORTEXT));
222 AddToListboxBottom(fc.hwndList,s);
223 break;
224 }
225 }
226 else if(memcmp(s,ss,numread1)) {
227 p1 = s;
228 p2 = ss;
229 while(p1 < s + numread1) {
230 if(*p1 != *p2) {
231 sprintf(s,GetPString(IDS_COMPMISMATCHERRORTEXT),
232 offset + (p1 - s),offset + (p1 - s));
233 AddToListboxBottom(fc.hwndList,s);
234 WinSetWindowText(fc.hwndHelp,
235 GetPString(IDS_COMPDONTMATCHTEXT));
236 break;
237 }
238 p1++;
239 p2++;
240 }
241 break;
242 }
243 offset += numread1;
244 }
245 }
246 fclose(fp2);
247 }
248 else {
249 sprintf(s,GetPString(IDS_COMPCANTOPENTEXT),fc.file2);
250 AddToListboxBottom(fc.hwndList,s);
251 WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
252 }
253 fclose(fp1);
254 }
255 else {
256 sprintf(s,GetPString(IDS_COMPCANTOPENTEXT),fc.file1);
257 AddToListboxBottom(fc.hwndList,s);
258 WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
259 }
260 WinDestroyMsgQueue(hmq2);
261 }
262 WinTerminate(hab2);
263 }
264 }
265}
266
[316]267//=== CFileDlgProc() Select directories to compare dialog procedure ===
[2]268
[316]269MRESULT EXPENTRY CFileDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
270{
[2]271 FCOMPARE *fc;
272
273 switch(msg) {
274 case WM_INITDLG:
275 if(!mp2)
276 WinDismissDlg(hwnd,0);
277 else {
278 WinSetWindowPtr(hwnd,0,mp2);
279 fc = (FCOMPARE *)mp2;
280 fc->hwndReport = hwnd;
281 fc->hwndList = WinWindowFromID(hwnd,FCMP_LISTBOX);
282 fc->hwndHelp = WinWindowFromID(hwnd,FCMP_HELP);
283 if(!*fc->file1 || !fc->file2) {
284 WinDismissDlg(hwnd,0);
285 break;
286 }
287 MakeFullName(fc->file1);
288 MakeFullName(fc->file2);
289 if(!stricmp(fc->file1,fc->file2)) {
290 saymsg(MB_CANCEL,hwnd,
291 GetPString(IDS_COMPSILLYALERTTEXT),
292 GetPString(IDS_COMPTOITSELFTEXT));
293 WinDismissDlg(hwnd,0);
294 break;
295 }
[316]296 if(_beginthread(CompareFilesThread,
[2]297 NULL,
298 65536,
299 (PVOID)fc) == -1) {
[145]300 Win_Error(hwnd,hwnd,__FILE__,__LINE__,
301 GetPString(IDS_CANTCOMPARETEXT));
[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:
394 DosBeep(250,100);
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 }
495 else if(rc) {
496 rc = Dos_Error(MB_ENTERCANCEL,
497 rc,
498 HWND_DESKTOP,
499 __FILE__,
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);
529 if(!rc) {
530 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pci),
531 MPFROM2SHORT(FALSE,CRA_SELECTED));
532 if(pciO->rc.flRecordAttr & CRA_SELECTED)
533 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciO),
534 MPFROM2SHORT(FALSE,CRA_SELECTED));
535 strcpy(pciO->szFileName,newname);
536 if(hwndCnrS == WinWindowFromID(cmp->hwnd,COMP_RIGHTDIR)) {
537 pciO->pszFileName = pciO->szFileName + strlen(cmp->leftdir);
538 if(cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
539 pciO->pszFileName++;
540 }
541 else {
542 pciO->pszFileName = pciO->szFileName + strlen(cmp->rightdir);
543 if(cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
544 pciO->pszFileName++;
545 }
546 strcpy(pciO->szDispAttr,pci->szDispAttr);
547 pciO->attrFile = pci->attrFile;
548 pciO->flags = CNRITEM_EXISTS;
549 pciO->date = pci->date;
550 pciO->time = pci->time;
551 pciO->ladate = pci->ladate;
552 pciO->latime = pci->latime;
553 pciO->crdate = pci->crdate;
554 pciO->crtime = pci->crtime;
555 pciO->cbFile = pci->cbFile;
556 pciO->easize = pci->easize;
[157]557 *pci->szSubject = 0;
[2]558 pci->flags = CNRITEM_EXISTS;
559 WinSendMsg(hwndCnrS,CM_INVALIDATERECORD,MPFROMP(&pci),
560 MPFROM2SHORT(1,CMA_ERASE | CMA_TEXTCHANGED));
561 WinSendMsg(hwndCnrD,CM_INVALIDATERECORD,MPFROMP(&pciO),
562 MPFROM2SHORT(1,CMA_ERASE | CMA_TEXTCHANGED));
563 }
564 else {
565 rc = Dos_Error(MB_ENTERCANCEL,
566 rc,
567 HWND_DESKTOP,
568 __FILE__,
569 __LINE__,
570 GetPString(IDS_COMPCOPYFAILEDTEXT),
571 pci->szFileName,
572 newname);
573 if(rc == MBID_CANCEL) /* cause loop to break */
574 pcin = NULL;
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;
656 maskstr = malloc(CCHMAXPATH);
657 if(!maskstr)
658 return;
659 ffb4 = malloc(sizeof(FILEFINDBUF4) * ulM);
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);
752 if(hab) {
753 hmq = WinCreateMsgQueue(hab,0);
754 if(hmq) {
755
[316]756 INT x;
757 INT l;
758 INT r;
759 INT y;
760 ULONG cntr;
761 FILELIST **filesl = NULL;
762 FILELIST **filesr = NULL;
763 INT numfilesl = 0;
764 INT numfilesr = 0;
765 INT numallocl = 0;
766 INT numallocr = 0;
767 INT lenl; // Directory prefix length
768 INT lenr;
769 UINT recsNeeded; // fixme to check ovf
770 PCNRITEM pcilFirst;
771 PCNRITEM pcirFirst;
772 PCNRITEM pcil;
773 PCNRITEM pcir;
774 PCNRITEM pcit;
[2]775 RECORDINSERT ri;
[316]776 CHAR *pch;
[2]777
778 WinCancelShutdown(hmq,TRUE);
779 hwndLeft = WinWindowFromID(cmp->hwnd,COMP_LEFTDIR);
780 hwndRight = WinWindowFromID(cmp->hwnd,COMP_RIGHTDIR);
781 lenl = strlen(cmp->leftdir);
782 if(cmp->leftdir[strlen(cmp->leftdir) - 1] != '\\')
783 lenl++;
784 lenr = strlen(cmp->rightdir);
785 if(cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\')
786 lenr++;
787 priority_normal();
788 /* clear containers */
789 WinSendMsg(hwndRight,CM_REMOVERECORD,
790 MPVOID,MPFROM2SHORT(0,CMA_FREE | CMA_INVALIDATE));
791 WinSendMsg(hwndLeft,CM_REMOVERECORD,
792 MPVOID,MPFROM2SHORT(0,CMA_FREE | CMA_INVALIDATE));
793 cmp->cmp->totalleft = cmp->cmp->totalright = 0;
794
795 /* build list of all files in left directory */
796 if(fForceLower)
797 strlwr(cmp->leftdir);
798 else if(fForceUpper)
799 strupr(cmp->leftdir);
800 FillDirList(cmp->leftdir,lenl,cmp->includesubdirs,
801 &filesl,&numfilesl,&numallocl);
802
803 if(filesl)
804 qsort(filesl,numfilesl,sizeof(CHAR *),CompNames);
805 /* build list of all files in right directory */
806 if(!*cmp->rightlist) {
807 if(fForceLower)
808 strlwr(cmp->rightdir);
809 else if(fForceUpper)
810 strupr(cmp->rightdir);
811 FillDirList(cmp->rightdir,lenr,cmp->includesubdirs,
812 &filesr,&numfilesr,&numallocr);
813 }
[316]814 else
815 {
816 /* use snapshot file */
[2]817 FILE *fp;
818 FILEFINDBUF4 fb4;
819 CHAR str[CCHMAXPATH * 2],*p;
820
821 memset(&fb4,0,sizeof(fb4));
822 fp = fopen(cmp->rightlist,"r");
823 if(fp) {
[316]824 while(!feof(fp)) {
825 /* first get name of directory */
[2]826 if(!fgets(str,sizeof(str) - 1,fp))
[316]827 break; // EOF
[2]828 str[sizeof(str) - 1] = 0;
[123]829 bstrip(str);
[2]830 p = str;
831 if(*p == '\"') {
[316]832 /* Quoted */
[2]833 p++;
834 if(*p && *p != '\"') {
835 p = strchr(p,'\"');
836 if(p) {
837 *p = 0;
838 if(*(str + 1)) {
839 strcpy(cmp->rightdir,str + 1);
840 if(fForceUpper)
841 strupr(cmp->rightdir);
842 else if(fForceLower)
843 strlwr(cmp->rightdir);
844 p = cmp->rightdir + (strlen(cmp->rightdir) - 1);
845 if(p - cmp->rightdir > 3 && *p == '\\')
[316]846 *p = 0; // Chop trailing slash
[2]847 break;
848 }
849 }
850 }
851 }
[316]852 } // while !EOF
[2]853 {
854 CNRINFO cnri;
855
856 memset(&cnri,0,sizeof(cnri));
857 cnri.cb = sizeof(cnri);
858 cnri.pszCnrTitle = cmp->rightdir;
859 WinSendMsg(hwndRight,CM_SETCNRINFO,
860 MPFROMP(&cnri),
861 MPFROMLONG(CMA_CNRTITLE));
862 }
863 if(*cmp->rightdir) {
864 lenr = strlen(cmp->rightdir) +
865 (cmp->rightdir[strlen(cmp->rightdir) - 1] != '\\');
866 while(!feof(fp)) {
867 if(!fgets(str,sizeof(str) - 1,fp))
868 break;
869 str[sizeof(str) - 1] = 0;
[123]870 bstrip(str);
[2]871 p = str;
872 if(*p == '\"') {
873 p++;
874 if(*p && *p != '\"') {
875 p = strchr(p,'\"');
876 if(p) {
877 *p = 0;
878 p++;
879 if(*p == ',') {
880 p++;
881 if(!cmp->includesubdirs && atol(p) > lenr)
882 continue;
883 p = strchr(p,',');
884 if(p) {
885 p++;
886 fb4.cbFile = atol(p);
887 p = strchr(p,',');
888 if(p) {
889 p++;
890 fb4.fdateLastWrite.year = atol(p) - 1980;
891 p = strchr(p,'/');
892 if(p) {
893 p++;
894 fb4.fdateLastWrite.month = atol(p);
895 p = strchr(p,'/');
896 if(p) {
897 p++;
898 fb4.fdateLastWrite.day = atol(p);
899 p = strchr(p,',');
900 if(p) {
901 p++;
902 fb4.ftimeLastWrite.hours = atol(p);
903 p = strchr(p,':');
904 if(p) {
905 p++;
906 fb4.ftimeLastWrite.minutes = atol(p);
907 p = strchr(p,':');
908 if(p) {
909 p++;
910 fb4.ftimeLastWrite.twosecs = atol(p);
911 p = strchr(p,',');
912 if(p) {
913 p++;
914 fb4.attrFile = atol(p);
915 p = strchr(p,',');
916 if(p) {
917 p++;
918 fb4.cbList = atol(p) * 2;
919 if(fForceUpper)
920 strupr(str + 1);
921 else if(fForceLower)
922 strlwr(str + 1);
923 if(AddToFileList((str + 1) + lenr,
924 &fb4,
925 &filesr,
926 &numfilesr,
927 &numallocr))
928 break;
929 }
930 }
931 }
932 }
933 }
934 }
935 }
936 }
937 }
938 }
939 }
940 }
941 }
[316]942 } // while
943 } // if have rightdir
[2]944 fclose(fp);
945 }
946 else
947 DosBeep(50,100);
[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));
[2]984 if(!pcilFirst) {
[316]985 recsNeeded = 0;
[2]986 DosBeep(100,100);
987 }
[316]988 }
989 if(recsNeeded) {
[2]990 pcirFirst = WinSendMsg(hwndRight,CM_ALLOCRECORD,
991 MPFROMLONG(EXTRA_RECORD_BYTES2),
[316]992 MPFROMLONG(recsNeeded));
[2]993 if(!pcirFirst) {
[316]994 recsNeeded = 0;
[2]995 DosBeep(100,100);
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 }
[316]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;
1060 if(*cmp->dcd.mask.szMask) {
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;
1196 if(*cmp->dcd.mask.szMask) {
1197 if(!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
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;
1214 for(x = 0;x < 6;x++)
1215 if(attrstring[x])
1216 pcir->szDispAttr[y++] = (CHAR)((pcir->attrFile & (1 << x)) ?
1217 attrstring[x] : '-');
1218 pcir->szDispAttr[5] = 0;
1219 pcir->cbFile = filesr[r]->cbFile;
1220 pcir->easize = filesr[r]->easize;
1221 pcir->date.day = filesr[r]->date.day;
1222 pcir->date.month = filesr[r]->date.month;
1223 pcir->date.year = filesr[r]->date.year + 1980;
1224 pcir->time.seconds = filesr[r]->time.twosecs * 2;
1225 pcir->time.minutes = filesr[r]->time.minutes;
1226 pcir->time.hours = filesr[r]->time.hours;
1227 pcir->ladate.day = filesr[r]->ladate.day;
1228 pcir->ladate.month = filesr[r]->ladate.month;
1229 pcir->ladate.year = filesr[r]->ladate.year + 1980;
1230 pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
1231 pcir->latime.minutes = filesr[r]->latime.minutes;
1232 pcir->latime.hours = filesr[r]->latime.hours;
1233 pcir->crdate.day = filesr[r]->crdate.day;
1234 pcir->crdate.month = filesr[r]->crdate.month;
1235 pcir->crdate.year = filesr[r]->crdate.year + 1980;
1236 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
1237 pcir->crtime.minutes = filesr[r]->crtime.minutes;
1238 pcir->crtime.hours = filesr[r]->crtime.hours;
1239 if(*cmp->dcd.mask.szMask) {
1240 if(!Filter((PMINIRECORDCORE)pcir,(PVOID)&cmp->dcd.mask)) {
1241 pcir->rc.flRecordAttr |= CRA_FILTERED;
1242 pcil->rc.flRecordAttr |= CRA_FILTERED;
1243 }
1244 }
1245 free(filesr[r]);
1246 r++;
1247 }
1248 }
1249 else if(filesl && filesl[l]) {
[316]1250 // Just on left
[2]1251 sprintf(pcil->szFileName,"%s%s%s",cmp->leftdir,
1252 (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
1253 NullStr : "\\",filesl[l]->fname);
1254 pcil->pszFileName = pcil->szFileName + lenl;
1255 pcil->attrFile = filesl[l]->attrFile;
[316]1256 // pcil->rc.hptrIcon = hptrFile;
[2]1257 y = 0;
1258 for(x = 0;x < 6;x++)
1259 if(attrstring[x])
1260 pcil->szDispAttr[y++] = (CHAR)((pcil->attrFile & (1 << x)) ?
1261 attrstring[x] : '-');
1262 pcil->szDispAttr[5] = 0;
1263 pcil->cbFile = filesl[l]->cbFile;
1264 pcil->easize = filesl[l]->easize;
1265 pcil->date.day = filesl[l]->date.day;
1266 pcil->date.month = filesl[l]->date.month;
1267 pcil->date.year = filesl[l]->date.year + 1980;
1268 pcil->time.seconds = filesl[l]->time.twosecs * 2;
1269 pcil->time.minutes = filesl[l]->time.minutes;
1270 pcil->time.hours = filesl[l]->time.hours;
1271 pcil->ladate.day = filesl[l]->ladate.day;
1272 pcil->ladate.month = filesl[l]->ladate.month;
1273 pcil->ladate.year = filesl[l]->ladate.year + 1980;
1274 pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
1275 pcil->latime.minutes = filesl[l]->latime.minutes;
1276 pcil->latime.hours = filesl[l]->latime.hours;
1277 pcil->crdate.day = filesl[l]->crdate.day;
1278 pcil->crdate.month = filesl[l]->crdate.month;
1279 pcil->crdate.year = filesl[l]->crdate.year + 1980;
1280 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
1281 pcil->crtime.minutes = filesl[l]->crtime.minutes;
1282 pcil->crtime.hours = filesl[l]->crtime.hours;
1283 if(*cmp->dcd.mask.szMask) {
1284 if(!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
1285 pcil->rc.flRecordAttr |= CRA_FILTERED;
1286 pcir->rc.flRecordAttr |= CRA_FILTERED;
1287 }
1288 }
1289 free(filesl[l]);
1290 l++;
1291 }
[316]1292 else {
1293 /* filesr && filesr[r] */
1294 // Just on right
[2]1295 sprintf(pcir->szFileName,"%s%s%s",cmp->rightdir,
1296 (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
1297 NullStr : "\\",filesr[r]->fname);
1298 pcir->pszFileName = pcir->szFileName + lenr;
1299 pcir->attrFile = filesr[r]->attrFile;
[316]1300 // pcir->rc.hptrIcon = hptrFile;
[2]1301 y = 0;
1302 for(x = 0;x < 6;x++)
1303 if(attrstring[x])
1304 pcir->szDispAttr[y++] = (CHAR)((pcir->attrFile & (1 << x)) ?
1305 attrstring[x] : '-');
1306 pcir->szDispAttr[5] = 0;
1307 pcir->cbFile = filesr[r]->cbFile;
1308 pcir->easize = filesr[r]->easize;
1309 pcir->date.day = filesr[r]->date.day;
1310 pcir->date.month = filesr[r]->date.month;
1311 pcir->date.year = filesr[r]->date.year + 1980;
1312 pcir->time.seconds = filesr[r]->time.twosecs * 2;
1313 pcir->time.minutes = filesr[r]->time.minutes;
1314 pcir->time.hours = filesr[r]->time.hours;
1315 pcir->ladate.day = filesr[r]->ladate.day;
1316 pcir->ladate.month = filesr[r]->ladate.month;
1317 pcir->ladate.year = filesr[r]->ladate.year + 1980;
1318 pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
1319 pcir->latime.minutes = filesr[r]->latime.minutes;
1320 pcir->latime.hours = filesr[r]->latime.hours;
1321 pcir->crdate.day = filesr[r]->crdate.day;
1322 pcir->crdate.month = filesr[r]->crdate.month;
1323 pcir->crdate.year = filesr[r]->crdate.year + 1980;
1324 pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
1325 pcir->crtime.minutes = filesr[r]->crtime.minutes;
1326 pcir->crtime.hours = filesr[r]->crtime.hours;
1327 if(*cmp->dcd.mask.szMask) {
1328 if(!Filter((PMINIRECORDCORE)pcir,(PVOID)&cmp->dcd.mask)) {
1329 pcir->rc.flRecordAttr |= CRA_FILTERED;
1330 pcil->rc.flRecordAttr |= CRA_FILTERED;
1331 }
1332 }
1333 free(filesr[r]);
1334 r++;
1335 }
1336 if(!(cntr % 500))
1337 DosSleep(1L);
1338 else if(!(cntr % 50))
1339 DosSleep(0L);
1340 cntr++;
1341 pcil = (PCNRITEM)pcil->rc.preccNextRecord;
1342 pcir = (PCNRITEM)pcir->rc.preccNextRecord;
[316]1343 } // while
[2]1344 if(filesl)
[316]1345 free(filesl); // Free header - have already freed elements
[2]1346 filesl = NULL;
1347 if(filesr)
1348 free(filesr);
1349 filesr = NULL;
1350 /* insert 'em */
1351 WinSendMsg(cmp->hwnd,UM_CONTAINERDIR,MPVOID,MPVOID);
1352 memset(&ri, 0, sizeof(RECORDINSERT));
1353 ri.cb = sizeof(RECORDINSERT);
1354 ri.pRecordOrder = (PRECORDCORE)CMA_END;
1355 ri.pRecordParent = (PRECORDCORE)NULL;
1356 ri.zOrder = (ULONG)CMA_TOP;
[316]1357 ri.cRecordsInsert = recsNeeded;
[2]1358 ri.fInvalidateRecord = FALSE;
1359 if(!WinSendMsg(hwndLeft,CM_INSERTRECORD,
1360 MPFROMP(pcilFirst),MPFROMP(&ri))) {
1361 pcil = pcilFirst;
1362 while(pcil) {
1363 pcit = (PCNRITEM)pcil->rc.preccNextRecord;
1364 WinSendMsg(hwndLeft,CM_FREERECORD,
1365 MPFROMP(&pcil),MPFROMSHORT(1));
1366 pcil = pcit;
1367 }
1368 numfilesl = 0;
1369 }
1370 memset(&ri, 0, sizeof(RECORDINSERT));
1371 ri.cb = sizeof(RECORDINSERT);
1372 ri.pRecordOrder = (PRECORDCORE)CMA_END;
1373 ri.pRecordParent = (PRECORDCORE)NULL;
1374 ri.zOrder = (ULONG)CMA_TOP;
[316]1375 ri.cRecordsInsert = recsNeeded;
[2]1376 ri.fInvalidateRecord = FALSE;
1377 if(!WinSendMsg(hwndRight,CM_INSERTRECORD,
1378 MPFROMP(pcirFirst),MPFROMP(&ri))) {
1379 WinSendMsg(hwndLeft,CM_REMOVERECORD,
1380 MPVOID,MPFROM2SHORT(0,CMA_FREE | CMA_INVALIDATE));
1381 pcir = pcirFirst;
1382 while(pcir) {
1383 pcit = (PCNRITEM)pcir->rc.preccNextRecord;
1384 WinSendMsg(hwndRight,CM_FREERECORD,
1385 MPFROMP(&pcir),MPFROMSHORT(1));
1386 pcir = pcit;
1387 }
1388 numfilesr = 0;
1389 }
1390 cmp->cmp->totalleft = numfilesl;
1391 cmp->cmp->totalright = numfilesr;
[316]1392 } // if recsNeeded
[2]1393 Deselect(hwndLeft);
1394 Deselect(hwndRight);
1395 if(!PostMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID))
1396 WinSendMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
1397 notified = TRUE;
1398 if(filesl)
[316]1399 FreeList((CHAR **)filesl); // Must have failed to create container
[2]1400 if(filesr)
1401 FreeList((CHAR **)filesr);
1402 WinDestroyMsgQueue(hmq);
1403 }
1404 else
1405 DosBeep(250,100);
1406 WinTerminate(hab);
1407 }
1408 else
1409 DosBeep(50,100);
1410 if(!notified)
1411 PostMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
1412 free(cmp);
1413 DosPostEventSem(CompactSem);
1414}
1415
1416#define hwndLeft (WinWindowFromID(hwnd,COMP_LEFTDIR))
1417#define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
1418
[316]1419//=== CompareDlgProc() Compare directories dialog procedure ===
[2]1420
[316]1421MRESULT EXPENTRY CompareDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
1422{
[2]1423 COMPARE *cmp;
1424 static HPOINTER hptr = (HPOINTER)0;
1425
1426 switch(msg) {
1427 case WM_INITDLG:
1428 cmp = (COMPARE *)mp2;
1429 if(cmp) {
1430 if(!hptr)
1431 hptr = WinLoadPointer(HWND_DESKTOP,FM3ModHandle,COMPARE_ICON);
1432 WinDefDlgProc(hwnd,WM_SETICON,MPFROMLONG(hptr),MPVOID);
1433 cmp->hwnd = hwnd;
1434 WinSetWindowPtr(hwnd,0,(PVOID)cmp);
1435 SetCnrCols(hwndLeft,TRUE);
1436 SetCnrCols(hwndRight,TRUE);
1437 WinSendMsg(hwnd,UM_SETUP,MPVOID,MPVOID);
1438 WinSendMsg(hwnd,UM_SETDIR,MPVOID,MPVOID);
1439 PostMsg(hwnd,UM_STRETCH,MPVOID,MPVOID);
1440 {
1441 USHORT ids[] = {COMP_LEFTDIR,COMP_RIGHTDIR,COMP_TOTALLEFT,
1442 COMP_TOTALRIGHT,COMP_SELLEFT,COMP_SELRIGHT,
1443 0};
1444 register INT x;
1445
1446 for(x = 0;ids[x];x++)
1447 SetPresParams(WinWindowFromID(hwnd,ids[x]),
1448 &RGBGREY,
1449 &RGBBLACK,
1450 &RGBBLACK,
1451 GetPString(IDS_8HELVTEXT));
1452 }
1453 }
1454 else
1455 WinDismissDlg(hwnd,0);
1456 break;
1457
1458 case UM_STRETCH:
1459 {
1460 SWP swp,swpC;
1461 LONG titl,szbx,szby,sz;
1462 HWND hwndActive;
1463
1464 WinQueryWindowPos(hwnd,&swp);
1465 if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
1466 hwndActive = WinQueryFocus(HWND_DESKTOP);
1467 szbx = SysVal(SV_CXSIZEBORDER);
1468 szby = SysVal(SV_CYSIZEBORDER);
1469 titl = SysVal(SV_CYTITLEBAR);
1470 titl += 26;
1471 swp.cx -= (szbx * 2);
1472 sz = (swp.cx / 8);
1473 WinQueryWindowPos(WinWindowFromID(hwnd,COMP_LEFTDIR),&swpC);
1474 WinSetWindowPos(WinWindowFromID(hwnd,COMP_LEFTDIR),HWND_TOP,
1475 szbx + 6,
1476 swpC.y,
1477 (swp.cx / 2) - (szbx + 6),
1478 ((swp.cy - swpC.y) - titl) - szby,
1479 SWP_MOVE | SWP_SIZE);
1480 WinSetWindowPos(WinWindowFromID(hwnd,COMP_RIGHTDIR),HWND_TOP,
1481 (swp.cx / 2) + (szbx + 6),
1482 swpC.y,
1483 (swp.cx / 2) - (szbx + 6),
1484 ((swp.cy - swpC.y) - titl) - szby,
1485 SWP_MOVE | SWP_SIZE);
1486 WinSetWindowPos(WinWindowFromID(hwnd,COMP_TOTALLEFTHDR),HWND_TOP,
1487 szbx + 6,
1488 ((swp.cy - titl) - szby) + 4,
1489 sz - (szbx + 6),
1490 20,
1491 SWP_MOVE | SWP_SIZE);
1492 WinSetWindowPos(WinWindowFromID(hwnd,COMP_TOTALLEFT),HWND_TOP,
1493 sz + (szbx + 6),
1494 ((swp.cy - titl) - szby) + 4,
1495 sz - (szbx + 6),
1496 20,
1497 SWP_MOVE | SWP_SIZE);
1498 WinSetWindowPos(WinWindowFromID(hwnd,COMP_SELLEFTHDR),HWND_TOP,
1499 (sz * 2) + (szbx + 6),
1500 ((swp.cy - titl) - szby) + 4,
1501 sz - (szbx + 6),
1502 20,
1503 SWP_MOVE | SWP_SIZE);
1504 WinSetWindowPos(WinWindowFromID(hwnd,COMP_SELLEFT),HWND_TOP,
1505 (sz * 3) + (szbx + 6),
1506 ((swp.cy - titl) - szby) + 4,
1507 sz - (szbx + 6),
1508 20,
1509 SWP_MOVE | SWP_SIZE);
1510 WinSetWindowPos(WinWindowFromID(hwnd,COMP_TOTALRIGHTHDR),HWND_TOP,
1511 (sz * 4) + (szbx + 6),
1512 ((swp.cy - titl) - szby) + 4,
1513 sz - (szbx + 6),
1514 20,
1515 SWP_MOVE | SWP_SIZE);
1516 WinSetWindowPos(WinWindowFromID(hwnd,COMP_TOTALRIGHT),HWND_TOP,
1517 (sz * 5) + (szbx + 6),
1518 ((swp.cy - titl) - szby) + 4,
1519 sz - (szbx + 6),
1520 20,
1521 SWP_MOVE | SWP_SIZE);
1522 WinSetWindowPos(WinWindowFromID(hwnd,COMP_SELRIGHTHDR),HWND_TOP,
1523 (sz * 6) + (szbx + 6),
1524 ((swp.cy - titl) - szby) + 4,
1525 sz - (szbx + 6),
1526 20,
1527 SWP_MOVE | SWP_SIZE);
1528 WinSetWindowPos(WinWindowFromID(hwnd,COMP_SELRIGHT),HWND_TOP,
1529 (sz * 7) + (szbx + 6),
1530 ((swp.cy - titl) - szby) + 4,
1531 sz - (szbx + 6),
1532 20,
1533 SWP_MOVE | SWP_SIZE);
1534 PaintRecessedWindow(WinWindowFromID(hwnd,COMP_TOTALLEFT),
1535 (HPS)0,FALSE,FALSE);
1536 PaintRecessedWindow(WinWindowFromID(hwnd,COMP_SELLEFT),
1537 (HPS)0,FALSE,FALSE);
1538 PaintRecessedWindow(WinWindowFromID(hwnd,COMP_TOTALRIGHT),
1539 (HPS)0,FALSE,FALSE);
1540 PaintRecessedWindow(WinWindowFromID(hwnd,COMP_SELRIGHT),
1541 (HPS)0,FALSE,FALSE);
1542 PaintRecessedWindow(hwndLeft,(HPS)0,
1543 (hwndActive == hwndLeft),
1544 TRUE);
1545 PaintRecessedWindow(hwndRight,(HPS)0,
1546 (hwndActive == hwndRight),
1547 TRUE);
1548 }
1549 }
1550 return 0;
1551
1552 case WM_ADJUSTWINDOWPOS:
1553 PostMsg(hwnd,UM_STRETCH,MPVOID,MPVOID);
1554 break;
1555
1556 case UM_SETUP:
1557 {
1558 CNRINFO cnri;
1559 BOOL tempsubj;
1560
1561 cmp = INSTDATA(hwnd);
1562 if(cmp) {
1563 cmp->dcd.size = sizeof(DIRCNRDATA);
1564 cmp->dcd.type = DIR_FRAME;
1565 cmp->dcd.hwndFrame = hwnd;
1566 cmp->dcd.hwndClient = hwnd;
1567 cmp->dcd.mask.attrFile = (FILE_DIRECTORY | FILE_ARCHIVED |
1568 FILE_READONLY | FILE_SYSTEM |
1569 FILE_HIDDEN);
1570 LoadDetailsSwitches("DirCmp",&cmp->dcd);
1571 cmp->dcd.detailslongname = FALSE;
1572 cmp->dcd.detailsicon = FALSE; /* TRUE; */
1573 }
1574 memset(&cnri,0,sizeof(CNRINFO));
1575 cnri.cb = sizeof(CNRINFO);
1576 WinSendDlgItemMsg(hwnd,COMP_LEFTDIR,CM_QUERYCNRINFO,
1577 MPFROMP(&cnri),MPFROMLONG(sizeof(CNRINFO)));
1578 cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
1579 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 68;
1580 WinSendDlgItemMsg(hwnd,COMP_LEFTDIR,CM_SETCNRINFO,MPFROMP(&cnri),
1581 MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
1582 memset(&cnri,0,sizeof(CNRINFO));
1583 cnri.cb = sizeof(CNRINFO);
1584 WinSendDlgItemMsg(hwnd,COMP_RIGHTDIR,CM_QUERYCNRINFO,
1585 MPFROMP(&cnri),MPFROMLONG(sizeof(CNRINFO)));
1586 cnri.flWindowAttr |= (CA_OWNERDRAW | CV_MINI);
1587 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 54;
1588 WinSendDlgItemMsg(hwnd,COMP_RIGHTDIR,CM_SETCNRINFO,MPFROMP(&cnri),
1589 MPFROMLONG(CMA_FLWINDOWATTR | CMA_XVERTSPLITBAR));
1590 AdjustCnrColRO(hwndLeft,GetPString(IDS_FILENAMECOLTEXT),
1591 TRUE,FALSE);
1592 AdjustCnrColRO(hwndLeft,GetPString(IDS_LONGNAMECOLTEXT),
1593 TRUE,FALSE);
1594 AdjustCnrColRO(hwndRight,GetPString(IDS_FILENAMECOLTEXT),
1595 TRUE,FALSE);
1596 AdjustCnrColRO(hwndRight,GetPString(IDS_LONGNAMECOLTEXT),
1597 TRUE,FALSE);
1598 AdjustCnrColsForPref(hwndLeft,
1599 cmp->leftdir,&cmp->dcd,TRUE);
1600 tempsubj = cmp->dcd.detailssubject;
1601 cmp->dcd.detailssubject = FALSE;
1602 AdjustCnrColsForPref(hwndRight,
1603 cmp->rightdir,&cmp->dcd,TRUE);
1604 if(*cmp->rightlist) {
1605 AdjustCnrColVis(hwndRight,GetPString(IDS_LADATECOLTEXT),FALSE,FALSE);
1606 AdjustCnrColVis(hwndRight,GetPString(IDS_LATIMECOLTEXT),FALSE,FALSE);
1607 AdjustCnrColVis(hwndRight,GetPString(IDS_CRDATECOLTEXT),FALSE,FALSE);
1608 AdjustCnrColVis(hwndRight,GetPString(IDS_CRTIMECOLTEXT),FALSE,FALSE);
1609 }
1610 cmp->dcd.detailssubject = tempsubj;
1611 }
1612 return 0;
1613
1614 case WM_DRAWITEM:
1615 if(mp2) {
1616
1617 POWNERITEM pown = (POWNERITEM)mp2;
1618 PCNRDRAWITEMINFO pcown;
1619 PCNRITEM pci;
1620
1621 pcown = (PCNRDRAWITEMINFO)pown->hItem;
1622 if(pcown) {
1623 pci = (PCNRITEM)pcown->pRecord;
1624 if(pci && (INT)pci != -1 && !*pci->szFileName)
1625 return MRFROMLONG(TRUE);
1626 }
1627 }
1628 return 0;
1629
1630 case UM_CONTAINERHWND:
1631 WinSetDlgItemText(hwnd,COMP_NOTE,
1632 GetPString(IDS_COMPHOLDBLDLISTTEXT));
1633 return 0;
1634
1635 case UM_CONTAINERDIR:
1636 WinSetDlgItemText(hwnd,COMP_NOTE,
1637 GetPString(IDS_COMPHOLDFILLCNRTEXT));
1638 return 0;
1639
1640 case UM_CONTAINER_FILLED:
1641 cmp = INSTDATA(hwnd);
1642 if(cmp) {
1643 cmp->filling = FALSE;
1644 WinEnableWindow(hwndLeft,TRUE);
1645 WinEnableWindow(hwndRight,TRUE);
1646 WinEnableWindowUpdate(hwndLeft,TRUE);
1647 WinEnableWindowUpdate(hwndRight,TRUE);
[316]1648 // if(!mp1) {
[2]1649 {
1650 CHAR s[81];
1651
1652 sprintf(s," %d",cmp->totalleft);
1653 WinSetDlgItemText(hwnd,COMP_TOTALLEFT,s);
1654 sprintf(s," %d",cmp->totalright);
1655 WinSetDlgItemText(hwnd,COMP_TOTALRIGHT,s);
1656 sprintf(s," %d",cmp->selleft);
1657 WinSetDlgItemText(hwnd,COMP_SELLEFT,s);
1658 sprintf(s," %d",cmp->selright);
1659 WinSetDlgItemText(hwnd,COMP_SELRIGHT,s);
1660 }
1661 WinEnableWindow(WinWindowFromID(hwnd,DID_OK),TRUE);
1662 WinEnableWindow(WinWindowFromID(hwnd,DID_CANCEL),TRUE);
1663 WinEnableWindow(WinWindowFromID(hwnd,COMP_COLLECT),TRUE);
1664 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBOTH),TRUE);
1665 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTONE),TRUE);
1666 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTNEWER),TRUE);
1667 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTOLDER),TRUE);
1668 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBIGGER),TRUE);
1669 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSMALLER),TRUE);
1670 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBOTH),TRUE);
1671 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTONE),TRUE);
1672 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTNEWER),TRUE);
1673 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTOLDER),TRUE);
1674 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBIGGER),TRUE);
1675 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTSMALLER),TRUE);
1676 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTALL),TRUE);
[316]1677 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),TRUE);
[2]1678 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),TRUE);
1679 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),TRUE);
1680 WinEnableWindow(WinWindowFromID(hwnd,IDM_INVERT),TRUE);
1681 WinEnableWindow(WinWindowFromID(hwnd,COMP_SETDIRS),TRUE);
1682 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETELEFT),TRUE);
1683 WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),TRUE);
1684 if(!*cmp->rightlist) {
1685 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYLEFT),TRUE);
1686 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVELEFT),TRUE);
1687 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETERIGHT),TRUE);
1688 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),TRUE);
1689 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),TRUE);
1690 }
1691 WinEnableWindow(WinWindowFromID(hwnd,COMP_INCLUDESUBDIRS),TRUE);
1692 if(*cmp->dcd.mask.szMask)
1693 WinSetDlgItemText(hwnd,COMP_NOTE,
1694 GetPString(IDS_COMPREADYFILTEREDTEXT));
1695 else
1696 WinSetDlgItemText(hwnd,COMP_NOTE,
1697 GetPString(IDS_COMPREADYTEXT));
1698 }
1699 else {
1700 DosBeep(50,100);
1701 WinDismissDlg(hwnd,0);
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 {
1844 PFIELDINFO pfi = ((PCNREDITDATA)mp2)->pFieldInfo;
1845 PCNRITEM pci = (PCNRITEM)((PCNREDITDATA)mp2)->pRecord;
1846
1847 if(pfi || pci) {
1848 PostMsg(hwnd,
1849 CM_CLOSEEDIT,
1850 MPVOID,
1851 MPVOID);
1852 DosBeep(250,100);
1853 }
1854 }
1855 break;
1856
1857 case CN_REALLOCPSZ:
1858 cmp = INSTDATA(hwnd);
1859 if(cmp) {
1860
1861 PFIELDINFO pfi = ((PCNREDITDATA)mp2)->pFieldInfo;
1862 PCNRITEM pci = (PCNRITEM)((PCNREDITDATA)mp2)->pRecord;
1863 HWND hwndMLE;
1864 CHAR szData[CCHMAXPATH],testname[CCHMAXPATH],*p;
1865
1866 if(!pci && !pfi) {
1867 hwndMLE = WinWindowFromID(WinWindowFromID(hwnd,
1868 SHORT1FROMMP(mp1)),CID_MLE);
1869 WinQueryWindowText(hwndMLE,
1870 sizeof(szData),
1871 szData);
1872 p = strchr(szData,'\n');
1873 if(p)
1874 *p = 0;
1875 p = strchr(szData,'\r');
1876 if(p)
1877 *p = 0;
[123]1878 bstrip(szData);
[2]1879 if(*szData) {
1880 if(!DosQueryPathInfo(szData,
1881 FIL_QUERYFULLNAME,
1882 testname,
1883 sizeof(testname))) {
1884 if(!SetDir(cmp->hwndParent,
1885 hwnd,
1886 testname,
1887 1)) {
1888 if(SHORT1FROMMP(mp1) == COMP_LEFTDIR)
1889 strcpy(cmp->leftdir,testname);
1890 else {
1891 strcpy(cmp->rightdir,testname);
1892 *cmp->rightlist = 0;
1893 }
1894 PostMsg(hwnd,
1895 UM_SETUP,
1896 MPVOID,
1897 MPVOID);
1898 PostMsg(hwnd,
1899 UM_SETDIR,
1900 MPVOID,
1901 MPVOID);
1902 }
1903 }
1904 }
1905 }
1906 }
1907 break;
1908
1909 case CN_EMPHASIS:
1910 {
1911 PNOTIFYRECORDEMPHASIS pre = mp2;
1912 PCNRITEM pci;
1913
1914 if(pre->fEmphasisMask & CRA_SELECTED) {
1915 pci = (PCNRITEM)pre->pRecord;
1916 if(pci) {
1917 if(!*pci->szFileName) {
1918 if(pci->rc.flRecordAttr & CRA_SELECTED)
1919 WinSendDlgItemMsg(hwnd,SHORT1FROMMP(mp1),
1920 CM_SETRECORDEMPHASIS,
1921 MPFROMP(pci),
1922 MPFROM2SHORT(FALSE,CRA_SELECTED));
1923 }
1924 else {
1925
1926 CHAR s[81];
1927
1928 cmp = INSTDATA(hwnd);
1929 if(pci->rc.flRecordAttr & CRA_SELECTED) {
1930 if(SHORT1FROMMP(mp1) == COMP_LEFTDIR)
1931 cmp->selleft++;
1932 else
1933 cmp->selright++;
1934 }
1935 else {
1936 if(SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
1937 if(cmp->selleft)
1938 cmp->selleft--;
1939 }
1940 else {
1941 if(cmp->selright)
1942 cmp->selright--;
1943 }
1944 }
1945 if(SHORT1FROMMP(mp1) == COMP_LEFTDIR) {
1946 if(WinIsWindowEnabled(hwndLeft) ||
1947 !(cmp->selleft % 50)) {
1948 sprintf(s," %d",cmp->selleft);
1949 WinSetDlgItemText(hwnd,COMP_SELLEFT,s);
1950 }
1951 }
1952 else {
1953 if(WinIsWindowEnabled(hwndRight) ||
1954 !(cmp->selright % 50)) {
1955 sprintf(s," %d",cmp->selright);
1956 WinSetDlgItemText(hwnd,COMP_SELRIGHT,s);
1957 }
1958 }
1959 }
1960 }
1961 }
1962 }
1963 break;
1964
1965 case CN_SCROLL:
1966 cmp = INSTDATA(hwnd);
1967 if(!cmp->forcescroll) {
1968
1969 PNOTIFYSCROLL pns = mp2;
1970
1971 if(pns->fScroll & CMA_VERTICAL) {
1972 cmp->forcescroll = TRUE;
1973 WinSendDlgItemMsg(hwnd,(SHORT1FROMMP(mp1) == COMP_LEFTDIR) ?
1974 COMP_RIGHTDIR : COMP_LEFTDIR,
1975 CM_SCROLLWINDOW,MPFROMSHORT(CMA_VERTICAL),
1976 MPFROMLONG(pns->lScrollInc));
1977 cmp->forcescroll = FALSE;
1978 }
1979 }
1980 break;
1981 }
[316]1982 break; // COMP_RIGHTDIR
[2]1983 }
[316]1984 return 0; // WM_CONTROL
[2]1985
1986 case UM_SETDIR:
1987 cmp = INSTDATA(hwnd);
1988 if(cmp) {
1989
1990 COMPARE *forthread;
1991 CNRINFO cnri;
1992
1993 cmp->includesubdirs = WinQueryButtonCheckstate(hwnd,
1994 COMP_INCLUDESUBDIRS);
1995 memset(&cnri,0,sizeof(CNRINFO));
1996 cnri.cb = sizeof(CNRINFO);
1997 cnri.pszCnrTitle = cmp->leftdir;
1998 cnri.flWindowAttr = CV_DETAIL | CV_MINI |
1999 CA_CONTAINERTITLE | CA_TITLESEPARATOR |
2000 CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
2001 WinSendDlgItemMsg(hwnd,COMP_LEFTDIR,CM_SETCNRINFO,MPFROMP(&cnri),
2002 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
2003 cnri.pszCnrTitle = cmp->rightdir;
2004 WinSendDlgItemMsg(hwnd,COMP_RIGHTDIR,CM_SETCNRINFO,MPFROMP(&cnri),
2005 MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
2006 cmp->filling = TRUE;
2007 forthread = malloc(sizeof(COMPARE));
2008 if(forthread) {
2009 *forthread = *cmp;
2010 forthread->cmp = cmp;
[316]2011 if(_beginthread(FillCnrsThread,NULL,122880,(PVOID)forthread) != -1) {
[2]2012 WinEnableWindowUpdate(hwndLeft,FALSE);
2013 WinEnableWindowUpdate(hwndRight,FALSE);
2014 cmp->selleft = cmp->selright = 0;
2015 WinSetDlgItemText(hwnd,COMP_SELLEFT,"0");
2016 WinSetDlgItemText(hwnd,COMP_SELRIGHT,"0");
2017 WinSetDlgItemText(hwnd,COMP_TOTALLEFT,"0");
2018 WinSetDlgItemText(hwnd,COMP_TOTALRIGHT,"0");
2019 WinSetDlgItemText(hwnd,COMP_NOTE,
2020 GetPString(IDS_COMPHOLDREADDISKTEXT));
2021 WinEnableWindow(hwndRight,FALSE);
2022 WinEnableWindow(hwndLeft,FALSE);
2023 WinEnableWindow(WinWindowFromID(hwnd,DID_OK),FALSE);
2024 WinEnableWindow(WinWindowFromID(hwnd,DID_CANCEL),FALSE);
2025 WinEnableWindow(WinWindowFromID(hwnd,COMP_COLLECT),FALSE);
2026 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBOTH),FALSE);
2027 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTONE),FALSE);
2028 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTNEWER),FALSE);
2029 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTOLDER),FALSE);
2030 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBIGGER),FALSE);
2031 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSMALLER),FALSE);
2032 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBOTH),FALSE);
2033 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTONE),FALSE);
2034 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTNEWER),FALSE);
2035 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTOLDER),FALSE);
2036 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBIGGER),FALSE);
2037 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTSMALLER),FALSE);
2038 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTALL),FALSE);
2039 WinEnableWindow(WinWindowFromID(hwnd,COMP_INCLUDESUBDIRS),FALSE);
2040 WinEnableWindow(WinWindowFromID(hwnd,COMP_SETDIRS),FALSE);
2041 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETELEFT),FALSE);
2042 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETERIGHT),FALSE);
2043 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYLEFT),FALSE);
2044 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVELEFT),FALSE);
2045 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),FALSE);
2046 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),FALSE);
[316]2047 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),FALSE);
[2]2048 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),FALSE);
2049 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),FALSE);
2050 WinEnableWindow(WinWindowFromID(hwnd,IDM_INVERT),FALSE);
2051 WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
2052 }
2053 else {
2054 DosBeep(250,100);
2055 WinDismissDlg(hwnd,0);
2056 free(forthread);
2057 }
2058 }
2059 else {
2060 DosBeep(250,100);
2061 WinDismissDlg(hwnd,0);
2062 }
2063 }
2064 return 0;
2065
2066 case UM_FILTER:
2067 cmp = INSTDATA(hwnd);
2068 if(cmp) {
2069 if(mp1) {
2070 DosEnterCritSec();
2071 SetMask((CHAR *)mp1,&cmp->dcd.mask);
2072 DosExitCritSec();
2073 }
2074 cmp->dcd.suspendview = 1;
2075 WinSendMsg(hwndLeft,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
2076 WinSendMsg(hwndRight,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
2077 cmp->dcd.suspendview = 0;
2078 if(*cmp->dcd.mask.szMask)
2079 WinSetDlgItemText(hwnd,COMP_NOTE,
2080 GetPString(IDS_COMPREADYFILTEREDTEXT));
2081 else
2082 WinSetDlgItemText(hwnd,COMP_NOTE,
2083 GetPString(IDS_COMPREADYTEXT));
2084 }
2085 return 0;
2086
[316]2087 case UM_HIDENOTSELECTED:
2088 cmp = INSTDATA(hwnd);
2089 if(cmp) {
2090 USHORT wantHide = WinQueryButtonCheckstate(hwnd,
2091 COMP_HIDENOTSELECTED);
2092
2093 cmp->dcd.suspendview = 1;
2094 if (wantHide) {
2095 BOOL needRefresh = FALSE;
2096 HWND hwndl = WinWindowFromID(cmp->hwnd,COMP_LEFTDIR);
2097 HWND hwndr = WinWindowFromID(cmp->hwnd,COMP_RIGHTDIR);
2098 PCNRITEM pcil = WinSendMsg(hwndl,CM_QUERYRECORD,MPVOID,
2099 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
2100 PCNRITEM pcir = WinSendMsg(hwndr,CM_QUERYRECORD,MPVOID,
2101 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
2102 while(pcil && (INT)pcil != -1 && pcir && (INT)pcir != -1) {
2103 if (~pcil->rc.flRecordAttr & CRA_SELECTED &&
2104 ~pcir->rc.flRecordAttr & CRA_SELECTED) {
2105 pcil->rc.flRecordAttr |= CRA_FILTERED;
2106 pcir->rc.flRecordAttr |= CRA_FILTERED;
2107 needRefresh = TRUE;
2108 }
2109 pcil = WinSendMsg(hwndl,CM_QUERYRECORD,MPFROMP(pcil),
2110 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
2111 pcir = WinSendMsg(hwndr,CM_QUERYRECORD,MPFROMP(pcir),
2112 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
2113 } // while
2114 if (needRefresh) {
2115 WinSendMsg(hwndl,CM_INVALIDATERECORD,
2116 MPVOID,MPFROM2SHORT(0,CMA_REPOSITION));
2117 WinSendMsg(hwndr,CM_INVALIDATERECORD,
2118 MPVOID,MPFROM2SHORT(0,CMA_REPOSITION));
2119 }
2120 }
2121 else {
2122 WinSendMsg(hwndLeft,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
2123 WinSendMsg(hwndRight,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
2124 }
2125 cmp->dcd.suspendview = 0;
2126 if(*cmp->dcd.mask.szMask)
2127 WinSetDlgItemText(hwnd,COMP_NOTE,
2128 GetPString(IDS_COMPREADYFILTEREDTEXT));
2129 else
2130 WinSetDlgItemText(hwnd,COMP_NOTE,
2131 GetPString(IDS_COMPREADYTEXT));
2132 }
2133 return 0;
2134
[2]2135 case WM_COMMAND:
2136 switch(SHORT1FROMMP(mp1)) {
2137 case IDM_COMPARE:
2138 cmp = INSTDATA(hwnd);
2139 if(cmp) {
2140
2141 PCNRITEM pci;
2142 CHAR ofile[CCHMAXPATH];
2143
2144 pci = (PCNRITEM)WinSendMsg(cmp->hwndCalling,
2145 CM_QUERYRECORDEMPHASIS,
2146 MPFROMLONG(CMA_FIRST),
2147 MPFROMSHORT(CRA_CURSORED));
2148 if(pci) {
2149 if(cmp->hwndCalling == hwndLeft)
2150 strcpy(ofile,cmp->rightdir);
2151 else
2152 strcpy(ofile,cmp->leftdir);
2153 if(ofile[strlen(ofile) - 1] != '\\')
2154 strcat(ofile,"\\");
2155 strcat(ofile,pci->pszFileName);
2156 if(*compare) {
2157
2158 CHAR *fakelist[3];
2159
2160 fakelist[0] = pci->szFileName;
2161 fakelist[1] = ofile;
2162 fakelist[2] = NULL;
2163 ExecOnList(hwnd,compare,
2164 WINDOWED | SEPARATEKEEP,
2165 NULL,fakelist,NULL);
2166 }
2167 else {
2168
2169 FCOMPARE fc;
2170
2171 memset(&fc,0,sizeof(fc));
2172 fc.size = sizeof(fc);
2173 fc.hwndParent = hwnd;
2174 strcpy(fc.file1,pci->szFileName);
2175 strcpy(fc.file2,ofile);
2176 WinDlgBox(HWND_DESKTOP,hwnd,
2177 CFileDlgProc,FM3ModHandle,
2178 FCMP_FRAME,(PVOID)&fc);
2179 }
2180 }
2181 }
2182 break;
2183
2184 case COMP_FILTER:
2185 case IDM_FILTER:
2186 cmp = INSTDATA(hwnd);
2187 if(cmp) {
2188
2189 BOOL empty = FALSE;
2190 PCNRITEM pci;
2191 CHAR *p;
2192 BOOL temp;
2193
2194 if(!*cmp->dcd.mask.szMask) {
2195 empty = TRUE;
2196 temp = fSelectedAlways;
2197 fSelectedAlways = TRUE;
2198 pci = (PCNRITEM)CurrentRecord(hwnd);
2199 fSelectedAlways = temp;
2200 if(pci && !(pci->attrFile & FILE_DIRECTORY)) {
2201 p = strrchr(pci->szFileName,'\\');
2202 if(p) {
2203 p++;
2204 strcpy(cmp->dcd.mask.szMask,p);
2205 }
2206 }
2207 }
2208 cmp->dcd.mask.fNoAttribs = TRUE;
2209 cmp->dcd.mask.attrFile = ALLATTRS;
2210 cmp->dcd.mask.antiattr = 0;
2211 if(WinDlgBox(HWND_DESKTOP,hwnd,PickMaskDlgProc,
2212 FM3ModHandle,MSK_FRAME,MPFROMP(&cmp->dcd.mask))) {
2213 cmp->dcd.mask.attrFile = ALLATTRS;
2214 cmp->dcd.mask.antiattr = 0;
2215 WinSendMsg(hwnd,UM_FILTER,MPVOID,MPVOID);
2216 }
2217 else if(empty) {
2218 *cmp->dcd.mask.szMask = 0;
2219 cmp->dcd.mask.attrFile = ALLATTRS;
2220 cmp->dcd.mask.antiattr = 0;
2221 }
2222 }
2223 break;
2224
2225 case IDM_SHOWSUBJECT:
2226 case IDM_SHOWEAS:
2227 case IDM_SHOWSIZE:
2228 case IDM_SHOWLWDATE:
2229 case IDM_SHOWLWTIME:
2230 case IDM_SHOWLADATE:
2231 case IDM_SHOWLATIME:
2232 case IDM_SHOWCRDATE:
2233 case IDM_SHOWCRTIME:
2234 case IDM_SHOWATTR:
2235 cmp = INSTDATA(hwnd);
2236 if(cmp) {
2237
2238 DIRCNRDATA dcd1;
2239 BOOL tempsubj;
2240
2241 dcd1 = cmp->dcd;
2242 AdjustDetailsSwitches(hwndLeft,
2243 (HWND)0,SHORT1FROMMP(mp1),
2244 cmp->leftdir,"DirCmp",&cmp->dcd,
2245 TRUE);
2246 tempsubj = cmp->dcd.detailssubject;
2247 cmp->dcd = dcd1;
2248 cmp->dcd.detailssubject = FALSE;
2249 AdjustDetailsSwitches(hwndRight,
2250 cmp->dcd.hwndLastMenu,SHORT1FROMMP(mp1),
2251 cmp->rightdir,"DirCmp",&cmp->dcd,TRUE);
2252 cmp->dcd.detailssubject = tempsubj;
2253 }
2254 break;
2255
2256 case IDM_LOADLISTFILE:
2257 cmp = INSTDATA(hwnd);
2258 if(cmp) {
2259
2260 CHAR fullname[CCHMAXPATH];
2261
2262 strcpy(fullname,"*.PMD");
2263 if(insert_filename(HWND_DESKTOP,fullname,TRUE,FALSE) &&
2264 *fullname && !strchr(fullname,'*') && !strchr(fullname,'?')) {
2265 strcpy(cmp->rightlist,fullname);
2266 PostMsg(hwnd,UM_SETUP,MPVOID,MPVOID);
2267 PostMsg(hwnd,UM_SETDIR,MPVOID,MPVOID);
2268 }
2269 }
2270 break;
2271
2272 case IDM_SAVELISTFILE:
2273 cmp = INSTDATA(hwnd);
2274 if(cmp) {
2275
2276 SNAPSTUFF *sf;
2277 CHAR fullname[CCHMAXPATH];
2278
2279 strcpy(fullname,"*.PMD");
2280 if(export_filename(HWND_DESKTOP,fullname,1) && *fullname &&
2281 !strchr(fullname,'*') && !strchr(fullname,'?')) {
2282 sf = malloc(sizeof(SNAPSTUFF));
2283 if(sf) {
2284 memset(sf,0,sizeof(SNAPSTUFF));
2285 strcpy(sf->filename,fullname);
2286 if(hwndLeft == cmp->hwndCalling)
2287 strcpy(sf->dirname,cmp->leftdir);
2288 else
2289 strcpy(sf->dirname,cmp->rightdir);
2290 sf->recurse = cmp->includesubdirs;
2291 if(_beginthread(StartSnap,NULL,65536,(PVOID)sf) == -1) {
2292 free(sf);
2293 DosBeep(50,100);
2294 }
2295 }
2296 }
2297 }
2298 break;
2299
2300 case COMP_SETDIRS:
2301 cmp = INSTDATA(hwnd);
2302 if(cmp) {
2303
2304 WALK2 wa;
2305
2306 memset(&wa,0,sizeof(wa));
2307 wa.size = sizeof(wa);
2308 strcpy(wa.szCurrentPath1,cmp->leftdir);
2309 strcpy(wa.szCurrentPath2,cmp->rightdir);
2310 if(WinDlgBox(HWND_DESKTOP,hwnd,WalkTwoCmpDlgProc,
2311 FM3ModHandle,WALK2_FRAME,
2312 MPFROMP(&wa)) &&
2313 !IsFile(wa.szCurrentPath1) &&
2314 !IsFile(wa.szCurrentPath2)) {
2315 strcpy(cmp->leftdir,wa.szCurrentPath1);
2316 strcpy(cmp->rightdir,wa.szCurrentPath2);
2317 *cmp->rightlist = 0;
2318 PostMsg(hwnd,UM_SETUP,MPVOID,MPVOID);
2319 PostMsg(hwnd,UM_SETDIR,MPVOID,MPVOID);
2320 }
2321 }
2322 break;
2323
2324 case COMP_COPYLEFT:
2325 case COMP_MOVELEFT:
2326 case COMP_COPYRIGHT:
2327 case COMP_MOVERIGHT:
2328 case COMP_DELETELEFT:
2329 case COMP_DELETERIGHT:
2330 cmp = INSTDATA(hwnd);
2331 if(cmp) {
2332
2333 COMPARE *forthread;
2334
2335 cmp->filling = TRUE;
2336 forthread = malloc(sizeof(COMPARE));
2337 if(forthread) {
2338 *forthread = *cmp;
2339 forthread->cmp = cmp;
2340 forthread->action = SHORT1FROMMP(mp1);
[316]2341 if(_beginthread(ActionCnrThread,NULL,122880,(PVOID)forthread) != -1) {
[2]2342 WinEnableWindowUpdate(hwndLeft,FALSE);
2343 WinEnableWindowUpdate(hwndRight,FALSE);
2344 switch(SHORT1FROMMP(mp1)) {
2345 case COMP_DELETELEFT:
2346 case COMP_DELETERIGHT:
2347 WinSetDlgItemText(hwnd,COMP_NOTE,
2348 GetPString(IDS_COMPHOLDDELETINGTEXT));
2349 break;
2350 case COMP_MOVELEFT:
2351 case COMP_MOVERIGHT:
2352 WinSetDlgItemText(hwnd,COMP_NOTE,
2353 GetPString(IDS_COMPHOLDMOVINGTEXT));
2354 break;
2355 case COMP_COPYLEFT:
2356 case COMP_COPYRIGHT:
2357 WinSetDlgItemText(hwnd,COMP_NOTE,
2358 GetPString(IDS_COMPHOLDCOPYINGTEXT));
2359 break;
2360 default:
2361 WinSetDlgItemText(hwnd,COMP_NOTE,
2362 GetPString(IDS_COMPHOLDDUNNOTEXT));
2363 break;
2364 }
2365 WinEnableWindow(hwndRight,FALSE);
2366 WinEnableWindow(hwndLeft,FALSE);
2367 WinEnableWindow(WinWindowFromID(hwnd,DID_OK),FALSE);
2368 WinEnableWindow(WinWindowFromID(hwnd,DID_CANCEL),FALSE);
2369 WinEnableWindow(WinWindowFromID(hwnd,COMP_COLLECT),FALSE);
2370 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBOTH),FALSE);
2371 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTONE),FALSE);
2372 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTNEWER),FALSE);
2373 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTOLDER),FALSE);
2374 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBIGGER),FALSE);
2375 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSMALLER),FALSE);
2376 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBOTH),FALSE);
2377 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTONE),FALSE);
2378 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTNEWER),FALSE);
2379 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTOLDER),FALSE);
2380 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBIGGER),FALSE);
2381 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTSMALLER),FALSE);
2382 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTALL),FALSE);
2383 WinEnableWindow(WinWindowFromID(hwnd,COMP_INCLUDESUBDIRS),FALSE);
2384 WinEnableWindow(WinWindowFromID(hwnd,COMP_SETDIRS),FALSE);
2385 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETELEFT),FALSE);
2386 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETERIGHT),FALSE);
2387 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYLEFT),FALSE);
2388 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVELEFT),FALSE);
2389 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),FALSE);
2390 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),FALSE);
[316]2391 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),FALSE);
[2]2392 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),FALSE);
2393 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),FALSE);
2394 WinEnableWindow(WinWindowFromID(hwnd,IDM_INVERT),FALSE);
2395 WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
2396 }
2397 else {
2398 DosBeep(250,100);
2399 free(forthread);
2400 }
2401 }
2402 else
2403 DosBeep(250,100);
2404 }
2405 break;
2406
2407 case DID_OK:
2408 WinDismissDlg(hwnd,0);
2409 break;
2410 case DID_CANCEL:
2411 WinDismissDlg(hwnd,1);
2412 break;
2413
2414 case IDM_HELP:
2415 if(hwndHelp)
2416 WinSendMsg(hwndHelp,HM_DISPLAY_HELP,
2417 MPFROM2SHORT(HELP_COMPARE,0),
2418 MPFROMSHORT(HM_RESOURCEID));
2419 break;
2420
2421 case IDM_DESELECTALL:
2422 case IDM_SELECTNEWER:
2423 case IDM_SELECTOLDER:
2424 case IDM_SELECTBIGGER:
2425 case IDM_SELECTSMALLER:
2426 case IDM_DESELECTNEWER:
2427 case IDM_DESELECTOLDER:
2428 case IDM_DESELECTBIGGER:
2429 case IDM_DESELECTSMALLER:
2430 case IDM_DESELECTONE:
2431 case IDM_DESELECTBOTH:
2432 case IDM_SELECTBOTH:
2433 case IDM_SELECTONE:
[316]2434 case IDM_SELECTSAMECONTENT:
2435 case IDM_SELECTIDENTICAL: // name, size and time
2436 case IDM_SELECTSAME: // name and size
[2]2437 case IDM_INVERT:
2438 cmp = INSTDATA(hwnd);
2439 if(cmp) {
2440
2441 COMPARE *forthread;
2442
2443 cmp->filling = TRUE;
2444 forthread = malloc(sizeof(COMPARE));
2445 if(forthread) {
2446 *forthread = *cmp;
2447 forthread->cmp = cmp;
2448 forthread->action = SHORT1FROMMP(mp1);
[316]2449 if(_beginthread(SelectCnrsThread,NULL,65536,(PVOID)forthread) != -1) {
[2]2450 WinEnableWindowUpdate(hwndLeft,FALSE);
2451 WinEnableWindowUpdate(hwndRight,FALSE);
2452 switch(SHORT1FROMMP(mp1)) {
2453 case IDM_DESELECTALL:
2454 case IDM_DESELECTNEWER:
2455 case IDM_DESELECTOLDER:
2456 case IDM_DESELECTBIGGER:
2457 case IDM_DESELECTSMALLER:
2458 case IDM_DESELECTONE:
2459 case IDM_DESELECTBOTH:
2460 WinSetDlgItemText(hwnd,COMP_NOTE,
2461 GetPString(IDS_COMPHOLDDESELTEXT));
2462 break;
2463 case IDM_INVERT:
2464 WinSetDlgItemText(hwnd,COMP_NOTE,
2465 GetPString(IDS_COMPHOLDINVERTTEXT));
2466 break;
2467 default:
2468 WinSetDlgItemText(hwnd,COMP_NOTE,
2469 GetPString(IDS_COMPHOLDSELTEXT));
2470 break;
2471 }
2472 WinEnableWindow(hwndRight,FALSE);
2473 WinEnableWindow(hwndLeft,FALSE);
2474 WinEnableWindow(WinWindowFromID(hwnd,DID_OK),FALSE);
2475 WinEnableWindow(WinWindowFromID(hwnd,DID_CANCEL),FALSE);
2476 WinEnableWindow(WinWindowFromID(hwnd,COMP_COLLECT),FALSE);
2477 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBOTH),FALSE);
2478 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTONE),FALSE);
2479 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTNEWER),FALSE);
2480 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTOLDER),FALSE);
2481 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTBIGGER),FALSE);
2482 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSMALLER),FALSE);
2483 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBOTH),FALSE);
2484 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTONE),FALSE);
2485 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTNEWER),FALSE);
2486 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTOLDER),FALSE);
2487 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTBIGGER),FALSE);
2488 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTSMALLER),FALSE);
2489 WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTALL),FALSE);
2490 WinEnableWindow(WinWindowFromID(hwnd,COMP_INCLUDESUBDIRS),FALSE);
2491 WinEnableWindow(WinWindowFromID(hwnd,COMP_SETDIRS),FALSE);
2492 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETELEFT),FALSE);
2493 WinEnableWindow(WinWindowFromID(hwnd,COMP_DELETERIGHT),FALSE);
2494 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYLEFT),FALSE);
2495 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVELEFT),FALSE);
2496 WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),FALSE);
2497 WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),FALSE);
[316]2498 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),FALSE);
[2]2499 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),FALSE);
2500 WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),FALSE);
2501 WinEnableWindow(WinWindowFromID(hwnd,IDM_INVERT),FALSE);
2502 WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
2503 }
2504 else {
2505 DosBeep(250,100);
2506 free(forthread);
2507 }
2508 }
2509 else
2510 DosBeep(250,100);
2511 }
2512 break;
2513
2514 case COMP_COLLECT:
2515 cmp = INSTDATA(hwnd);
2516 if(cmp) {
2517
2518 CHAR **listl,**listr = NULL;
2519
2520 if(!Collector) {
2521
2522 SWP swp;
2523 HWND hwndC;
2524
2525 if(!fAutoTile && !ParentIsDesktop(hwnd,cmp->hwndParent) &&
2526 (!fExternalCollector && !strcmp(realappname,FM3Str)))
2527 GetNextWindowPos(cmp->hwndParent,&swp,NULL,NULL);
2528 hwndC = StartCollector((fExternalCollector ||
2529 strcmp(realappname,FM3Str)) ?
2530 HWND_DESKTOP :
2531 cmp->hwndParent,4);
2532 if(hwndC) {
2533 if(!fAutoTile && !ParentIsDesktop(hwnd,cmp->hwndParent) &&
2534 (!fExternalCollector && !strcmp(realappname,FM3Str)))
2535 WinSetWindowPos(hwndC,HWND_TOP,swp.x,swp.y,
2536 swp.cx,swp.cy,SWP_MOVE | SWP_SIZE |
2537 SWP_SHOW | SWP_ZORDER);
2538 else if(!ParentIsDesktop(hwnd,cmp->hwndParent) && fAutoTile &&
2539 !strcmp(realappname,FM3Str))
2540 TileChildren(cmp->hwndParent,TRUE);
2541 DosSleep(64L);
2542 PostMsg(hwnd,WM_COMMAND,MPFROM2SHORT(COMP_COLLECT,0),
2543 MPVOID);
2544 break;
2545 }
2546 }
2547 else
2548 StartCollector(cmp->hwndParent,4);
2549 {
2550 BOOL temp;
2551
2552 temp = fSelectedAlways;
2553 fSelectedAlways = TRUE;
2554 listl = BuildList(hwndLeft);
2555 if(!*cmp->rightlist)
2556 listr = BuildList(hwndRight);
2557 fSelectedAlways = temp;
2558 }
2559 if(listl || listr) {
2560 if(Collector) {
2561 if(listl) {
2562 if(!PostMsg(Collector,WM_COMMAND,
2563 MPFROM2SHORT(IDM_COLLECTOR,0),
2564 MPFROMP(listl)))
2565 FreeList(listl);
2566 }
2567 if(listr) {
2568 if(!PostMsg(Collector,WM_COMMAND,
2569 MPFROM2SHORT(IDM_COLLECTOR,0),
2570 MPFROMP(listr)))
2571 FreeList(listr);
2572 }
2573 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2574 QW_PARENT),QW_PARENT),HWND_TOP,
2575 0,0,0,0,SWP_ACTIVATE);
2576 }
2577 else {
2578 FreeList(listl);
2579 FreeList(listr);
2580 }
2581 }
2582 }
2583 break;
2584 }
2585 return 0;
2586
2587 case WM_CLOSE:
2588 WinDismissDlg(hwnd,0);
2589 return 0;
2590
2591 case WM_DESTROY:
2592 cmp = INSTDATA(hwnd);
2593 if(cmp) {
2594 if(cmp->dcd.hwndLastMenu)
2595 WinDestroyWindow(cmp->dcd.hwndLastMenu);
2596 if(cmp->dcd.hwndObject) {
2597 WinSetWindowPtr(cmp->dcd.hwndObject,0,(PVOID)NULL);
2598 if(!PostMsg(cmp->dcd.hwndObject,WM_CLOSE,MPVOID,MPVOID))
2599 WinSendMsg(cmp->dcd.hwndObject,WM_CLOSE,MPVOID,MPVOID);
2600 }
2601 free(cmp);
2602 }
2603 EmptyCnr(hwndLeft);
2604 EmptyCnr(hwndRight);
2605 DosPostEventSem(CompactSem);
2606 break;
2607 }
2608 return WinDefDlgProc(hwnd,msg,mp1,mp2);
2609}
Note: See TracBrowser for help on using the repository browser.