Changeset 618
- Timestamp:
- Apr 20, 2007, 9:19:03 PM (18 years ago)
- Location:
- trunk/dll
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/arccnrs.c
r606 r618 33 33 14 Mar 07 SHL ArcObjWndProc/UM_ENTER: delay before starting viewer 34 34 30 Mar 07 GKY Remove GetPString for window class names 35 35 06 Apr 07 GKY Work around PM DragInfo and DrgFreeISH limit 36 36 06 Apr 07 GKY Add some error checking in drag/drop 37 20 Apr 07 SHL Sync with NumItemsToUnhilite mods 38 37 39 ***********************************************************************/ 38 40 … … 950 952 switch (msg) { 951 953 case DM_DRAGOVER: 952 if (AcceptOneDrop( mp1, mp2))954 if (AcceptOneDrop(hwnd, mp1, mp2)) 953 955 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 954 956 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */ … … 964 966 DrawTargetEmphasis(hwnd, emphasized); 965 967 } 966 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom)))968 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) 967 969 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 968 970 ARC_CNR), … … 1130 1132 li = DoFileDrop(dcd->hwndCnr, 1131 1133 dcd->directory, FALSE, MPVOID, MPFROMP(&cni)); 1132 if ( fExceedPMDrgLimit)1134 if (NumItemsToUnhilite) 1133 1135 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 1134 1136 hwnd, … … 3006 3008 dcd->hwndObject, 3007 3009 mp2, dcd->arcname, NULL, TRUE)) { 3008 if ((fUnHilite && wasemphasized) || fExceedPMDrgLimit)3010 if ((fUnHilite && wasemphasized) || NumItemsToUnhilite) 3009 3011 UnHilite(hwnd, TRUE, &dcd->lastselection); 3010 3012 } … … 3036 3038 li = DoFileDrop(hwnd, dcd->arcname, FALSE, mp1, mp2); 3037 3039 DosBeep(50, 100); // fixme to know why beep? 3038 if ( fExceedPMDrgLimit)3040 if (NumItemsToUnhilite) 3039 3041 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 3040 3042 hwnd, -
trunk/dll/assoc.c
r552 r618 12 12 10 Sep 06 GKY Add Move to last, Okay adds if new, Replace Current in Listbox Dialog 13 13 19 Oct 06 GKY Rework replace logic 14 18 Feb 07 GKY Movw error messages etc to string file 14 18 Feb 07 GKY Move error messages etc to string file 15 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods 15 16 16 17 **************************************************************************************/ … … 74 75 DrawTargetEmphasis(hwnd, emphasized); 75 76 } 76 if (AcceptOneDrop( mp1, mp2))77 if (AcceptOneDrop(hwnd, mp1, mp2)) 77 78 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 78 79 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 97 98 DrawTargetEmphasis(hwnd, emphasized); 98 99 } 99 if (GetOneDrop( mp1, mp2, szFrom, CCHMAXPATH)) {100 if (GetOneDrop(hwnd, mp1, mp2, szFrom, CCHMAXPATH)) { 100 101 strcat(szFrom, " %a"); 101 102 WinSetWindowText(hwnd, szFrom); -
trunk/dll/avl.c
r603 r618 26 26 01 Nov 06 SHL Turn off leftover debug code 27 27 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limit 28 19 Apr 07 SHL Use FreeDragInfoData 29 19 Apr 07 SHL Add more drag/drop error checking 28 30 29 31 ***********************************************************************/ … … 548 550 PFNWP pfnOldProc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); 549 551 550 PDRAGITEM p ditem;551 PDRAGINFO p dinfo;552 PDRAGITEM pDItem; 553 PDRAGINFO pDInfo; 552 554 BOOL ok; 553 555 … … 568 570 569 571 if (cur_ndx != LIT_NONE) { 570 p dinfo = DrgAllocDraginfo(1);571 if (p dinfo) {572 p dinfo->usOperation = DO_DEFAULT;573 p dinfo->hwndSource = hwnd;572 pDInfo = DrgAllocDraginfo(1); 573 if (pDInfo) { 574 pDInfo->usOperation = DO_DEFAULT; 575 pDInfo->hwndSource = hwnd; 574 576 575 577 memset(&ditem, 0, sizeof(DRAGITEM)); … … 593 595 dimage.cxOffset = -16; 594 596 dimage.cyOffset = 0; 595 DrgSetDragitem(p dinfo, &ditem, sizeof(DRAGITEM), 0); /* Index of DRAGITEM */596 hwndDrop = DrgDrag(hwnd, p dinfo, &dimage, 1, /* One DRAGIMAGE */597 DrgSetDragitem(pDInfo, &ditem, sizeof(DRAGITEM), 0); /* Index of DRAGITEM */ 598 hwndDrop = DrgDrag(hwnd, pDInfo, &dimage, 1, /* One DRAGIMAGE */ 597 599 VK_ENDDRAG, NULL); 598 600 if (!hwndDrop) 599 601 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DrgDrag"); 600 602 601 DrgFreeDraginfo(p dinfo);603 DrgFreeDraginfo(pDInfo); 602 604 // WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ACTIVATE); 603 605 } … … 623 625 // fprintf(stderr, "DRAGOVER posted 0x%x WM_BUTTON1CLICK x y %d %d\n", hwnd, ptl2.x, ptl2.y); 624 626 } 625 pdinfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 626 if (pdinfo) { 627 DrgAccessDraginfo(pdinfo); 628 pditem = DrgQueryDragitemPtr(pdinfo, 0); 629 /* Check valid rendering mechanisms and data format */ 630 ok = DrgVerifyRMF(pditem, DRM_LBOX, NULL); 631 DrgFreeDraginfo(pdinfo); 632 if (ok) { 633 } 634 } 635 return ok ? MRFROM2SHORT(DOR_DROP, DO_MOVE) : MRFROM2SHORT(DOR_NEVERDROP, 636 0); 627 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 628 if (pDInfo) { 629 if (!DrgAccessDraginfo(pDInfo)) { 630 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 631 "DrgAccessDraginfo"); 632 } 633 else { 634 pDItem = DrgQueryDragitemPtr(pDInfo, 0); 635 /* Check valid rendering mechanisms and data format */ 636 ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL); 637 DrgFreeDraginfo(pDInfo); 638 } 639 } 640 return ok ? MRFROM2SHORT(DOR_DROP, DO_MOVE) : 641 MRFROM2SHORT(DOR_NEVERDROP, 0); 637 642 638 643 case DM_DRAGLEAVE: … … 652 657 case DM_DROP: 653 658 ok = FALSE; 654 // fprintf(stderr, "DROP\n");655 fflush(stderr);656 659 if (emphasized) { 657 660 emphasized = FALSE; 658 661 // DrawTargetEmphasis(hwnd, emphasized); 659 662 } 660 pdinfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 661 if (pdinfo) { 662 DrgAccessDraginfo(pdinfo); 663 pditem = DrgQueryDragitemPtr(pdinfo, 0); 664 if (!pditem) 665 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DM_DROP"); 666 /* Check valid rendering mechanisms and data */ 667 ok = DrgVerifyRMF(pditem, DRM_LBOX, NULL) 668 && ~pditem->fsControl & DC_PREPARE; 669 if (ok) { 670 // ret = FullDrgName(pditem,buffer,buflen); 671 /* note: targetfail is returned to source for all items */ 672 DrgSendTransferMsg(pdinfo->hwndSource, DM_ENDCONVERSATION, 673 MPFROMLONG(pditem->ulItemID), 674 MPFROMLONG(DMFL_TARGETSUCCESSFUL)); 675 } 676 DeleteDragitemStrHandles(pdinfo); // 677 DrgDeleteDraginfoStrHandles(pdinfo); 678 DrgFreeDraginfo(pdinfo); 663 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 664 if (pDInfo) { 665 if (!DrgAccessDraginfo(pDInfo)) { 666 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 667 "DrgAccessDraginfo"); 668 } 669 else { 670 pDItem = DrgQueryDragitemPtr(pDInfo, 0); 671 if (!pDItem) 672 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DM_DROP"); 673 /* Check valid rendering mechanisms and data */ 674 ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL) 675 && ~pDItem->fsControl & DC_PREPARE; 676 if (ok) { 677 // ret = FullDrgName(pDItem,buffer,buflen); 678 /* note: targetfail is returned to source for all items */ 679 DrgSendTransferMsg(pDInfo->hwndSource, DM_ENDCONVERSATION, 680 MPFROMLONG(pDItem->ulItemID), 681 MPFROMLONG(DMFL_TARGETSUCCESSFUL)); 682 } 683 FreeDragInfoData(hwnd, pDInfo); 684 } 679 685 } 680 686 return 0; 681 } 687 } // switch 682 688 return pfnOldProc ? pfnOldProc(hwnd, msg, mp1, mp2) : 683 689 WinDefWindowProc(hwnd, msg, mp1, mp2); -
trunk/dll/collect.c
r606 r618 33 33 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 34 34 06 Apr 07 GKY Add some error checking in drag/drop 35 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks. 35 36 36 37 ***********************************************************************/ … … 459 460 cni.pDragInfo = (PDRAGINFO) mp1; 460 461 li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni)); 461 if ( fExceedPMDrgLimit)462 463 464 465 462 if (NumItemsToUnhilite) 463 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 464 hwnd, 465 GetPString(IDS_ERRORTEXT), 466 GetPString(IDS_EXCEEDPMDRGLMT)); 466 467 if (li) { 467 468 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE; … … 2113 2114 ULONG numitems; 2114 2115 USHORT usOperation; 2115 2116 APIRET rc; 2116 2117 2117 2118 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord; … … 2119 2120 if (!DrgAccessDraginfo(pDInfo)) { 2120 2121 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 2121 " %s", GetPString(IDS_DROPERRORTEXT));2122 break;2122 "DrgAccessDraginfo"); 2123 return 0; 2123 2124 } 2124 2125 numitems = DrgQueryDragitemCount(pDInfo); 2125 2126 usOperation = pDInfo->usOperation; 2126 rc = DeleteDragitemStrHandles(pDInfo); // 2127 if(!rc) 2128 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 2129 "DeleteDragitemStrHandles"); 2130 DrgDeleteDraginfoStrHandles (pDInfo); 2131 rc = DrgFreeDraginfo(pDInfo); 2132 if(!rc) 2133 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 2134 "DrgFreeDraginfo"); 2127 FreeDragInfoData(hwnd, pDInfo); 2135 2128 saymsg(MB_ENTER | MB_ICONASTERISK, 2136 2129 hwnd, … … 2154 2147 PDRAGINFO pDInfo; 2155 2148 2149 // fixme to know why needed 2156 2150 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo; 2157 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO 2158 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO 2151 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 2152 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 2159 2153 } 2160 2154 return 0; … … 2163 2157 case CN_DRAGOVER: 2164 2158 if (mp2) { 2165 PDRAGITEM pDItem; /* Pointer to DRAGITEM 2166 PDRAGINFO pDInfo; /* Pointer to DRAGINFO 2159 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 2160 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */ 2167 2161 PCNRITEM pci; 2168 2162 USHORT uso; 2169 2163 2170 2164 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord; 2171 //if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)2172 // 2165 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER) 2166 // pci = NULL; 2173 2167 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo; 2174 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 2168 if (!DrgAccessDraginfo(pDInfo)) { 2169 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 2170 "DrgAccessDraginfo"); 2171 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */ 2172 } 2175 2173 if (pci) { 2176 2174 if (pci->rc.flRecordAttr & CRA_SOURCE) { … … 2205 2203 } 2206 2204 } 2207 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM 2208 0); /* Index to DRAGITEM 2205 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 2206 0); /* Index to DRAGITEM */ 2209 2207 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 2210 DRM_OS2FILE, /* mechanisms and data 2208 DRM_OS2FILE, /* mechanisms and data */ 2211 2209 NULL)) { 2212 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO 2210 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 2213 2211 if (pci) { 2214 2212 if (driveflags[toupper(*pci->szFileName) - 'A'] & … … 2217 2215 if (toupper(*pci->szFileName) < 'C') 2218 2216 return MRFROM2SHORT(DOR_DROP, DO_COPY); 2219 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop 2217 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 2220 2218 ((fCopyDefault) ? DO_COPY : DO_MOVE)); 2221 2219 } 2222 2220 else 2223 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop 2221 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 2224 2222 DO_COPY); 2225 2223 } 2226 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO 2227 } 2228 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid 2224 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 2225 } 2226 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */ 2229 2227 2230 2228 case CN_INITDRAG: … … 2245 2243 GetPString(IDS_DRAGFILEOBJTEXT)); 2246 2244 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) { 2247 if ((fUnHilite && wasemphasized) || fExceedPMDrgLimit)2245 if ((fUnHilite && wasemphasized) || NumItemsToUnhilite) 2248 2246 UnHilite(hwnd, TRUE, &dcd->lastselection); 2249 2247 } … … 2260 2258 ULONG action = UM_ACTION; 2261 2259 2262 2263 if (fExceedPMDrgLimit)2264 2265 2266 2267 2260 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2); 2261 if (NumItemsToUnhilite) 2262 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 2263 hwnd, 2264 GetPString(IDS_ERRORTEXT), 2265 GetPString(IDS_EXCEEDPMDRGLMT)); 2268 2266 if (li) { 2269 2267 if (!*li->targetpath) { … … 2285 2283 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent, 2286 2284 DropListProc, FM3ModHandle, 2287 2288 2289 2290 2291 2285 DND_FRAME, MPFROMP(&cl)); 2286 if (li->type == DID_ERROR) 2287 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__, 2288 "Drag & Drop Dialog"); 2289 if (!li->type) { 2292 2290 FreeListInfo(li); 2293 2291 return 0; 2294 2292 } 2295 2293 li->list = cl.list; 2296 2294 if (!li->list || !li->list[0]) { 2297 2295 FreeListInfo(li); 2298 2296 return 0; -
trunk/dll/command.c
r574 r618 19 19 23 Mar 07 GKY Replace doesn't change item position 20 20 23 Mar 07 GKY Okay fails silently when item not changed 21 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods 21 22 22 23 ***********************************************************************/ … … 63 64 DrawTargetEmphasis(hwnd, emphasized); 64 65 } 65 if (AcceptOneDrop( mp1, mp2))66 if (AcceptOneDrop(hwnd, mp1, mp2)) 66 67 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 67 68 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 86 87 DrawTargetEmphasis(hwnd, emphasized); 87 88 } 88 if (GetOneDrop( mp1, mp2, szFrom, CCHMAXPATH)) {89 if (GetOneDrop(hwnd, mp1, mp2, szFrom, CCHMAXPATH)) { 89 90 strcat(szFrom, " %a"); 90 91 WinSetWindowText(hwnd, szFrom); -
trunk/dll/dircnrs.c
r606 r618 24 24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 25 25 06 Apr 07 GKY Add some error checking in drag/drop 26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking. 26 27 27 28 ***********************************************************************/ … … 386 387 switch (msg) { 387 388 case DM_DRAGOVER: 388 if (AcceptOneDrop( mp1, mp2))389 if (AcceptOneDrop(hwnd, mp1, mp2)) 389 390 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 390 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid 391 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */ 391 392 case DM_DROPHELP: 392 393 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DIRCNRFOLDERDROPHELP)); … … 400 401 DrawTargetEmphasis(hwnd, emphasized); 401 402 } 402 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom)))403 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) 403 404 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), 404 405 DIR_CNR), … … 589 590 DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID, 590 591 MPFROMP(&cni)); 591 if ( fExceedPMDrgLimit)592 593 594 595 592 if (NumItemsToUnhilite) 593 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 594 hwnd, 595 GetPString(IDS_ERRORTEXT), 596 GetPString(IDS_EXCEEDPMDRGLMT)); 596 597 if (li) { 597 598 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE; … … 2634 2635 2635 2636 /* 2636 2637 2637 case CN_PICKUP: 2638 return PickUp(hwnd,dcd->hwndObject,mp2); 2638 2639 */ 2639 2640 … … 2694 2695 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 2695 2696 GetPString(IDS_DROPERRORTEXT)); 2696 break; 2697 } 2698 numitems = DrgQueryDragitemCount(pDInfo); 2699 usOperation = pDInfo->usOperation; 2700 rc = DeleteDragitemStrHandles(pDInfo); // 2701 if(!rc) 2702 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 2703 "DeleteDragitemStrHandles"); 2704 DrgDeleteDraginfoStrHandles (pDInfo); 2705 rc = DrgFreeDraginfo(pDInfo); 2706 if(!rc) 2707 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 2708 "DrgFreeDraginfo"); 2709 saymsg(MB_ENTER | MB_ICONASTERISK, 2710 hwnd, 2711 GetPString(IDS_DROPHELPHDRTEXT), 2712 GetPString(IDS_DROPHELPTEXT), 2713 numitems, 2714 &"s"[numitems == 1L], 2715 (pci) ? NullStr : GetPString(IDS_NOTEXT), 2716 (pci) ? NullStr : " ", 2717 (pci) ? pci->szFileName : NullStr, 2718 (pci) ? " " : NullStr, 2719 GetPString((usOperation == DO_COPY) ? 2720 IDS_COPYTEXT : 2721 (usOperation == DO_LINK) ? 2722 IDS_LINKTEXT : IDS_MOVETEXT)); 2697 } 2698 else { 2699 numitems = DrgQueryDragitemCount(pDInfo); 2700 usOperation = pDInfo->usOperation; 2701 FreeDragInfoData(hwnd, pDInfo); 2702 saymsg(MB_ENTER | MB_ICONASTERISK, 2703 hwnd, 2704 GetPString(IDS_DROPHELPHDRTEXT), 2705 GetPString(IDS_DROPHELPTEXT), 2706 numitems, 2707 &"s"[numitems == 1L], 2708 pci ? NullStr : GetPString(IDS_NOTEXT), 2709 pci ? NullStr : " ", 2710 pci ? pci->szFileName : NullStr, 2711 pci ? " " : NullStr, 2712 GetPString((usOperation == DO_COPY) ? 2713 IDS_COPYTEXT : 2714 (usOperation == DO_LINK) ? 2715 IDS_LINKTEXT : IDS_MOVETEXT)); 2716 } 2723 2717 } 2724 2718 return 0; 2725 2719 2726 2720 case CN_DRAGLEAVE: 2727 #ifdef NEVER2728 if (mp2) {2729 2730 PDRAGINFO pDInfo;2731 2732 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;2733 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */2734 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */2735 }2736 #endif2737 2721 return 0; 2738 2722 … … 2741 2725 if (mp2) { 2742 2726 2743 PDRAGITEM pDItem; /* Pointer to DRAGITEM 2744 PDRAGINFO pDInfo; /* Pointer to DRAGINFO 2727 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 2728 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */ 2745 2729 PCNRITEM pci; 2746 2730 USHORT uso; … … 2748 2732 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord; 2749 2733 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo; 2750 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 2734 if (!DrgAccessDraginfo(pDInfo)) { 2735 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 2736 "DrgAccessDraginfo"); 2737 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); 2738 } 2751 2739 if (*dcd->directory && 2752 2740 (driveflags[toupper(*dcd->directory) - 'A'] & … … 2754 2742 DrgFreeDraginfo(pDInfo); 2755 2743 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */ 2756 DO_LINK); /* (compare) only 2744 DO_LINK); /* (compare) only */ 2757 2745 } 2758 2746 if (pci) { … … 2763 2751 uso = pDInfo->usOperation; 2764 2752 if (uso == DO_DEFAULT) 2765 uso = (fCopyDefault)? DO_COPY : DO_MOVE;2753 uso = fCopyDefault ? DO_COPY : DO_MOVE; 2766 2754 if (!(pci->attrFile & FILE_DIRECTORY)) { 2767 2755 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) { … … 2797 2785 ((!pci || (pci->attrFile & FILE_DIRECTORY)) && 2798 2786 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) { 2799 /* Free DRAGINFO */2800 2787 DrgFreeDraginfo(pDInfo); 2801 2788 if (driveflags[toupper(*dcd->directory) - 'A'] & … … 2804 2791 if (toupper(*dcd->directory) < 'C') 2805 2792 return MRFROM2SHORT(DOR_DROP, DO_COPY); 2806 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop 2793 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 2807 2794 ((fCopyDefault) ? DO_COPY : DO_MOVE)); 2808 2795 } 2809 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO 2810 } 2811 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid 2796 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 2797 } 2798 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */ 2812 2799 2813 2800 case CN_INITDRAG: … … 2830 2817 } 2831 2818 else if (IsRoot(dcd->directory)) { 2832 2833 2819 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT), 2820 GetPString(IDS_CANTDRAGROOTDIR)); 2834 2821 break; 2835 2822 } … … 2845 2832 mp2, 2846 2833 NULL, 2847 (pci)? NULL : dcd->directory,2848 (pci)? TRUE : FALSE)) {2849 if ((pci && fUnHilite && wasemphasized) || fExceedPMDrgLimit)2834 pci ? NULL : dcd->directory, 2835 pci ? TRUE : FALSE)) { 2836 if ((pci && fUnHilite && wasemphasized) || NumItemsToUnhilite) { 2850 2837 UnHilite(hwnd, TRUE, &dcd->lastselection); 2838 } 2851 2839 } 2852 2840 if (hwndStatus2) { … … 2864 2852 ULONG action = UM_ACTION; 2865 2853 2866 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2); 2867 if (fExceedPMDrgLimit) 2868 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 2869 hwnd, 2870 GetPString(IDS_ERRORTEXT), 2871 GetPString(IDS_EXCEEDPMDRGLMT)); 2854 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2); 2855 if (NumItemsToUnhilite) { 2856 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 2857 hwnd, 2858 GetPString(IDS_ERRORTEXT), 2859 GetPString(IDS_EXCEEDPMDRGLMT)); 2860 } 2872 2861 if (li) { 2873 2862 if (li->list && li->list[0] && IsRoot(li->list[0])) … … 2885 2874 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent, 2886 2875 DropListProc, FM3ModHandle, 2887 2888 2889 2890 2891 2876 DND_FRAME, MPFROMP(&cl)); 2877 if (li->type == DID_ERROR) 2878 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__, 2879 "Drag & Drop Dialog"); 2880 if (!li->type) { 2892 2881 FreeListInfo(li); 2893 2882 return 0; 2894 2883 } 2895 2884 li->list = cl.list; 2896 2885 if (!li->list || !li->list[0]) { 2897 2886 FreeListInfo(li); 2898 2887 return 0; -
trunk/dll/draglist.c
r606 r618 14 14 06 Apr 07 GKY Add DeleteDragitemStrHandles 15 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 16 19 17 20 ***********************************************************************/ … … 19 22 #define INCL_DOS 20 23 #define INCL_WIN 24 #define INCL_SHLERRORS 21 25 #include <os2.h> 22 26 … … 30 34 static PSZ pszSrcFile = __FILE__; 31 35 32 #pragma alloc_text(DRAGLIST,DragOne,DoFileDrag,DragList,PickUp,DeleteDragitemStrHandles) 33 /* work around for DrgDeleteDraginfoStrHandles 34 which seems to fail with a large number of strings */ 35 BOOL DeleteDragitemStrHandles (PDRAGINFO pDInfo) 36 #pragma alloc_text(DRAGLIST,DragOne,DoFileDrag,DragList,PickUp,FreeDragInfoData) 37 38 /** 39 * Delete drag item string handles. 40 * Work around for DrgDeleteDraginfoStrHandles 41 * which seems to fail with a large number of strings 42 * Assume called after successful DrgAccessDraginfo 43 */ 44 45 46 // #define USE_FAST_FREE // Define to let PM do free 47 48 VOID FreeDragInfoData (HWND hwnd, PDRAGINFO pDInfo) 36 49 { 37 PDRAGITEM pDItem; 38 ULONG cDitem; 39 UINT i = 0; 40 APIRET rc; 41 42 cDitem = DrgQueryDragitemCount(pDInfo); 43 for (; i < (UINT)cDitem; i++){ 44 pDItem = DrgQueryDragitemPtr(pDInfo, i); 45 if (!pDItem) 46 return FALSE; 47 else { 48 DrgDeleteStrHandle(pDItem->hstrType); 49 DrgDeleteStrHandle(pDItem->hstrRMF); 50 DrgDeleteStrHandle(pDItem->hstrContainerName); 51 rc = DrgDeleteStrHandle(pDItem->hstrSourceName); 52 if (!rc) 53 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 54 "DrgDeleteStrHandle"); 55 DrgDeleteStrHandle(pDItem->hstrTargetName); 56 } 57 } // for 58 return TRUE; 50 PDRAGITEM pDItem; 51 ULONG cDitem; 52 ULONG curitem; 53 APIRET ok; 54 55 # ifdef USE_FAST_FREE 56 if (!DrgDeleteDraginfoStrHandles(pDInfo)) { 57 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 58 "DrgDeleteDraginfoStrHandles"); 59 } 60 # else // The slow way 61 cDitem = DrgQueryDragitemCount(pDInfo); 62 for (curitem = 0; curitem < cDitem; curitem++) { 63 pDItem = DrgQueryDragitemPtr(pDInfo, curitem); 64 if (!pDItem) { 65 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 66 "DrgQueryDragitemPtr(%u)", curitem); 67 } 68 else { 69 ok = DrgDeleteStrHandle(pDItem->hstrType); 70 if (!ok) { 71 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 72 "DrgDeleteStrHandle(0x%x) hstrType",pDItem->hstrType); 73 } 74 ok = DrgDeleteStrHandle(pDItem->hstrRMF); 75 if (!ok) { 76 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 77 "DrgDeleteStrHandle(0x%x) hstrRMF",pDItem->hstrRMF); 78 } 79 ok = DrgDeleteStrHandle(pDItem->hstrContainerName); 80 if (!ok) { 81 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 82 "DrgDeleteStrHandle(0x%x) hstrContainerName",pDItem->hstrContainerName); 83 } 84 ok = DrgDeleteStrHandle(pDItem->hstrSourceName); 85 if (!ok) { 86 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 87 "DrgDeleteStrHandle(0x%x) hstrSourceName",pDItem->hstrSourceName); 88 } 89 ok = DrgDeleteStrHandle(pDItem->hstrTargetName); 90 if (!ok) { 91 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 92 "DrgDeleteStrHandle(0x%x) hstrTargetName",pDItem->hstrTargetName); 93 } 94 } 95 } // for 96 # endif 97 if (!DrgFreeDraginfo(pDInfo)) { 98 // fixme to find callers responsible for PMERR_SOURCE_SAME_AS_TARGET 99 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) != PMERR_SOURCE_SAME_AS_TARGET) { 100 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 101 "DrgFreeDraginfo"); 102 } 103 else 104 DbgMsg(pszSrcFile, __LINE__, "DrgFreeDraginfo PMERR_SOURCE_SAME_AS_TARGET"); 105 } 59 106 } 60 107 … … 95 142 hptrDir : hptrFile; 96 143 memset(&DItem, 0, sizeof(DRAGITEM)); 97 DItem.hwndItem = (hwndObj) ? hwndObj : hwndCnr; / * Initialize DRAGITEM */144 DItem.hwndItem = (hwndObj) ? hwndObj : hwndCnr; // Initialize DRAGITEM 98 145 // DItem.hwndItem = hwndCnr; 99 146 DItem.ulItemID = 1; … … 103 150 DItem.hstrSourceName = DrgAddStrHandle(szFile); 104 151 if (!DItem.hstrSourceName) 105 106 152 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 153 "DrgQueryStrName"); 107 154 DItem.hstrTargetName = DrgAddStrHandle(szFile); 108 155 DItem.fsControl = 0; … … 125 172 fakeicon.cxOffset = -16; 126 173 fakeicon.cyOffset = 0; 127 pDInfo = DrgAllocDraginfo(1); /* Allocate DRAGINFO */174 pDInfo = DrgAllocDraginfo(1); 128 175 if (pDInfo) { 129 176 if (IsFullName(filename) && … … 136 183 pDInfo->hwndSource = (hwndObj) ? hwndObj : hwndCnr; 137 184 // pDInfo->hwndSource = hwndCnr; 138 DrgSetDragitem(pDInfo, /* Set item in DRAGINFO */ 139 &DItem, /* Pointer to DRAGITEM */ 140 sizeof(DRAGITEM), /* Size of DRAGITEM */ 141 0); /* Index of DRAGITEM */ 185 DrgSetDragitem(pDInfo, &DItem, sizeof(DRAGITEM), 0); 142 186 WinSetFocus(HWND_DESKTOP, HWND_DESKTOP); 143 hDrop = DrgDrag(hwndCnr, /* Initiate drag */ 144 pDInfo, /* DRAGINFO structure */ 145 &fakeicon, 1L, VK_ENDDRAG, /* End of drag indicator */ 146 (PVOID) NULL); /* Reserved */ 147 //if (hDrop == NULLHANDLE) 148 if (!DeleteDragitemStrHandles(pDInfo)) //) 149 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 150 "DeleteDragistr"); 151 DrgDeleteDraginfoStrHandles (pDInfo); 152 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO struct */ 187 hDrop = DrgDrag(hwndCnr, 188 pDInfo, 189 &fakeicon, 190 1, // DragImage count 191 VK_ENDDRAG, // Drag end button 192 NULL); 193 if (hDrop == NULLHANDLE) 194 FreeDragInfoData(hwndCnr, pDInfo); 153 195 WinSetWindowPos(hwndCnr, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); 154 196 } … … 161 203 CHAR * directory, BOOL moveok) 162 204 { 163 / * drag files from a container */205 // Drag files from a container 164 206 165 207 BOOL isdir, rooting = FALSE; 166 208 PCNRITEM pci; 167 registerCHAR *p;209 CHAR *p; 168 210 INT attribute = CRA_CURSORED; 169 211 PDRAGINFO pDInfo = NULL; 170 DRAGITEM **ppDItem = NULL, **ppTest; 212 DRAGITEM **ppDItem = NULL, **ppDITest; 213 DRAGITEM *pDItem; 171 214 PCNRITEM pciRec = (PCNRITEM) pcd->pRecord; 172 HWND hDrop = 0;173 register ULONG ulNumfiles = 0L, numdragalloc = 0L,Select, ulNumIcon = 0;215 HWND hDrop = NULLHANDLE; 216 ULONG ulNumfiles = 0, ulNumDIAlloc = 0, ulSelect, ulNumIcon = 0; 174 217 CHAR szFile[CCHMAXPATH], szBuffer[CCHMAXPATH]; 175 DRAGIMAGE *padiIcon = NULL, *padiTest, diFakeIcon; 176 APIRET rc; 177 178 fExceedPMDrgLimit = 0; 218 DRAGIMAGE *paDImgIcons = NULL, *pDImg, dimgFakeIcon; 219 BOOL ok; 220 221 // fixme to be multi-drag safe - count needs to be in DCD etc. and passed to UnHilite 222 NumItemsToUnhilite = 0; 179 223 if (!pciRec && directory && *directory) 180 224 return DragOne(hwndCnr, hwndObj, directory, moveok); … … 202 246 } 203 247 204 Select = 0L;248 ulSelect = 0; 205 249 while (pci && (INT) pci > -1) { 206 250 if (!(pci->rc.flRecordAttr & CRA_FILTERED)) { … … 223 267 if (!arcfile) { 224 268 // Filesystem object 225 isdir = ((pci->attrFile & FILE_DIRECTORY) != 0); 226 if (ulNumfiles + 2L > numdragalloc) { 227 if (!padiIcon) { 228 padiTest = 229 xrealloc(padiIcon, sizeof(DRAGIMAGE) * (numdragalloc + 4L), 269 isdir = pci->attrFile & FILE_DIRECTORY; 270 // fixme to expand smarter - expand fast at first - do same for similar code 271 if (ulNumfiles + 2 > ulNumDIAlloc) { 272 // Expand 273 if (!paDImgIcons) { 274 pDImg = 275 xrealloc(paDImgIcons, sizeof(DRAGIMAGE) * (ulNumDIAlloc + 4L), 230 276 pszSrcFile, __LINE__); 231 if (padiTest) 232 padiIcon = padiTest; 233 else 277 if (!pDImg) 234 278 break; 279 paDImgIcons = pDImg; 235 280 } 236 281 else if (!ulNumIcon) { 237 padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); 238 padiIcon[ulNumfiles].cptl = 0; 239 padiIcon[ulNumfiles].hImage = hptrLast; 240 padiIcon[ulNumfiles].fl = DRG_ICON; 241 padiIcon[ulNumfiles].sizlStretch.cx = 32; 242 padiIcon[ulNumfiles].sizlStretch.cy = 32; 243 padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 4); 244 padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 7); 282 pDImg = &paDImgIcons[ulNumfiles]; 283 pDImg->cb = sizeof(DRAGIMAGE); 284 pDImg->cptl = 0; 285 pDImg->hImage = hptrLast; 286 pDImg->fl = DRG_ICON; 287 pDImg->sizlStretch.cx = 32; 288 pDImg->sizlStretch.cy = 32; 289 pDImg->cxOffset = -16 + (ulNumfiles * 4); 290 pDImg->cyOffset = 0 + (ulNumfiles * 7); 245 291 ulNumIcon = ulNumfiles + 1; 246 292 } 247 pp Test =248 xrealloc(ppDItem, sizeof(DRAGITEM *) * ( numdragalloc + 4L),293 ppDITest = 294 xrealloc(ppDItem, sizeof(DRAGITEM *) * (ulNumDIAlloc + 4L), 249 295 pszSrcFile, __LINE__); 250 if (ppTest) { 251 ppDItem = ppTest; 252 numdragalloc += 4L; 253 } 254 else 296 if (!ppDITest) 255 297 break; 256 } 257 ppDItem[ulNumfiles] = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 258 if (ppDItem[ulNumfiles]) { 259 if (!ulNumIcon) { 260 padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); 261 padiIcon[ulNumfiles].cptl = 0; 262 padiIcon[ulNumfiles].hImage = pci->rc.hptrIcon; 263 if (!padiIcon[ulNumfiles].hImage) 264 padiIcon[ulNumfiles].hImage = (isdir) ? hptrDir : hptrFile; 265 padiIcon[ulNumfiles].fl = DRG_ICON; 266 padiIcon[ulNumfiles].sizlStretch.cx = 32; 267 padiIcon[ulNumfiles].sizlStretch.cy = 32; 268 padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 3); 269 padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 6); 270 } 271 memset(ppDItem[ulNumfiles], 0, sizeof(DRAGITEM)); 272 ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM */ 273 ppDItem[ulNumfiles]->hwndItem = hwndCnr; 274 ppDItem[ulNumfiles]->ulItemID = (ULONG) pci; 275 ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 276 ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFLIST); 277 ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(szBuffer); 278 ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); 279 if (!ppDItem[ulNumfiles]->hstrSourceName){ 280 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrType); 281 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrRMF); 282 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrContainerName); 283 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrSourceName); 284 xfree(ppDItem[ulNumfiles]); 285 fExceedPMDrgLimit = ulNumfiles - 1; 286 break; 287 } 288 /*Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 289 "DrgAddStrHandle");*/ 290 ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); 291 ppDItem[ulNumfiles]->fsControl = (isdir) ? DC_CONTAINER : 0; 292 if (IsFullName(pci->szFileName) && 293 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)) 294 ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; 295 ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE | DO_LINKABLE; 296 if (moveok && IsFullName(pci->szFileName) && 297 !(driveflags[toupper(*pci->szFileName) - 'A'] & 298 DRIVE_NOTWRITEABLE)) 299 ppDItem[ulNumfiles]->fsSupportedOps |= DO_MOVEABLE; 300 if (IsRoot(pci->szFileName)) { 301 ppDItem[ulNumfiles]->fsSupportedOps = DO_LINKABLE; 302 rooting = TRUE; 303 } 304 //if (ulNumfiles >= 2000){ 305 // pDInfo = DrgAllocDraginfo(ulNumfiles); 306 // fExceedPMDrgLimit = TRUE; 307 // goto Thatsall; 308 // } 309 ulNumfiles++; 310 ppDItem[ulNumfiles] = NULL; 311 } 312 else 298 ppDItem = ppDITest; 299 ulNumDIAlloc += 4L; 300 } 301 pDItem = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 302 if (!pDItem) 303 break; // Already complained 304 ppDItem[ulNumfiles] = pDItem; 305 if (!ulNumIcon) { 306 pDImg = &paDImgIcons[ulNumfiles]; 307 pDImg->cb = sizeof(DRAGIMAGE); 308 pDImg->cptl = 0; 309 pDImg->hImage = pci->rc.hptrIcon; 310 if (!pDImg->hImage) 311 pDImg->hImage = isdir ? hptrDir : hptrFile; 312 pDImg->fl = DRG_ICON; 313 pDImg->sizlStretch.cx = 32; 314 pDImg->sizlStretch.cy = 32; 315 pDImg->cxOffset = -16 + (ulNumfiles * 3); 316 pDImg->cyOffset = 0 + (ulNumfiles * 6); 317 } 318 // Initialize DRAGITEM 319 memset(pDItem, 0, sizeof(DRAGITEM)); 320 pDItem->hwndItem = (hwndObj) ? hwndObj : hwndCnr; 321 pDItem->hwndItem = hwndCnr; 322 pDItem->ulItemID = (ULONG) pci; 323 pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 324 ok = pDItem->hstrType; 325 pDItem->hstrRMF = DrgAddStrHandle(DRMDRFLIST); 326 ok = ok && pDItem->hstrRMF; 327 pDItem->hstrContainerName = DrgAddStrHandle(szBuffer); 328 ok = ok && pDItem->hstrContainerName; 329 pDItem->hstrSourceName = DrgAddStrHandle(szFile); 330 ok = ok && pDItem->hstrSourceName; 331 pDItem->hstrTargetName = DrgAddStrHandle(szFile); 332 ok = ok && pDItem->hstrTargetName; 333 if (!ok) { 334 DbgMsg(pszSrcFile, __LINE__, "DrgAddStrHandle failed at %lu for %s", ulNumfiles, szFile); 335 // Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,"DrgAddStrHandle"); 336 if (pDItem->hstrType) 337 DrgDeleteStrHandle(pDItem->hstrType); 338 if (pDItem->hstrRMF) 339 DrgDeleteStrHandle(pDItem->hstrRMF); 340 if (pDItem->hstrContainerName) 341 DrgDeleteStrHandle(pDItem->hstrContainerName); 342 if (pDItem->hstrSourceName) 343 DrgDeleteStrHandle(pDItem->hstrSourceName); 344 if (pDItem->hstrTargetName) 345 DrgDeleteStrHandle(pDItem->hstrTargetName); 346 xfree(pDItem); 347 // ppDItem[ulNumfiles] = NULL; // Why bother - we can count - fixme to be gone 348 NumItemsToUnhilite = ulNumfiles + 1; // Use +1 to ensure non-zero on any failure 313 349 break; 350 } 351 pDItem->fsControl = isdir ? DC_CONTAINER : 0; 352 if (IsFullName(pci->szFileName) && 353 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE)) 354 pDItem->fsControl |= DC_REMOVEABLEMEDIA; 355 pDItem->fsSupportedOps = DO_COPYABLE | DO_LINKABLE; 356 if (moveok && IsFullName(pci->szFileName) && 357 !(driveflags[toupper(*pci->szFileName) - 'A'] & 358 DRIVE_NOTWRITEABLE)) 359 pDItem->fsSupportedOps |= DO_MOVEABLE; 360 if (IsRoot(pci->szFileName)) { 361 pDItem->fsSupportedOps = DO_LINKABLE; 362 rooting = TRUE; 363 } 364 ulNumfiles++; 365 // ppDItem[ulNumfiles] = NULL; // Why bother - can't we count - fixme to be gone? 314 366 } 315 367 else { 316 368 // Archive object 317 if (ulNumfiles + 3L > numdragalloc) {318 pp Test =319 xrealloc(ppDItem, sizeof(DRAGITEM *) * ( numdragalloc + 5L),369 if (ulNumfiles + 3L > ulNumDIAlloc) { 370 ppDITest = 371 xrealloc(ppDItem, sizeof(DRAGITEM *) * (ulNumDIAlloc + 5L), 320 372 pszSrcFile, __LINE__); 321 if (!pp Test)373 if (!ppDITest) 322 374 break; 323 else { 324 ppDItem = ppTest; 325 numdragalloc += 5L; 326 } 327 } 328 ppDItem[ulNumfiles] = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 329 if (!ppDItem[ulNumfiles]) 375 ppDItem = ppDITest; 376 ulNumDIAlloc += 5L; 377 } 378 pDItem = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 379 if (!pDItem) 330 380 break; 331 else { 332 diFakeIcon.hImage = hptrFile; 333 memset(ppDItem[ulNumfiles], 0, sizeof(DRAGITEM)); 334 ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM */ 335 ppDItem[ulNumfiles]->hwndItem = hwndCnr; 336 ppDItem[ulNumfiles]->ulItemID = (ULONG) pci; 337 ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 338 ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFOS2FILE); 339 ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(arcfile); 340 ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); 341 if (!ppDItem[ulNumfiles]->hstrSourceName){ 342 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrType); 343 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrRMF); 344 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrContainerName); 345 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrSourceName); 346 xfree(ppDItem[ulNumfiles]); 347 fExceedPMDrgLimit = ulNumfiles - 1; 348 break; 349 } 350 ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); 351 ppDItem[ulNumfiles]->fsControl = DC_PREPARE; 381 ppDItem[ulNumfiles] = pDItem; 382 dimgFakeIcon.hImage = hptrFile; 383 // Initialize DRAGITEM 384 memset(pDItem, 0, sizeof(DRAGITEM)); 385 pDItem->hwndItem = (hwndObj) ? hwndObj : hwndCnr; 386 pDItem->hwndItem = hwndCnr; 387 pDItem->ulItemID = (ULONG) pci; 388 pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 389 ok = pDItem->hstrType; 390 pDItem->hstrRMF = DrgAddStrHandle(DRMDRFOS2FILE); 391 ok = ok && pDItem->hstrRMF; 392 pDItem->hstrContainerName = DrgAddStrHandle(arcfile); 393 ok = ok && pDItem->hstrContainerName; 394 pDItem->hstrSourceName = DrgAddStrHandle(szFile); 395 ok = ok && pDItem->hstrSourceName; 396 pDItem->hstrTargetName = DrgAddStrHandle(szFile); 397 ok = ok && pDItem->hstrTargetName; 398 if (!ok){ 399 if (pDItem->hstrType) 400 DrgDeleteStrHandle(pDItem->hstrType); 401 if (pDItem->hstrRMF) 402 DrgDeleteStrHandle(pDItem->hstrRMF); 403 if (pDItem->hstrContainerName) 404 DrgDeleteStrHandle(pDItem->hstrContainerName); 405 if (pDItem->hstrSourceName) 406 DrgDeleteStrHandle(pDItem->hstrSourceName); 407 if (pDItem->hstrTargetName) 408 DrgDeleteStrHandle(pDItem->hstrTargetName); 409 xfree(pDItem); 410 NumItemsToUnhilite = ulNumfiles + 1; // +1 to ensure non-zero 411 break; 412 } 413 pDItem->fsControl = DC_PREPARE; 414 if (IsFullName(arcfile) && 415 (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE)) 416 pDItem->fsControl |= DC_REMOVEABLEMEDIA; 417 pDItem->fsSupportedOps = DO_COPYABLE; 418 ulNumfiles++; 419 420 pDItem = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 421 if (pDItem) { 422 ppDItem[ulNumfiles] = pDItem; 423 dimgFakeIcon.hImage = hptrFile; 424 // Initialize DRAGITEM 425 memset(pDItem, 0, sizeof(DRAGITEM)); 426 pDItem->hwndItem = (hwndObj) ? hwndObj : hwndCnr; 427 pDItem->hwndItem = hwndCnr; 428 pDItem->ulItemID = ulSelect++; 429 pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 430 ok = ok && pDItem->hstrType; 431 pDItem->hstrRMF = DrgAddStrHandle(DRMDRFFM2ARC); 432 ok = ok && pDItem->hstrRMF; 433 pDItem->hstrContainerName = DrgAddStrHandle(arcfile); 434 ok = ok && pDItem->hstrContainerName; 435 pDItem->hstrSourceName = DrgAddStrHandle(szFile); 436 ok = ok && pDItem->hstrSourceName; 437 pDItem->hstrTargetName = DrgAddStrHandle(szFile); 438 ok = ok && pDItem->hstrTargetName; 439 if (!ok) { 440 DbgMsg(pszSrcFile, __LINE__, "DrgAddStrHandle failed at %lu for %s", ulNumfiles, szFile); 441 if (pDItem->hstrType) 442 DrgDeleteStrHandle(pDItem->hstrType); 443 if (pDItem->hstrRMF) 444 DrgDeleteStrHandle(pDItem->hstrRMF); 445 if (pDItem->hstrContainerName) 446 DrgDeleteStrHandle(pDItem->hstrContainerName); 447 if (pDItem->hstrSourceName) 448 DrgDeleteStrHandle(pDItem->hstrSourceName); 449 if (pDItem->hstrTargetName) 450 DrgDeleteStrHandle(pDItem->hstrTargetName); 451 xfree(pDItem); 452 // pDItem = NULL; // Why bother - fixme to be gone? 453 NumItemsToUnhilite = ulNumfiles + 1; 454 break; 455 } 456 pDItem->fsControl = 0; 352 457 if (IsFullName(arcfile) && 353 458 (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE)) 354 p pDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA;355 p pDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE;459 pDItem->fsControl |= DC_REMOVEABLEMEDIA; 460 pDItem->fsSupportedOps = DO_COPYABLE; 356 461 ulNumfiles++; 357 ppDItem[ulNumfiles] = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 358 if (ppDItem[ulNumfiles]) { 359 diFakeIcon.hImage = hptrFile; 360 memset(ppDItem[ulNumfiles], 0, sizeof(DRAGITEM)); 361 ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwndCnr; /* Initialize DRAGITEM */ 362 ppDItem[ulNumfiles]->hwndItem = hwndCnr; 363 ppDItem[ulNumfiles]->ulItemID = Select++; 364 ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 365 ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFFM2ARC); 366 ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(arcfile); 367 ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); 368 if (!ppDItem[ulNumfiles]->hstrSourceName){ 369 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrType); 370 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrRMF); 371 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrContainerName); 372 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrSourceName); 373 xfree(ppDItem[ulNumfiles]); 374 fExceedPMDrgLimit = ulNumfiles - 1; 375 break; 376 } 377 ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); 378 ppDItem[ulNumfiles]->fsControl = 0; 379 if (IsFullName(arcfile) && 380 (driveflags[toupper(*arcfile) - 'A'] & DRIVE_REMOVABLE)) 381 ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; 382 ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE; 383 //if (ulNumfiles >= 1000){ 384 // pDInfo = DrgAllocDraginfo(ulNumfiles); 385 // fexceedpmdrglimit = TRUE; 386 // goto Thatsall; 387 // } 388 ulNumfiles++; 389 } 390 ppDItem[ulNumfiles] = NULL; 391 } 462 } 463 // ppDItem[ulNumfiles] = NULL; // Why bother - fixme to be gone? 392 464 } 393 465 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci), … … 400 472 pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci), 401 473 MPFROMSHORT(attribute)); 402 } // while 403 if (fExceedPMDrgLimit) 404 ulNumfiles = ulNumfiles - 1; 474 } // while 475 405 476 if (ulNumfiles) { 406 pDInfo = DrgAllocDraginfo(ulNumfiles); /* Allocate DRAGINFO */477 pDInfo = DrgAllocDraginfo(ulNumfiles); 407 478 if (pDInfo) { 408 479 if ((arcfile && *arcfile) || (IsFullName(szBuffer) && … … 416 487 pDInfo->hwndSource = (hwndObj) ? hwndObj : hwndCnr; 417 488 // pDInfo->hwndSource = hwndCnr; 418 for (Select = 0L; Select < ulNumfiles; Select++) { 419 DrgSetDragitem(pDInfo, /* Set item in DRAGINFO */ 420 ppDItem[Select], /* Pointer to DRAGITEM */ 421 sizeof(DRAGITEM), /* Size of DRAGITEM */ 422 Select); /* Index of DRAGITEM */ 423 xfree(ppDItem[Select]); 489 for (ulSelect = 0; ulSelect < ulNumfiles; ulSelect++) { 490 DrgSetDragitem(pDInfo, ppDItem[ulSelect], sizeof(DRAGITEM), ulSelect); 491 xfree(ppDItem[ulSelect]); 424 492 } 425 493 #ifdef __DEBUG_ALLOC__ … … 427 495 #endif 428 496 xfree(ppDItem); 429 ppDItem = NULL; 497 ppDItem = NULL; // Remember gone 430 498 DosPostEventSem(CompactSem); 431 499 432 500 if (arcfile) { 433 di FakeIcon.cb = sizeof(DRAGIMAGE);434 di FakeIcon.cptl = 0;501 dimgFakeIcon.cb = sizeof(DRAGIMAGE); 502 dimgFakeIcon.cptl = 0; 435 503 if (ulNumfiles > 1) 436 di FakeIcon.hImage = hptrFile;437 di FakeIcon.fl = DRG_ICON;438 di FakeIcon.sizlStretch.cx = 32;439 di FakeIcon.sizlStretch.cy = 32;440 di FakeIcon.cxOffset = -16;441 di FakeIcon.cyOffset = 0;442 pa diIcon = &diFakeIcon;504 dimgFakeIcon.hImage = hptrFile; 505 dimgFakeIcon.fl = DRG_ICON; 506 dimgFakeIcon.sizlStretch.cx = 32; 507 dimgFakeIcon.sizlStretch.cy = 32; 508 dimgFakeIcon.cxOffset = -16; 509 dimgFakeIcon.cyOffset = 0; 510 paDImgIcons = &dimgFakeIcon; 443 511 } 444 512 if (!arcfile) { … … 447 515 } 448 516 else 449 ulNumIcon = 1 L;517 ulNumIcon = 1; 450 518 451 519 WinSetFocus(HWND_DESKTOP, HWND_DESKTOP); 452 hDrop = DrgDrag(hwndCnr, /* Initiate drag */ 453 pDInfo, /* DRAGINFO structure */ 454 padiIcon, ulNumIcon, VK_ENDDRAG, /* End of drag indicator */ 455 (PVOID) NULL); /* Reserved */ 456 rc = DeleteDragitemStrHandles(pDInfo); 457 if (!rc) 458 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 459 "DeleteDragistr"); 460 DrgDeleteDraginfoStrHandles (pDInfo); 461 rc = DrgFreeDraginfo(pDInfo); /* Free DRAGINFO struct */ 462 if (!rc) 463 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 464 "DrgFreeDraginfo"); 465 if (padiIcon && padiIcon != &diFakeIcon) 466 xfree(padiIcon); 467 padiIcon = NULL; 520 hDrop = DrgDrag(hwndCnr, 521 pDInfo, 522 paDImgIcons, 523 ulNumIcon, 524 VK_ENDDRAG, // Drag end button 525 NULL); 468 526 WinSetWindowPos(hwndCnr, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); 469 DosPostEventSem(CompactSem);470 527 } 471 528 } 529 530 if (hDrop == NULLHANDLE ) { 531 NumItemsToUnhilite = 0; 532 if (pDInfo) 533 FreeDragInfoData(hwndCnr, pDInfo); 534 } 535 472 536 if (ppDItem) 473 537 xfree(ppDItem); 474 if (padiIcon && padiIcon != &diFakeIcon) 475 xfree(padiIcon); 538 if (paDImgIcons && paDImgIcons != &dimgFakeIcon) 539 xfree(paDImgIcons); 540 DosPostEventSem(CompactSem); 476 541 MarkAll(hwndCnr, TRUE, FALSE, TRUE); 477 542 return hDrop; … … 480 545 HWND DragList(HWND hwnd, HWND hwndObj, CHAR ** list, BOOL moveok) 481 546 { 482 483 /* drag a linked list of files */ 547 // Drag a linked list of files 484 548 485 549 BOOL isdir; 486 550 register CHAR *p; 487 551 PDRAGINFO pDInfo = NULL; 488 DRAGITEM **ppDItem = NULL, **ppTest; 552 DRAGITEM **ppDItem = NULL, **ppDITest; 553 DRAGITEM *pDItem; 489 554 HWND hDrop = (HWND) 0; 490 register ULONG ulNumfiles = 0L, numdragalloc = 0L,Select, ulNumIcon = 0;555 ULONG ulNumfiles = 0, ulNumDIAlloc = 0, ulSelect, ulNumIcon = 0; 491 556 CHAR szFile[CCHMAXPATH], szBuffer[CCHMAXPATH]; 492 DRAGIMAGE *pa diIcon = NULL, *padiTest;557 DRAGIMAGE *paDImgIcons = NULL, *pDImg; 493 558 FILESTATUS3 fs3; 559 BOOL ok; 494 560 495 561 if (!list || !list[0]) 496 562 return hDrop; 497 for ( Select = 0; list[Select];Select++) {498 if ((!IsRoot(list[ Select]) || !IsValidDrive(*list[Select])) &&499 DosQueryPathInfo(list[ Select], FIL_STANDARD, &fs3, sizeof(fs3)))563 for (ulSelect = 0; list[ulSelect]; ulSelect++) { 564 if ((!IsRoot(list[ulSelect]) || !IsValidDrive(*list[ulSelect])) && 565 DosQueryPathInfo(list[ulSelect], FIL_STANDARD, &fs3, sizeof(fs3))) 500 566 continue; 501 strcpy(szBuffer, list[ Select]);567 strcpy(szBuffer, list[ulSelect]); 502 568 p = strrchr(szBuffer, '\\'); 503 569 if (p) { … … 509 575 continue; 510 576 if (*szFile) { 511 isdir = (IsRoot(list[Select])) ? TRUE :512 ((fs3.attrFile & FILE_DIRECTORY) != 0); 513 if (ulNumfiles + 2 L > numdragalloc) {514 if (!pa diIcon) {515 p adiTest=516 xrealloc(pa diIcon, sizeof(DRAGIMAGE) * (numdragalloc + 4L),577 isdir = IsRoot(list[ulSelect]) || fs3.attrFile & FILE_DIRECTORY; 578 // fixme to expand smarter - expand fast at first - do same for similar code 579 if (ulNumfiles + 2 > ulNumDIAlloc) { 580 if (!paDImgIcons) { 581 pDImg = 582 xrealloc(paDImgIcons, sizeof(DRAGIMAGE) * (ulNumDIAlloc + 4L), 517 583 pszSrcFile, __LINE__); 518 if (!p adiTest)584 if (!pDImg) 519 585 break; 520 else 521 padiIcon = padiTest; 586 paDImgIcons = pDImg; 522 587 } 523 588 else if (!ulNumIcon) { 524 padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); 525 padiIcon[ulNumfiles].cptl = 0; 526 padiIcon[ulNumfiles].hImage = hptrLast; 527 padiIcon[ulNumfiles].fl = DRG_ICON; 528 padiIcon[ulNumfiles].sizlStretch.cx = 32; 529 padiIcon[ulNumfiles].sizlStretch.cy = 32; 530 padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 4); 531 padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 7); 589 pDImg = &paDImgIcons[ulNumfiles]; 590 pDImg->cb = sizeof(DRAGIMAGE); 591 pDImg->cptl = 0; 592 pDImg->hImage = hptrLast; 593 pDImg->fl = DRG_ICON; 594 pDImg->sizlStretch.cx = 32; 595 pDImg->sizlStretch.cy = 32; 596 pDImg->cxOffset = -16 + (ulNumfiles * 4); 597 pDImg->cyOffset = 0 + (ulNumfiles * 7); 532 598 ulNumIcon = ulNumfiles + 1; 533 599 } 534 pp Test =535 xrealloc(ppDItem, sizeof(DRAGITEM *) * ( numdragalloc + 4L),600 ppDITest = 601 xrealloc(ppDItem, sizeof(DRAGITEM *) * (ulNumDIAlloc + 4L), 536 602 pszSrcFile, __LINE__); 537 if (!pp Test)603 if (!ppDITest) 538 604 break; 539 else { 540 ppDItem = ppTest; 541 numdragalloc += 4L; 542 } 543 } 544 ppDItem[ulNumfiles] = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 545 if (!ppDItem[ulNumfiles]) 605 ppDItem = ppDITest; 606 ulNumDIAlloc += 4L; 607 } 608 pDItem = xmalloc(sizeof(DRAGITEM), pszSrcFile, __LINE__); 609 if (!pDItem) 546 610 break; 547 else { 548 if (!ulNumIcon) { 549 padiIcon[ulNumfiles].cb = sizeof(DRAGIMAGE); 550 padiIcon[ulNumfiles].cptl = 0; 551 padiIcon[ulNumfiles].hImage = (isdir) ? hptrDir : hptrFile; 552 padiIcon[ulNumfiles].fl = DRG_ICON; 553 padiIcon[ulNumfiles].sizlStretch.cx = 32; 554 padiIcon[ulNumfiles].sizlStretch.cy = 32; 555 padiIcon[ulNumfiles].cxOffset = -16 + (ulNumfiles * 3); 556 padiIcon[ulNumfiles].cyOffset = 0 + (ulNumfiles * 6); 557 } 558 memset(ppDItem[ulNumfiles], 0, sizeof(DRAGITEM)); 559 ppDItem[ulNumfiles]->hwndItem = (hwndObj) ? hwndObj : hwnd; /* Initialize DRAGITEM */ 560 // ppDItem[ulNumfiles]->hwndItem = hwnd; 561 ppDItem[ulNumfiles]->ulItemID = (ULONG) Select; 562 ppDItem[ulNumfiles]->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 563 ppDItem[ulNumfiles]->hstrRMF = DrgAddStrHandle(DRMDRFLIST); 564 ppDItem[ulNumfiles]->hstrContainerName = DrgAddStrHandle(szBuffer); 565 ppDItem[ulNumfiles]->hstrSourceName = DrgAddStrHandle(szFile); 566 if (!ppDItem[ulNumfiles]->hstrSourceName){ 567 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrType); 568 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrRMF); 569 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrContainerName); 570 DrgDeleteStrHandle(ppDItem[ulNumfiles]->hstrSourceName); 571 xfree(ppDItem[ulNumfiles]); 572 fExceedPMDrgLimit = ulNumfiles - 1; 573 break; 574 } 575 ppDItem[ulNumfiles]->hstrTargetName = DrgAddStrHandle(szFile); 576 ppDItem[ulNumfiles]->fsControl = (isdir) ? DC_CONTAINER : 0; 577 if (IsFullName(list[Select]) && 578 (driveflags[toupper(*list[Select]) - 'A'] & DRIVE_REMOVABLE)) 579 ppDItem[ulNumfiles]->fsControl |= DC_REMOVEABLEMEDIA; 580 ppDItem[ulNumfiles]->fsSupportedOps = DO_COPYABLE | DO_LINKABLE; 581 if (moveok && IsFullName(list[Select]) && 582 !(driveflags[toupper(*list[Select]) - 'A'] & DRIVE_NOTWRITEABLE)) 583 ppDItem[ulNumfiles]->fsSupportedOps |= DO_MOVEABLE; 584 if (IsRoot(list[Select])) 585 ppDItem[ulNumfiles]->fsControl = DO_LINKABLE; 586 ulNumfiles++; 587 ppDItem[ulNumfiles] = NULL; 588 } 589 } 590 } // for 591 if (fExceedPMDrgLimit) 592 ulNumfiles = ulNumfiles - 1; 611 ppDItem[ulNumfiles] = pDItem; 612 if (!ulNumIcon) { 613 pDImg = &paDImgIcons[ulNumfiles]; 614 pDImg->cb = sizeof(DRAGIMAGE); 615 pDImg->cptl = 0; 616 pDImg->hImage = isdir ? hptrDir : hptrFile; 617 pDImg->fl = DRG_ICON; 618 pDImg->sizlStretch.cx = 32; 619 pDImg->sizlStretch.cy = 32; 620 pDImg->cxOffset = -16 + (ulNumfiles * 3); 621 pDImg->cyOffset = 0 + (ulNumfiles * 6); 622 } 623 memset(pDItem, 0, sizeof(DRAGITEM)); 624 pDItem->hwndItem = (hwndObj) ? hwndObj : hwnd; 625 // pDItem->hwndItem = hwnd; 626 pDItem->ulItemID = (ULONG) ulSelect; 627 pDItem->hstrType = DrgAddStrHandle(DRT_UNKNOWN); 628 ok = pDItem->hstrType; 629 pDItem->hstrRMF = DrgAddStrHandle(DRMDRFLIST); 630 ok = ok && pDItem->hstrRMF; 631 pDItem->hstrContainerName = DrgAddStrHandle(szBuffer); 632 ok = ok && pDItem->hstrContainerName; 633 pDItem->hstrSourceName = DrgAddStrHandle(szFile); 634 ok = ok && pDItem->hstrSourceName; 635 pDItem->hstrTargetName = DrgAddStrHandle(szFile); 636 ok = ok && pDItem->hstrTargetName; 637 if (!ok) { 638 if (pDItem->hstrType) 639 DrgDeleteStrHandle(pDItem->hstrType); 640 if (pDItem->hstrRMF) 641 DrgDeleteStrHandle(pDItem->hstrRMF); 642 if (pDItem->hstrContainerName) 643 DrgDeleteStrHandle(pDItem->hstrContainerName); 644 if (pDItem->hstrSourceName) 645 DrgDeleteStrHandle(pDItem->hstrSourceName); 646 if (pDItem->hstrTargetName) 647 DrgDeleteStrHandle(pDItem->hstrTargetName); 648 xfree(pDItem); 649 // pDItem = NULL; // Why bother, we can count - fixme to be gone 650 NumItemsToUnhilite = ulNumfiles + 1; 651 break; 652 } 653 pDItem->fsControl = isdir ? DC_CONTAINER : 0; 654 if (IsFullName(list[ulSelect]) && 655 (driveflags[toupper(*list[ulSelect]) - 'A'] & DRIVE_REMOVABLE)) 656 pDItem->fsControl |= DC_REMOVEABLEMEDIA; 657 pDItem->fsSupportedOps = DO_COPYABLE | DO_LINKABLE; 658 if (moveok && IsFullName(list[ulSelect]) && 659 !(driveflags[toupper(*list[ulSelect]) - 'A'] & DRIVE_NOTWRITEABLE)) 660 pDItem->fsSupportedOps |= DO_MOVEABLE; 661 if (IsRoot(list[ulSelect])) 662 pDItem->fsControl = DO_LINKABLE; 663 ulNumfiles++; 664 // ppDItem[ulNumfiles] = NULL; // Why bother - fixme to be gone 665 } 666 } // for 593 667 if (ulNumfiles) { 594 pDInfo = DrgAllocDraginfo(ulNumfiles); /* Allocate DRAGINFO */668 pDInfo = DrgAllocDraginfo(ulNumfiles); 595 669 if (pDInfo) { 596 670 if ((IsFullName(szBuffer) && … … 601 675 if (IsRoot(list[0])) 602 676 pDInfo->usOperation = DO_LINK; 603 pDInfo->hwndSource = (hwndObj)? hwndObj : hwnd;677 pDInfo->hwndSource = hwndObj ? hwndObj : hwnd; 604 678 // pDInfo->hwndSource = hwnd; 605 for ( Select = 0L; Select < ulNumfiles;Select++) {606 DrgSetDragitem(pDInfo, /* Set item in DRAGINFO */607 ppDItem[Select], /* Pointer to DRAGITEM */608 sizeof(DRAGITEM), /* Size of DRAGITEM */609 Select); /* Index of DRAGITEM */610 free(ppDItem[ Select]);611 } 679 for (ulSelect = 0; ulSelect < ulNumfiles; ulSelect++) { 680 if (!DrgSetDragitem(pDInfo, ppDItem[ulSelect], sizeof(DRAGITEM), ulSelect)) { 681 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 682 "DrgSetDragitem"); 683 } 684 free(ppDItem[ulSelect]); 685 } // for 612 686 #ifdef __DEBUG_ALLOC__ 613 687 _heap_check(); 614 688 #endif 615 689 free(ppDItem); 616 ppDItem = NULL; 690 ppDItem = NULL; // Remember gone 617 691 DosPostEventSem(CompactSem); 618 692 … … 621 695 622 696 WinSetFocus(HWND_DESKTOP, HWND_DESKTOP); 623 hDrop = DrgDrag(hwnd, /* Initiate drag */ 624 pDInfo, /* DRAGINFO structure */ 625 padiIcon, ulNumIcon, VK_ENDDRAG, /* End of drag indicator */ 626 (PVOID) NULL); /* Reserved */ 627 if (!DeleteDragitemStrHandles(pDInfo)) 628 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 629 "DeleteDragistr"); 630 DrgDeleteDraginfoStrHandles (pDInfo); 631 if (!DrgFreeDraginfo(pDInfo)); /* Free DRAGINFO struct */ 632 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 633 "DrgFreeDraginfo"); 634 xfree(padiIcon); 635 padiIcon = NULL; 697 hDrop = DrgDrag(hwnd, 698 pDInfo, 699 paDImgIcons, 700 ulNumIcon, 701 VK_ENDDRAG, // Drag end button 702 (PVOID) NULL); 703 if (hDrop == NULLHANDLE) { 704 NumItemsToUnhilite = 0; 705 FreeDragInfoData(hwnd, pDInfo); 706 } 707 xfree(paDImgIcons); 708 paDImgIcons = NULL; // Remember gone 636 709 WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); 637 710 DosPostEventSem(CompactSem); … … 640 713 if (ppDItem) 641 714 free(ppDItem); 642 if (pa diIcon)643 free(pa diIcon);715 if (paDImgIcons) 716 free(paDImgIcons); 644 717 return hDrop; 645 718 } 646 719 647 #ifdef NEVER 720 #ifdef NEVER // fixme to be enabled someday? 648 721 649 722 BOOL PickUp(HWND hwndCnr, HWND hwndObj, PCNRDRAGINIT pcd) … … 655 728 ULONG cditem = 0; 656 729 DRAGITEM ditem; 657 DRAGIMAGE di FakeIcon;730 DRAGIMAGE dimgFakeIcon; 658 731 CHAR szDir[CCHMAXPATH], szFile[CCHMAXPATH], *p; 659 732 … … 702 775 ditem.hstrContainerName = DrgAddStrHandle(szDir); 703 776 ditem.hstrSourceName = DrgAddStrHandle(szFile); 704 if (!ditem.hstrSourceName) 705 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 706 "DrgAddStrHandle"); 777 // fixme to check better if code ever enabled 778 if (!ditem.hstrSourceName) { 779 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 780 "DrgAddStrHandle"); 781 } 707 782 ditem.hstrTargetName = DrgAddStrHandle(szFile); 708 783 ditem.fsControl = 0; … … 719 794 if (IsRoot(pci->szFileName)) 720 795 ditem.fsSupportedOps = DO_LINKABLE; 721 memset(&di FakeIcon, 0, sizeof(DRAGIMAGE));722 di FakeIcon.hImage = pci->rc.hptrIcon;723 di FakeIcon.cb = sizeof(DRAGIMAGE);724 di FakeIcon.cptl = 0;725 di FakeIcon.fl = DRG_ICON;726 di FakeIcon.sizlStretch.cx = 32;727 di FakeIcon.sizlStretch.cy = 32;728 di FakeIcon.cxOffset = -16;729 di FakeIcon.cyOffset = 0;796 memset(&dimgFakeIcon, 0, sizeof(DRAGIMAGE)); 797 dimgFakeIcon.hImage = pci->rc.hptrIcon; 798 dimgFakeIcon.cb = sizeof(DRAGIMAGE); 799 dimgFakeIcon.cptl = 0; 800 dimgFakeIcon.fl = DRG_ICON; 801 dimgFakeIcon.sizlStretch.cx = 32; 802 dimgFakeIcon.sizlStretch.cy = 32; 803 dimgFakeIcon.cxOffset = -16; 804 dimgFakeIcon.cyOffset = 0; 730 805 if (IsFullName(pci->szFileName) && 731 806 (driveflags[toupper(*pci->szFileName) - 'A'] & … … 743 818 pci = WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, 744 819 MPFROMP(pci), MPFROMSHORT(CRA_SELECTED)); 745 } 820 } // while 746 821 if (pdinfoCurrent) 747 return DrgLazyDrag(hwndCnr, pdinfoCurrent, &di FakeIcon, 1, NULL);822 return DrgLazyDrag(hwndCnr, pdinfoCurrent, &dimgFakeIcon, 1, NULL); 748 823 } 749 824 return FALSE; -
trunk/dll/droplist.c
r603 r618 15 15 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 16 16 06 Apr 07 GKY Add some error checking in drag/drop 17 19 Apr 07 SHL Use FreeDragInfoData 18 19 Apr 07 SHL Add more drag/drop error checking 17 19 18 20 ***********************************************************************/ … … 31 33 32 34 static PSZ pszSrcFile = __FILE__; 35 36 static ULONG GetDropCount(HWND hwnd, MPARAM mp1); 33 37 34 38 #pragma alloc_text(DROPLIST,DoFileDrop,FullDrgName,TwoDrgNames,GetOneDrop) … … 102 106 blen = DrgQueryStrName(pDItem->hstrContainerName, buflen, buffer); 103 107 if(!blen) 104 108 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 105 109 "DrgQueryStrName"); 106 110 else { … … 112 116 buffer[blen] = 0; 113 117 len = DrgQueryStrName(pDItem->hstrSourceName, 114 buflen - blen, buffer + blen); 115 if(!len) 116 // printf("%s %d\n %s\n %d %X\n", pszSrcFile, __LINE__, pDItem->hstrSourceName, 117 // buflen - blen, buffer + blen); fflush(stdout); 118 // Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 119 // "DrgQueryStrName"); 118 buflen - blen, buffer + blen); 119 if(!len) { 120 // DbgMsg(pszSrcFile, __LINE__, "0x%x %d %d", pDItem->hstrSourceName, 121 // buflen - blen, buffer + blen); 122 // Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 123 // "DrgQueryStrName"); 124 } 120 125 buffer[blen + len] = 0; 121 126 { /* be sure we get full pathname of file/directory */ … … 125 130 if (!rc) { 126 131 strncpy(buffer, szTemp, buflen); 127 132 buffer[buflen - 1] = 0; 128 133 } 129 134 else … … 132 137 } 133 138 { /* be sure that file/directory is accessible */ 134 139 FILESTATUS3 fsa3; 135 140 136 141 rc = DosQueryPathInfo(buffer, FIL_STANDARD, &fsa3, sizeof(fsa3)); … … 138 143 ret = TRUE; 139 144 else { 140 141 142 145 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 146 "DosQueryPathInfo"); 147 *buffer = 0; 143 148 } 144 149 } … … 147 152 } 148 153 149 BOOL GetOneDrop( MPARAM mp1, MPARAM mp2, char *buffer, ULONG buflen)150 { 151 PDRAGITEM pDItem; /* DRAGITEM struct ptr*/152 PDRAGINFO pDInfo; /* DRAGINFO struct ptr*/154 BOOL GetOneDrop(HWND hwnd, MPARAM mp1, MPARAM mp2, char *buffer, ULONG buflen) 155 { 156 PDRAGITEM pDItem; /* DRAGITEM struct ptr */ 157 PDRAGINFO pDInfo; /* DRAGINFO struct ptr */ 153 158 ULONG numitems; 154 register ULONG x;159 register ULONG curitem; 155 160 BOOL ret = FALSE; 156 APIRET rc;157 161 158 162 if (buffer && buflen) 159 *buffer = 0; /* zero buffer field 160 161 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer 163 *buffer = 0; /* zero buffer field */ 164 165 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 162 166 if (pDInfo) { 163 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 164 numitems = DrgQueryDragitemCount(pDInfo); 165 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 166 0); /* Index to DRAGITEM */ 167 if (buflen && buffer) { 168 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 169 DRM_OS2FILE, /* mechanisms and data */ 170 NULL) && !(pDItem->fsControl & DC_PREPARE)) 171 ret = FullDrgName(pDItem, buffer, buflen); 172 } 173 /* note: targetfail is returned to source for all items */ 174 for (x = 0; x < numitems; x++) { 175 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 176 x); /* Index to DRAGITEM */ 177 DrgSendTransferMsg(pDInfo->hwndSource, DM_ENDCONVERSATION, 178 MPFROMLONG(pDItem->ulItemID), 179 MPFROMLONG(DMFL_TARGETFAIL)); 180 } 181 rc = DeleteDragitemStrHandles(pDInfo); // 182 if(!rc) 183 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 184 "DeleteDragitemStrHandles"); 185 DrgDeleteDraginfoStrHandles (pDInfo); 186 rc = DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 187 if(!rc) 188 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 189 "DrgFreeDraginfo"); 167 if (!DrgAccessDraginfo(pDInfo)) { 168 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 169 "DrgAccessDraginfo"); 170 } 171 else { 172 numitems = DrgQueryDragitemCount(pDInfo); 173 pDItem = DrgQueryDragitemPtr(pDInfo,0); 174 if (buflen && buffer) { 175 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 176 DRM_OS2FILE, /* mechanisms and data */ 177 NULL) && !(pDItem->fsControl & DC_PREPARE)) 178 ret = FullDrgName(pDItem, buffer, buflen); 179 } 180 // Return targetfail to source for all items - fixme to know why 181 for (curitem = 0; curitem < numitems; curitem++) { 182 pDItem = DrgQueryDragitemPtr(pDInfo,curitem); 183 DrgSendTransferMsg(pDInfo->hwndSource, DM_ENDCONVERSATION, 184 MPFROMLONG(pDItem->ulItemID), 185 MPFROMLONG(DMFL_TARGETFAIL)); 186 } 187 FreeDragInfoData(hwnd, pDInfo); 188 } 190 189 } 191 190 … … 193 192 } 194 193 195 BOOL AcceptOneDrop( MPARAM mp1, MPARAM mp2)196 { 197 PDRAGITEM pDItem; /* Pointer to DRAGITEM*/198 PDRAGINFO pDInfo; /* Pointer to DRAGINFO*/194 BOOL AcceptOneDrop(HWND hwnd, MPARAM mp1, MPARAM mp2) 195 { 196 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 197 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */ 199 198 BOOL ret = FALSE; 200 APIRET rc; 201 202 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 199 200 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */ 203 201 if (pDInfo) { 204 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 205 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 206 0); /* Index to DRAGITEM */ 207 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 208 DRM_OS2FILE, /* mechanisms and data */ 209 NULL)) /* formats */ 210 ret = TRUE; 211 rc = DeleteDragitemStrHandles(pDInfo); // 212 if(!rc) 213 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 214 "DeleteDragitemStrHandles"); 215 DrgDeleteDraginfoStrHandles(pDInfo); 216 rc = DrgFreeDraginfo(pDInfo); 217 if(!rc) 218 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 219 "DrgFreeDraginfo"); 202 if (!DrgAccessDraginfo(pDInfo)) { 203 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 204 "DrgAccessDraginfo"); 205 } 206 else { 207 pDItem = DrgQueryDragitemPtr(pDInfo, 0); 208 209 /* Check valid rendering mechanisms and data formats */ 210 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) 211 ret = TRUE; 212 213 // FreeDragInfoData(hwnd, pDInfo); // 20 Apr 07 SHL 214 DrgFreeDraginfo(pDInfo); 215 } 220 216 } 221 217 return ret; 222 218 } 223 219 224 ULONG FreeDrop(MPARAM mp1, MPARAM mp2)220 static ULONG GetDropCount(HWND hwnd, MPARAM mp1) 225 221 { 226 222 PDRAGINFO pDInfo; 227 223 ULONG numitems; 228 APIRET rc;229 224 230 225 pDInfo = mp1; 231 226 if (pDInfo) { 232 DrgAccessDraginfo(pDInfo); 233 numitems = DrgQueryDragitemCount(pDInfo); 234 rc = DeleteDragitemStrHandles(pDInfo); // 235 if(!rc) 236 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 237 "DeleteDragitemStrHandles"); 238 DrgDeleteDraginfoStrHandles(pDInfo); 239 rc = DrgFreeDraginfo(pDInfo); 240 if(!rc) 241 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 242 "DrgFreeDraginfo"); 227 if (!DrgAccessDraginfo(pDInfo)) { 228 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 229 "DrgAccessDraginfo"); 230 numitems = 0; // Oh well 231 } 232 else { 233 numitems = DrgQueryDragitemCount(pDInfo); 234 FreeDragInfoData(hwnd, pDInfo); 235 } 243 236 } 244 237 return numitems; … … 249 242 ULONG numitems; 250 243 251 numitems = FreeDrop(mp1, mp2);244 numitems = GetDropCount(hwnd, mp1); 252 245 saymsg(MB_ENTER | MB_ICONASTERISK, 253 246 hwnd, GetPString(IDS_FM2DROPHELPTEXT), text, numitems, numitems); … … 265 258 PCNRITEM pci; 266 259 CHAR szFrom[CCHMAXPATH + 1], szArc[CCHMAXPATH + 1]; 267 registerCHAR **files = NULL;260 CHAR **files = NULL; 268 261 INT numfiles = 0, numalloc = 0; 269 register ULONG curitem = 0L, numitems, *cbFile = NULL, *ulitemID = NULL;262 ULONG curitem, numitems, *cbFile = NULL, *ulitemID = NULL; 270 263 LISTINFO *li = NULL; 271 264 ARC_TYPE *arcinfo = NULL; 272 265 USHORT Operation; 273 APIRET rc;274 266 275 267 *szArc = 0; … … 278 270 if (!pDInfo) 279 271 return NULL; 280 rc = DrgAccessDraginfo(pDInfo); 281 if(!rc) 282 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 283 "DrgAccessDraginfo"); 284 Operation = pDInfo->usOperation; 285 pDItem = DrgQueryDragitemPtr(pDInfo, 0L); 286 if(!pDItem) 287 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 288 "DrgQueryDragitemPtr"); 289 if (Operation == DO_MOVE && !(pDItem->fsSupportedOps & DO_MOVEABLE)) { 290 saymsg(MB_ENTER, HWND_DESKTOP, GetPString(IDS_WARNINGTEXT), 291 GetPString(IDS_FORCINGCOPYTEXT)); 292 Operation = DO_COPY; 293 } 294 numitems = DrgQueryDragitemCount(pDInfo); 295 while (curitem < numitems) { 272 if (!DrgAccessDraginfo(pDInfo)) { 273 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 274 "DrgAccessDraginfo"); 275 numitems = 0; // Avoid death 276 } 277 else { 278 numitems = DrgQueryDragitemCount(pDInfo); 279 Operation = pDInfo->usOperation; 280 pDItem = DrgQueryDragitemPtr(pDInfo, 0); 281 if (!pDItem) { 282 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 283 "DrgQueryDragitemPtr"); 284 } 285 else { 286 if (Operation == DO_MOVE && !(pDItem->fsSupportedOps & DO_MOVEABLE)) { 287 saymsg(MB_ENTER, HWND_DESKTOP, GetPString(IDS_WARNINGTEXT), 288 GetPString(IDS_FORCINGCOPYTEXT)); 289 Operation = DO_COPY; 290 } 291 } 292 } 293 294 for (curitem = 0; curitem < numitems; curitem++) { 296 295 pDItem = DrgQueryDragitemPtr(pDInfo, curitem); 297 if (!pDItem) 296 if (!pDItem) { 297 Win_Error(hwndCnr, hwndCnr, pszSrcFile, __LINE__, 298 "DrgQueryDragitemPtr(%u)", curitem); 298 299 break; 300 } 299 301 300 302 /* ambiguous drop request -- see what's allowed */ … … 309 311 else { 310 312 /* ignore object if selected command not allowed for it */ 313 BOOL ok; 311 314 switch (Operation) { 312 315 case DO_MOVE: 313 if (pDItem->fsSupportedOps & DO_MOVEABLE) 314 goto Okay; 316 ok = pDItem->fsSupportedOps & DO_MOVEABLE; 315 317 break; 316 318 case DO_COPY: 317 if (pDItem->fsSupportedOps & DO_COPYABLE) 318 goto Okay; 319 ok = pDItem->fsSupportedOps & DO_COPYABLE; 319 320 break; 320 321 case DO_LINK: 321 if (pDItem->fsSupportedOps & DO_LINKABLE) 322 goto Okay; 322 ok = pDItem->fsSupportedOps & DO_LINKABLE; 323 323 break; 324 } 325 // Fail request 326 DrgSendTransferMsg(pDItem->hwndItem, 327 DM_ENDCONVERSATION, 328 MPFROMLONG(pDItem->ulItemID), 329 MPFROMLONG(DMFL_TARGETFAIL)); 330 curitem++; 331 continue; 332 } 333 334 Okay: 324 default: 325 ok = FALSE; 326 } 327 if (!ok) { 328 // Fail request 329 DrgSendTransferMsg(pDItem->hwndItem, 330 DM_ENDCONVERSATION, 331 MPFROMLONG(pDItem->ulItemID), 332 MPFROMLONG(DMFL_TARGETFAIL)); 333 continue; 334 } 335 } 335 336 336 337 if (DrgVerifyRMF(pDItem, … … 346 347 MPFROMLONG(pDItem->ulItemID), 347 348 MPFROMLONG(DMFL_TARGETFAIL)); 348 curitem++;349 349 continue; 350 350 } … … 375 375 MPFROMLONG(pDItem->ulItemID), 376 376 MPFROMLONG(DMFL_TARGETFAIL)); 377 curitem++;378 377 continue; 379 378 } … … 388 387 xrealloc(files, numalloc * sizeof(CHAR *), pszSrcFile, __LINE__); 389 388 if (!test) 390 goto AbortDrop;389 break; 391 390 files = test; 392 391 ltest = 393 392 xrealloc(cbFile, numalloc * sizeof(ULONG), pszSrcFile, __LINE__); 394 393 if (!ltest) 395 goto AbortDrop;394 break; 396 395 cbFile = ltest; 397 396 ltest = 398 397 xrealloc(ulitemID, numalloc * sizeof(ULONG), pszSrcFile, __LINE__); 399 398 if (!ltest) 400 goto AbortDrop;399 break; 401 400 ulitemID = ltest; 402 401 } … … 413 412 files[numfiles + 1] = NULL; 414 413 if (!files[numfiles]) 415 goto AbortDrop;414 break; 416 415 numfiles++; 417 416 DrgSendTransferMsg(pDItem->hwndItem, … … 425 424 MPFROMLONG(pDItem->ulItemID), 426 425 MPFROMLONG(DMFL_TARGETFAIL)); 427 curitem++; 428 } 429 430 AbortDrop: 426 } // for 431 427 432 428 if (files && numfiles && files[0] && cbFile && ulitemID) { … … 466 462 FreeList(files); 467 463 } 468 rc = DeleteDragitemStrHandles(pDInfo); // 469 if(!rc) 470 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 471 "DeleteDragitemStrHandles"); 472 DrgDeleteDraginfoStrHandles(pDInfo); 473 DrgFreeDraginfo(pDInfo); 464 465 FreeDragInfoData(hwndCnr, pDInfo); 466 474 467 return li; 475 468 } -
trunk/dll/extract.c
r574 r618 12 12 20 Dec 06 GKY Added checkbox to make default extract with directories 13 13 22 Mar 07 GKY Use QWL_USER 14 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods 14 15 15 16 ***********************************************************************/ … … 46 47 DrawTargetEmphasis(hwnd, emphasized); 47 48 } 48 if (AcceptOneDrop( mp1, mp2))49 if (AcceptOneDrop(hwnd, mp1, mp2)) 49 50 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 50 51 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 69 70 DrawTargetEmphasis(hwnd, emphasized); 70 71 } 71 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom)))72 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) 72 73 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND, 73 74 MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom)); -
trunk/dll/fm3dll.h
r606 r618 40 40 18 Mar 07 GKY Add MM import typedefines for fix for files misindentified as multimedia 41 41 30 Mar 07 GKY Defined golbals for removing GetPString for window class names 42 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits fExceedPMDrgLimit& DeleteDragitemStrHandles42 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits NumItemsToUnhilite & DeleteDragitemStrHandles 43 43 06 Apr 07 GKY Add some error checking in drag/drop 44 19 Apr 07 SHL Rework DeleteDragitemStrHandles to be FreeDragInfoData 45 19 Apr 07 SHL Add DbgMsg. Sync with AcceptOneDrop GetOneDrop mods. 44 46 45 47 ***********************************************************************/ … … 641 643 VOID Runtime_Error2(PCSZ pszSrcFile, UINT uSrcLineNo, UINT idMsg); 642 644 APIRET saymsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszFmt, ...); 645 VOID DbgMsg(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...); 643 646 644 647 /* valid.c */ … … 1049 1052 1050 1053 /* droplist.c */ 1051 ULONG FreeDrop(MPARAM mp1, MPARAM mp2);1052 1054 void DropHelp(MPARAM mp1, MPARAM mp2, HWND hwnd, char *text); 1053 BOOL AcceptOneDrop( MPARAM mp1, MPARAM mp2);1054 BOOL GetOneDrop( MPARAM mp1, MPARAM mp2, char *buffer, ULONG buflen);1055 BOOL AcceptOneDrop(HWND hwnd, MPARAM mp1, MPARAM mp2); 1056 BOOL GetOneDrop(HWND hwnd, MPARAM mp1, MPARAM mp2, char *buffer, ULONG buflen); 1055 1057 BOOL FullDrgName(PDRAGITEM pDItem, CHAR * buffer, ULONG buflen); 1056 1058 BOOL TwoDrgNames(PDRAGITEM pDItem, CHAR * buffer1, ULONG buflen1, … … 1058 1060 LISTINFO *DoFileDrop(HWND hwndCnr, CHAR * directory, BOOL arcfilesok, 1059 1061 MPARAM mp1, MPARAM mp2); 1060 BOOL DeleteDragitemStrHandles (PDRAGINFO pDInfo);1062 VOID FreeDragInfoData (HWND hwnd, PDRAGINFO pDInfo); 1061 1063 1062 1064 /* shadow.c */ … … 1351 1353 DATADEF PID mypid; 1352 1354 DATADEF INT driveflags[26], driveserial[26]; 1353 DATADEF ULONG NoBrokenNotify, fwsAnimate, OS2ver[2], DriveLines, fExceedPMDrgLimit;1355 DATADEF ULONG NoBrokenNotify, fwsAnimate, OS2ver[2], DriveLines, NumItemsToUnhilite; 1354 1356 DATADEF HINI fmprof; 1355 1357 DATADEF HELPINIT hini; -
trunk/dll/info.c
r576 r618 18 18 24 Mar 07 SHL Correct FileInfoProc binary file detect 19 19 24 Mar 07 SHL Correct FileInfoProc/IconProc race crash 20 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods 20 21 21 22 ***********************************************************************/ … … 368 369 DrawTargetEmphasis(hwnd, emphasized); 369 370 } 370 if (AcceptOneDrop( mp1, mp2))371 if (AcceptOneDrop(hwnd, mp1, mp2)) 371 372 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 372 373 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 389 390 emphasized = FALSE; 390 391 DrawTargetEmphasis(hwnd, emphasized); 391 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom))) {392 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { 392 393 memset(&ici, 0, sizeof(ICONINFO)); 393 394 ici.cb = sizeof(ICONINFO); -
trunk/dll/inis.c
r603 r618 18 18 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 19 19 06 Apr 07 GKY Add some error checking in drag/drop 20 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks. 20 21 21 22 ***********************************************************************/ … … 1572 1573 DrgSetDragitem(pDInfo, &DItem, sizeof(DRAGITEM), 0L); 1573 1574 hDrop = DrgDrag(hwnd, pDInfo, &DIcon, 1L, VK_ENDDRAG, (PVOID) NULL); 1574 DeleteDragitemStrHandles(pDInfo); // 1575 DrgDeleteDraginfoStrHandles (pDInfo); 1576 DrgFreeDraginfo(pDInfo); 1575 if (hDrop == NULLHANDLE) 1576 FreeDragInfoData(hwnd, pDInfo); 1577 1577 WinDestroyPointer(hptrINI); 1578 1578 } … … 1582 1582 { 1583 1583 PDRAGINFO pDInfo = (PDRAGINFO) mp1; 1584 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 1585 1586 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 1587 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 1588 0); /* Index to DRAGITEM */ 1589 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 1590 DRM_OS2FILE, /* mechanisms and data */ 1591 NULL)) { 1592 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 1593 return (MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 1594 DO_LINK)); 1595 } 1596 else if (DrgVerifyRMF(pDItem, DRM_FM2INIRECORD, DRF_FM2INI)) { 1597 if (WinQueryWindow(pDInfo->hwndSource, QW_PARENT) == 1598 WinQueryWindow(hwnd, QW_PARENT)) { 1584 PDRAGITEM pDItem; 1585 1586 if (!DrgAccessDraginfo(pDInfo)) { 1587 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 1588 "DrgAccessDraginfo"); 1589 } 1590 else { 1591 pDItem = DrgQueryDragitemPtr(pDInfo,0); 1592 /* Check valid rendering mechanisms and data */ 1593 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) { 1599 1594 DrgFreeDraginfo(pDInfo); 1600 return MRFROM2SHORT(DOR_NEVERDROP, 0); 1601 } 1602 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 1603 return (MRFROM2SHORT(DOR_DROP, ((fCopyDefault) ? DO_COPY : DO_MOVE))); 1604 } 1605 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 1606 return MRFROM2SHORT(DOR_NEVERDROP, 0); 1607 } 1595 return (MRFROM2SHORT(DOR_DROP, DO_LINK)); /* OK to drop */ 1596 } 1597 else if (DrgVerifyRMF(pDItem, DRM_FM2INIRECORD, DRF_FM2INI)) { 1598 if (WinQueryWindow(pDInfo->hwndSource, QW_PARENT) != 1599 WinQueryWindow(hwnd, QW_PARENT)) 1600 { 1601 DrgFreeDraginfo(pDInfo); 1602 return (MRFROM2SHORT(DOR_DROP, ((fCopyDefault) ? DO_COPY : DO_MOVE))); 1603 } 1604 } 1605 DrgFreeDraginfo(pDInfo); 1606 } 1607 } 1608 return MRFROM2SHORT(DOR_NEVERDROP, 0); 1608 1609 1609 1610 case DM_DRAGLEAVE: … … 1615 1616 PDRAGINFO pDInfo = (PDRAGINFO) mp1; 1616 1617 PDRAGITEM pDItem; /* Pointer to DRAGITEM */ 1617 ULONG numitems, curitem = 0L, len;1618 ULONG numitems, curitem, len; 1618 1619 USHORT action; 1619 1620 CHAR szFrom[CCHMAXPATH + 2], szDir[CCHMAXPATH + 1], … … 1622 1623 INIREC inirec; 1623 1624 1624 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */ 1625 if (!DrgAccessDraginfo(pDInfo)) { 1626 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 1627 "DrgAccessDraginfo"); 1628 return 0; 1629 } 1625 1630 numitems = DrgQueryDragitemCount(pDInfo); 1626 while (curitem < numitems) {1631 for (curitem = 0; curitem < numitems; curitem++) { 1627 1632 pDItem = DrgQueryDragitemPtr(pDInfo, curitem); 1628 1633 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) { … … 1677 1682 MPFROMLONG(DMFL_TARGETFAIL)); 1678 1683 } 1679 curitem++; 1680 } 1681 rc = DeleteDragitemStrHandles(pDInfo); // 1682 1683 if(!rc) 1684 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 1685 "DrgDeleteDraginfoStrHandles"); 1686 DrgDeleteDraginfoStrHandles(pDInfo); 1687 rc = DrgFreeDraginfo(pDInfo); 1688 if(!rc) 1689 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 1690 "DrgFreeDraginfo"); 1684 } // for 1685 FreeDragInfoData(hwnd, pDInfo); 1691 1686 } 1692 1687 return 0; … … 1697 1692 hwndPopup = (HWND) 0; 1698 1693 break; 1699 } 1694 } // switch 1700 1695 if (oldproc) 1701 1696 return oldproc(hwnd, msg, mp1, mp2); -
trunk/dll/mainwnd.c
r606 r618 30 30 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 31 31 06 Apr 07 GKY Add some error checking in drag/drop 32 15 Apr 07 SHL mainwnd MAIN_SETUPLIST restore state not found reporting 33 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods 34 20 Apr 07 SHL Avoid spurious add_udir error reports 32 35 33 36 ***********************************************************************/ … … 35 38 #define INCL_DOS 36 39 #define INCL_WIN 40 // #define INCL_WINERRORS 41 #define INCL_SHLERRORS 37 42 #define INCL_WINHELP 38 43 #define INCL_GPI … … 628 633 DrawTargetEmphasis(hwnd, emphasized); 629 634 } 630 if (AcceptOneDrop( mp1, mp2))635 if (AcceptOneDrop(hwnd, mp1, mp2)) 631 636 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 632 637 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 662 667 DrawTargetEmphasis(hwnd, emphasized); 663 668 } 664 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom))) {669 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { 665 670 MakeValidDir(szFrom); 666 671 WinSetWindowText(hwnd, szFrom); … … 1233 1238 cdi.pDragInfo = mp1; 1234 1239 li = DoFileDrop(hwnd, NULL, FALSE, mp1, MPFROMP(&cdi)); 1235 if ( fExceedPMDrgLimit)1240 if (NumItemsToUnhilite) 1236 1241 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 1237 1242 hwnd, … … 1752 1757 DrawTargetEmphasis(hwnd, emphasized); 1753 1758 } 1754 if (AcceptOneDrop( mp1, mp2))1759 if (AcceptOneDrop(hwnd, mp1, mp2)) 1755 1760 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 1756 1761 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 1806 1811 NULL, 1807 1812 TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd)); 1808 if ( fExceedPMDrgLimit)1813 if (NumItemsToUnhilite) 1809 1814 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 1810 1815 hwnd, … … 3456 3461 DrawTargetEmphasis(hwnd, emphasized); 3457 3462 } 3458 if (AcceptOneDrop( mp1, mp2))3463 if (AcceptOneDrop(hwnd, mp1, mp2)) 3459 3464 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 3460 3465 } … … 3480 3485 DrawTargetEmphasis(hwnd, emphasized); 3481 3486 } 3482 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom))) {3487 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { 3483 3488 if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) { 3484 3489 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom); … … 4151 4156 !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) { 4152 4157 if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) { 4153 if (!add_udir(TRUE, path)) 4154 Runtime_Error(pszSrcFile, __LINE__, "add_udir"); 4155 else { 4156 if (fUdirsChanged) 4157 save_udirs(); 4158 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); 4159 } 4158 add_udir(TRUE, path); 4159 if (fUdirsChanged) 4160 save_udirs(); 4161 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); 4160 4162 } 4161 4163 else { … … 4180 4182 WinQueryWindowText(hwndStatelist, 13, szStateName); 4181 4183 bstrip(szStateName); 4182 if (*szStateName) { 4184 // Ignore request if blank or attempting to using illegal name 4185 if (*szStateName && stricmp(szStateName, GetPString(IDS_STATETEXT))) { 4183 4186 if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) { 4184 4187 // Save … … 4189 4192 save_setups(); 4190 4193 } 4194 else { 4195 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, 4196 GetPString(IDS_WARNINGTEXT), 4197 GetPString(IDS_EXISTSASATEXT), szStateName, "state name"); 4198 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); 4199 } 4191 4200 } 4192 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); 4201 else { 4202 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, 4203 GetPString(IDS_WARNINGTEXT), 4204 "\"%s\" state save failed", szStateName); // 15 Apr 07 SHL failed 4205 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); 4206 } 4193 4207 } 4194 4208 else { … … 5307 5321 (CHAR *) mp1); 5308 5322 if (add_udir(FALSE, (CHAR *) mp1)) { 5309 if (fUserComboBox) { 5310 if (fAutoAddDirs) 5311 WinSendMsg(hwndUserlist, LM_INSERTITEM, 5312 MPFROM2SHORT(LIT_SORTASCENDING, 0), 5313 MPFROMP((CHAR *) mp1)); 5323 if (fUserComboBox && fAutoAddDirs) { 5324 WinSendMsg(hwndUserlist, LM_INSERTITEM, 5325 MPFROM2SHORT(LIT_SORTASCENDING, 0), 5326 MPFROMP((CHAR *) mp1)); 5314 5327 } 5315 5328 } … … 5434 5447 WinSendMsg(hwndStatelist, LM_DELETEALL, MPVOID, MPVOID); 5435 5448 if (fUserComboBox) { 5436 5437 5449 INT x; 5438 5450 … … 5704 5716 SetShiftState(); 5705 5717 size = sizeof(ULONG); 5706 sprintf(s, "%s.NumDirsLastTime", path); 5718 sprintf(s, "%s.NumDirsLastTime", path); // path is state name 5707 5719 if (!PrfQueryProfileData 5708 5720 (fmprof, FM3Str, s, (PVOID) & numsaves, &size)) 5709 Win_Error2(hwnd, hwnd, __FILE__, __LINE__, 5710 IDS_PRFQUERYPROFILEDATA); 5721 { 5722 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) { 5723 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, 5724 GetPString(IDS_WARNINGTEXT), 5725 GetPString(IDS_DOESNTEXISTTEXT), path); 5726 } 5727 else { 5728 Win_Error2(hwnd, hwnd, __FILE__, __LINE__, 5729 IDS_PRFQUERYPROFILEDATA); 5730 } 5731 } 5711 5732 else if (!numsaves) 5712 5733 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); … … 5730 5751 } 5731 5752 } 5732 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); 5753 // fixme to hold restored state name for a while 5754 // WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); // 15 Apr 07 SHL 5733 5755 } 5734 5756 else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) { -
trunk/dll/select.c
r606 r618 17 17 15 Aug 06 SHL Rework SetMask args and logic 18 18 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 19 19 Apr 07 SHL Sync with NumItemsToUnhilite mods 19 20 20 21 ***********************************************************************/ … … 62 63 if (!all) 63 64 break; 64 if(fExceedPMDrgLimit && x == fExceedPMDrgLimit - 1){ 65 fExceedPMDrgLimit = 0; 66 break; 65 // Count is one extra to ensure non-zero elsewhere 66 if (NumItemsToUnhilite && x + 2 == NumItemsToUnhilite){ 67 NumItemsToUnhilite = 0; 68 break; 67 69 } 68 70 if (list) … … 421 423 422 424 if (quitit) 423 attribute = (target) ? CRA_TARGET : (source)? CRA_SOURCE : CRA_INUSE;425 attribute = target ? CRA_TARGET : source ? CRA_SOURCE : CRA_INUSE; 424 426 pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, 425 427 MPFROMLONG(CMA_FIRST), MPFROMSHORT(attribute)); … … 437 439 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci), 438 440 MPFROM2SHORT(!quitit, 439 ((target) ? CRA_TARGET : (source)? CRA_SOURCE :440 CRA_INUSE)) );441 target ? CRA_TARGET : source ? CRA_SOURCE : 442 CRA_INUSE)); 441 443 pci = 442 444 WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, MPFROMP(pci), -
trunk/dll/treecnr.c
r606 r618 28 28 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits 29 29 06 Apr 07 GKY Add some error checking in drag/drop 30 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods 31 19 Apr 07 SHL Add more drag/drop error checking 30 32 31 33 ***********************************************************************/ … … 99 101 EmphasizeButton(hwnd, emphasized); 100 102 } 101 if (AcceptOneDrop( mp1, mp2))103 if (AcceptOneDrop(hwnd, mp1, mp2)) 102 104 return MRFROM2SHORT(DOR_DROP, DO_MOVE); 103 105 return MRFROM2SHORT(DOR_NEVERDROP, 0); … … 122 124 EmphasizeButton(hwnd, emphasized); 123 125 } 124 if (GetOneDrop( mp1, mp2, szFrom, sizeof(szFrom))) {126 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { 125 127 MakeValidDir(szFrom); 126 128 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), … … 544 546 cni.pDragInfo = (PDRAGINFO) mp1; 545 547 li = DoFileDrop(dcd->hwndCnr, 546 547 if ( fExceedPMDrgLimit)548 549 550 551 548 dcd->directory, FALSE, MPVOID, MPFROMP(&cni)); 549 if (NumItemsToUnhilite) 550 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 551 hwnd, 552 GetPString(IDS_ERRORTEXT), 553 GetPString(IDS_EXCEEDPMDRGLMT)); 552 554 if (li) { 553 555 li->type = ((fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE); … … 1254 1256 PDRAGINFO pDInfo; 1255 1257 1258 // fixme to know why - seems superfluous 1256 1259 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo; 1257 1260 DrgAccessDraginfo(pDInfo); … … 1270 1273 1271 1274 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo; 1272 DrgAccessDraginfo(pDInfo); 1275 if (!DrgAccessDraginfo(pDInfo)) { 1276 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 1277 "DrgAccessDraginfo"); 1278 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */ 1279 } 1273 1280 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord; 1274 1281 if ((INT) pci == -1) 1275 1282 pci = NULL; 1276 1283 if (pci && (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODROP))) { 1277 DrgFreeDraginfo(pDInfo);1278 return MRFROM2SHORT(DOR_NODROP, 0);1279 }1280 if (!pDInfo) {1281 1284 DrgFreeDraginfo(pDInfo); 1282 1285 return MRFROM2SHORT(DOR_NODROP, 0); … … 1315 1318 } 1316 1319 } 1317 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM 1318 0); /* Index to DRAGITEM 1320 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */ 1321 0); /* Index to DRAGITEM */ 1319 1322 if (DrgVerifyRMF(pDItem, /* Check valid rendering */ 1320 DRM_OS2FILE, /* mechanisms and data 1321 NULL) || DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE)) { /* formats 1322 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO 1323 DRM_OS2FILE, /* mechanisms and data */ 1324 NULL) || DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE)) { /* formats */ 1325 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 1323 1326 if (!pci || (INT) pci == -1) 1324 1327 return MRFROM2SHORT(DOR_DROP, DO_MOVE); … … 1328 1331 if (toupper(*pci->szFileName) < 'C') 1329 1332 return MRFROM2SHORT(DOR_DROP, DO_COPY); 1330 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop 1333 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */ 1331 1334 ((fCopyDefault) ? DO_COPY : DO_MOVE)); 1332 1335 } 1333 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO 1334 } 1335 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid 1336 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */ 1337 } 1338 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */ 1336 1339 1337 1340 case CN_INITDRAG: … … 1374 1377 ULONG action = UM_ACTION; 1375 1378 1376 1377 if (fExceedPMDrgLimit)1378 1379 1380 1381 1379 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2); 1380 if (NumItemsToUnhilite) 1381 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, 1382 hwnd, 1383 GetPString(IDS_ERRORTEXT), 1384 GetPString(IDS_EXCEEDPMDRGLMT)); 1382 1385 if (li) { 1383 1386 if (!*li->targetpath) { … … 1402 1405 dcd->hwndParent, 1403 1406 DropListProc, 1404 1405 1406 1407 1408 1407 FM3ModHandle, DND_FRAME, MPFROMP(&cl)); 1408 if (li->type == DID_ERROR) 1409 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, 1410 "Drag & Drop Dialog"); 1411 if (!li->type) { 1409 1412 FreeListInfo(li); 1410 1413 return 0; 1411 1414 } 1412 1415 li->list = cl.list; 1413 1416 if (!li->list || !li->list[0]) { 1414 1417 FreeListInfo(li); 1415 1418 return 0; … … 1798 1801 if (drvtype & DRIVE_REMOTE) 1799 1802 driveflags[x] |= DRIVE_REMOTE; 1800 1803 if (!strcmp(FileSystem, CBSIFS)) { 1801 1804 driveflags[x] |= DRIVE_ZIPSTREAM; 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1805 driveflags[x] &= (~DRIVE_REMOTE); 1806 } 1807 if(!strcmp(FileSystem,NDFS32)) { 1808 driveflags[x] |= DRIVE_VIRTUAL; 1809 driveflags[x] &= (~DRIVE_REMOTE); 1810 } 1811 if(!strcmp(FileSystem,RAMFS)) { 1812 driveflags[x] |= DRIVE_RAMDISK; 1813 driveflags[x] &= (~DRIVE_REMOTE); 1814 } 1812 1815 if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS)) 1813 1816 driveflags[x] |= (DRIVE_REMOVABLE | 1814 1815 1816 1817 DRIVE_NOTWRITEABLE | DRIVE_CDROM); 1818 if(!strcmp(FileSystem,NTFS)) 1819 driveflags[x] |= DRIVE_NOTWRITEABLE; 1817 1820 if (strcmp(FileSystem, HPFS) && 1818 1821 strcmp(FileSystem, JFS) && 1819 1822 strcmp(FileSystem, CDFS) && 1820 1821 1823 strcmp(FileSystem, ISOFS) && 1824 strcmp(FileSystem, RAMFS) && 1822 1825 strcmp(FileSystem, FAT32) && 1823 1824 1825 1826 strcmp(FileSystem, NDFS32) && 1827 strcmp(FileSystem, NTFS) && 1828 strcmp(FileSystem, HPFS386)) { 1826 1829 driveflags[x] |= DRIVE_NOLONGNAMES; 1827 1828 1830 } 1831 SelectDriveIcon(pciP); 1829 1832 WinSendMsg(hwnd, 1830 1833 CM_INVALIDATERECORD, … … 2563 2566 // Check if drive type might need update 2564 2567 if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) || 2565 2568 (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno)) 2566 2569 { 2567 2570 driveflags[toupper(*pci->szFileName) - 'A'] &= … … 2569 2572 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | DRIVE_NOSTATS); 2570 2573 DriveFlagsOne(toupper(*pci->szFileName) - 'A'); 2571 2574 driveflag = driveflags[toupper(*pci->szFileName) - 'A']; 2572 2575 if (driveflag & DRIVE_INVALID) 2573 2576 pci->rc.hptrIcon = hptrDunno; 2574 2577 else { 2575 2578 SelectDriveIcon(pci); 2576 2579 } 2577 2580 WinSendMsg(hwnd,
Note:
See TracChangeset
for help on using the changeset viewer.