1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: draglist.c 1181 2008-09-10 21:55:02Z jbs $
|
---|
5 |
|
---|
6 | Drag drop support
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001, 2007 Steven H.Levine
|
---|
10 |
|
---|
11 | 16 Oct 02 SHL DoFileDrag: don't free stack
|
---|
12 | 26 Jul 06 SHL Check more run time errors
|
---|
13 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
|
---|
14 | 06 Apr 07 GKY Add DeleteDragitemStrHandles
|
---|
15 | 06 Apr 07 GKY Add some error checking in drag/drop
|
---|
16 | 19 Apr 07 SHL Rework DeleteDragitemStrHandles to be FreeDragInfoData
|
---|
17 | 19 Apr 07 SHL Add more drag/drop error checking
|
---|
18 | 19 Apr 07 SHL Optimize DRAGITEM DRAGIMAGE array access
|
---|
19 | 21 Apr 07 SHL Avoid odd first time drag failure
|
---|
20 | 12 May 07 SHL Use dcd->ulItemsToUnHilite
|
---|
21 | 05 Jul 07 SHL FreeDragInfoData: suppress PMERR_SOURCE_SAME_AS_TARGET notices
|
---|
22 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
23 | 29 Feb 08 GKY Use xmallocz where appropriate
|
---|
24 |
|
---|
25 | ***********************************************************************/
|
---|
26 |
|
---|
27 | #include <stdlib.h>
|
---|
28 | #include <string.h>
|
---|
29 | #include <ctype.h>
|
---|
30 |
|
---|
31 | #define INCL_DOS
|
---|
32 | #define INCL_WIN
|
---|
33 | #define INCL_SHLERRORS
|
---|
34 | #define INCL_LONGLONG
|
---|
35 |
|
---|
36 | #include "fm3dll.h"
|
---|
37 | #include "errutil.h" // Dos_Error...
|
---|
38 | #include "draglist.h"
|
---|
39 | #include "valid.h" // IsValidDrive
|
---|
40 | #include "misc.h" // IsFm2Window
|
---|
41 | #include "select.h" // MarkAll
|
---|
42 | #include "wrappers.h" // xrealloc
|
---|
43 | #include "fortify.h"
|
---|
44 |
|
---|
45 | static PSZ pszSrcFile = __FILE__;
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Delete drag item string handles.
|
---|
49 | * Work around for DrgDeleteDraginfoStrHandles
|
---|
50 | * which seems to fail with a large number of strings
|
---|
51 | * Assume called after successful DrgAccessDraginfo
|
---|
52 | */
|
---|
53 |
|
---|
54 |
|
---|
55 | // #define USE_FAST_FREE // Define to let PM do free
|
---|
56 |
|
---|
57 | VOID FreeDragInfoData (HWND hwnd, PDRAGINFO pDInfo)
|
---|
58 | {
|
---|
59 | PDRAGITEM pDItem;
|
---|
60 | ULONG cDitem;
|
---|
61 | ULONG curitem;
|
---|
62 | APIRET ok;
|
---|
63 |
|
---|
64 | # ifdef USE_FAST_FREE
|
---|
65 | if (!DrgDeleteDraginfoStrHandles(pDInfo)) {
|
---|
66 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
67 | "DrgDeleteDraginfoStrHandles");
|
---|
68 | }
|
---|
69 | # else // The slow way
|
---|
70 | cDitem = DrgQueryDragitemCount(pDInfo);
|
---|
71 | for (curitem = 0; curitem < cDitem; curitem++) {
|
---|
72 | pDItem = DrgQueryDragitemPtr(pDInfo, curitem);
|
---|
73 | if (!pDItem) {
|
---|
74 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
75 | "DrgQueryDragitemPtr(%u)", curitem);
|
---|
76 | }
|
---|
77 | else {
|
---|
78 | ok = DrgDeleteStrHandle(pDItem->hstrType);
|
---|
79 | if (!ok) {
|
---|
80 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
81 | "DrgDeleteStrHandle(0x%x) hstrType",pDItem->hstrType);
|
---|
82 | }
|
---|
83 | ok = DrgDeleteStrHandle(pDItem->hstrRMF);
|
---|
84 | if (!ok) {
|
---|
85 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
86 | "DrgDeleteStrHandle(0x%x) hstrRMF",pDItem->hstrRMF);
|
---|
87 | }
|
---|
88 | ok = DrgDeleteStrHandle(pDItem->hstrContainerName);
|
---|
89 | if (!ok) {
|
---|
90 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
91 | "DrgDeleteStrHandle(0x%x) hstrContainerName",pDItem->hstrContainerName);
|
---|
92 | }
|
---|
93 | ok = DrgDeleteStrHandle(pDItem->hstrSourceName);
|
---|
94 | if (!ok) {
|
---|
95 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
96 | "DrgDeleteStrHandle(0x%x) hstrSourceName",pDItem->hstrSourceName);
|
---|
97 | }
|
---|
98 | ok = DrgDeleteStrHandle(pDItem->hstrTargetName);
|
---|
99 | if (!ok) {
|
---|
100 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
101 | "DrgDeleteStrHandle(0x%x) hstrTargetName",pDItem->hstrTargetName);
|
---|
102 | }
|
---|
103 | }
|
---|
104 | } // for
|
---|
105 | # endif
|
---|
106 | if (!DrgFreeDraginfo(pDInfo)) {
|
---|
107 | // PMERR_SOURCE_SAME_AS_TARGET is not an error if dragging within same fm/2 process
|
---|
108 | if (!IsFm2Window(pDInfo->hwndSource, FALSE) ||
|
---|
109 | (WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) != PMERR_SOURCE_SAME_AS_TARGET)
|
---|
110 | {
|
---|
111 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DrgFreeDraginfo");
|
---|
112 | }
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | HWND DragOne(HWND hwndCnr, HWND hwndObj, CHAR * filename, BOOL moveok)
|
---|
117 | {
|
---|
118 |
|
---|
119 | DRAGITEM DItem;
|
---|
120 | HWND hDrop = 0;
|
---|
121 | DRAGIMAGE fakeicon;
|
---|
122 | PDRAGINFO pDInfo;
|
---|
123 | FILESTATUS3 fs3;
|
---|
124 | CHAR szDir[CCHMAXPATH], szFile[CCHMAXPATH], *p;
|
---|
125 |
|
---|
126 | if (filename && *filename) {
|
---|
127 | if ((IsRoot(filename) && IsValidDrive(*filename)) ||
|
---|
128 | !DosQueryPathInfo(filename, FIL_STANDARD, &fs3, sizeof(fs3))) {
|
---|
129 | strcpy(szDir, filename);
|
---|
130 | p = szDir;
|
---|
131 | while (*p) {
|
---|
132 | if (*p == '/')
|
---|
133 | *p = '\\';
|
---|
134 | p++;
|
---|
135 | }
|
---|
136 | p = strrchr(szDir, '\\');
|
---|
137 | if (p) {
|
---|
138 | *p = 0;
|
---|
139 | p++;
|
---|
140 | strcpy(szFile, p);
|
---|
141 | strcat(szDir, "\\");
|
---|
142 | }
|
---|
143 | else {
|
---|
144 | strcpy(szFile, filename);
|
---|
145 | *szDir = 0;
|
---|
146 | }
|
---|
147 | memset(&fakeicon, 0, sizeof(DRAGIMAGE));
|
---|
148 | fakeicon.hImage = (IsRoot(filename) ||
|
---|
149 | (fs3.attrFile & FILE_DIRECTORY) != 0) ?
|
---|
150 | hptrDir : hptrFile;
|
---|
151 | memset(&DItem, 0, sizeof(DRAGITEM));
|
---|
152 | DItem.hwndItem = (hwndObj) ? hwndObj : hwndCnr; // Initialize DRAGITEM
|
---|
153 | // DItem.hwndItem = hwndCnr;
|
---|
154 | DItem.ulItemID = 1;
|
---|
155 | DItem.hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
156 | DItem.hstrRMF = DrgAddStrHandle(DRMDRFLIST);
|
---|
157 | DItem.hstrContainerName = DrgAddStrHandle(szDir);
|
---|
158 | DItem.hstrSourceName = DrgAddStrHandle(szFile);
|
---|
159 | if (!DItem.hstrSourceName)
|
---|
160 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
161 | "DrgQueryStrName");
|
---|
162 | DItem.hstrTargetName = DrgAddStrHandle(szFile);
|
---|
163 | DItem.fsControl = 0;
|
---|
164 | if (IsRoot(filename) || (fs3.attrFile & FILE_DIRECTORY) != 0)
|
---|
165 | DItem.fsControl |= DC_CONTAINER;
|
---|
166 | if (IsFullName(filename) &&
|
---|
167 | (driveflags[toupper(*filename) - 'A'] & DRIVE_REMOVABLE))
|
---|
168 | DItem.fsControl |= DC_REMOVEABLEMEDIA;
|
---|
169 | DItem.fsSupportedOps = DO_COPYABLE | DO_LINKABLE;
|
---|
170 | if (moveok && IsFullName(filename) &&
|
---|
171 | !(driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE))
|
---|
172 | DItem.fsSupportedOps |= DO_MOVEABLE;
|
---|
173 | if (IsRoot(filename))
|
---|
174 | DItem.fsSupportedOps = DO_LINKABLE;
|
---|
175 | fakeicon.cb = sizeof(DRAGIMAGE);
|
---|
176 | fakeicon.cptl = 0;
|
---|
177 | fakeicon.fl = DRG_ICON;
|
---|
178 | fakeicon.sizlStretch.cx = 32;
|
---|
179 | fakeicon.sizlStretch.cy = 32;
|
---|
180 | fakeicon.cxOffset = -16;
|
---|
181 | fakeicon.cyOffset = 0;
|
---|
182 | pDInfo = DrgAllocDraginfo(1);
|
---|
183 | if (pDInfo) {
|
---|
184 | if (IsFullName(filename) &&
|
---|
185 | (driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE))
|
---|
186 | pDInfo->usOperation = DO_COPY;
|
---|
187 | else
|
---|
188 | pDInfo->usOperation = DO_DEFAULT;
|
---|
189 | if (IsRoot(filename))
|
---|
190 | pDInfo->usOperation = DO_LINK;
|
---|
191 | pDInfo->hwndSource = (hwndObj) ? hwndObj : hwndCnr;
|
---|
192 | // pDInfo->hwndSource = hwndCnr;
|
---|
193 | DrgSetDragitem(pDInfo, &DItem, sizeof(DRAGITEM), 0);
|
---|
194 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
---|
195 | hDrop = DrgDrag(hwndCnr,
|
---|
196 | pDInfo,
|
---|
197 | &fakeicon,
|
---|
198 | 1, // DragImage count
|
---|
199 | VK_ENDDRAG, // Drag end button
|
---|
200 | NULL);
|
---|
201 | if (hDrop == NULLHANDLE)
|
---|
202 | FreeDragInfoData(hwndCnr, pDInfo);
|
---|
203 | WinSetWindowPos(hwndCnr, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
204 | }
|
---|
205 | }
|
---|
206 | }
|
---|
207 | return hDrop;
|
---|
208 | }
|
---|
209 |
|
---|
210 | HWND DoFileDrag(HWND hwndCnr, HWND hwndObj, PCNRDRAGINIT pcd, CHAR * arcfile,
|
---|
211 | CHAR * directory, BOOL moveok)
|
---|
212 | {
|
---|
213 | // Drag files from a container
|
---|
214 |
|
---|
215 | BOOL isdir, rooting = FALSE;
|
---|
216 | PCNRITEM pci;
|
---|
217 | CHAR *p;
|
---|
218 | INT attribute = CRA_CURSORED;
|
---|
219 | PDRAGINFO pDInfo = NULL;
|
---|
220 | DRAGITEM **ppDItem = NULL, **ppDITest;
|
---|
221 | DRAGITEM *pDItem;
|
---|
222 | PCNRITEM pciRec = (PCNRITEM) pcd->pRecord;
|
---|
223 | HWND hDrop = NULLHANDLE;
|
---|
224 | ULONG ulNumfiles = 0, ulNumDIAlloc = 0, ulSelect, ulNumIcon = 0;
|
---|
225 | CHAR szFile[CCHMAXPATH], szBuffer[CCHMAXPATH];
|
---|
226 | DRAGIMAGE *paDImgIcons = NULL, *pDImg, dimgFakeIcon;
|
---|
227 | BOOL ok;
|
---|
228 | UINT c;
|
---|
229 | DIRCNRDATA *dcd;
|
---|
230 |
|
---|
231 | static BOOL first_drag = TRUE;
|
---|
232 |
|
---|
233 | // Count items to unhilite, pass to UnHilite when partial unhilite required
|
---|
234 | dcd = INSTDATA(hwndCnr);
|
---|
235 | dcd->ulItemsToUnHilite = 0;
|
---|
236 | if (!pciRec && directory && *directory)
|
---|
237 | return DragOne(hwndCnr, hwndObj, directory, moveok);
|
---|
238 |
|
---|
239 | if (!pciRec) {
|
---|
240 | pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
241 | MPFROMLONG(CMA_FIRST),
|
---|
242 | MPFROMSHORT(attribute));
|
---|
243 | if (pci && (INT) pci > -1) {
|
---|
244 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
245 | attribute = CRA_SELECTED;
|
---|
246 | pci =
|
---|
247 | WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
248 | MPFROMSHORT(attribute));
|
---|
249 | }
|
---|
250 | }
|
---|
251 | }
|
---|
252 | else {
|
---|
253 | pci = pciRec;
|
---|
254 | attribute = (pci->rc.flRecordAttr & CRA_SELECTED) ? CRA_SELECTED : 0;
|
---|
255 | if (attribute) {
|
---|
256 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
|
---|
257 | MPFROMSHORT(attribute));
|
---|
258 | }
|
---|
259 | }
|
---|
260 |
|
---|
261 | ulSelect = 0;
|
---|
262 | while (pci && (INT) pci > -1) {
|
---|
263 | if (!(pci->rc.flRecordAttr & CRA_FILTERED)) {
|
---|
264 | if (IsRoot(pci->pszFileName) && !IsValidDrive(*pci->pszFileName))
|
---|
265 | goto Continuing;
|
---|
266 | if (!arcfile) {
|
---|
267 | strcpy(szBuffer, pci->pszFileName);
|
---|
268 | p = strrchr(szBuffer, '\\');
|
---|
269 | if (p) {
|
---|
270 | p++;
|
---|
271 | strcpy(szFile, p);
|
---|
272 | *p = 0;
|
---|
273 | }
|
---|
274 | else
|
---|
275 | goto Continuing;
|
---|
276 | }
|
---|
277 | else
|
---|
278 | strcpy(szFile, pci->pszFileName);
|
---|
279 | }
|
---|
280 | if (!arcfile) {
|
---|
281 | // Filesystem object
|
---|
282 | isdir = pci->attrFile & FILE_DIRECTORY;
|
---|
283 | // fixme to expand smarter - expand fast at first - do same for similar code
|
---|
284 | if (ulNumfiles + 2 > ulNumDIAlloc) {
|
---|
285 | // Expand
|
---|
286 | if (!paDImgIcons) {
|
---|
287 | pDImg =
|
---|
288 | xrealloc(paDImgIcons, sizeof(DRAGIMAGE) * (ulNumDIAlloc + 4L),
|
---|
289 | pszSrcFile, __LINE__);
|
---|
290 | if (!pDImg)
|
---|
291 | break;
|
---|
292 | paDImgIcons = pDImg;
|
---|
293 | }
|
---|
294 | else if (!ulNumIcon) {
|
---|
295 | pDImg = &paDImgIcons[ulNumfiles];
|
---|
296 | pDImg->cb = sizeof(DRAGIMAGE);
|
---|
297 | pDImg->cptl = 0;
|
---|
298 | pDImg->hImage = hptrLast;
|
---|
299 | pDImg->fl = DRG_ICON;
|
---|
300 | pDImg->sizlStretch.cx = 32;
|
---|
301 | pDImg->sizlStretch.cy = 32;
|
---|
302 | pDImg->cxOffset = -16 + (ulNumfiles * 4);
|
---|
303 | pDImg->cyOffset = 0 + (ulNumfiles * 7);
|
---|
304 | ulNumIcon = ulNumfiles + 1;
|
---|
305 | }
|
---|
306 | ppDITest =
|
---|
307 | xrealloc(ppDItem, sizeof(DRAGITEM *) * (ulNumDIAlloc + 4L),
|
---|
308 | pszSrcFile, __LINE__);
|
---|
309 | if (!ppDITest)
|
---|
310 | break;
|
---|
311 | ppDItem = ppDITest;
|
---|
312 | ulNumDIAlloc += 4L;
|
---|
313 | }
|
---|
314 | // Create & Initialize DRAGITEM
|
---|
315 | pDItem = xmallocz(sizeof(DRAGITEM), pszSrcFile, __LINE__);
|
---|
316 | if (!pDItem)
|
---|
317 | break; // Already complained
|
---|
318 | ppDItem[ulNumfiles] = pDItem;
|
---|
319 | if (!ulNumIcon) {
|
---|
320 | pDImg = &paDImgIcons[ulNumfiles];
|
---|
321 | pDImg->cb = sizeof(DRAGIMAGE);
|
---|
322 | pDImg->cptl = 0;
|
---|
323 | pDImg->hImage = pci->rc.hptrIcon;
|
---|
324 | if (!pDImg->hImage)
|
---|
325 | pDImg->hImage = isdir ? hptrDir : hptrFile;
|
---|
326 | pDImg->fl = DRG_ICON;
|
---|
327 | pDImg->sizlStretch.cx = 32;
|
---|
328 | pDImg->sizlStretch.cy = 32;
|
---|
329 | pDImg->cxOffset = -16 + (ulNumfiles * 3);
|
---|
330 | pDImg->cyOffset = 0 + (ulNumfiles * 6);
|
---|
331 | }
|
---|
332 | pDItem->hwndItem = (hwndObj) ? hwndObj : hwndCnr;
|
---|
333 | pDItem->hwndItem = hwndCnr;
|
---|
334 | pDItem->ulItemID = (ULONG) pci;
|
---|
335 | pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
336 | ok = pDItem->hstrType;
|
---|
337 | pDItem->hstrRMF = DrgAddStrHandle(DRMDRFLIST);
|
---|
338 | ok = ok && pDItem->hstrRMF;
|
---|
339 | pDItem->hstrContainerName = DrgAddStrHandle(szBuffer);
|
---|
340 | ok = ok && pDItem->hstrContainerName;
|
---|
341 | pDItem->hstrSourceName = DrgAddStrHandle(szFile);
|
---|
342 | ok = ok && pDItem->hstrSourceName;
|
---|
343 | pDItem->hstrTargetName = DrgAddStrHandle(szFile);
|
---|
344 | ok = ok && pDItem->hstrTargetName;
|
---|
345 | if (!ok) {
|
---|
346 | DbgMsg(pszSrcFile, __LINE__, "DrgAddStrHandle failed at %lu for %s", ulNumfiles, szFile);
|
---|
347 | // If we have string handle add overflow, release corrupt DragItem
|
---|
348 | // We release 3 more to work around 1st time drag failure reported by Gregg
|
---|
349 | // fixme to know why this happens - PM may need to create a handle?
|
---|
350 | c = first_drag ? 4 : 1;
|
---|
351 | first_drag = FALSE;
|
---|
352 | for (; c > 0 && ulNumfiles > 0; c--) {
|
---|
353 | if (pDItem->hstrType)
|
---|
354 | DrgDeleteStrHandle(pDItem->hstrType);
|
---|
355 | if (pDItem->hstrRMF)
|
---|
356 | DrgDeleteStrHandle(pDItem->hstrRMF);
|
---|
357 | if (pDItem->hstrContainerName)
|
---|
358 | DrgDeleteStrHandle(pDItem->hstrContainerName);
|
---|
359 | if (pDItem->hstrSourceName)
|
---|
360 | DrgDeleteStrHandle(pDItem->hstrSourceName);
|
---|
361 | if (pDItem->hstrTargetName)
|
---|
362 | DrgDeleteStrHandle(pDItem->hstrTargetName);
|
---|
363 | free(pDItem);
|
---|
364 | // Last item not yet count so only decrement by one less than loop count
|
---|
365 | // Unhilite code will adjust this when unhighliting
|
---|
366 | if (c > 1) {
|
---|
367 | ulNumfiles--;
|
---|
368 | pDItem = ppDItem[ulNumfiles];
|
---|
369 | }
|
---|
370 | }
|
---|
371 | // Set count to actual count + 1 to ensure count non-zero on any failure
|
---|
372 | dcd->ulItemsToUnHilite = ulNumfiles + 1;
|
---|
373 | break;
|
---|
374 | }
|
---|
375 | pDItem->fsControl = isdir ? DC_CONTAINER : 0;
|
---|
376 | if (IsFullName(pci->pszFileName) &&
|
---|
377 | (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE))
|
---|
378 | pDItem->fsControl |= DC_REMOVEABLEMEDIA;
|
---|
379 | pDItem->fsSupportedOps = DO_COPYABLE | DO_LINKABLE;
|
---|
380 | if (moveok && IsFullName(pci->pszFileName) &&
|
---|
381 | !(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
382 | DRIVE_NOTWRITEABLE))
|
---|
383 | pDItem->fsSupportedOps |= DO_MOVEABLE;
|
---|
384 | if (IsRoot(pci->pszFileName)) {
|
---|
385 | pDItem->fsSupportedOps = DO_LINKABLE;
|
---|
386 | rooting = TRUE;
|
---|
387 | }
|
---|
388 | ulNumfiles++;
|
---|
389 | // ppDItem[ulNumfiles] = NULL; // Why bother - can't we count - fixme to be gone?
|
---|
390 | } // if filesystem object
|
---|
391 | else {
|
---|
392 | // Archive object
|
---|
393 | if (ulNumfiles + 3L > ulNumDIAlloc) {
|
---|
394 | ppDITest =
|
---|
395 | xrealloc(ppDItem, sizeof(DRAGITEM *) * (ulNumDIAlloc + 5L),
|
---|
396 | pszSrcFile, __LINE__);
|
---|
397 | if (!ppDITest)
|
---|
398 | break;
|
---|
399 | ppDItem = ppDITest;
|
---|
400 | ulNumDIAlloc += 5L;
|
---|
401 | }
|
---|
402 | // Create & Initialize DRAGITEM
|
---|
403 | pDItem = xmallocz(sizeof(DRAGITEM), pszSrcFile, __LINE__);
|
---|
404 | if (!pDItem)
|
---|
405 | break;
|
---|
406 | ppDItem[ulNumfiles] = pDItem;
|
---|
407 | dimgFakeIcon.hImage = hptrFile;
|
---|
408 | pDItem->hwndItem = (hwndObj) ? hwndObj : hwndCnr;
|
---|
409 | pDItem->hwndItem = hwndCnr;
|
---|
410 | pDItem->ulItemID = (ULONG) pci;
|
---|
411 | pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
412 | ok = pDItem->hstrType;
|
---|
413 | pDItem->hstrRMF = DrgAddStrHandle(DRMDRFOS2FILE);
|
---|
414 | ok = ok && pDItem->hstrRMF;
|
---|
415 | pDItem->hstrContainerName = DrgAddStrHandle(arcfile);
|
---|
416 | ok = ok && pDItem->hstrContainerName;
|
---|
417 | pDItem->hstrSourceName = DrgAddStrHandle(szFile);
|
---|
418 | ok = ok && pDItem->hstrSourceName;
|
---|
419 | pDItem->hstrTargetName = DrgAddStrHandle(szFile);
|
---|
420 | ok = ok && pDItem->hstrTargetName;
|
---|
421 | if (!ok){
|
---|
422 | if (pDItem->hstrType)
|
---|
423 | DrgDeleteStrHandle(pDItem->hstrType);
|
---|
424 | if (pDItem->hstrRMF)
|
---|
425 | DrgDeleteStrHandle(pDItem->hstrRMF);
|
---|
426 | if (pDItem->hstrContainerName)
|
---|
427 | DrgDeleteStrHandle(pDItem->hstrContainerName);
|
---|
428 | if (pDItem->hstrSourceName)
|
---|
429 | DrgDeleteStrHandle(pDItem->hstrSourceName);
|
---|
430 | if (pDItem->hstrTargetName)
|
---|
431 | DrgDeleteStrHandle(pDItem->hstrTargetName);
|
---|
432 | free(pDItem);
|
---|
433 | dcd->ulItemsToUnHilite = ulNumfiles + 1; // +1 to ensure non-zero
|
---|
434 | break;
|
---|
435 | }
|
---|
436 | pDItem->fsControl = DC_PREPARE;
|
---|
437 | if (IsFullName(arcfile) &&
|
---|
438 | (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE))
|
---|
439 | pDItem->fsControl |= DC_REMOVEABLEMEDIA;
|
---|
440 | pDItem->fsSupportedOps = DO_COPYABLE;
|
---|
441 | ulNumfiles++;
|
---|
442 | // Create & Initialize DRAGITEM
|
---|
443 | pDItem = xmallocz(sizeof(DRAGITEM), pszSrcFile, __LINE__);
|
---|
444 | if (pDItem) {
|
---|
445 | ppDItem[ulNumfiles] = pDItem;
|
---|
446 | dimgFakeIcon.hImage = hptrFile;
|
---|
447 | pDItem->hwndItem = (hwndObj) ? hwndObj : hwndCnr;
|
---|
448 | pDItem->hwndItem = hwndCnr;
|
---|
449 | pDItem->ulItemID = ulSelect++;
|
---|
450 | pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
451 | ok = ok && pDItem->hstrType;
|
---|
452 | pDItem->hstrRMF = DrgAddStrHandle(DRMDRFFM2ARC);
|
---|
453 | ok = ok && pDItem->hstrRMF;
|
---|
454 | pDItem->hstrContainerName = DrgAddStrHandle(arcfile);
|
---|
455 | ok = ok && pDItem->hstrContainerName;
|
---|
456 | pDItem->hstrSourceName = DrgAddStrHandle(szFile);
|
---|
457 | ok = ok && pDItem->hstrSourceName;
|
---|
458 | pDItem->hstrTargetName = DrgAddStrHandle(szFile);
|
---|
459 | ok = ok && pDItem->hstrTargetName;
|
---|
460 | if (!ok) {
|
---|
461 | DbgMsg(pszSrcFile, __LINE__, "DrgAddStrHandle failed at %lu for %s", ulNumfiles, szFile);
|
---|
462 | // If we have string handle add overflow, release corrupt DragItem
|
---|
463 | // We release 3 more to work around 1st time drag failure reported by Gregg
|
---|
464 | // fixme to know why this happens - PM may need to create a handle?
|
---|
465 | c = first_drag ? 4 : 1;
|
---|
466 | first_drag = FALSE;
|
---|
467 | for (; c > 0 && ulNumfiles > 0; c--) {
|
---|
468 | if (pDItem->hstrType)
|
---|
469 | DrgDeleteStrHandle(pDItem->hstrType);
|
---|
470 | if (pDItem->hstrRMF)
|
---|
471 | DrgDeleteStrHandle(pDItem->hstrRMF);
|
---|
472 | if (pDItem->hstrContainerName)
|
---|
473 | DrgDeleteStrHandle(pDItem->hstrContainerName);
|
---|
474 | if (pDItem->hstrSourceName)
|
---|
475 | DrgDeleteStrHandle(pDItem->hstrSourceName);
|
---|
476 | if (pDItem->hstrTargetName)
|
---|
477 | DrgDeleteStrHandle(pDItem->hstrTargetName);
|
---|
478 | free(pDItem);
|
---|
479 | // Last item not yet count so only decrement by one less than loop count
|
---|
480 | if (c > 1) {
|
---|
481 | ulNumfiles--;
|
---|
482 | pDItem = ppDItem[ulNumfiles];
|
---|
483 | }
|
---|
484 | }
|
---|
485 | // Set count to actual count + 1 to ensure count non-zero on any failure
|
---|
486 | // Unhilite code will adjust this when unhighliting
|
---|
487 | dcd->ulItemsToUnHilite = ulNumfiles + 1;
|
---|
488 | break;
|
---|
489 | }
|
---|
490 | pDItem->fsControl = 0;
|
---|
491 | if (IsFullName(arcfile) &&
|
---|
492 | (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE))
|
---|
493 | pDItem->fsControl |= DC_REMOVEABLEMEDIA;
|
---|
494 | pDItem->fsSupportedOps = DO_COPYABLE;
|
---|
495 | ulNumfiles++;
|
---|
496 | }
|
---|
497 | // ppDItem[ulNumfiles] = NULL; // Why bother - fixme to be gone?
|
---|
498 | } // if archive object
|
---|
499 | WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
500 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
---|
501 |
|
---|
502 | Continuing:
|
---|
503 |
|
---|
504 | if (!attribute)
|
---|
505 | break;
|
---|
506 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci),
|
---|
507 | MPFROMSHORT(attribute));
|
---|
508 | } // while
|
---|
509 |
|
---|
510 | if (ulNumfiles) {
|
---|
511 | pDInfo = DrgAllocDraginfo(ulNumfiles);
|
---|
512 | if (pDInfo) {
|
---|
513 | if ((arcfile && *arcfile) || (IsFullName(szBuffer) &&
|
---|
514 | (driveflags[toupper(*szBuffer) - 'A'] &
|
---|
515 | DRIVE_NOTWRITEABLE)))
|
---|
516 | pDInfo->usOperation = DO_COPY;
|
---|
517 | else
|
---|
518 | pDInfo->usOperation = DO_DEFAULT;
|
---|
519 | if ((!arcfile || !*arcfile) && rooting)
|
---|
520 | pDInfo->usOperation = DO_LINK;
|
---|
521 | pDInfo->hwndSource = (hwndObj) ? hwndObj : hwndCnr;
|
---|
522 | // pDInfo->hwndSource = hwndCnr;
|
---|
523 | for (ulSelect = 0; ulSelect < ulNumfiles; ulSelect++) {
|
---|
524 | DrgSetDragitem(pDInfo, ppDItem[ulSelect], sizeof(DRAGITEM), ulSelect);
|
---|
525 | xfree(ppDItem[ulSelect], pszSrcFile, __LINE__);
|
---|
526 | }
|
---|
527 | #ifdef __DEBUG_ALLOC__
|
---|
528 | _heap_check();
|
---|
529 | #endif
|
---|
530 | xfree(ppDItem, pszSrcFile, __LINE__);
|
---|
531 | ppDItem = NULL; // Remember gone
|
---|
532 | DosPostEventSem(CompactSem);
|
---|
533 |
|
---|
534 | if (arcfile) {
|
---|
535 | dimgFakeIcon.cb = sizeof(DRAGIMAGE);
|
---|
536 | dimgFakeIcon.cptl = 0;
|
---|
537 | if (ulNumfiles > 1)
|
---|
538 | dimgFakeIcon.hImage = hptrFile;
|
---|
539 | dimgFakeIcon.fl = DRG_ICON;
|
---|
540 | dimgFakeIcon.sizlStretch.cx = 32;
|
---|
541 | dimgFakeIcon.sizlStretch.cy = 32;
|
---|
542 | dimgFakeIcon.cxOffset = -16;
|
---|
543 | dimgFakeIcon.cyOffset = 0;
|
---|
544 | paDImgIcons = &dimgFakeIcon;
|
---|
545 | }
|
---|
546 | if (!arcfile) {
|
---|
547 | if (!ulNumIcon)
|
---|
548 | ulNumIcon = ulNumfiles;
|
---|
549 | }
|
---|
550 | else
|
---|
551 | ulNumIcon = 1;
|
---|
552 |
|
---|
553 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
---|
554 | hDrop = DrgDrag(hwndCnr,
|
---|
555 | pDInfo,
|
---|
556 | paDImgIcons,
|
---|
557 | ulNumIcon,
|
---|
558 | VK_ENDDRAG, // Drag end button
|
---|
559 | NULL);
|
---|
560 | WinSetWindowPos(hwndCnr, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
561 | }
|
---|
562 | }
|
---|
563 |
|
---|
564 | if (hDrop == NULLHANDLE ) {
|
---|
565 | dcd->ulItemsToUnHilite = 0;
|
---|
566 | if (pDInfo)
|
---|
567 | FreeDragInfoData(hwndCnr, pDInfo);
|
---|
568 | }
|
---|
569 | xfree(ppDItem, pszSrcFile, __LINE__);
|
---|
570 | if (paDImgIcons && paDImgIcons != &dimgFakeIcon)
|
---|
571 | free(paDImgIcons);
|
---|
572 | DosPostEventSem(CompactSem);
|
---|
573 | MarkAll(hwndCnr, TRUE, FALSE, TRUE);
|
---|
574 | return hDrop;
|
---|
575 | }
|
---|
576 |
|
---|
577 | HWND DragList(HWND hwnd, HWND hwndObj, CHAR ** list, BOOL moveok)
|
---|
578 | {
|
---|
579 | // Drag a linked list of files
|
---|
580 |
|
---|
581 | BOOL isdir;
|
---|
582 | register CHAR *p;
|
---|
583 | PDRAGINFO pDInfo = NULL;
|
---|
584 | DRAGITEM **ppDItem = NULL, **ppDITest;
|
---|
585 | DRAGITEM *pDItem;
|
---|
586 | HWND hDrop = (HWND) 0;
|
---|
587 | ULONG ulNumfiles = 0, ulNumDIAlloc = 0, ulSelect, ulNumIcon = 0;
|
---|
588 | CHAR szFile[CCHMAXPATH], szBuffer[CCHMAXPATH];
|
---|
589 | DRAGIMAGE *paDImgIcons = NULL, *pDImg;
|
---|
590 | FILESTATUS3 fs3;
|
---|
591 | BOOL ok;
|
---|
592 | DIRCNRDATA *dcd;
|
---|
593 |
|
---|
594 | if (!list || !list[0])
|
---|
595 | return hDrop;
|
---|
596 |
|
---|
597 | dcd = INSTDATA(hwnd);
|
---|
598 |
|
---|
599 | for (ulSelect = 0; list[ulSelect]; ulSelect++) {
|
---|
600 | if ((!IsRoot(list[ulSelect]) || !IsValidDrive(*list[ulSelect])) &&
|
---|
601 | DosQueryPathInfo(list[ulSelect], FIL_STANDARD, &fs3, sizeof(fs3)))
|
---|
602 | continue;
|
---|
603 | strcpy(szBuffer, list[ulSelect]);
|
---|
604 | p = strrchr(szBuffer, '\\');
|
---|
605 | if (p) {
|
---|
606 | p++;
|
---|
607 | strcpy(szFile, p);
|
---|
608 | *p = 0;
|
---|
609 | }
|
---|
610 | else
|
---|
611 | continue;
|
---|
612 | if (*szFile) {
|
---|
613 | isdir = IsRoot(list[ulSelect]) || fs3.attrFile & FILE_DIRECTORY;
|
---|
614 | // fixme to expand smarter - expand fast at first - do same for similar code
|
---|
615 | if (ulNumfiles + 2 > ulNumDIAlloc) {
|
---|
616 | if (!paDImgIcons) {
|
---|
617 | pDImg =
|
---|
618 | xrealloc(paDImgIcons, sizeof(DRAGIMAGE) * (ulNumDIAlloc + 4L),
|
---|
619 | pszSrcFile, __LINE__);
|
---|
620 | if (!pDImg)
|
---|
621 | break;
|
---|
622 | paDImgIcons = pDImg;
|
---|
623 | }
|
---|
624 | else if (!ulNumIcon) {
|
---|
625 | pDImg = &paDImgIcons[ulNumfiles];
|
---|
626 | pDImg->cb = sizeof(DRAGIMAGE);
|
---|
627 | pDImg->cptl = 0;
|
---|
628 | pDImg->hImage = hptrLast;
|
---|
629 | pDImg->fl = DRG_ICON;
|
---|
630 | pDImg->sizlStretch.cx = 32;
|
---|
631 | pDImg->sizlStretch.cy = 32;
|
---|
632 | pDImg->cxOffset = -16 + (ulNumfiles * 4);
|
---|
633 | pDImg->cyOffset = 0 + (ulNumfiles * 7);
|
---|
634 | ulNumIcon = ulNumfiles + 1;
|
---|
635 | }
|
---|
636 | ppDITest =
|
---|
637 | xrealloc(ppDItem, sizeof(DRAGITEM *) * (ulNumDIAlloc + 4L),
|
---|
638 | pszSrcFile, __LINE__);
|
---|
639 | if (!ppDITest)
|
---|
640 | break;
|
---|
641 | ppDItem = ppDITest;
|
---|
642 | ulNumDIAlloc += 4L;
|
---|
643 | }
|
---|
644 | // Create & Initialize DRAGITEM
|
---|
645 | pDItem = xmallocz(sizeof(DRAGITEM), pszSrcFile, __LINE__);
|
---|
646 | if (!pDItem)
|
---|
647 | break;
|
---|
648 | ppDItem[ulNumfiles] = pDItem;
|
---|
649 | if (!ulNumIcon) {
|
---|
650 | pDImg = &paDImgIcons[ulNumfiles];
|
---|
651 | pDImg->cb = sizeof(DRAGIMAGE);
|
---|
652 | pDImg->cptl = 0;
|
---|
653 | pDImg->hImage = isdir ? hptrDir : hptrFile;
|
---|
654 | pDImg->fl = DRG_ICON;
|
---|
655 | pDImg->sizlStretch.cx = 32;
|
---|
656 | pDImg->sizlStretch.cy = 32;
|
---|
657 | pDImg->cxOffset = -16 + (ulNumfiles * 3);
|
---|
658 | pDImg->cyOffset = 0 + (ulNumfiles * 6);
|
---|
659 | }
|
---|
660 | pDItem->hwndItem = (hwndObj) ? hwndObj : hwnd;
|
---|
661 | pDItem->ulItemID = (ULONG) ulSelect;
|
---|
662 | pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
663 | ok = pDItem->hstrType;
|
---|
664 | pDItem->hstrRMF = DrgAddStrHandle(DRMDRFLIST);
|
---|
665 | ok = ok && pDItem->hstrRMF;
|
---|
666 | pDItem->hstrContainerName = DrgAddStrHandle(szBuffer);
|
---|
667 | ok = ok && pDItem->hstrContainerName;
|
---|
668 | pDItem->hstrSourceName = DrgAddStrHandle(szFile);
|
---|
669 | ok = ok && pDItem->hstrSourceName;
|
---|
670 | pDItem->hstrTargetName = DrgAddStrHandle(szFile);
|
---|
671 | ok = ok && pDItem->hstrTargetName;
|
---|
672 | if (!ok) {
|
---|
673 | if (pDItem->hstrType)
|
---|
674 | DrgDeleteStrHandle(pDItem->hstrType);
|
---|
675 | if (pDItem->hstrRMF)
|
---|
676 | DrgDeleteStrHandle(pDItem->hstrRMF);
|
---|
677 | if (pDItem->hstrContainerName)
|
---|
678 | DrgDeleteStrHandle(pDItem->hstrContainerName);
|
---|
679 | if (pDItem->hstrSourceName)
|
---|
680 | DrgDeleteStrHandle(pDItem->hstrSourceName);
|
---|
681 | if (pDItem->hstrTargetName)
|
---|
682 | DrgDeleteStrHandle(pDItem->hstrTargetName);
|
---|
683 | free(pDItem);
|
---|
684 | // pDItem = NULL; // Why bother, we can count - fixme to be gone
|
---|
685 | dcd->ulItemsToUnHilite = ulNumfiles + 1;
|
---|
686 | break;
|
---|
687 | }
|
---|
688 | pDItem->fsControl = isdir ? DC_CONTAINER : 0;
|
---|
689 | if (IsFullName(list[ulSelect]) &&
|
---|
690 | (driveflags[toupper(*list[ulSelect]) - 'A'] & DRIVE_REMOVABLE))
|
---|
691 | pDItem->fsControl |= DC_REMOVEABLEMEDIA;
|
---|
692 | pDItem->fsSupportedOps = DO_COPYABLE | DO_LINKABLE;
|
---|
693 | if (moveok && IsFullName(list[ulSelect]) &&
|
---|
694 | !(driveflags[toupper(*list[ulSelect]) - 'A'] & DRIVE_NOTWRITEABLE))
|
---|
695 | pDItem->fsSupportedOps |= DO_MOVEABLE;
|
---|
696 | if (IsRoot(list[ulSelect]))
|
---|
697 | pDItem->fsControl = DO_LINKABLE;
|
---|
698 | ulNumfiles++;
|
---|
699 | // ppDItem[ulNumfiles] = NULL; // Why bother - fixme to be gone
|
---|
700 | }
|
---|
701 | } // for
|
---|
702 | if (ulNumfiles) {
|
---|
703 | pDInfo = DrgAllocDraginfo(ulNumfiles);
|
---|
704 | if (pDInfo) {
|
---|
705 | if ((IsFullName(szBuffer) &&
|
---|
706 | (driveflags[toupper(*szBuffer) - 'A'] & DRIVE_NOTWRITEABLE)))
|
---|
707 | pDInfo->usOperation = DO_COPY;
|
---|
708 | else
|
---|
709 | pDInfo->usOperation = DO_DEFAULT;
|
---|
710 | if (IsRoot(list[0]))
|
---|
711 | pDInfo->usOperation = DO_LINK;
|
---|
712 | pDInfo->hwndSource = hwndObj ? hwndObj : hwnd;
|
---|
713 | // pDInfo->hwndSource = hwnd;
|
---|
714 | for (ulSelect = 0; ulSelect < ulNumfiles; ulSelect++) {
|
---|
715 | if (!DrgSetDragitem(pDInfo, ppDItem[ulSelect], sizeof(DRAGITEM), ulSelect)) {
|
---|
716 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
717 | "DrgSetDragitem");
|
---|
718 | }
|
---|
719 | xfree(ppDItem[ulSelect], pszSrcFile, __LINE__);
|
---|
720 | } // for
|
---|
721 | #ifdef __DEBUG_ALLOC__
|
---|
722 | _heap_check();
|
---|
723 | #endif
|
---|
724 | xfree(ppDItem, pszSrcFile, __LINE__);
|
---|
725 | ppDItem = NULL; // Remember gone
|
---|
726 | DosPostEventSem(CompactSem);
|
---|
727 |
|
---|
728 | if (!ulNumIcon)
|
---|
729 | ulNumIcon = ulNumfiles;
|
---|
730 |
|
---|
731 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
---|
732 | hDrop = DrgDrag(hwnd,
|
---|
733 | pDInfo,
|
---|
734 | paDImgIcons,
|
---|
735 | ulNumIcon,
|
---|
736 | VK_ENDDRAG, // Drag end button
|
---|
737 | (PVOID) NULL);
|
---|
738 | if (hDrop == NULLHANDLE) {
|
---|
739 | dcd->ulItemsToUnHilite = 0;
|
---|
740 | FreeDragInfoData(hwnd, pDInfo);
|
---|
741 | }
|
---|
742 | xfree(paDImgIcons, pszSrcFile, __LINE__);
|
---|
743 | paDImgIcons = NULL; // Remember gone
|
---|
744 | WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
745 | DosPostEventSem(CompactSem);
|
---|
746 | }
|
---|
747 | }
|
---|
748 | xfree(ppDItem, pszSrcFile, __LINE__);
|
---|
749 | xfree(paDImgIcons, pszSrcFile, __LINE__);
|
---|
750 | return hDrop;
|
---|
751 | }
|
---|
752 |
|
---|
753 | #ifdef NEVER // fixme to be enabled someday?
|
---|
754 |
|
---|
755 | BOOL PickUp(HWND hwndCnr, HWND hwndObj, PCNRDRAGINIT pcd)
|
---|
756 | {
|
---|
757 |
|
---|
758 | PCNRITEM pci;
|
---|
759 | BOOL loop = TRUE;
|
---|
760 | PDRAGINFO pdinfoOld = NULL, pdinfoCurrent = NULL;
|
---|
761 | ULONG cditem = 0;
|
---|
762 | DRAGITEM ditem;
|
---|
763 | DRAGIMAGE dimgFakeIcon;
|
---|
764 | CHAR szDir[CCHMAXPATH], szFile[CCHMAXPATH], *p;
|
---|
765 |
|
---|
766 | pci = (PCNRITEM) pcd->pRecord;
|
---|
767 | if (pci && (INT) pci != -1) {
|
---|
768 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
769 | loop = TRUE;
|
---|
770 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
771 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_SELECTED));
|
---|
772 | }
|
---|
773 | while (pci && (INT) pci != -1 && *pci->pszFileName) {
|
---|
774 | if (pdinfoOld || DrgQueryDragStatus() & DGS_LAZYDRAGINPROGRESS) {
|
---|
775 | if (!pdinfoOld)
|
---|
776 | pdinfoOld = DrgQueryDraginfoPtr(NULL);
|
---|
777 | if (pdinfoOld) {
|
---|
778 | cditem = pdinfoOld->cditem + 1;
|
---|
779 | pdinfoCurrent = DrgReallocDraginfo(pdinfoOld, cditem);
|
---|
780 | pdinfoOld = pdinfoCurrent;
|
---|
781 | }
|
---|
782 | }
|
---|
783 | else
|
---|
784 | pdinfoCurrent = pdinfoOld = DrgAllocDraginfo(1);
|
---|
785 | if (pdinfoCurrent) {
|
---|
786 | strcpy(szDir, pci->pszFileName);
|
---|
787 | p = szDir;
|
---|
788 | while (*p) {
|
---|
789 | if (*p == '/')
|
---|
790 | *p = '\\';
|
---|
791 | p++;
|
---|
792 | }
|
---|
793 | p = strrchr(szDir, '\\');
|
---|
794 | if (p) {
|
---|
795 | *p = 0;
|
---|
796 | p++;
|
---|
797 | strcpy(szFile, p);
|
---|
798 | strcat(szDir, "\\");
|
---|
799 | }
|
---|
800 | else {
|
---|
801 | strcpy(szFile, pci->pszFileName);
|
---|
802 | *szDir = 0;
|
---|
803 | }
|
---|
804 | ditem.ulItemID = (ULONG) pci;
|
---|
805 | ditem.hwndItem = (hwndObj) ? hwndObj : hwndCnr;
|
---|
806 | ditem.hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
807 | ditem.hstrRMF = DrgAddStrHandle(DRMDRFLIST);
|
---|
808 | ditem.hstrContainerName = DrgAddStrHandle(szDir);
|
---|
809 | ditem.hstrSourceName = DrgAddStrHandle(szFile);
|
---|
810 | // fixme to check better if code ever enabled
|
---|
811 | if (!ditem.hstrSourceName) {
|
---|
812 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
813 | "DrgAddStrHandle");
|
---|
814 | }
|
---|
815 | ditem.hstrTargetName = DrgAddStrHandle(szFile);
|
---|
816 | ditem.fsControl = 0;
|
---|
817 | if (IsRoot(pci->pszFileName) || (pci->attrFile & FILE_DIRECTORY) != 0)
|
---|
818 | ditem.fsControl |= DC_CONTAINER;
|
---|
819 | if (IsFullName(pci->pszFileName) &&
|
---|
820 | (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE))
|
---|
821 | ditem.fsControl |= DC_REMOVEABLEMEDIA;
|
---|
822 | ditem.fsSupportedOps = DO_COPYABLE | DO_LINKABLE;
|
---|
823 | if (IsFullName(pci->pszFileName) &&
|
---|
824 | !(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
825 | DRIVE_NOTWRITEABLE))
|
---|
826 | ditem.fsSupportedOps |= DO_MOVEABLE;
|
---|
827 | if (IsRoot(pci->pszFileName))
|
---|
828 | ditem.fsSupportedOps = DO_LINKABLE;
|
---|
829 | memset(&dimgFakeIcon, 0, sizeof(DRAGIMAGE));
|
---|
830 | dimgFakeIcon.hImage = pci->rc.hptrIcon;
|
---|
831 | dimgFakeIcon.cb = sizeof(DRAGIMAGE);
|
---|
832 | dimgFakeIcon.cptl = 0;
|
---|
833 | dimgFakeIcon.fl = DRG_ICON;
|
---|
834 | dimgFakeIcon.sizlStretch.cx = 32;
|
---|
835 | dimgFakeIcon.sizlStretch.cy = 32;
|
---|
836 | dimgFakeIcon.cxOffset = -16;
|
---|
837 | dimgFakeIcon.cyOffset = 0;
|
---|
838 | if (IsFullName(pci->pszFileName) &&
|
---|
839 | (driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
840 | DRIVE_NOTWRITEABLE))
|
---|
841 | pdinfoCurrent->usOperation = DO_COPY;
|
---|
842 | else
|
---|
843 | pdinfoCurrent->usOperation = DO_DEFAULT;
|
---|
844 | if (IsRoot(pci->pszFileName))
|
---|
845 | pdinfoCurrent->usOperation = DO_LINK;
|
---|
846 | pdinfoCurrent->hwndSource = (hwndObj) ? hwndObj : hwndCnr;
|
---|
847 | DrgSetDragitem(pdinfoCurrent, &ditem, sizeof(DRAGITEM), cditem);
|
---|
848 | }
|
---|
849 | if (!loop)
|
---|
850 | break;
|
---|
851 | pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
852 | MPFROMP(pci), MPFROMSHORT(CRA_SELECTED));
|
---|
853 | } // while
|
---|
854 | if (pdinfoCurrent)
|
---|
855 | return DrgLazyDrag(hwndCnr, pdinfoCurrent, &dimgFakeIcon, 1, NULL);
|
---|
856 | }
|
---|
857 | return FALSE;
|
---|
858 | }
|
---|
859 |
|
---|
860 | #endif // NEVER
|
---|
861 |
|
---|
862 | #pragma alloc_text(DRAGLIST,DragOne,DoFileDrag,DragList,PickUp,FreeDragInfoData)
|
---|