Changeset 3243 for trunk/src/comdlg32/filedlgbrowser.c
- Timestamp:
- Mar 26, 2000, 6:34:57 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/comdlg32/filedlgbrowser.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/filedlgbrowser.c
r3216 r3243 1 /* $Id: filedlgbrowser.c,v 1.3 2000-03-26 16:31:42 cbratschi Exp $ */ 1 2 /* 2 3 * Implementation of IShellBrowser for the File Open common dialog 3 4 * 5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch) 6 * Project Odin Software License can be found in LICENSE.TXT 7 * 8 * Corel WINE 20000324 level 4 9 */ 5 10 … … 41 46 static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl = 42 47 { 48 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 43 49 /* IUnknown */ 44 50 IShellBrowserImpl_QueryInterface, … … 66 72 static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl = 67 73 { 74 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 68 75 /* IUnknown */ 69 76 IShellBrowserImpl_ICommDlgBrowser_QueryInterface, … … 327 334 return NOERROR; 328 335 } 336 #ifdef SHELL_NO_DESKTOP 337 338 if(pidlTmp->mkid.cb == 0x00) 339 { 340 IShellFolder_Release(psfTmp); 341 COMDLG32_SHFree(pidlTmp); 342 return NOERROR; 343 } 344 #endif 329 345 330 346 /* Release the current fodInfos->Shell.FOIShellFolder and update its value */ … … 339 355 { 340 356 HWND hwndView; 357 HWND hDlgWnd; 358 BOOL bViewHasFocus; 359 360 /* Check if listview has focus */ 361 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus()); 362 341 363 /* Get the foldersettings from the old view */ 342 364 if(fodInfos->Shell.FOIShellView) … … 383 405 fodInfos->ShellInfos.hwndView = hwndView; 384 406 407 /* changes the tab order of the ListView to reflect the window's File Dialog */ 408 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN); 409 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); 410 411 /* Since we destroyed the old view if it had focus set focus 412 to the newly created view */ 413 if (bViewHasFocus) 414 SetFocus(fodInfos->ShellInfos.hwndView); 415 385 416 return NOERROR; 386 417 } … … 662 693 else 663 694 { 664 hRes = FILEDLG95_OnOpen(This->hwndOwner);695 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L); 665 696 } 666 697 … … 689 720 { 690 721 case CDBOSC_SETFOCUS: 722 /* FIXME: Reset the default button. 723 This should be taken care of by defdlg. If control 724 other than button receives focus the default button 725 should be restored. */ 726 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0); 691 727 break; 692 728 case CDBOSC_KILLFOCUS: … … 754 790 HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv) 755 791 { 756 LPITEMIDLIST pidl;792 ULONG uAttr; 757 793 FileOpenDlgInfos *fodInfos; 794 UINT nFiles = 0; /* Intial to zero */ 795 UINT nCurrLength; 796 UINT nFileToOpen; 797 UINT nAllLength = 2; /* Include intial '"' and final NULL */ 798 UINT nSize = MAX_PATH; 799 UINT nFileSelected = 0; 800 LPITEMIDLIST pidlSelection; 801 LPSTR lpstrTemp = NULL; 802 LPSTR lpstrAllFile = NULL; 803 char lpstrCurrFile[MAX_PATH]; 804 758 805 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface); 759 806 … … 761 808 TRACE("(%p)\n", This); 762 809 763 pidl = GetSelectedPidl(ppshv); 764 if (pidl) 765 { 766 HRESULT hRes = E_FAIL; 767 char lpstrFileName[MAX_PATH]; 768 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 769 770 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); 771 if (!ulAttr) 810 /* Locate memory and Get selected item counter */ 811 if((lpstrAllFile = (LPSTR)SHAlloc(nSize * sizeof(char))) != NULL) 812 { 813 ZeroMemory(lpstrAllFile, nSize * sizeof(char)); 814 *lpstrAllFile = '\"'; 815 lpstrTemp = lpstrAllFile + 1; 816 nFileSelected = GetNumSelected(fodInfos->Shell.FOIShellView); /* Get all selected counter */ 817 } 818 819 /* Count all selected files we have */ 820 for(nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++) 821 { /* get the file selected */ 822 pidlSelection = NULL; 823 uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 824 ZeroMemory(lpstrCurrFile, MAX_PATH * sizeof(char)); 825 EnumSelectedPidls(fodInfos->Shell.FOIShellView, nFileToOpen, &pidlSelection); 826 827 /* get the file name and attrib of the selected files*/ 828 GetName(fodInfos->Shell.FOIShellFolder, pidlSelection, SHGDN_NORMAL, lpstrCurrFile); 829 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr); 830 COMDLG32_SHFree((LPVOID) pidlSelection); 831 832 if(!uAttr) 833 { /* Get the new file name */ 834 nCurrLength = lstrlenA(lpstrCurrFile); 835 if(nAllLength + nCurrLength + 3 > nSize) 836 { /* increase the memory and transfer string to new location */ 837 nSize += MAX_PATH; 838 if((lpstrTemp = (LPSTR)SHAlloc(nSize * sizeof(char))) != NULL) 839 { /* Transfer old file names */ 840 ZeroMemory(lpstrTemp, nSize * sizeof(char)); 841 lstrcpyA(lpstrTemp, lpstrAllFile); 842 SHFree(lpstrAllFile); 843 lpstrAllFile = lpstrTemp; 844 lpstrTemp = lpstrAllFile + nAllLength - 1; 845 } 846 else 847 { /* if failure, stop the loop to get filename */ 848 nFileSelected = 0; 849 } 850 } 851 852 if(lpstrTemp != NULL) 853 { /* Add the new file name */ 854 nFiles++; 855 lstrcpyA(lpstrTemp, lpstrCurrFile); 856 *(lpstrTemp + nCurrLength) = '\"'; 857 *(lpstrTemp + nCurrLength + 1) = ' '; 858 *(lpstrTemp + nCurrLength + 2) = '\"'; 859 nAllLength += nCurrLength + 3; 860 lpstrTemp = lpstrAllFile + nAllLength - 1; 861 } 862 } 863 } 864 865 if(lpstrAllFile) 866 { 867 if(nFiles > 1) 772 868 { 773 if(SUCCEEDED(hRes = GetName(fodInfos->Shell.FOIShellFolder,pidl,SHGDN_NORMAL,lpstrFileName))) 774 SetWindowTextA(fodInfos->DlgInfos.hwndFileName,lpstrFileName); 775 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) 776 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save"); 869 *(lpstrTemp - 2) = '\0'; 870 SetWindowTextA(fodInfos->DlgInfos.hwndFileName, lpstrAllFile); 777 871 } 778 872 else 779 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Open"); 873 { 874 *(lpstrTemp - 3) = '\0'; 875 SetWindowTextA(fodInfos->DlgInfos.hwndFileName, lpstrAllFile + 1); 876 } 780 877 781 878 fodInfos->DlgInfos.dwDlgProp |= FODPROP_USEVIEW; 782 783 COMDLG32_SHFree((LPVOID)pidl);784 879 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE); 785 return hRes; 786 } 880 SHFree( lpstrAllFile ); 881 } 882 else 883 { 884 SetWindowTextA(fodInfos->DlgInfos.hwndFileName, ""); 885 } 886 787 887 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) 788 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save"); 888 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner, IDOK, "&Save"); 889 else 890 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner, IDOK, "&Open"); 789 891 790 892 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW; 791 return E_FAIL; 893 894 return nFileSelected ? S_OK : E_FAIL; 792 895 } 793 896 … … 841 944 } 842 945 843 844 845 846 946 /*********************************************************************** 947 * EnumSelectedPidls 948 * 949 * Return the pidl(s) of the selected item(s) in the view. 950 * 951 */ 952 BOOL EnumSelectedPidls( IShellView *ppshv, /*[in]*/ 953 UINT nPidlIndex, /*[in]*/ 954 LPITEMIDLIST *pidlSelected /*[out]*/ ) 955 { 956 957 IDataObject *doSelected; 958 BOOL retVal = TRUE; 959 960 /* Get an IDataObject from the view */ 961 if(SUCCEEDED(IShellView_GetItemObject(ppshv, 962 SVGIO_SELECTION, 963 &IID_IDataObject, 964 (LPVOID *)&doSelected))) 965 { 966 STGMEDIUM medium; 967 FORMATETC formatetc; 968 969 /* Set the FORMATETC structure*/ 970 SETDefFormatEtc(formatetc, 971 RegisterClipboardFormatA(CFSTR_SHELLIDLIST), 972 TYMED_HGLOBAL); 973 974 /* Get the pidls from IDataObject */ 975 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) 976 { 977 LPIDA cida = GlobalLock(medium.u.hGlobal); 978 if(nPidlIndex < cida->cidl) 979 { 980 *pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex + 1]])); 981 } 982 else 983 { 984 retVal = FALSE; 985 } 986 987 if(medium.pUnkForRelease) 988 { 989 IUnknown_Release(medium.pUnkForRelease); 990 } 991 else 992 { 993 GlobalUnlock(medium.u.hGlobal); 994 GlobalFree(medium.u.hGlobal); 995 } 996 } 997 IDataObject_Release(doSelected); 998 return retVal; 999 } 1000 return FALSE; 1001 } 1002 1003 /*********************************************************************** 1004 * GetNumSelected 1005 * 1006 * Return the number of selected items in the view. 1007 * 1008 */ 1009 UINT GetNumSelected( IShellView *ppshv ) 1010 { 1011 IDataObject *doSelected; 1012 UINT retVal = 0; 1013 1014 /* Get an IDataObject from the view */ 1015 if(SUCCEEDED(IShellView_GetItemObject(ppshv, 1016 SVGIO_SELECTION, 1017 &IID_IDataObject, 1018 (LPVOID *)&doSelected))) 1019 { 1020 STGMEDIUM medium; 1021 FORMATETC formatetc; 1022 1023 /* Set the FORMATETC structure*/ 1024 SETDefFormatEtc(formatetc, 1025 RegisterClipboardFormatA(CFSTR_SHELLIDLIST), 1026 TYMED_HGLOBAL); 1027 1028 /* Get the pidls from IDataObject */ 1029 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) 1030 { 1031 LPIDA cida = GlobalLock(medium.u.hGlobal); 1032 retVal = cida->cidl; 1033 1034 if(medium.pUnkForRelease) 1035 IUnknown_Release(medium.pUnkForRelease); 1036 else 1037 { 1038 GlobalUnlock(medium.u.hGlobal); 1039 GlobalFree(medium.u.hGlobal); 1040 } 1041 } 1042 IDataObject_Release(doSelected); 1043 return retVal; 1044 } 1045 1046 return 0; 1047 } 1048 1049 1050
Note:
See TracChangeset
for help on using the changeset viewer.
