Changeset 8541 for trunk/src/user32/pmwindow.cpp
- Timestamp:
- Jun 1, 2002, 7:26:32 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/pmwindow.cpp
r8406 r8541 1 /* $Id: pmwindow.cpp,v 1.17 3 2002-05-14 09:06:49sandervl Exp $ */1 /* $Id: pmwindow.cpp,v 1.174 2002-06-01 17:26:30 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Managment Code for OS/2 … … 780 780 break; 781 781 782 case DM_DRAGOVER: 783 { 784 PDRAGINFO pDragInfo = (PDRAGINFO)mp1; 785 PDRAGITEM pDragItem; 786 USHORT sxDrop = SHORT1FROMMP(mp2); 787 USHORT syDrop = SHORT2FROMMP(mp2); 788 USHORT usIndicator, usOp; 789 ULONG ulBytes; 790 int i, cItems; 791 BOOL ret; 792 char szFileName[CCHMAXPATH]; 793 char szContainerName[CCHMAXPATH]; 794 795 dprintf(("OS2: DM_DRAGOVER %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop)); 796 797 //does this window accept dropped files? 798 if(!win32wnd->AcceptsDropFiles()) { 799 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 800 break; 801 } 802 /* Get access to the DRAGINFO data structure */ 803 if(!DrgAccessDraginfo(pDragInfo)) { 804 rc = (MRFROM2SHORT (DOR_NODROP, 0)); 805 break; 806 } 807 808 /* Can we accept this drop? */ 809 switch (pDragInfo->usOperation) { 810 /* Return DOR_NODROPOP if current operation */ 811 /* is link or unknown */ 812 case DO_LINK: 813 case DO_COPY: 814 case DO_UNKNOWN: 815 DrgFreeDraginfo(pDragInfo); 816 rc = (MRFROM2SHORT (DOR_NODROPOP, 0)); 817 break; 818 819 /* Our default operation is Move */ 820 case DO_MOVE: 821 case DO_DEFAULT: 822 pDragItem = DrgQueryDragitemPtr(pDragInfo, 0); 823 ulBytes = DrgQueryStrName(pDragItem->hstrContainerName, 824 sizeof(szContainerName), 825 szContainerName); 826 ulBytes = DrgQueryStrName(pDragItem->hstrSourceName, 827 sizeof(szFileName), 828 szFileName); 829 if (!ulBytes) { 830 rc = (MRFROM2SHORT (DOR_NODROPOP, 0)); 831 break; 832 } 833 else usOp = DO_MOVE; 834 835 dprintf(("dropped file %s%s", szContainerName, szFileName)); 836 break; 837 } 838 if(rc == MRFROM2SHORT (DOR_NODROPOP, 0)) { 839 break; 840 } 841 842 usIndicator = (USHORT)DOR_DROP; 843 cItems = DrgQueryDragitemCount(pDragInfo); 844 845 /* Now, we need to look at each item in turn */ 846 for (i = 0; i < cItems; i++) { 847 pDragItem = DrgQueryDragitemPtr(pDragInfo, i); 848 849 /* Make sure we can move for a Move request */ 850 if ((pDragItem->fsSupportedOps & DO_MOVEABLE) && 851 (usOp == (USHORT)DO_MOVE)) 852 { 853 usIndicator = DOR_DROP; 854 } 855 else { 856 dprintf(("item %d not accepted", i)); 857 usIndicator = DOR_NODROPOP; 858 break; 859 } 860 } 861 /* Release the draginfo data structure */ 862 DrgFreeDraginfo(pDragInfo); 863 864 dprintf(("return %x", MRFROM2SHORT(usIndicator, usOp))); 865 rc = (MRFROM2SHORT(usIndicator, usOp)); 866 break; 867 } 868 869 case DM_DRAGLEAVE: 870 { 871 dprintf(("OS2: DM_DRAGLEAVE %x", win32wnd->getWindowHandle())); 872 break; 873 } 874 875 case DM_DROP: 876 { 877 PDRAGINFO pDragInfo = (PDRAGINFO)mp1; 878 PDRAGITEM pDragItem; 879 USHORT sxDrop = SHORT1FROMMP(mp2); 880 USHORT syDrop = SHORT2FROMMP(mp2); 881 USHORT usIndicator, usOp; 882 ULONG ulBytes; 883 int i, cItems; 884 BOOL ret; 885 char szFileName[CCHMAXPATH]; 886 char szContainerName[CCHMAXPATH]; 887 888 dprintf(("OS2: DM_DROP %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop)); 889 890 //does this window accept dropped files? 891 if(!win32wnd->AcceptsDropFiles()) { 892 rc = 0; 893 break; 894 } 895 /* Get access to the DRAGINFO data structure */ 896 if(!DrgAccessDraginfo(pDragInfo)) { 897 rc = 0; 898 break; 899 } 900 901 usIndicator = (USHORT)DOR_DROP; 902 cItems = DrgQueryDragitemCount(pDragInfo); 903 904 //computer memory required to hold all filenames 905 int bufsize = 0; 906 for (i = 0; i < cItems; i++) { 907 pDragItem = DrgQueryDragitemPtr(pDragInfo, i); 908 909 bufsize += DrgQueryStrNameLen(pDragItem->hstrContainerName) + DrgQueryStrNameLen(pDragItem->hstrSourceName); 910 bufsize++; //0 terminator 911 bufsize++; //+ potential missing backslash 912 } 913 //copy all filenames 914 char *pszFiles = (char *)malloc(bufsize); 915 if(pszFiles == NULL) { 916 dprintf(("Out of memory!!")); 917 DebugInt3(); 918 break; 919 } 920 char *pszCurFile = pszFiles; 921 922 for (i = 0; i < cItems; i++) { 923 char *pszTemp = pszCurFile; 924 925 pDragItem = DrgQueryDragitemPtr(pDragInfo, i); 926 927 ulBytes = DrgQueryStrNameLen(pDragItem->hstrContainerName); 928 929 ulBytes = DrgQueryStrName(pDragItem->hstrContainerName, 930 ulBytes, pszCurFile); 931 if(pszCurFile[ulBytes-1] != '\\') { 932 pszCurFile[ulBytes] = '\\'; 933 pszCurFile++; 934 } 935 pszCurFile += ulBytes; 936 937 ulBytes = DrgQueryStrNameLen(pDragItem->hstrSourceName); 938 ulBytes = DrgQueryStrName(pDragItem->hstrSourceName, 939 ulBytes+1, pszCurFile); 940 pszCurFile += ulBytes + 1; //+ terminator 941 942 dprintf(("dropped file %s", pszTemp)); 943 } 944 POINT point = {sxDrop, syDrop}; 945 win32wnd->MsgDropFiles(cItems, point, pszFiles, bufsize); 946 free(pszFiles); 947 948 /* Release the draginfo data structure */ 949 DrgFreeDraginfo(pDragInfo); 950 951 rc = 0; 952 break; 953 } 954 782 955 case WM_DDE_INITIATE: 783 956 case WM_DDE_INITIATEACK:
Note:
See TracChangeset
for help on using the changeset viewer.