1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: dirsize.c 91 2004-05-21 15:16:05Z root $
|
---|
5 |
|
---|
6 | Directory sizes
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001, 2002 Steven H.Levine
|
---|
10 |
|
---|
11 | Revisions 16 Oct 02 SHL - Handle large partitions
|
---|
12 | 12 Feb 03 SHL - Use CBLIST_TO_EASIZE
|
---|
13 | 21 Nov 03 SHL - Avoid VAC \ after // bug (wierd)
|
---|
14 | 21 Nov 03 SHL - Correct minor typos
|
---|
15 | 21 Nov 03 SHL - Total drives >4GB better
|
---|
16 |
|
---|
17 | ***********************************************************************/
|
---|
18 |
|
---|
19 | #define INCL_DOS
|
---|
20 | #define INCL_WIN
|
---|
21 | #define INCL_GPI
|
---|
22 |
|
---|
23 | #include <os2.h>
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include <ctype.h>
|
---|
28 | #include "fm3dll.h"
|
---|
29 | #include "fm3dlg.h"
|
---|
30 | #include "fm3str.h"
|
---|
31 |
|
---|
32 | #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc)
|
---|
33 | #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr)
|
---|
34 |
|
---|
35 | typedef struct {
|
---|
36 | CHAR *pszFileName;
|
---|
37 | HWND hwndCnr;
|
---|
38 | CHAR *pchStopFlag;
|
---|
39 | DIRCNRDATA *pDCD;
|
---|
40 | } DIRSIZE;
|
---|
41 |
|
---|
42 | typedef struct {
|
---|
43 | CHAR dirname[CCHMAXPATH];
|
---|
44 | CHAR pchStopFlag;
|
---|
45 | BOOL dying;
|
---|
46 | BOOL working;
|
---|
47 | HPOINTER hptr;
|
---|
48 | } TEMP;
|
---|
49 |
|
---|
50 |
|
---|
51 | static SHORT APIENTRY SortSizeCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2,
|
---|
52 | PVOID SortFlags)
|
---|
53 | {
|
---|
54 | ULONG size1,size2;
|
---|
55 |
|
---|
56 | size1 = ((PCNRITEM)p1)->cbFile + ((PCNRITEM)p1)->easize;
|
---|
57 | size2 = ((PCNRITEM)p2)->cbFile + ((PCNRITEM)p2)->easize;
|
---|
58 | return (size1 < size2) ? 1 : (size1 == size2) ? 0 : -1;
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | static ULONG ProcessDir (HWND hwndCnr,CHAR *pszFileName,PCNRITEM pciParent,
|
---|
63 | CHAR *pchStopFlag,BOOL top, BOOL *pfIsKB)
|
---|
64 | {
|
---|
65 | CHAR maskstr[CCHMAXPATH];
|
---|
66 | CHAR *pEndMask;
|
---|
67 | register char *p;
|
---|
68 | register char *sp;
|
---|
69 | register char *pp;
|
---|
70 | ULONG nm;
|
---|
71 | ULONG ulCurDirKB = 0L;
|
---|
72 | ULONG ulCurDirBytes = 0L;
|
---|
73 | ULONG ulSubDirKB = 0L;
|
---|
74 | ULONG ulSubDirBytes = 0L;
|
---|
75 | ULONG ulTotal;
|
---|
76 | HDIR hdir;
|
---|
77 | FILEFINDBUF4 *pFFB;
|
---|
78 | APIRET rc;
|
---|
79 | RECORDINSERT ri;
|
---|
80 | PCNRITEM pCI;
|
---|
81 |
|
---|
82 | pFFB = malloc(sizeof(FILEFINDBUF4) /* * FilesToGet */);
|
---|
83 | if(!pFFB)
|
---|
84 | return -1L;
|
---|
85 | strcpy(maskstr,pszFileName);
|
---|
86 | if(maskstr[strlen(maskstr) - 1] != '\\')
|
---|
87 | strcat(maskstr,"\\");
|
---|
88 | pEndMask = &maskstr[strlen(maskstr)]; // Point after last backslash
|
---|
89 | strcat(maskstr,"*");
|
---|
90 | //printf("%s\n",maskstr);
|
---|
91 |
|
---|
92 | hdir = HDIR_CREATE;
|
---|
93 | nm = 1L;
|
---|
94 | memset(pFFB,0,sizeof(FILEFINDBUF4));
|
---|
95 | DosError(FERR_DISABLEHARDERR);
|
---|
96 | //printf("FIND1\n");
|
---|
97 | rc = DosFindFirst(pszFileName, &hdir,
|
---|
98 | FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
|
---|
99 | FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY,
|
---|
100 | pFFB, sizeof(FILEFINDBUF4),&nm, FIL_QUERYEASIZE);
|
---|
101 |
|
---|
102 | if(!rc)
|
---|
103 | DosFindClose(hdir);
|
---|
104 |
|
---|
105 | /*
|
---|
106 | * the "|| strlen(pszFileName) < 4 below works around an OS/2 bug
|
---|
107 | * that prevents FAT root directories from being found when
|
---|
108 | * requesting EASIZE. sheesh.
|
---|
109 | */
|
---|
110 | if((!rc && (pFFB->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4)
|
---|
111 | {
|
---|
112 | if(*pchStopFlag) {
|
---|
113 | free(pFFB);
|
---|
114 | return -1L;
|
---|
115 | }
|
---|
116 | //printf("CM_ALLOCRECORD\n");
|
---|
117 | pCI = WinSendMsg(hwndCnr,CM_ALLOCRECORD,MPFROMLONG(EXTRA_RECORD_BYTES2),
|
---|
118 | MPFROMLONG(1L));
|
---|
119 | if(!pCI) {
|
---|
120 | free(pFFB);
|
---|
121 | return -1L;
|
---|
122 | }
|
---|
123 | if(!rc) {
|
---|
124 | ulCurDirKB = pFFB->cbFile >> 10;
|
---|
125 | ulCurDirBytes = pFFB->cbFile & 0x3ff;
|
---|
126 | ulCurDirKB += CBLIST_TO_EASIZE(pFFB->cbList) >> 10;
|
---|
127 | ulCurDirBytes += CBLIST_TO_EASIZE(pFFB->cbList) & 0x3ff;
|
---|
128 | }
|
---|
129 | else
|
---|
130 | DosError(FERR_DISABLEHARDERR);
|
---|
131 | pCI->pszLongname = pCI->szFileName;
|
---|
132 | pCI->rc.hptrIcon = hptrDir;
|
---|
133 | *pCI->szDispAttr = *pCI->Longname = *pCI->subject = 0;
|
---|
134 | pCI->attrFile = 0L;
|
---|
135 | }
|
---|
136 | else
|
---|
137 | {
|
---|
138 | free(pFFB);
|
---|
139 | Dos_Error(MB_ENTER,
|
---|
140 | rc,
|
---|
141 | HWND_DESKTOP,
|
---|
142 | __FILE__,
|
---|
143 | __LINE__,
|
---|
144 | GetPString(IDS_CANTFINDDIRTEXT),
|
---|
145 | pszFileName);
|
---|
146 | return -1L;
|
---|
147 | }
|
---|
148 |
|
---|
149 | if(strlen(pszFileName) < 4 || top)
|
---|
150 | strcpy(pCI->szFileName,pszFileName);
|
---|
151 | else {
|
---|
152 | p = strrchr(pszFileName,'\\');
|
---|
153 | if(!p)
|
---|
154 | p = pszFileName;
|
---|
155 | else
|
---|
156 | p++;
|
---|
157 | sp = (strchr(pszFileName,' ') != NULL) ? "\"" : NullStr;
|
---|
158 | pp = pCI->szFileName;
|
---|
159 | if(*sp) {
|
---|
160 | *pp = *sp;
|
---|
161 | pp++;
|
---|
162 | *pp = 0;
|
---|
163 | }
|
---|
164 | strcpy(pp,p);
|
---|
165 | if(*sp)
|
---|
166 | strcat(pp,sp);
|
---|
167 | }
|
---|
168 | pCI->pszFileName = pCI->szFileName + strlen(pCI->szFileName);
|
---|
169 | pCI->rc.pszIcon = pCI->pszLongname;
|
---|
170 | pCI->rc.flRecordAttr |= CRA_RECORDREADONLY;
|
---|
171 | if(fForceUpper)
|
---|
172 | strupr(pCI->szFileName);
|
---|
173 | else if(fForceLower)
|
---|
174 | strlwr(pCI->szFileName);
|
---|
175 | memset(&ri,0,sizeof(RECORDINSERT));
|
---|
176 | ri.cb = sizeof(RECORDINSERT);
|
---|
177 | ri.pRecordOrder = (PRECORDCORE)CMA_END;
|
---|
178 | ri.pRecordParent = (PRECORDCORE)pciParent;
|
---|
179 | ri.zOrder = (USHORT)CMA_TOP;
|
---|
180 | ri.cRecordsInsert = 1L;
|
---|
181 | ri.fInvalidateRecord = TRUE;
|
---|
182 | //printf("CM_INSERTRECORD\n");
|
---|
183 | if(!WinSendMsg(hwndCnr,CM_INSERTRECORD,MPFROMP(pCI),MPFROMP(&ri))) {
|
---|
184 | //printf("Insert failed\n");
|
---|
185 | free(pFFB);
|
---|
186 | return -1L;
|
---|
187 | }
|
---|
188 | hdir = HDIR_CREATE;
|
---|
189 | nm = 1L;
|
---|
190 | //printf("FIND2\n");
|
---|
191 | rc = DosFindFirst(maskstr,&hdir,
|
---|
192 | FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
|
---|
193 | FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY,
|
---|
194 | pFFB,
|
---|
195 | sizeof(FILEFINDBUF4),
|
---|
196 | &nm,
|
---|
197 | FIL_QUERYEASIZE);
|
---|
198 | if(!rc)
|
---|
199 | {
|
---|
200 | register PBYTE fb = (PBYTE)pFFB;
|
---|
201 | FILEFINDBUF4 *pffbFile;
|
---|
202 | ULONG x;
|
---|
203 |
|
---|
204 | while(!rc)
|
---|
205 | {
|
---|
206 | priority_normal();
|
---|
207 | //printf("Found %lu\n",nm);
|
---|
208 | for(x = 0L;x < nm;x++)
|
---|
209 | {
|
---|
210 | pffbFile = (FILEFINDBUF4 *)fb;
|
---|
211 | //printf("%s\n",pffbFile->achName);
|
---|
212 | //fflush(stdout);
|
---|
213 | // Total size skipping . and ..
|
---|
214 | if((*pffbFile->achName != '.' ||
|
---|
215 | (pffbFile->achName[1] && pffbFile->achName[1] != '.')) ||
|
---|
216 | !(pffbFile->attrFile & FILE_DIRECTORY))
|
---|
217 | {
|
---|
218 | ulCurDirKB += pffbFile->cbFile >> 10;
|
---|
219 | ulCurDirBytes += pffbFile->cbFile & 0x3ff;
|
---|
220 | ulCurDirKB += CBLIST_TO_EASIZE(pffbFile->cbList) >> 10;
|
---|
221 | ulCurDirBytes += CBLIST_TO_EASIZE(pffbFile->cbList) & 0x3ff;
|
---|
222 |
|
---|
223 | if(!(pffbFile->attrFile & FILE_DIRECTORY))
|
---|
224 | pCI->attrFile++; // Bump file count
|
---|
225 | if(*pchStopFlag)
|
---|
226 | break;
|
---|
227 | if(pffbFile->attrFile & FILE_DIRECTORY) {
|
---|
228 | // Recurse into subdir
|
---|
229 | strcpy(pEndMask,pffbFile->achName); // Append dirname to base dirname
|
---|
230 | if(!*pchStopFlag)
|
---|
231 | {
|
---|
232 | BOOL fIsKB;
|
---|
233 | ulTotal = ProcessDir(hwndCnr,maskstr,pCI,pchStopFlag,FALSE, &fIsKB);
|
---|
234 | if(ulTotal != (ULONG)-1L) {
|
---|
235 | if (fIsKB)
|
---|
236 | ulSubDirKB += ulTotal;
|
---|
237 | else {
|
---|
238 | ulSubDirKB += (ulTotal >> 10);
|
---|
239 | // Assume we can delay propagating to KB
|
---|
240 | ulSubDirBytes += (ulTotal & 0x3ff);
|
---|
241 | }
|
---|
242 | }
|
---|
243 | }
|
---|
244 | }
|
---|
245 | }
|
---|
246 | if(!pffbFile->oNextEntryOffset)
|
---|
247 | break;
|
---|
248 | fb += pffbFile->oNextEntryOffset;
|
---|
249 | } // for matches
|
---|
250 | if(*pchStopFlag)
|
---|
251 | break;
|
---|
252 | DosSleep(0L);
|
---|
253 | nm = 1L; /* FilesToGet */
|
---|
254 | rc = DosFindNext(hdir,pFFB,sizeof(FILEFINDBUF4) ,&nm);
|
---|
255 | } // while more found
|
---|
256 | DosFindClose(hdir);
|
---|
257 | priority_normal();
|
---|
258 | }
|
---|
259 |
|
---|
260 | free(pFFB);
|
---|
261 |
|
---|
262 | // Propage carry
|
---|
263 | ulCurDirKB += ulCurDirBytes >> 10;
|
---|
264 | ulCurDirBytes &= 0x3ff;
|
---|
265 | if (ulCurDirBytes)
|
---|
266 | ulCurDirKB++;
|
---|
267 |
|
---|
268 | ulSubDirKB += ulSubDirBytes >> 10;
|
---|
269 | ulSubDirBytes &= 0x3ff;
|
---|
270 | if (ulSubDirBytes)
|
---|
271 | ulSubDirKB++;
|
---|
272 |
|
---|
273 | pCI->cbFile = ulCurDirKB;
|
---|
274 | pCI->easize = ulSubDirKB;
|
---|
275 | WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPFROMP(&pCI),
|
---|
276 | MPFROM2SHORT(1,CMA_ERASE | CMA_TEXTCHANGED));
|
---|
277 |
|
---|
278 | ulTotal = ulCurDirKB + ulSubDirKB
|
---|
279 | + (ulCurDirBytes >> 10) + (ulSubDirBytes >> 10);
|
---|
280 | if (ulTotal >= 1L << 21) {
|
---|
281 | *pfIsKB = TRUE;
|
---|
282 | }
|
---|
283 | else {
|
---|
284 | *pfIsKB = FALSE;
|
---|
285 | ulTotal = (ulCurDirKB << 10) + (ulSubDirKB << 10)
|
---|
286 | + ulCurDirBytes + ulSubDirBytes;
|
---|
287 | }
|
---|
288 |
|
---|
289 | return ulTotal;
|
---|
290 | }
|
---|
291 |
|
---|
292 |
|
---|
293 | static VOID FillInRecSizes (HWND hwndCnr,PCNRITEM pciParent,ULONG ulTotalKB,
|
---|
294 | CHAR *pchStopFlag,BOOL isroot)
|
---|
295 | {
|
---|
296 | PCNRITEM pCI = pciParent;
|
---|
297 | SHORT attrib = CMA_FIRSTCHILD;
|
---|
298 |
|
---|
299 | if(pCI) {
|
---|
300 |
|
---|
301 | float fltPct = 0.0;
|
---|
302 | CHAR szCurDirKB[80];
|
---|
303 | CHAR szSubDirKB[80];
|
---|
304 | CHAR szAllDirKB[80];
|
---|
305 | CHAR szBar[80];
|
---|
306 |
|
---|
307 | // cbFile = currect directory usage in KB
|
---|
308 | // easize = subdirectory usage in KB
|
---|
309 | commafmt(szCurDirKB,sizeof(szCurDirKB),pCI->cbFile);
|
---|
310 | *szBar = 0;
|
---|
311 |
|
---|
312 | if(ulTotalKB) {
|
---|
313 |
|
---|
314 | register UINT cBar;
|
---|
315 |
|
---|
316 | if(isroot) {
|
---|
317 |
|
---|
318 | FSALLOCATE fsa;
|
---|
319 | APIRET rc;
|
---|
320 |
|
---|
321 | memset(&fsa,0,sizeof(fsa));
|
---|
322 | rc = DosQueryFSInfo(toupper(*pCI->szFileName) - '@',FSIL_ALLOC,&fsa,
|
---|
323 | sizeof(FSALLOCATE));
|
---|
324 | if(!rc)
|
---|
325 | {
|
---|
326 | fltPct = (ulTotalKB * 100.0) /
|
---|
327 | ((float)fsa.cUnit * (fsa.cSectorUnit * fsa.cbSector) / 1024);
|
---|
328 | }
|
---|
329 | pCI->Longname[1] = 1; // Flag root
|
---|
330 | }
|
---|
331 | else
|
---|
332 | fltPct = (((float)pCI->cbFile + pCI->easize) * 100.0) / ulTotalKB;
|
---|
333 |
|
---|
334 | cBar = (UINT)fltPct / 2;
|
---|
335 | if (cBar)
|
---|
336 | memset(szBar, '#', cBar);
|
---|
337 | if(cBar * 2 != (UINT)fltPct) {
|
---|
338 | szBar[cBar] = '=';
|
---|
339 | cBar++;
|
---|
340 | }
|
---|
341 | if (cBar < 50)
|
---|
342 | memset(szBar + cBar, ' ', 50 - cBar);
|
---|
343 | szBar[50] = 0;
|
---|
344 | }
|
---|
345 |
|
---|
346 | pCI->flags = (ULONG)fltPct;
|
---|
347 | commafmt(szSubDirKB,sizeof(szSubDirKB),pCI->easize);
|
---|
348 | commafmt(szAllDirKB,sizeof(szAllDirKB),pCI->cbFile + pCI->easize);
|
---|
349 | sprintf(&pCI->szFileName[strlen(pCI->szFileName)],
|
---|
350 | " %sk + %sk = %sk (%.02lf%%%s)\r%s",
|
---|
351 | szCurDirKB,
|
---|
352 | szSubDirKB,
|
---|
353 | szAllDirKB,
|
---|
354 | fltPct,
|
---|
355 | (isroot) ? GetPString(IDS_OFDRIVETEXT) : NullStr,
|
---|
356 | szBar);
|
---|
357 | WinSendMsg(hwndCnr,
|
---|
358 | CM_INVALIDATERECORD,
|
---|
359 | MPFROMP(&pCI),
|
---|
360 | MPFROM2SHORT(1,0));
|
---|
361 | isroot = FALSE;
|
---|
362 | }
|
---|
363 | else
|
---|
364 | attrib = CMA_FIRST;
|
---|
365 | pCI = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pCI),
|
---|
366 | MPFROM2SHORT(attrib,CMA_ITEMORDER));
|
---|
367 | while(pCI && (INT)pCI != -1) {
|
---|
368 | if(*pchStopFlag)
|
---|
369 | break;
|
---|
370 | FillInRecSizes(hwndCnr,pCI,ulTotalKB,pchStopFlag,isroot);
|
---|
371 | isroot = FALSE;
|
---|
372 | pCI = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pCI),
|
---|
373 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
374 | }
|
---|
375 | }
|
---|
376 |
|
---|
377 |
|
---|
378 | static VOID PrintToFile (HWND hwndCnr,ULONG indent,PCNRITEM pciParent,
|
---|
379 | FILE *fp)
|
---|
380 | {
|
---|
381 | PCNRITEM pci;
|
---|
382 | register CHAR *p;
|
---|
383 |
|
---|
384 | if(!pciParent) {
|
---|
385 | pciParent = WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(NULL),
|
---|
386 | MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
|
---|
387 | indent = 0;
|
---|
388 | }
|
---|
389 | if(pciParent) {
|
---|
390 | p = strchr(pciParent->szFileName,'\r');
|
---|
391 | if(p)
|
---|
392 | *p = 0;
|
---|
393 | fprintf(fp,"%*.*s%s %lu %s%s\n",
|
---|
394 | indent * 2,indent * 2," ",
|
---|
395 | pciParent->szFileName,
|
---|
396 | pciParent->attrFile,
|
---|
397 | GetPString(IDS_FILETEXT),
|
---|
398 | &"s"[pciParent->attrFile == 1]);
|
---|
399 | if(p)
|
---|
400 | *p = '\r';
|
---|
401 | if(pciParent->rc.flRecordAttr & CRA_EXPANDED) {
|
---|
402 | pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pciParent),
|
---|
403 | MPFROM2SHORT(CMA_FIRSTCHILD,CMA_ITEMORDER));
|
---|
404 | while(pci && (INT)pci != -1) {
|
---|
405 | DosSleep(0L);
|
---|
406 | PrintToFile(hwndCnr,indent + 1,pci,fp);
|
---|
407 | pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pci),
|
---|
408 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
409 | }
|
---|
410 | }
|
---|
411 | }
|
---|
412 | }
|
---|
413 |
|
---|
414 |
|
---|
415 | static VOID FillCnrThread (VOID *args)
|
---|
416 | {
|
---|
417 | HAB hab;
|
---|
418 | HMQ hmq;
|
---|
419 | DIRSIZE *dirsize = (DIRSIZE *)args;
|
---|
420 | HWND hwndCnr;
|
---|
421 | ULONG ulTotal;
|
---|
422 |
|
---|
423 | if(!dirsize)
|
---|
424 | return;
|
---|
425 | hwndCnr = dirsize->hwndCnr;
|
---|
426 |
|
---|
427 | DosError(FERR_DISABLEHARDERR);
|
---|
428 |
|
---|
429 | // priority_normal();
|
---|
430 | hab = WinInitialize(0);
|
---|
431 | if(hab) {
|
---|
432 | hmq = WinCreateMsgQueue(hab,0);
|
---|
433 | if(hmq) {
|
---|
434 | BOOL fIsKB;
|
---|
435 | WinCancelShutdown(hmq,TRUE);
|
---|
436 | ulTotal = ProcessDir(hwndCnr,dirsize->pszFileName,
|
---|
437 | (PCNRITEM)NULL,dirsize->pchStopFlag,TRUE, &fIsKB);
|
---|
438 | DosPostEventSem(CompactSem);
|
---|
439 | WinEnableWindowUpdate(hwndCnr,FALSE);
|
---|
440 | if (!fIsKB)
|
---|
441 | ulTotal = (ulTotal >> 10) + (ulTotal & 0x3ff ? 1 : 0);
|
---|
442 | FillInRecSizes(hwndCnr,NULL,ulTotal,dirsize->pchStopFlag,TRUE);
|
---|
443 | WinEnableWindowUpdate(hwndCnr,TRUE);
|
---|
444 | WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
|
---|
445 | MPFROM2SHORT(0,CMA_ERASE | CMA_TEXTCHANGED));
|
---|
446 | WinDestroyMsgQueue(hmq);
|
---|
447 | }
|
---|
448 | WinTerminate(hab);
|
---|
449 | }
|
---|
450 | PostMsg(WinQueryWindow(hwndCnr,QW_PARENT),
|
---|
451 | UM_CONTAINER_FILLED,
|
---|
452 | MPVOID,MPVOID);
|
---|
453 | free(dirsize);
|
---|
454 | }
|
---|
455 |
|
---|
456 |
|
---|
457 | MRESULT EXPENTRY DirSizeProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
|
---|
458 | {
|
---|
459 | TEMP *pTemp;
|
---|
460 |
|
---|
461 | switch(msg) {
|
---|
462 | case WM_INITDLG:
|
---|
463 | if(!mp2) {
|
---|
464 | WinDismissDlg(hwnd,0);
|
---|
465 | break;
|
---|
466 | }
|
---|
467 | pTemp = malloc(sizeof(TEMP));
|
---|
468 | if(!pTemp) {
|
---|
469 | WinDismissDlg(hwnd,0);
|
---|
470 | break;
|
---|
471 | }
|
---|
472 | memset(pTemp,0,sizeof(TEMP));
|
---|
473 | strcpy(pTemp->dirname,(CHAR *)mp2);
|
---|
474 | WinSetWindowPtr(hwnd,0,(PVOID)pTemp);
|
---|
475 | pTemp->hptr = WinLoadPointer(HWND_DESKTOP,FM3ModHandle,DIRSIZE_ICON);
|
---|
476 | WinDefDlgProc(hwnd,WM_SETICON,MPFROMLONG(pTemp->hptr),MPVOID);
|
---|
477 | {
|
---|
478 | CHAR s[CCHMAXPATH + 81];
|
---|
479 |
|
---|
480 | sprintf(s,
|
---|
481 | GetPString(IDS_DIRSIZETITLETEXT),
|
---|
482 | pTemp->dirname);
|
---|
483 | WinSetWindowText(hwnd,s);
|
---|
484 | }
|
---|
485 | {
|
---|
486 | DIRSIZE *dirsize;
|
---|
487 |
|
---|
488 | dirsize = malloc(sizeof(DIRSIZE));
|
---|
489 | if(!dirsize) {
|
---|
490 | WinDismissDlg(hwnd,0);
|
---|
491 | break;
|
---|
492 | }
|
---|
493 | dirsize->pchStopFlag = (CHAR *)&pTemp->pchStopFlag;
|
---|
494 | dirsize->pszFileName = pTemp->dirname;
|
---|
495 | dirsize->hwndCnr = WinWindowFromID(hwnd,DSZ_CNR);
|
---|
496 | if(_beginthread(FillCnrThread,NULL,122880L * 5L,(PVOID)dirsize) == -1) {
|
---|
497 | free(dirsize);
|
---|
498 | WinDismissDlg(hwnd,0);
|
---|
499 | break;
|
---|
500 | }
|
---|
501 | pTemp->working = TRUE;
|
---|
502 | }
|
---|
503 | PostMsg(hwnd,UM_SETUP,MPVOID,MPVOID);
|
---|
504 | break;
|
---|
505 |
|
---|
506 | case UM_SETUP:
|
---|
507 | {
|
---|
508 | CNRINFO cnri;
|
---|
509 | FSALLOCATE fsa;
|
---|
510 | APIRET rc;
|
---|
511 |
|
---|
512 | memset(&cnri,0,sizeof(CNRINFO));
|
---|
513 | cnri.cb = sizeof(CNRINFO);
|
---|
514 | WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYCNRINFO,
|
---|
515 | MPFROMP(&cnri),MPFROMLONG(sizeof(CNRINFO)));
|
---|
516 | cnri.cyLineSpacing = 0;
|
---|
517 | cnri.cxTreeIndent = 12L;
|
---|
518 | cnri.flWindowAttr = CV_TREE | CV_FLOW | CA_TREELINE | CA_OWNERDRAW;
|
---|
519 | WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_SETCNRINFO,MPFROMP(&cnri),
|
---|
520 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
|
---|
521 | CMA_LINESPACING | CMA_CXTREEINDENT));
|
---|
522 | pTemp = INSTDATA(hwnd);
|
---|
523 | if(pTemp && isalpha(*pTemp->dirname)) {
|
---|
524 | memset(&fsa,0,sizeof(fsa));
|
---|
525 | rc = DosQueryFSInfo(toupper(*pTemp->dirname) - '@',FSIL_ALLOC,&fsa,
|
---|
526 | sizeof(FSALLOCATE));
|
---|
527 | if(!rc) {
|
---|
528 |
|
---|
529 | CHAR s[132],tf[80],tb[80],tu[80];
|
---|
530 |
|
---|
531 | commafmt(tf,sizeof(tf),
|
---|
532 | (ULONG)(((float)fsa.cUnitAvail *
|
---|
533 | (fsa.cSectorUnit * fsa.cbSector)) / 1024L));
|
---|
534 | commafmt(tb,sizeof(tb),
|
---|
535 | (ULONG)(((float)fsa.cUnit *
|
---|
536 | (fsa.cSectorUnit * fsa.cbSector)) / 1024L));
|
---|
537 | commafmt(tu,sizeof(tu),
|
---|
538 | (ULONG)(((float)(fsa.cUnit - fsa.cUnitAvail) *
|
---|
539 | (fsa.cSectorUnit * fsa.cbSector)) / 1024L));
|
---|
540 | sprintf(s,
|
---|
541 | GetPString(IDS_FREESPACETEXT),
|
---|
542 | tf,
|
---|
543 | tb,
|
---|
544 | tu);
|
---|
545 | WinSetDlgItemText(hwnd,
|
---|
546 | DSZ_FREESPACE,
|
---|
547 | s);
|
---|
548 | }
|
---|
549 | else
|
---|
550 | WinSetDlgItemText(hwnd,
|
---|
551 | DSZ_FREESPACE,
|
---|
552 | GetPString(IDS_FREESPACEUTEXT));
|
---|
553 | }
|
---|
554 | }
|
---|
555 | return 0;
|
---|
556 |
|
---|
557 | case UM_CONTAINER_FILLED:
|
---|
558 | pTemp = INSTDATA(hwnd);
|
---|
559 | if(!pTemp || pTemp->dying) {
|
---|
560 | if (pTemp)
|
---|
561 | pTemp->working = FALSE;
|
---|
562 | WinDismissDlg(hwnd,0);
|
---|
563 | return 0;
|
---|
564 | }
|
---|
565 | pTemp->working = FALSE;
|
---|
566 | {
|
---|
567 | CHAR tb[44],s[66];
|
---|
568 | PCNRITEM pci;
|
---|
569 |
|
---|
570 | pci = WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYRECORD,MPVOID,
|
---|
571 | MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
|
---|
572 | if(pci && (INT)pci != -1)
|
---|
573 | WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_EXPANDTREE,MPFROMP(pci),MPVOID);
|
---|
574 | *s = 0;
|
---|
575 | pci = WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYRECORDEMPHASIS,
|
---|
576 | MPFROMLONG(CMA_FIRST),
|
---|
577 | MPFROMSHORT(CRA_CURSORED));
|
---|
578 | if(pci && (INT)pci != -1) {
|
---|
579 | commafmt(tb,sizeof(tb),pci->attrFile);
|
---|
580 | sprintf(s,
|
---|
581 | "%s %s%s",
|
---|
582 | tb,
|
---|
583 | GetPString(IDS_FILETEXT),
|
---|
584 | &"s"[pci->attrFile == 1]);
|
---|
585 | }
|
---|
586 | WinSetDlgItemText(hwnd,DSZ_NUMFILES,s);
|
---|
587 | }
|
---|
588 | WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_SORTRECORD,MPFROMP(SortSizeCnr),
|
---|
589 | MPVOID);
|
---|
590 | DosBeep(500,25);
|
---|
591 | return 0;
|
---|
592 |
|
---|
593 | case WM_ADJUSTWINDOWPOS:
|
---|
594 | PostMsg(hwnd,UM_STRETCH,MPVOID,MPVOID);
|
---|
595 | break;
|
---|
596 |
|
---|
597 | case UM_STRETCH:
|
---|
598 | {
|
---|
599 | SWP swpC,swp;
|
---|
600 |
|
---|
601 | WinQueryWindowPos(hwnd,&swp);
|
---|
602 | if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
|
---|
603 | WinQueryWindowPos(WinWindowFromID(hwnd,DSZ_CNR),&swpC);
|
---|
604 | WinSetWindowPos(WinWindowFromID(hwnd,DSZ_CNR),HWND_TOP,
|
---|
605 | SysVal(SV_CXSIZEBORDER),
|
---|
606 | swpC.y,
|
---|
607 | swp.cx - (SysVal(SV_CXSIZEBORDER) * 2),
|
---|
608 | (swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) +
|
---|
609 | SysVal(SV_CYSIZEBORDER)),
|
---|
610 | SWP_MOVE | SWP_SIZE);
|
---|
611 | }
|
---|
612 | }
|
---|
613 | return 0;
|
---|
614 |
|
---|
615 | case WM_DRAWITEM:
|
---|
616 | if(mp2) {
|
---|
617 |
|
---|
618 | OWNERITEM *oi = mp2;
|
---|
619 | CNRDRAWITEMINFO *cnd;
|
---|
620 | PCNRITEM pci;
|
---|
621 |
|
---|
622 | if(oi->idItem == CMA_TEXT) {
|
---|
623 | cnd = (CNRDRAWITEMINFO *)oi->hItem;
|
---|
624 | if(cnd) {
|
---|
625 | pci = (PCNRITEM)cnd->pRecord;
|
---|
626 | if(pci) {
|
---|
627 |
|
---|
628 | POINTL aptl[TXTBOX_COUNT],ptl;
|
---|
629 | CHAR *p;
|
---|
630 | LONG clr,x;
|
---|
631 |
|
---|
632 | p = strchr(pci->szFileName,'\r');
|
---|
633 | if(p) {
|
---|
634 | /* draw text */
|
---|
635 | if(!pci->cbFile) /* no size */
|
---|
636 | GpiSetColor(oi->hps,CLR_DARKGRAY);
|
---|
637 | else if(!pci->easize) /* no size below */
|
---|
638 | GpiSetColor(oi->hps,CLR_DARKBLUE);
|
---|
639 | else
|
---|
640 | GpiSetColor(oi->hps,CLR_BLACK);
|
---|
641 | GpiSetBackMix(oi->hps,BM_LEAVEALONE);
|
---|
642 | GpiSetMix(oi->hps,FM_OVERPAINT);
|
---|
643 | *p = 0;
|
---|
644 | GpiQueryTextBox(oi->hps,strlen(pci->szFileName),
|
---|
645 | pci->szFileName,TXTBOX_COUNT,aptl);
|
---|
646 | ptl.x = oi->rclItem.xLeft;
|
---|
647 | ptl.y = (oi->rclItem.yTop - aptl[TXTBOX_TOPRIGHT].y);
|
---|
648 | GpiMove(oi->hps,&ptl);
|
---|
649 | GpiCharString(oi->hps,strlen(pci->szFileName),
|
---|
650 | pci->szFileName);
|
---|
651 | *p = '\r';
|
---|
652 |
|
---|
653 | /* draw the graph box */
|
---|
654 | GpiQueryTextBox(oi->hps,1,"#",TXTBOX_COUNT,aptl);
|
---|
655 | /* draw black outline */
|
---|
656 | GpiSetColor(oi->hps,CLR_BLACK);
|
---|
657 | ptl.x = oi->rclItem.xLeft;
|
---|
658 | ptl.y = oi->rclItem.yBottom + 2;
|
---|
659 | GpiMove(oi->hps,&ptl);
|
---|
660 | ptl.x = oi->rclItem.xLeft + 101;
|
---|
661 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y);
|
---|
662 | GpiBox(oi->hps,DRO_OUTLINE,&ptl,0,0);
|
---|
663 | /* fill with gray */
|
---|
664 | GpiSetColor(oi->hps,CLR_PALEGRAY);
|
---|
665 | ptl.x = oi->rclItem.xLeft + 1;
|
---|
666 | ptl.y = oi->rclItem.yBottom + 3;
|
---|
667 | GpiMove(oi->hps,&ptl);
|
---|
668 | ptl.x = oi->rclItem.xLeft + 100;
|
---|
669 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1;
|
---|
670 | GpiBox(oi->hps,DRO_OUTLINEFILL,&ptl,0,0);
|
---|
671 |
|
---|
672 | /* draw shadow at bottom & right sides */
|
---|
673 | GpiSetColor(oi->hps,CLR_DARKGRAY);
|
---|
674 | ptl.x = oi->rclItem.xLeft + 1;
|
---|
675 | ptl.y = oi->rclItem.yBottom + 3;
|
---|
676 | GpiMove(oi->hps,&ptl);
|
---|
677 | ptl.x = oi->rclItem.xLeft + 100;
|
---|
678 | GpiLine(oi->hps,&ptl);
|
---|
679 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1;
|
---|
680 | GpiLine(oi->hps,&ptl);
|
---|
681 |
|
---|
682 | /* draw highlight at top and left sides */
|
---|
683 | GpiSetColor(oi->hps,CLR_WHITE);
|
---|
684 | ptl.x = oi->rclItem.xLeft + 1;
|
---|
685 | GpiLine(oi->hps,&ptl);
|
---|
686 | ptl.y = oi->rclItem.yBottom + 3;
|
---|
687 | GpiLine(oi->hps,&ptl);
|
---|
688 |
|
---|
689 | /* draw shadow of box */
|
---|
690 | GpiSetColor(oi->hps,CLR_DARKGRAY);
|
---|
691 | ptl.x = oi->rclItem.xLeft + 2;
|
---|
692 | ptl.y = oi->rclItem.yBottom;
|
---|
693 | GpiMove(oi->hps,&ptl);
|
---|
694 | ptl.x = oi->rclItem.xLeft + 103;
|
---|
695 | GpiLine(oi->hps,&ptl);
|
---|
696 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 2;
|
---|
697 | GpiLine(oi->hps,&ptl);
|
---|
698 | ptl.x--;
|
---|
699 | GpiMove(oi->hps,&ptl);
|
---|
700 | ptl.y = oi->rclItem.yBottom + 1;
|
---|
701 | GpiLine(oi->hps,&ptl);
|
---|
702 | ptl.x = oi->rclItem.xLeft + 2;
|
---|
703 | GpiLine(oi->hps,&ptl);
|
---|
704 |
|
---|
705 | /* fill box with graph bar, flags is integer % */
|
---|
706 | if(pci->flags) {
|
---|
707 | if(pci->Longname[1] == 1) /* is root record */
|
---|
708 | GpiSetColor(oi->hps,CLR_DARKGREEN);
|
---|
709 | else
|
---|
710 | GpiSetColor(oi->hps,CLR_RED);
|
---|
711 | ptl.x = oi->rclItem.xLeft + 1;
|
---|
712 | ptl.y = oi->rclItem.yBottom + 3;
|
---|
713 | GpiMove(oi->hps,&ptl);
|
---|
714 | ptl.x = oi->rclItem.xLeft + pci->flags;
|
---|
715 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1;
|
---|
716 | GpiBox(oi->hps,DRO_OUTLINEFILL,&ptl,0,0);
|
---|
717 |
|
---|
718 | /* draw highlights and shadows on graph */
|
---|
719 | if(pci->Longname[1] == 1)
|
---|
720 | GpiSetColor(oi->hps,CLR_GREEN);
|
---|
721 | else
|
---|
722 | GpiSetColor(oi->hps,CLR_PALEGRAY);
|
---|
723 | if(pci->flags > 5) {
|
---|
724 | ptl.x = oi->rclItem.xLeft + 1;
|
---|
725 | ptl.y = oi->rclItem.yBottom + 3;
|
---|
726 | GpiMove(oi->hps,&ptl);
|
---|
727 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1;
|
---|
728 | GpiLine(oi->hps,&ptl);
|
---|
729 | }
|
---|
730 | else {
|
---|
731 | ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1;
|
---|
732 | GpiMove(oi->hps,&ptl);
|
---|
733 | }
|
---|
734 | ptl.x = oi->rclItem.xLeft + pci->flags;
|
---|
735 | GpiLine(oi->hps,&ptl);
|
---|
736 | if(pci->Longname[1] != 1) {
|
---|
737 | GpiSetColor(oi->hps,CLR_DARKRED);
|
---|
738 | ptl.x = oi->rclItem.xLeft + 2;
|
---|
739 | ptl.y = oi->rclItem.yBottom + 3;
|
---|
740 | GpiMove(oi->hps,&ptl);
|
---|
741 | ptl.x = oi->rclItem.xLeft + pci->flags;
|
---|
742 | GpiLine(oi->hps,&ptl);
|
---|
743 | }
|
---|
744 | }
|
---|
745 |
|
---|
746 | /* draw hash marks in box */
|
---|
747 | GpiSetColor(oi->hps,CLR_WHITE);
|
---|
748 | clr = CLR_WHITE;
|
---|
749 | for(x = 1;x < 10;x++) {
|
---|
750 | if(clr == CLR_WHITE && x * 10 > pci->flags) {
|
---|
751 | clr = CLR_BLACK;
|
---|
752 | GpiSetColor(oi->hps,CLR_BLACK);
|
---|
753 | }
|
---|
754 | ptl.x = (oi->rclItem.xLeft + 1) + (x * 10);
|
---|
755 | ptl.y = oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y - 1;
|
---|
756 | GpiMove(oi->hps,&ptl);
|
---|
757 | switch(x) {
|
---|
758 | case 1:
|
---|
759 | case 3:
|
---|
760 | case 7:
|
---|
761 | case 9:
|
---|
762 | ptl.y -= 1;
|
---|
763 | break;
|
---|
764 | case 5:
|
---|
765 | ptl.y -= 4;
|
---|
766 | break;
|
---|
767 | case 2:
|
---|
768 | case 4:
|
---|
769 | case 6:
|
---|
770 | case 8:
|
---|
771 | ptl.y -= 2;
|
---|
772 | break;
|
---|
773 | }
|
---|
774 | GpiLine(oi->hps,&ptl);
|
---|
775 | }
|
---|
776 | return MRFROMLONG(TRUE);
|
---|
777 | }
|
---|
778 | }
|
---|
779 | }
|
---|
780 | }
|
---|
781 | }
|
---|
782 | return FALSE;
|
---|
783 |
|
---|
784 | case WM_CONTROL:
|
---|
785 | switch(SHORT2FROMMP(mp1)) {
|
---|
786 | case CN_ENTER:
|
---|
787 | if(mp2) {
|
---|
788 |
|
---|
789 | PCNRITEM pci = (PCNRITEM)((PNOTIFYRECORDENTER)mp2)->pRecord;
|
---|
790 | CHAR pszFileName[CCHMAXPATH],szTemp[CCHMAXPATH];
|
---|
791 |
|
---|
792 | if(pci) {
|
---|
793 | *pszFileName = 0;
|
---|
794 | while(pci && (INT)pci != -1) {
|
---|
795 | memset(szTemp,0,sizeof(szTemp));
|
---|
796 | strncpy(szTemp,pci->szFileName,
|
---|
797 | pci->pszFileName - pci->szFileName);
|
---|
798 | strrev(szTemp);
|
---|
799 | if(*pszFileName && *szTemp != '\\')
|
---|
800 | strcat(pszFileName,"\\");
|
---|
801 | strcat(pszFileName,szTemp);
|
---|
802 | pci = WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYRECORD,
|
---|
803 | MPFROMP(pci),
|
---|
804 | MPFROM2SHORT(CMA_PARENT,
|
---|
805 | CMA_ITEMORDER));
|
---|
806 | }
|
---|
807 | strrev(pszFileName);
|
---|
808 | if(!fVTreeOpensWPS)
|
---|
809 | OpenDirCnr((HWND)0,
|
---|
810 | (hwndMain) ? hwndMain : HWND_DESKTOP,
|
---|
811 | hwnd,
|
---|
812 | FALSE,
|
---|
813 | pszFileName);
|
---|
814 | else {
|
---|
815 |
|
---|
816 | ULONG size = sizeof(ULONG),flWindowAttr = CV_ICON;
|
---|
817 | CHAR s[33];
|
---|
818 |
|
---|
819 | strcpy(s,"ICON");
|
---|
820 | PrfQueryProfileData(fmprof,appname,"DirflWindowAttr",
|
---|
821 | (PVOID)&flWindowAttr,&size);
|
---|
822 | if(flWindowAttr & CV_DETAIL) {
|
---|
823 | if(IsRoot(pszFileName))
|
---|
824 | strcpy(s,"TREE");
|
---|
825 | else
|
---|
826 | strcpy(s,"DETAILS");
|
---|
827 | }
|
---|
828 | OpenObject(pszFileName,s,hwnd);
|
---|
829 | }
|
---|
830 | }
|
---|
831 | }
|
---|
832 | break;
|
---|
833 | case CN_EMPHASIS:
|
---|
834 | pTemp = INSTDATA(hwnd);
|
---|
835 | if(pTemp && !pTemp->working && mp2) {
|
---|
836 |
|
---|
837 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
---|
838 | PCNRITEM pci;
|
---|
839 | CHAR tb[44],s[66];
|
---|
840 |
|
---|
841 | pci = (PCNRITEM)((pre) ? pre->pRecord : NULL);
|
---|
842 | if(pci && (pre->fEmphasisMask & CRA_SELECTED) &&
|
---|
843 | (pci->rc.flRecordAttr & CRA_SELECTED)) {
|
---|
844 | commafmt(tb,sizeof(tb),pci->attrFile);
|
---|
845 | sprintf(s,
|
---|
846 | "%s %s%s",
|
---|
847 | tb,
|
---|
848 | GetPString(IDS_FILETEXT),
|
---|
849 | &"s"[pci->attrFile == 1]);
|
---|
850 | WinSetDlgItemText(hwnd,
|
---|
851 | DSZ_NUMFILES,
|
---|
852 | s);
|
---|
853 | }
|
---|
854 | }
|
---|
855 | break;
|
---|
856 | }
|
---|
857 | return 0;
|
---|
858 |
|
---|
859 | case WM_COMMAND:
|
---|
860 | switch(SHORT1FROMMP(mp1)) {
|
---|
861 | case IDM_HELP:
|
---|
862 | if(hwndHelp)
|
---|
863 | WinSendMsg(hwndHelp,HM_DISPLAY_HELP,
|
---|
864 | MPFROM2SHORT(HELP_DIRSIZE,0),
|
---|
865 | MPFROMSHORT(HM_RESOURCEID));
|
---|
866 | break;
|
---|
867 |
|
---|
868 | case DSZ_PRINT:
|
---|
869 | pTemp = INSTDATA(hwnd);
|
---|
870 | if(pTemp && !pTemp->working) {
|
---|
871 |
|
---|
872 | CHAR pszFileName[CCHMAXPATH];
|
---|
873 | FILE *fp;
|
---|
874 |
|
---|
875 | save_dir2(pszFileName);
|
---|
876 | sprintf(&pszFileName[strlen(pszFileName)],"\\%csizes.Rpt",
|
---|
877 | (pTemp) ? toupper(*pTemp->dirname) : '+');
|
---|
878 | if(export_filename(hwnd,pszFileName,FALSE) && *pszFileName) {
|
---|
879 | if(stricmp(pszFileName,"PRN") &&
|
---|
880 | strnicmp(pszFileName,"\\DEV\\LPT",8) &&
|
---|
881 | !strchr(pszFileName,'.'))
|
---|
882 | strcat(pszFileName,".RPT");
|
---|
883 | fp = fopen(pszFileName,"a+");
|
---|
884 | if(fp) {
|
---|
885 | WinSetPointer(HWND_DESKTOP,hptrBusy);
|
---|
886 | PrintToFile(WinWindowFromID(hwnd,DSZ_CNR),0,NULL,fp);
|
---|
887 | fclose(fp);
|
---|
888 | WinSetPointer(HWND_DESKTOP,hptrArrow);
|
---|
889 | }
|
---|
890 | else
|
---|
891 | saymsg(MB_CANCEL,
|
---|
892 | hwnd,
|
---|
893 | GetPString(IDS_ERRORTEXT),
|
---|
894 | GetPString(IDS_COMPCANTOPENTEXT),
|
---|
895 | pszFileName);
|
---|
896 | }
|
---|
897 | }
|
---|
898 | else
|
---|
899 | DosBeep(50,100);
|
---|
900 | break;
|
---|
901 |
|
---|
902 | case DSZ_EXPAND:
|
---|
903 | case DSZ_COLLAPSE:
|
---|
904 | {
|
---|
905 | PCNRITEM pci;
|
---|
906 |
|
---|
907 | pci = (PCNRITEM)WinSendDlgItemMsg(hwnd,DSZ_CNR,
|
---|
908 | CM_QUERYRECORDEMPHASIS,
|
---|
909 | MPFROMLONG(CMA_FIRST),
|
---|
910 | MPFROMSHORT(CRA_CURSORED));
|
---|
911 | if(pci)
|
---|
912 | ExpandAll(WinWindowFromID(hwnd,DSZ_CNR),
|
---|
913 | (SHORT1FROMMP(mp1) == DSZ_EXPAND),pci);
|
---|
914 | }
|
---|
915 | break;
|
---|
916 |
|
---|
917 | case DID_OK:
|
---|
918 | case DID_CANCEL:
|
---|
919 | pTemp = INSTDATA(hwnd);
|
---|
920 | if(pTemp) {
|
---|
921 | if(pTemp->working) {
|
---|
922 | pTemp->dying = TRUE;
|
---|
923 | pTemp->pchStopFlag = 0xff;
|
---|
924 | DosBeep(1000,100);
|
---|
925 | }
|
---|
926 | else
|
---|
927 | WinDismissDlg(hwnd,0);
|
---|
928 | }
|
---|
929 | break;
|
---|
930 | }
|
---|
931 | return 0;
|
---|
932 |
|
---|
933 | case WM_CLOSE:
|
---|
934 | pTemp = INSTDATA(hwnd);
|
---|
935 | if(pTemp)
|
---|
936 | pTemp->pchStopFlag = 0xff;
|
---|
937 | DosSleep(1L);
|
---|
938 | break;
|
---|
939 |
|
---|
940 | case WM_DESTROY:
|
---|
941 | pTemp = INSTDATA(hwnd);
|
---|
942 | if(pTemp) {
|
---|
943 | pTemp->pchStopFlag = 0xff;
|
---|
944 | if(pTemp->hptr)
|
---|
945 | WinDestroyPointer(pTemp->hptr);
|
---|
946 | DosSleep(33L);
|
---|
947 | free(pTemp);
|
---|
948 | }
|
---|
949 | DosPostEventSem(CompactSem);
|
---|
950 | break;
|
---|
951 | }
|
---|
952 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
---|
953 | }
|
---|