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