| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: draglist.c 38 2002-10-17 18:59:51Z root $ | 
|---|
| 5 |  | 
|---|
| 6 | Drag drop support | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2001, 2002 Steven H.Levine | 
|---|
| 10 |  | 
|---|
| 11 | Revisions     16 Oct 02 SHL - DoFileDrag: don't free stack | 
|---|
| 12 |  | 
|---|
| 13 | ***********************************************************************/ | 
|---|
| 14 |  | 
|---|
| 15 | #define INCL_DOS | 
|---|
| 16 | #define INCL_WIN | 
|---|
| 17 |  | 
|---|
| 18 | #include <os2.h> | 
|---|
| 19 | #include <stdio.h> | 
|---|
| 20 | #include <stdlib.h> | 
|---|
| 21 | #include <string.h> | 
|---|
| 22 | #include <ctype.h> | 
|---|
| 23 | #include "fm3dll.h" | 
|---|
| 24 |  | 
|---|
| 25 | #pragma alloc_text(DRAGLIST,DragOne,DoFileDrag,DragList,PickUp) | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | HWND DragOne (HWND hwndCnr,HWND hwndObj,CHAR *filename,BOOL moveok) { | 
|---|
| 29 |  | 
|---|
| 30 | DRAGITEM    DItem; | 
|---|
| 31 | HWND        hDrop = 0; | 
|---|
| 32 | DRAGIMAGE   fakeicon; | 
|---|
| 33 | PDRAGINFO   pDInfo; | 
|---|
| 34 | FILESTATUS3 fs3; | 
|---|
| 35 | CHAR        szDir[CCHMAXPATH],szFile[CCHMAXPATH],*p; | 
|---|
| 36 |  | 
|---|
| 37 | if(filename && *filename) { | 
|---|
| 38 | if((IsRoot(filename) && IsValidDrive(*filename)) || | 
|---|
| 39 | !DosQueryPathInfo(filename,FIL_STANDARD,&fs3,sizeof(fs3))) { | 
|---|
| 40 | strcpy(szDir,filename); | 
|---|
| 41 | p = szDir; | 
|---|
| 42 | while(*p) { | 
|---|
| 43 | if(*p == '/') | 
|---|
| 44 | *p = '\\'; | 
|---|
| 45 | p++; | 
|---|
| 46 | } | 
|---|
| 47 | p = strrchr(szDir,'\\'); | 
|---|
| 48 | if(p) { | 
|---|
| 49 | *p = 0; | 
|---|
| 50 | p++; | 
|---|
| 51 | strcpy(szFile,p); | 
|---|
| 52 | strcat(szDir,"\\"); | 
|---|
| 53 | } | 
|---|
| 54 | else { | 
|---|
| 55 | strcpy(szFile,filename); | 
|---|
| 56 | *szDir = 0; | 
|---|
| 57 | } | 
|---|
| 58 | memset(&fakeicon,0,sizeof(DRAGIMAGE)); | 
|---|
| 59 | fakeicon.hImage = (IsRoot(filename) || | 
|---|
| 60 | (fs3.attrFile & FILE_DIRECTORY) != 0) ? | 
|---|
| 61 | hptrDir : hptrFile; | 
|---|
| 62 | memset(&DItem,0,sizeof(DRAGITEM)); | 
|---|
| 63 | DItem.hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM */ | 
|---|
| 64 | // DItem.hwndItem = hwndCnr; | 
|---|
| 65 | DItem.ulItemID = 1; | 
|---|
| 66 | DItem.hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
| 67 | DItem.hstrRMF = | 
|---|
| 68 | DrgAddStrHandle(DRMDRFLIST); | 
|---|
| 69 | DItem.hstrContainerName = DrgAddStrHandle(szDir); | 
|---|
| 70 | DItem.hstrSourceName = DrgAddStrHandle(szFile); | 
|---|
| 71 | DItem.hstrTargetName = DrgAddStrHandle(szFile); | 
|---|
| 72 | DItem.fsControl = 0; | 
|---|
| 73 | if(IsRoot(filename) || (fs3.attrFile & FILE_DIRECTORY) != 0) | 
|---|
| 74 | DItem.fsControl |= DC_CONTAINER; | 
|---|
| 75 | if(IsFullName(filename) && | 
|---|
| 76 | (driveflags[toupper(*filename) - 'A'] & DRIVE_REMOVABLE)) | 
|---|
| 77 | DItem.fsControl |= DC_REMOVEABLEMEDIA; | 
|---|
| 78 | DItem.fsSupportedOps = DO_COPYABLE | DO_LINKABLE; | 
|---|
| 79 | if(moveok && IsFullName(filename) && | 
|---|
| 80 | !(driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)) | 
|---|
| 81 | DItem.fsSupportedOps |= DO_MOVEABLE; | 
|---|
| 82 | if(IsRoot(filename)) | 
|---|
| 83 | DItem.fsSupportedOps = DO_LINKABLE; | 
|---|
| 84 | fakeicon.cb = sizeof(DRAGIMAGE); | 
|---|
| 85 | fakeicon.cptl = 0; | 
|---|
| 86 | fakeicon.fl = DRG_ICON; | 
|---|
| 87 | fakeicon.sizlStretch.cx = 32; | 
|---|
| 88 | fakeicon.sizlStretch.cy = 32; | 
|---|
| 89 | fakeicon.cxOffset = -16; | 
|---|
| 90 | fakeicon.cyOffset = 0; | 
|---|
| 91 | pDInfo = DrgAllocDraginfo(1);     /* Allocate DRAGINFO */ | 
|---|
| 92 | if(pDInfo) { | 
|---|
| 93 | if(IsFullName(filename) && | 
|---|
| 94 | (driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)) | 
|---|
| 95 | pDInfo->usOperation = DO_COPY; | 
|---|
| 96 | else | 
|---|
| 97 | pDInfo->usOperation = DO_DEFAULT; | 
|---|
| 98 | if(IsRoot(filename)) | 
|---|
| 99 | pDInfo->usOperation = DO_LINK; | 
|---|
| 100 | pDInfo->hwndSource = (hwndObj) ? hwndObj : hwndCnr; | 
|---|
| 101 | // pDInfo->hwndSource = hwndCnr; | 
|---|
| 102 | DrgSetDragitem(pDInfo,            /* Set item in DRAGINFO  */ | 
|---|
| 103 | &DItem,            /* Pointer to DRAGITEM   */ | 
|---|
| 104 | sizeof(DRAGITEM),  /* Size of DRAGITEM      */ | 
|---|
| 105 | 0);                /* Index of DRAGITEM     */ | 
|---|
| 106 | WinSetFocus(HWND_DESKTOP,HWND_DESKTOP); | 
|---|
| 107 | hDrop = DrgDrag(hwndCnr,              /* Initiate drag         */ | 
|---|
| 108 | pDInfo,               /* DRAGINFO structure    */ | 
|---|
| 109 | &fakeicon, | 
|---|
| 110 | 1L, | 
|---|
| 111 | VK_ENDDRAG,           /* End of drag indicator */ | 
|---|
| 112 | (PVOID)NULL);         /* Reserved              */ | 
|---|
| 113 |  | 
|---|
| 114 | DrgFreeDraginfo(pDInfo);              /* Free DRAGINFO struct  */ | 
|---|
| 115 | WinSetWindowPos(hwndCnr,HWND_TOP,0,0,0,0,SWP_ACTIVATE); | 
|---|
| 116 | } | 
|---|
| 117 | } | 
|---|
| 118 | } | 
|---|
| 119 | return hDrop; | 
|---|
| 120 | } | 
|---|
| 121 |  | 
|---|
| 122 |  | 
|---|
| 123 | HWND DoFileDrag (HWND hwndCnr,HWND hwndObj,PCNRDRAGINIT pcd,CHAR *arcfile, | 
|---|
| 124 | CHAR *directory,BOOL moveok) | 
|---|
| 125 | { | 
|---|
| 126 | /* drag files from a container */ | 
|---|
| 127 |  | 
|---|
| 128 | BOOL           isdir,rooting = FALSE; | 
|---|
| 129 | PCNRITEM       pci; | 
|---|
| 130 | register CHAR  *p; | 
|---|
| 131 | INT            attribute = CRA_CURSORED; | 
|---|
| 132 | PDRAGINFO      pDInfo = NULL; | 
|---|
| 133 | DRAGITEM       **ppDItem = NULL,**ppTest; | 
|---|
| 134 | PCNRITEM       pciRec = (PCNRITEM)pcd->pRecord; | 
|---|
| 135 | HWND           hDrop = 0; | 
|---|
| 136 | register ULONG ulNumfiles = 0L,numdragalloc = 0L,Select,ulNumIcon = 0; | 
|---|
| 137 | CHAR           szFile[CCHMAXPATH],szBuffer[CCHMAXPATH]; | 
|---|
| 138 | DRAGIMAGE      *padiIcon = NULL,*padiTest,diFakeIcon; | 
|---|
| 139 |  | 
|---|
| 140 | if(!pciRec && directory && *directory) | 
|---|
| 141 | return DragOne(hwndCnr,hwndObj,directory,moveok); | 
|---|
| 142 |  | 
|---|
| 143 | if(!pciRec) { | 
|---|
| 144 | pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS, | 
|---|
| 145 | MPFROMLONG(CMA_FIRST), | 
|---|
| 146 | MPFROMSHORT(attribute)); | 
|---|
| 147 | if(pci && (INT)pci > -1) { | 
|---|
| 148 | if(pci->rc.flRecordAttr & CRA_SELECTED) { | 
|---|
| 149 | attribute = CRA_SELECTED; | 
|---|
| 150 | pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), | 
|---|
| 151 | MPFROMSHORT(attribute)); | 
|---|
| 152 | } | 
|---|
| 153 | } | 
|---|
| 154 | } | 
|---|
| 155 | else { | 
|---|
| 156 | pci = pciRec; | 
|---|
| 157 | attribute = (pci->rc.flRecordAttr & CRA_SELECTED) ? CRA_SELECTED : 0; | 
|---|
| 158 | if(attribute) { | 
|---|
| 159 | pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), | 
|---|
| 160 | MPFROMSHORT(attribute)); | 
|---|
| 161 | } | 
|---|
| 162 | } | 
|---|
| 163 |  | 
|---|
| 164 | Select = 0L; | 
|---|
| 165 | while( pci && (INT)pci > -1) { | 
|---|
| 166 | if(!(pci->rc.flRecordAttr & CRA_FILTERED)) { | 
|---|
| 167 | if(IsRoot(pci->szFileName) && !IsValidDrive(*pci->szFileName)) | 
|---|
| 168 | goto Continuing; | 
|---|
| 169 | if(!arcfile) { | 
|---|
| 170 | strcpy(szBuffer,pci->szFileName); | 
|---|
| 171 | p = strrchr(szBuffer,'\\'); | 
|---|
| 172 | if(p) { | 
|---|
| 173 | p++; | 
|---|
| 174 | strcpy(szFile,p); | 
|---|
| 175 | *p = 0; | 
|---|
| 176 | } | 
|---|
| 177 | else | 
|---|
| 178 | goto Continuing; | 
|---|
| 179 | } | 
|---|
| 180 | else | 
|---|
| 181 | strcpy(szFile,pci->szFileName); | 
|---|
| 182 | } | 
|---|
| 183 | if(!arcfile) { | 
|---|
| 184 | // Filesystem object | 
|---|
| 185 | isdir = ((pci->attrFile & FILE_DIRECTORY) != 0); | 
|---|
| 186 | if(ulNumfiles + 2L > numdragalloc) { | 
|---|
| 187 | if(!padiIcon) { | 
|---|
| 188 | padiTest = realloc(padiIcon,sizeof(DRAGIMAGE) * (numdragalloc + 4L)); | 
|---|
| 189 | if(padiTest) | 
|---|
| 190 | padiIcon = padiTest; | 
|---|
| 191 | else | 
|---|
| 192 | break; | 
|---|
| 193 | } | 
|---|
| 194 | else if(!ulNumIcon) { | 
|---|
| 195 | padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); | 
|---|
| 196 | padiIcon[ulNumfiles].cptl = 0; | 
|---|
| 197 | padiIcon[ulNumfiles].hImage = hptrLast; | 
|---|
| 198 | padiIcon[ulNumfiles].fl = DRG_ICON; | 
|---|
| 199 | padiIcon[ulNumfiles].sizlStretch.cx = 32; | 
|---|
| 200 | padiIcon[ulNumfiles].sizlStretch.cy = 32; | 
|---|
| 201 | padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 4); | 
|---|
| 202 | padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 7); | 
|---|
| 203 | ulNumIcon = ulNumfiles + 1; | 
|---|
| 204 | } | 
|---|
| 205 | ppTest = realloc(ppDItem,sizeof(DRAGITEM *) * (numdragalloc + 4L)); | 
|---|
| 206 | if(ppTest) { | 
|---|
| 207 | ppDItem = ppTest; | 
|---|
| 208 | numdragalloc += 4L; | 
|---|
| 209 | } | 
|---|
| 210 | else | 
|---|
| 211 | break; | 
|---|
| 212 | } | 
|---|
| 213 | ppDItem[ulNumfiles] = malloc(sizeof(DRAGITEM)); | 
|---|
| 214 | if(ppDItem[ulNumfiles]) { | 
|---|
| 215 | if(!ulNumIcon) { | 
|---|
| 216 | padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); | 
|---|
| 217 | padiIcon[ulNumfiles].cptl = 0; | 
|---|
| 218 | padiIcon[ulNumfiles].hImage = pci->rc.hptrIcon; | 
|---|
| 219 | if(!padiIcon[ulNumfiles].hImage) | 
|---|
| 220 | padiIcon[ulNumfiles].hImage = (isdir) ? hptrDir : hptrFile; | 
|---|
| 221 | padiIcon[ulNumfiles].fl = DRG_ICON; | 
|---|
| 222 | padiIcon[ulNumfiles].sizlStretch.cx = 32; | 
|---|
| 223 | padiIcon[ulNumfiles].sizlStretch.cy = 32; | 
|---|
| 224 | padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 3); | 
|---|
| 225 | padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 6); | 
|---|
| 226 | } | 
|---|
| 227 | memset(ppDItem[ulNumfiles],0,sizeof(DRAGITEM)); | 
|---|
| 228 | ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM   */ | 
|---|
| 229 | ppDItem[ulNumfiles]->hwndItem = hwndCnr; | 
|---|
| 230 | ppDItem[ulNumfiles]->ulItemID = (ULONG)pci; | 
|---|
| 231 | ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
| 232 | ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFLIST); | 
|---|
| 233 | ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(szBuffer); | 
|---|
| 234 | ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); | 
|---|
| 235 | ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); | 
|---|
| 236 | ppDItem[ulNumfiles]->fsControl = (isdir) ? DC_CONTAINER : 0; | 
|---|
| 237 | if(IsFullName(pci->szFileName) && | 
|---|
| 238 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)) | 
|---|
| 239 | ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; | 
|---|
| 240 | ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE | DO_LINKABLE; | 
|---|
| 241 | if(moveok && IsFullName(pci->szFileName) && | 
|---|
| 242 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOTWRITEABLE)) | 
|---|
| 243 | ppDItem[ulNumfiles]->fsSupportedOps |= DO_MOVEABLE; | 
|---|
| 244 | if(IsRoot(pci->szFileName)) { | 
|---|
| 245 | ppDItem[ulNumfiles]->fsSupportedOps = DO_LINKABLE; | 
|---|
| 246 | rooting = TRUE; | 
|---|
| 247 | } | 
|---|
| 248 | ulNumfiles++; | 
|---|
| 249 | ppDItem[ulNumfiles] = NULL; | 
|---|
| 250 | } | 
|---|
| 251 | else | 
|---|
| 252 | break; | 
|---|
| 253 | } | 
|---|
| 254 | else { | 
|---|
| 255 | // Archive object | 
|---|
| 256 | if(ulNumfiles + 3L > numdragalloc) { | 
|---|
| 257 | ppTest = realloc(ppDItem,sizeof(DRAGITEM *) * (numdragalloc + 5L)); | 
|---|
| 258 | if(ppTest) { | 
|---|
| 259 | ppDItem = ppTest; | 
|---|
| 260 | numdragalloc += 5L; | 
|---|
| 261 | } | 
|---|
| 262 | else | 
|---|
| 263 | break; | 
|---|
| 264 | } | 
|---|
| 265 | ppDItem[ulNumfiles] = malloc(sizeof(DRAGITEM)); | 
|---|
| 266 | if(ppDItem[ulNumfiles]) { | 
|---|
| 267 | diFakeIcon.hImage = hptrFile; | 
|---|
| 268 | memset(ppDItem[ulNumfiles],0,sizeof(DRAGITEM)); | 
|---|
| 269 | ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM   */ | 
|---|
| 270 | ppDItem[ulNumfiles]->hwndItem = hwndCnr; | 
|---|
| 271 | ppDItem[ulNumfiles]->ulItemID = (ULONG)pci; | 
|---|
| 272 | ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
| 273 | ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFOS2FILE); | 
|---|
| 274 | ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(arcfile); | 
|---|
| 275 | ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); | 
|---|
| 276 | ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); | 
|---|
| 277 | ppDItem[ulNumfiles]->fsControl = DC_PREPARE; | 
|---|
| 278 | if(IsFullName(arcfile) && | 
|---|
| 279 | (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE)) | 
|---|
| 280 | ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; | 
|---|
| 281 | ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE; | 
|---|
| 282 | ulNumfiles++; | 
|---|
| 283 | ppDItem[ulNumfiles] = malloc(sizeof(DRAGITEM)); | 
|---|
| 284 | if(ppDItem[ulNumfiles]) { | 
|---|
| 285 | diFakeIcon.hImage = hptrFile; | 
|---|
| 286 | memset(ppDItem[ulNumfiles],0,sizeof(DRAGITEM)); | 
|---|
| 287 | ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM   */ | 
|---|
| 288 | ppDItem[ulNumfiles]->hwndItem = hwndCnr; | 
|---|
| 289 | ppDItem[ulNumfiles]->ulItemID = Select++; | 
|---|
| 290 | ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
| 291 | ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFFM2ARC); | 
|---|
| 292 | ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(arcfile); | 
|---|
| 293 | ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); | 
|---|
| 294 | ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); | 
|---|
| 295 | ppDItem[ulNumfiles]->fsControl = 0; | 
|---|
| 296 | if(IsFullName(arcfile) && | 
|---|
| 297 | (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE)) | 
|---|
| 298 | ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; | 
|---|
| 299 | ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE; | 
|---|
| 300 | ulNumfiles++; | 
|---|
| 301 | } | 
|---|
| 302 | ppDItem[ulNumfiles] = NULL; | 
|---|
| 303 | } | 
|---|
| 304 | else | 
|---|
| 305 | break; | 
|---|
| 306 | } | 
|---|
| 307 | WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci), | 
|---|
| 308 | MPFROM2SHORT(TRUE,CRA_SOURCE)); | 
|---|
| 309 |  | 
|---|
| 310 | Continuing: | 
|---|
| 311 |  | 
|---|
| 312 | if(!attribute) | 
|---|
| 313 | break; | 
|---|
| 314 | pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMP(pci), | 
|---|
| 315 | MPFROMSHORT(attribute)); | 
|---|
| 316 | } // while | 
|---|
| 317 |  | 
|---|
| 318 | if(ulNumfiles) { | 
|---|
| 319 | pDInfo = DrgAllocDraginfo(ulNumfiles);  /* Allocate DRAGINFO */ | 
|---|
| 320 | if(pDInfo) { | 
|---|
| 321 | if((arcfile && *arcfile) || (IsFullName(szBuffer) && | 
|---|
| 322 | (driveflags[toupper(*szBuffer) - 'A'] & DRIVE_NOTWRITEABLE))) | 
|---|
| 323 | pDInfo->usOperation = DO_COPY; | 
|---|
| 324 | else | 
|---|
| 325 | pDInfo->usOperation = DO_DEFAULT; | 
|---|
| 326 | if((!arcfile || !*arcfile) && rooting) | 
|---|
| 327 | pDInfo->usOperation = DO_LINK; | 
|---|
| 328 | pDInfo->hwndSource = (hwndObj) ? hwndObj : hwndCnr; | 
|---|
| 329 | // pDInfo->hwndSource = hwndCnr; | 
|---|
| 330 | for(Select = 0L;Select < ulNumfiles;Select++) { | 
|---|
| 331 | DrgSetDragitem(pDInfo,                  /* Set item in DRAGINFO  */ | 
|---|
| 332 | ppDItem[Select],         /* Pointer to DRAGITEM   */ | 
|---|
| 333 | sizeof(DRAGITEM),        /* Size of DRAGITEM      */ | 
|---|
| 334 | Select);                 /* Index of DRAGITEM     */ | 
|---|
| 335 | free(ppDItem[Select]); | 
|---|
| 336 | } | 
|---|
| 337 | #ifdef __DEBUG_ALLOC__ | 
|---|
| 338 | _heap_check(); | 
|---|
| 339 | #endif | 
|---|
| 340 | free(ppDItem); | 
|---|
| 341 | ppDItem = NULL; | 
|---|
| 342 | DosPostEventSem(CompactSem); | 
|---|
| 343 |  | 
|---|
| 344 | if(arcfile) { | 
|---|
| 345 | diFakeIcon.cb = sizeof(DRAGIMAGE); | 
|---|
| 346 | diFakeIcon.cptl = 0; | 
|---|
| 347 | if(ulNumfiles > 1) | 
|---|
| 348 | diFakeIcon.hImage = hptrFile; | 
|---|
| 349 | diFakeIcon.fl = DRG_ICON; | 
|---|
| 350 | diFakeIcon.sizlStretch.cx = 32; | 
|---|
| 351 | diFakeIcon.sizlStretch.cy = 32; | 
|---|
| 352 | diFakeIcon.cxOffset = -16; | 
|---|
| 353 | diFakeIcon.cyOffset = 0; | 
|---|
| 354 | padiIcon = &diFakeIcon; | 
|---|
| 355 | } | 
|---|
| 356 | if(!arcfile) { | 
|---|
| 357 | if(!ulNumIcon) | 
|---|
| 358 | ulNumIcon = ulNumfiles; | 
|---|
| 359 | } | 
|---|
| 360 | else | 
|---|
| 361 | ulNumIcon = 1L; | 
|---|
| 362 |  | 
|---|
| 363 | WinSetFocus(HWND_DESKTOP,HWND_DESKTOP); | 
|---|
| 364 | hDrop = DrgDrag(hwndCnr,              /* Initiate drag         */ | 
|---|
| 365 | pDInfo,               /* DRAGINFO structure    */ | 
|---|
| 366 | padiIcon, | 
|---|
| 367 | ulNumIcon, | 
|---|
| 368 | VK_ENDDRAG,           /* End of drag indicator */ | 
|---|
| 369 | (PVOID)NULL);         /* Reserved              */ | 
|---|
| 370 |  | 
|---|
| 371 | DrgFreeDraginfo(pDInfo);              /* Free DRAGINFO struct  */ | 
|---|
| 372 | if(padiIcon && padiIcon != &diFakeIcon) | 
|---|
| 373 | free(padiIcon); | 
|---|
| 374 | padiIcon = NULL; | 
|---|
| 375 | WinSetWindowPos(hwndCnr,HWND_TOP,0,0,0,0,SWP_ACTIVATE); | 
|---|
| 376 | DosPostEventSem(CompactSem); | 
|---|
| 377 | } | 
|---|
| 378 | } | 
|---|
| 379 | if(ppDItem) | 
|---|
| 380 | free(ppDItem); | 
|---|
| 381 | if(padiIcon && padiIcon != &diFakeIcon) | 
|---|
| 382 | free(padiIcon); | 
|---|
| 383 | MarkAll(hwndCnr,TRUE,FALSE,TRUE); | 
|---|
| 384 | return hDrop; | 
|---|
| 385 | } | 
|---|
| 386 |  | 
|---|
| 387 |  | 
|---|
| 388 | HWND DragList (HWND hwnd,HWND hwndObj,CHAR **list,BOOL moveok) { | 
|---|
| 389 |  | 
|---|
| 390 | /* drag a linked list of files */ | 
|---|
| 391 |  | 
|---|
| 392 | BOOL           isdir; | 
|---|
| 393 | register CHAR  *p; | 
|---|
| 394 | PDRAGINFO      pDInfo = NULL; | 
|---|
| 395 | DRAGITEM       **ppDItem = NULL,**ppTest; | 
|---|
| 396 | HWND           hDrop = (HWND)0; | 
|---|
| 397 | register ULONG ulNumfiles = 0L,numdragalloc = 0L,Select,ulNumIcon = 0; | 
|---|
| 398 | CHAR           szFile[CCHMAXPATH],szBuffer[CCHMAXPATH]; | 
|---|
| 399 | DRAGIMAGE      *padiIcon = NULL,*padiTest; | 
|---|
| 400 | FILESTATUS3    fs3; | 
|---|
| 401 |  | 
|---|
| 402 | if(!list || !list[0]) | 
|---|
| 403 | return hDrop; | 
|---|
| 404 | for(Select = 0;list[Select];Select++) { | 
|---|
| 405 | if((!IsRoot(list[Select]) || !IsValidDrive(*list[Select])) && | 
|---|
| 406 | DosQueryPathInfo(list[Select],FIL_STANDARD,&fs3,sizeof(fs3))) | 
|---|
| 407 | continue; | 
|---|
| 408 | strcpy(szBuffer,list[Select]); | 
|---|
| 409 | p = strrchr(szBuffer,'\\'); | 
|---|
| 410 | if(p) { | 
|---|
| 411 | p++; | 
|---|
| 412 | strcpy(szFile,p); | 
|---|
| 413 | *p = 0; | 
|---|
| 414 | } | 
|---|
| 415 | else | 
|---|
| 416 | continue; | 
|---|
| 417 | if(*szFile) { | 
|---|
| 418 | isdir = (IsRoot(list[Select])) ? TRUE : | 
|---|
| 419 | ((fs3.attrFile & FILE_DIRECTORY) != 0); | 
|---|
| 420 | if(ulNumfiles + 2L > numdragalloc) { | 
|---|
| 421 | if(!padiIcon) { | 
|---|
| 422 | padiTest = realloc(padiIcon,sizeof(DRAGIMAGE) * (numdragalloc + 4L)); | 
|---|
| 423 | if(padiTest) | 
|---|
| 424 | padiIcon = padiTest; | 
|---|
| 425 | else | 
|---|
| 426 | break; | 
|---|
| 427 | } | 
|---|
| 428 | else if(!ulNumIcon) { | 
|---|
| 429 | padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); | 
|---|
| 430 | padiIcon[ulNumfiles].cptl = 0; | 
|---|
| 431 | padiIcon[ulNumfiles].hImage = hptrLast; | 
|---|
| 432 | padiIcon[ulNumfiles].fl = DRG_ICON; | 
|---|
| 433 | padiIcon[ulNumfiles].sizlStretch.cx = 32; | 
|---|
| 434 | padiIcon[ulNumfiles].sizlStretch.cy = 32; | 
|---|
| 435 | padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 4); | 
|---|
| 436 | padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 7); | 
|---|
| 437 | ulNumIcon = ulNumfiles + 1; | 
|---|
| 438 | } | 
|---|
| 439 | ppTest = realloc(ppDItem,sizeof(DRAGITEM *) * (numdragalloc + 4L)); | 
|---|
| 440 | if(ppTest) { | 
|---|
| 441 | ppDItem = ppTest; | 
|---|
| 442 | numdragalloc += 4L; | 
|---|
| 443 | } | 
|---|
| 444 | else | 
|---|
| 445 | break; | 
|---|
| 446 | } | 
|---|
| 447 | ppDItem[ulNumfiles] = malloc(sizeof(DRAGITEM)); | 
|---|
| 448 | if(ppDItem[ulNumfiles]) { | 
|---|
| 449 | if(!ulNumIcon) { | 
|---|
| 450 | padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); | 
|---|
| 451 | padiIcon[ulNumfiles].cptl = 0; | 
|---|
| 452 | padiIcon[ulNumfiles].hImage = (isdir) ? hptrDir : hptrFile; | 
|---|
| 453 | padiIcon[ulNumfiles].fl = DRG_ICON; | 
|---|
| 454 | padiIcon[ulNumfiles].sizlStretch.cx = 32; | 
|---|
| 455 | padiIcon[ulNumfiles].sizlStretch.cy = 32; | 
|---|
| 456 | padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 3); | 
|---|
| 457 | padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 6); | 
|---|
| 458 | } | 
|---|
| 459 | memset(ppDItem[ulNumfiles],0,sizeof(DRAGITEM)); | 
|---|
| 460 | ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwnd; /* Initialize DRAGITEM */ | 
|---|
| 461 | // ppDItem[ulNumfiles]->hwndItem = hwnd; | 
|---|
| 462 | ppDItem[ulNumfiles]->ulItemID = (ULONG)Select; | 
|---|
| 463 | ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
| 464 | ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFLIST); | 
|---|
| 465 | ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(szBuffer); | 
|---|
| 466 | ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); | 
|---|
| 467 | ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); | 
|---|
| 468 | ppDItem[ulNumfiles]->fsControl = (isdir) ? DC_CONTAINER : 0; | 
|---|
| 469 | if(IsFullName(list[Select]) && | 
|---|
| 470 | (driveflags[toupper(*list[Select]) - 'A'] & DRIVE_REMOVABLE)) | 
|---|
| 471 | ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; | 
|---|
| 472 | ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE | DO_LINKABLE; | 
|---|
| 473 | if(moveok && IsFullName(list[Select]) && | 
|---|
| 474 | !(driveflags[toupper(*list[Select]) - 'A'] & DRIVE_NOTWRITEABLE)) | 
|---|
| 475 | ppDItem[ulNumfiles]->fsSupportedOps |= DO_MOVEABLE; | 
|---|
| 476 | if(IsRoot(list[Select])) | 
|---|
| 477 | ppDItem[ulNumfiles]->fsControl = DO_LINKABLE; | 
|---|
| 478 | ulNumfiles++; | 
|---|
| 479 | ppDItem[ulNumfiles] = NULL; | 
|---|
| 480 | } | 
|---|
| 481 | else | 
|---|
| 482 | break; | 
|---|
| 483 | } | 
|---|
| 484 | } | 
|---|
| 485 |  | 
|---|
| 486 | if(ulNumfiles) { | 
|---|
| 487 | pDInfo = DrgAllocDraginfo(ulNumfiles);  /* Allocate DRAGINFO */ | 
|---|
| 488 | if(pDInfo) { | 
|---|
| 489 | if((IsFullName(szBuffer) && | 
|---|
| 490 | (driveflags[toupper(*szBuffer) - 'A'] & DRIVE_NOTWRITEABLE))) | 
|---|
| 491 | pDInfo->usOperation = DO_COPY; | 
|---|
| 492 | else | 
|---|
| 493 | pDInfo->usOperation = DO_DEFAULT; | 
|---|
| 494 | if(IsRoot(list[0])) | 
|---|
| 495 | pDInfo->usOperation = DO_LINK; | 
|---|
| 496 | pDInfo->hwndSource = (hwndObj) ? hwndObj : hwnd; | 
|---|
| 497 | // pDInfo->hwndSource = hwnd; | 
|---|
| 498 | for(Select = 0L;Select < ulNumfiles;Select++) { | 
|---|
| 499 | DrgSetDragitem(pDInfo,            /* Set item in DRAGINFO  */ | 
|---|
| 500 | ppDItem[Select],     /* Pointer to DRAGITEM   */ | 
|---|
| 501 | sizeof(DRAGITEM),  /* Size of DRAGITEM      */ | 
|---|
| 502 | Select);           /* Index of DRAGITEM     */ | 
|---|
| 503 | free(ppDItem[Select]); | 
|---|
| 504 | } | 
|---|
| 505 | #ifdef __DEBUG_ALLOC__ | 
|---|
| 506 | _heap_check(); | 
|---|
| 507 | #endif | 
|---|
| 508 | free(ppDItem); | 
|---|
| 509 | ppDItem = NULL; | 
|---|
| 510 | DosPostEventSem(CompactSem); | 
|---|
| 511 |  | 
|---|
| 512 | if(!ulNumIcon) | 
|---|
| 513 | ulNumIcon = ulNumfiles; | 
|---|
| 514 |  | 
|---|
| 515 | WinSetFocus(HWND_DESKTOP,HWND_DESKTOP); | 
|---|
| 516 | hDrop = DrgDrag(hwnd,                 /* Initiate drag         */ | 
|---|
| 517 | pDInfo,               /* DRAGINFO structure    */ | 
|---|
| 518 | padiIcon, | 
|---|
| 519 | ulNumIcon, | 
|---|
| 520 | VK_ENDDRAG,           /* End of drag indicator */ | 
|---|
| 521 | (PVOID)NULL);         /* Reserved              */ | 
|---|
| 522 |  | 
|---|
| 523 | DrgFreeDraginfo(pDInfo);              /* Free DRAGINFO struct  */ | 
|---|
| 524 | free(padiIcon); | 
|---|
| 525 | padiIcon = NULL; | 
|---|
| 526 | WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ACTIVATE); | 
|---|
| 527 | DosPostEventSem(CompactSem); | 
|---|
| 528 | } | 
|---|
| 529 | } | 
|---|
| 530 | if(ppDItem) | 
|---|
| 531 | free(ppDItem); | 
|---|
| 532 | if(padiIcon) | 
|---|
| 533 | free(padiIcon); | 
|---|
| 534 | return hDrop; | 
|---|
| 535 | } | 
|---|
| 536 |  | 
|---|
| 537 |  | 
|---|
| 538 | #ifdef NEVER | 
|---|
| 539 |  | 
|---|
| 540 | BOOL PickUp (HWND hwndCnr,HWND hwndObj,PCNRDRAGINIT pcd) { | 
|---|
| 541 |  | 
|---|
| 542 | PCNRITEM  pci; | 
|---|
| 543 | BOOL      loop = TRUE; | 
|---|
| 544 | PDRAGINFO pdinfoOld = NULL,pdinfoCurrent = NULL; | 
|---|
| 545 | ULONG     cditem = 0; | 
|---|
| 546 | DRAGITEM  ditem; | 
|---|
| 547 | DRAGIMAGE diFakeIcon; | 
|---|
| 548 | CHAR      szDir[CCHMAXPATH],szFile[CCHMAXPATH],*p; | 
|---|
| 549 |  | 
|---|
| 550 | pci = (PCNRITEM)pcd->pRecord; | 
|---|
| 551 | if(pci && (INT)pci != -1) { | 
|---|
| 552 | if(pci->rc.flRecordAttr & CRA_SELECTED) { | 
|---|
| 553 | loop = TRUE; | 
|---|
| 554 | pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS, | 
|---|
| 555 | MPFROMLONG(CMA_FIRST),MPFROMSHORT(CRA_SELECTED)); | 
|---|
| 556 | } | 
|---|
| 557 | while(pci && (INT)pci != -1 && *pci->szFileName) { | 
|---|
| 558 | if(pdinfoOld || DrgQueryDragStatus() & DGS_LAZYDRAGINPROGRESS) { | 
|---|
| 559 | if(!pdinfoOld) | 
|---|
| 560 | pdinfoOld = DrgQueryDraginfoPtr(NULL); | 
|---|
| 561 | if(pdinfoOld) { | 
|---|
| 562 | cditem = pdinfoOld->cditem + 1; | 
|---|
| 563 | pdinfoCurrent = DrgReallocDraginfo(pdinfoOld,cditem); | 
|---|
| 564 | pdinfoOld = pdinfoCurrent; | 
|---|
| 565 | } | 
|---|
| 566 | } | 
|---|
| 567 | else | 
|---|
| 568 | pdinfoCurrent = pdinfoOld = DrgAllocDraginfo(1); | 
|---|
| 569 | if(pdinfoCurrent) { | 
|---|
| 570 | strcpy(szDir,pci->szFileName); | 
|---|
| 571 | p = szDir; | 
|---|
| 572 | while(*p) { | 
|---|
| 573 | if(*p == '/') | 
|---|
| 574 | *p = '\\'; | 
|---|
| 575 | p++; | 
|---|
| 576 | } | 
|---|
| 577 | p = strrchr(szDir,'\\'); | 
|---|
| 578 | if(p) { | 
|---|
| 579 | *p = 0; | 
|---|
| 580 | p++; | 
|---|
| 581 | strcpy(szFile,p); | 
|---|
| 582 | strcat(szDir,"\\"); | 
|---|
| 583 | } | 
|---|
| 584 | else { | 
|---|
| 585 | strcpy(szFile,pci->szFileName); | 
|---|
| 586 | *szDir = 0; | 
|---|
| 587 | } | 
|---|
| 588 | ditem.ulItemID = (ULONG)pci; | 
|---|
| 589 | ditem.hwndItem = (hwndObj) ? hwndObj : hwndCnr; | 
|---|
| 590 | ditem.hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
| 591 | ditem.hstrRMF = | 
|---|
| 592 | DrgAddStrHandle(DRMDRFLIST); | 
|---|
| 593 | ditem.hstrContainerName = DrgAddStrHandle(szDir); | 
|---|
| 594 | ditem.hstrSourceName = DrgAddStrHandle(szFile); | 
|---|
| 595 | ditem.hstrTargetName = DrgAddStrHandle(szFile); | 
|---|
| 596 | ditem.fsControl = 0; | 
|---|
| 597 | if(IsRoot(pci->szFileName) || (pci->attrFile & FILE_DIRECTORY) != 0) | 
|---|
| 598 | ditem.fsControl |= DC_CONTAINER; | 
|---|
| 599 | if(IsFullName(pci->szFileName) && | 
|---|
| 600 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)) | 
|---|
| 601 | ditem.fsControl |= DC_REMOVEABLEMEDIA; | 
|---|
| 602 | ditem.fsSupportedOps = DO_COPYABLE | DO_LINKABLE; | 
|---|
| 603 | if(IsFullName(pci->szFileName) && | 
|---|
| 604 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOTWRITEABLE)) | 
|---|
| 605 | ditem.fsSupportedOps |= DO_MOVEABLE; | 
|---|
| 606 | if(IsRoot(pci->szFileName)) | 
|---|
| 607 | ditem.fsSupportedOps = DO_LINKABLE; | 
|---|
| 608 | memset(&diFakeIcon,0,sizeof(DRAGIMAGE)); | 
|---|
| 609 | diFakeIcon.hImage = pci->rc.hptrIcon; | 
|---|
| 610 | diFakeIcon.cb = sizeof(DRAGIMAGE); | 
|---|
| 611 | diFakeIcon.cptl = 0; | 
|---|
| 612 | diFakeIcon.fl = DRG_ICON; | 
|---|
| 613 | diFakeIcon.sizlStretch.cx = 32; | 
|---|
| 614 | diFakeIcon.sizlStretch.cy = 32; | 
|---|
| 615 | diFakeIcon.cxOffset = -16; | 
|---|
| 616 | diFakeIcon.cyOffset = 0; | 
|---|
| 617 | if(IsFullName(pci->szFileName) && | 
|---|
| 618 | (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOTWRITEABLE)) | 
|---|
| 619 | pdinfoCurrent->usOperation = DO_COPY; | 
|---|
| 620 | else | 
|---|
| 621 | pdinfoCurrent->usOperation = DO_DEFAULT; | 
|---|
| 622 | if(IsRoot(pci->szFileName)) | 
|---|
| 623 | pdinfoCurrent->usOperation = DO_LINK; | 
|---|
| 624 | pdinfoCurrent->hwndSource = (hwndObj) ? hwndObj : hwndCnr; | 
|---|
| 625 | DrgSetDragitem(pdinfoCurrent, | 
|---|
| 626 | &ditem, | 
|---|
| 627 | sizeof(DRAGITEM), | 
|---|
| 628 | cditem); | 
|---|
| 629 | } | 
|---|
| 630 | if(!loop) | 
|---|
| 631 | break; | 
|---|
| 632 | pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS, | 
|---|
| 633 | MPFROMP(pci),MPFROMSHORT(CRA_SELECTED)); | 
|---|
| 634 | } | 
|---|
| 635 | if(pdinfoCurrent) | 
|---|
| 636 | return DrgLazyDrag(hwndCnr,pdinfoCurrent,&diFakeIcon,1,NULL); | 
|---|
| 637 | } | 
|---|
| 638 | return FALSE; | 
|---|
| 639 | } | 
|---|
| 640 |  | 
|---|
| 641 | #endif // NEVER | 
|---|