- Timestamp:
- Mar 23, 2000, 6:13:41 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/filedlg95.c
r2607 r3202 11 11 #include <misc.h> 12 12 13 #define MapHModuleSL(a) 13 #define MapHModuleSL(a) a 14 14 #define MapHModuleLS(a) a 15 15 … … 29 29 #include "debugtools.h" 30 30 #include "cderr.h" 31 #include "tweak.h"32 31 #include "winnls.h" 33 32 #include "shellapi.h" … … 43 42 typedef struct SFolder 44 43 { 45 int m_iImageIndex; /* Index of picture in image list */ 46 HIMAGELIST hImgList; 47 int m_iIndent; /* Indentation index */ 48 LPITEMIDLIST pidlItem; /* absolute pidl of the item */ 44 int m_iImageIndex; /* Index of picture in image list */ 45 HIMAGELIST hImgList; 46 int m_iIndent; /* Indentation index */ 47 LPITEMIDLIST pidlItem; /* absolute pidl of the item */ 48 CHAR* szDisplayName; 49 INT iIcon; 50 HIMAGELIST ilItemImage; 49 51 50 52 } SFOLDER,*LPSFOLDER; … … 175 177 * GetFileName95 176 178 * 177 * Creates an Open common dialog box that lets the user select 179 * Creates an Open common dialog box that lets the user select 178 180 * the drive, directory, and the name of a file or set of files to open. 179 181 * … … 212 214 if( lRes == -1) 213 215 return FALSE; 214 216 215 217 return lRes; 216 218 } … … 230 232 BOOL ret; 231 233 FileOpenDlgInfos *fodInfos; 232 233 /* Initialise FileOpenDlgInfos structure*/ 234 235 /* Initialise FileOpenDlgInfos structure*/ 234 236 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos)); 235 237 memset(&fodInfos->ofnInfos,'\0',sizeof(*ofn)); fodInfos->ofnInfos.lStructSize = sizeof(*ofn); … … 317 319 fodInfos->DlgInfos.dwDlgProp = 0; 318 320 fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL; 319 321 320 322 switch(iDlgType) 321 323 { … … 353 355 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrCustomFilter)); 354 356 355 if (fodInfos->ofnInfos.lpstrFile) 357 if (fodInfos->ofnInfos.lpstrFile) 356 358 { 357 359 /* … … 364 366 MemFree((LPVOID)fodInfos->ofnInfos.lpstrFile); 365 367 } 366 if (fodInfos->ofnInfos.lpstrFileTitle) 368 if (fodInfos->ofnInfos.lpstrFileTitle) 367 369 { 368 370 if (ofn->lpstrFileTitle) … … 404 406 /* filter is a list... title\0ext\0......\0\0 */ 405 407 s = (LPWSTR)ofn->lpstrFilter; 406 408 407 409 while (*s) 408 410 s = s+lstrlenW(s)+1; … … 470 472 471 473 if (HIWORD(ofn->lpTemplateName)) 472 { 474 { 473 475 fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName)+1); 474 476 lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpTemplateName,ofn->lpTemplateName); … … 481 483 /* Initialise the dialog property */ 482 484 fodInfos->DlgInfos.dwDlgProp = 0; 483 485 484 486 switch(iDlgType) 485 487 { … … 494 496 ret = 0; 495 497 } 496 498 497 499 /* Cleaning */ 498 500 ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset; … … 518 520 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrCustomFilter)); 519 521 520 if (fodInfos->ofnInfos.lpstrFile) 522 if (fodInfos->ofnInfos.lpstrFile) 521 523 { 522 524 /* … … 544 546 { 545 547 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 548 HWND hwndChild,hwndStc32; 549 RECT rectParent, rectChild, rectCtrl, rectStc32, rectTemp; 550 POINT ptMoveCtl; 551 POINT ptParentClient; 552 553 ptMoveCtl.x = ptMoveCtl.y = 0; 554 hwndStc32=GetDlgItem(hwndChildDlg,stc32); 555 GetClientRect(hwndParentDlg,&rectParent); 556 GetClientRect(hwndChildDlg,&rectChild); 557 if(hwndStc32) 558 { 559 GetWindowRect(hwndStc32,&rectStc32); 560 MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2); 561 CopyRect(&rectTemp,&rectStc32); 562 563 SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top)); 564 SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE); 565 566 if(rectStc32.right < rectTemp.right) 567 { 568 ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left)); 569 ptMoveCtl.x = 0; 570 } 571 else 572 { 573 ptMoveCtl.x = (rectStc32.right - rectTemp.right); 574 ptParentClient.x = max((rectParent.right-rectParent.left),((rectChild.right-rectChild.left)+rectStc32.right-rectTemp.right)); 575 } 576 if(rectStc32.bottom < rectTemp.bottom) 577 { 578 ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top)); 579 ptMoveCtl.y = 0; 580 } 581 else 582 { 583 ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom); 584 ptParentClient.y = max((rectParent.bottom-rectParent.top),((rectChild.bottom-rectChild.top)+rectStc32.bottom-rectTemp.bottom)); 585 } 586 } 587 else 588 { 589 if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL) 588 590 return; 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 591 ptParentClient.x = rectParent.right-rectParent.left; 592 ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top); 593 ptMoveCtl.y = rectParent.bottom-rectParent.top; 594 ptMoveCtl.x=0; 595 } 596 SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y); 597 AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE)); 598 599 SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y, 600 SWP_NOZORDER ); 601 SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left), 602 (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER); 603 604 hwndChild = GetWindow(hwndChildDlg,GW_CHILD); 605 if(hwndStc32) 606 { 607 GetWindowRect(hwndStc32,&rectStc32); 608 MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2); 609 } 610 else 611 SetRect(&rectStc32,0,0,0,0); 612 613 if (hwndChild ) 614 { 615 do 616 { 617 if(hwndChild != hwndStc32) 618 { 619 if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE) 620 continue; 621 GetWindowRect(hwndChild,&rectCtrl); 622 MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2); 623 624 /* 625 Check the initial position of the controls relative to the initial 626 position and size of stc32 (before it is expanded). 627 */ 626 628 if (rectCtrl.left > rectTemp.right && rectCtrl.top > rectTemp.bottom) 627 628 629 630 631 632 633 634 635 636 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 637 638 639 640 641 642 } 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 667 668 669 670 671 672 } 673 629 { 630 rectCtrl.left += ptMoveCtl.x; 631 rectCtrl.top += ptMoveCtl.y; 632 } 633 else if (rectCtrl.left > rectTemp.right) 634 rectCtrl.left += ptMoveCtl.x; 635 else if (rectCtrl.top > rectTemp.bottom) 636 rectCtrl.top += ptMoveCtl.y; 637 638 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 639 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top, 640 SWP_NOSIZE | SWP_NOZORDER ); 641 } 642 } 643 while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL); 644 } 645 hwndChild = GetWindow(hwndParentDlg,GW_CHILD); 646 647 if(hwndStc32) 648 { 649 GetWindowRect(hwndStc32,&rectStc32); 650 MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2); 651 ptMoveCtl.x = rectStc32.left - 0; 652 ptMoveCtl.y = rectStc32.top - 0; 653 if (hwndChild ) 654 { 655 do 656 { 657 if(hwndChild != hwndChildDlg) 658 { 659 660 if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE) 661 continue; 662 GetWindowRect(hwndChild,&rectCtrl); 663 MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2); 664 665 rectCtrl.left += ptMoveCtl.x; 666 rectCtrl.top += ptMoveCtl.y; 667 668 SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top, 669 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top, 670 SWP_NOSIZE |SWP_NOZORDER ); 671 } 672 } 673 while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL); 674 } 675 } 674 676 675 677 } … … 681 683 switch(uMsg) 682 684 { 683 684 { 685 case WM_INITDIALOG: 686 { 685 687 fodInfos = (FileOpenDlgInfos *)lParam; 686 688 lParam = (LPARAM) &fodInfos->ofnInfos; 687 689 ArrangeCtrlPositions(hwnd,GetParent(hwnd)); 688 690 if(fodInfos && (fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos.lpfnHook) 689 691 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos.lpfnHook,hwnd,uMsg,wParam,lParam); 690 return 0; 691 } 692 return 0; 693 } 692 694 } 693 695 if(fodInfos && (fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos.lpfnHook ) 694 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos.lpfnHook,hwnd,uMsg,wParam,lParam); 695 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 696 return CallWindowProcA((WNDPROC)fodInfos->ofnInfos.lpfnHook,hwnd,uMsg,wParam,lParam); 697 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 696 698 } 697 699 … … 704 706 if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATE || fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE) 705 707 { 706 707 708 if (fodInfos->ofnInfos.Flags & OFN_ENABLETEMPLATEHANDLE) 709 { 708 710 if( !(template = LockResource( fodInfos->ofnInfos.hInstance))) 709 710 711 712 713 714 715 716 717 711 { 712 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 713 return (HWND)NULL; 714 } 715 716 } 717 else 718 { 719 if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos.hInstance), 718 720 (fodInfos->ofnInfos.lpTemplateName), RT_DIALOGA))) 719 720 721 722 723 721 { 722 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE); 723 return (HWND)NULL; 724 } 725 if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos.hInstance), 724 726 hRes )) || 725 727 !(template = LockResource( hDlgTmpl ))) 726 727 728 729 730 731 732 733 734 735 ShowWindow(hChildDlg,SW_SHOW);736 737 728 { 729 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 730 return (HWND)NULL; 731 } 732 } 733 734 hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,template,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos); 735 if(hChildDlg) 736 { 737 ShowWindow(hChildDlg,SW_SHOW); 738 return hChildDlg; 739 } 738 740 } 739 741 else if(fodInfos->ofnInfos.Flags & OFN_ENABLEHOOK && fodInfos->ofnInfos.lpfnHook) 740 742 { 741 742 743 744 745 746 747 748 749 750 751 752 743 RECT rectHwnd; 744 DLGTEMPLATE tmplate; 745 GetClientRect(hwnd,&rectHwnd); 746 tmplate.style = WS_CHILD | WS_CLIPSIBLINGS; 747 tmplate.dwExtendedStyle = 0; 748 tmplate.cdit = 0; 749 tmplate.x = 0; 750 tmplate.y = 0; 751 tmplate.cx = rectHwnd.right-rectHwnd.left; 752 tmplate.cy = rectHwnd.bottom-rectHwnd.top; 753 754 return CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos); 753 755 } 754 756 return (HWND)NULL; 755 757 } 756 758 757 759 /*********************************************************************** 758 760 * SendCustomDlgNotificationMessage … … 830 832 return -1; 831 833 } 832 834 833 835 /*********************************************************************** 834 836 * FileOpenDlgProc95 … … 841 843 { 842 844 case WM_INITDIALOG : 843 /* Adds the FileOpenDlgInfos in the property list of the dialog 845 /* Adds the FileOpenDlgInfos in the property list of the dialog 844 846 so it will be easily accessible through a GetPropA(...) */ 845 846 847 848 ((FileOpenDlgInfos *)lParam)->DlgInfos.hwndCustomDlg =849 847 SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) lParam); 848 849 FILEDLG95_OnWMInitDialog(hwnd, wParam, lParam); 850 ((FileOpenDlgInfos *)lParam)->DlgInfos.hwndCustomDlg = 851 CreateTemplateDialog((FileOpenDlgInfos *)lParam,hwnd); 850 852 SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE); 851 853 return 0; … … 862 864 } 863 865 return FALSE; 864 866 865 867 case WM_GETISHELLBROWSER: 866 868 return FILEDLG95_OnWMGetIShellBrowser(hwnd); … … 889 891 890 892 #ifndef __WIN32OS2__ 891 /* Make sure the common control DLL is loaded */ 893 /* Make sure the common control DLL is loaded */ 892 894 InitCommonControls(); 893 895 #endif … … 992 994 /* Do not use the listview selection anymore */ 993 995 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW; 994 return 0; 996 return 0; 995 997 } 996 998 … … 1009 1011 SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser); 1010 1012 1011 return TRUE; 1013 return TRUE; 1012 1014 } 1013 1015 … … 1029 1031 TBADDBITMAP tba = { HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR }; 1030 1032 RECT rectTB; 1031 1033 1032 1034 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); 1033 1035 … … 1043 1045 MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2); 1044 1046 1045 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL, 1047 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL, 1046 1048 WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE, 1047 1049 0, 0, 150, 26, 1048 hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL); 1049 1050 SetWindowPos(fodInfos->DlgInfos.hwndTB, 0, 1051 1052 1050 hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL); 1051 1052 SetWindowPos(fodInfos->DlgInfos.hwndTB, 0, 1053 rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top, 1054 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER ); 1053 1055 1054 1056 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); … … 1059 1061 1060 1062 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 6,(LPARAM) &tbb); 1061 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0); 1063 SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0); 1062 1064 1063 1065 /* Set the window text with the text specified in the OPENFILENAME structure */ … … 1098 1100 * 1099 1101 * Ok button WM_COMMAND message handler 1100 * 1102 * 1101 1103 * If the function succeeds, the return value is nonzero. 1102 1104 */ … … 1132 1134 char lpstrPathAndFile[MAX_PATH]; 1133 1135 1134 lpstrPathSpec[0] 1136 lpstrPathSpec[0] = '\0'; 1135 1137 lpstrCurrentDir[0] = '\0'; 1136 1138 lpstrPathAndFile[0] = '\0'; 1137 1139 1138 /* Separate the file spec from the path spec 1139 e.g.: 1140 1141 1142 */ 1140 /* Separate the file spec from the path spec 1141 e.g.: 1142 lpstrSpecifiedByUser lpstrPathSpec lpstrFileSpec 1143 C:\TEXT1\TEXT2 C:\TEXT1 TEXT2 1144 */ 1143 1145 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser); 1144 1146 strcpy(lpstrPathSpec,lpstrSpecifiedByUser); 1145 1147 COMDLG32_PathRemoveFileSpecA(lpstrPathSpec); 1146 1148 1147 1149 /* Get the index of the selected item in the filetype combo box */ 1148 1150 fodInfos->ofnInfos.nFilterIndex = (DWORD) CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); … … 1152 1154 /* Get the current directory name */ 1153 1155 COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, 1154 1155 1156 /* Create an absolute path name */ 1156 lpstrCurrentDir); 1157 1158 /* Create an absolute path name */ 1157 1159 if(lpstrSpecifiedByUser[1] != ':') 1158 1160 { 1159 1161 switch(lpstrSpecifiedByUser[0]) 1160 1162 { 1161 1162 1163 1163 /* Add drive spec \TEXT => C:\TEXT */ 1164 case '\\': 1165 { 1164 1166 int lenPathSpec=strlen(lpstrPathSpec); 1165 1167 INT iCopy = (lenPathSpec!=0?2:3); 1166 1168 memmove(lpstrPathSpec+iCopy,lpstrPathSpec,lenPathSpec); 1167 1168 1169 break;1170 /* Go to parent ..\TEXT */ 1171 1172 1173 1174 1175 1176 1177 1178 1179 1169 strncpy(lpstrPathSpec,lpstrCurrentDir,iCopy); 1170 } 1171 break; 1172 /* Go to parent ..\TEXT */ 1173 case '.': 1174 { 1175 INT iSize; 1176 char lpstrTmp2[MAX_PATH]; 1177 LPSTR lpstrTmp = strrchr(lpstrCurrentDir,'\\'); 1178 1179 iSize = lpstrTmp - lpstrCurrentDir; 1180 strncpy(lpstrTmp2,lpstrCurrentDir,iSize + 1); 1181 if(strlen(lpstrSpecifiedByUser) <= 3) 1180 1182 *lpstrFileSpec='\0'; 1181 1182 1183 1184 1185 1186 1187 { 1188 1189 1190 1191 1192 1193 1194 1195 1196 1183 if(strcmp(lpstrPathSpec,"..")) 1184 strcat(lpstrTmp2,&lpstrPathSpec[3]); 1185 strcpy(lpstrPathSpec,lpstrTmp2); 1186 } 1187 break; 1188 default: 1189 { 1190 char lpstrTmp[MAX_PATH]; 1191 1192 if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\")) 1193 strcat(lpstrCurrentDir,"\\"); 1194 strcpy(lpstrTmp,lpstrCurrentDir); 1195 strcat(lpstrTmp,lpstrPathSpec); 1196 strcpy(lpstrPathSpec,lpstrTmp); 1197 } 1198 1197 1199 } /* end switch */ 1198 1200 } … … 1200 1202 if(strlen(lpstrPathSpec)) 1201 1203 { 1202 1203 COMDLG32_SHGetDesktopFolder(&psfDesktop); 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1204 /* Browse to the right directory */ 1205 COMDLG32_SHGetDesktopFolder(&psfDesktop); 1206 if((browsePidl = GetPidlFromName(psfDesktop,lpstrPathSpec))) 1207 { 1208 /* Browse to directory */ 1209 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, 1210 browsePidl, 1211 SBSP_ABSOLUTE); 1212 COMDLG32_SHFree(browsePidl); 1213 } 1214 else 1215 { 1216 /* Path does not exist */ 1217 if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST) 1218 { 1219 MessageBoxA(hwnd, 1220 "Path does not exist", 1221 fodInfos->ofnInfos.lpstrTitle, 1222 MB_OK | MB_ICONEXCLAMATION); 1223 return FALSE; 1224 } 1225 } 1226 1227 strcat(lpstrPathAndFile,lpstrPathSpec); 1228 IShellFolder_Release(psfDesktop); 1227 1229 } 1228 1230 else 1229 1231 { 1230 1232 strcat(lpstrPathAndFile,lpstrCurrentDir); 1231 1233 } 1232 1234 … … 1234 1236 COMDLG32_PathAddBackslashA(lpstrPathAndFile); 1235 1237 strcat(lpstrPathAndFile,lpstrFileSpec); 1236 1238 1237 1239 /* Update the edit field */ 1238 1240 SetDlgItemTextA(hwnd,IDC_FILENAME,lpstrFileSpec); 1239 1241 SendDlgItemMessageA(hwnd,IDC_FILENAME,EM_SETSEL,0,-1); 1240 1242 1241 1243 /* Don't go further if we dont have a file spec */ 1242 1244 if(!strlen(lpstrFileSpec) || !strcmp(lpstrFileSpec,lpstrPathSpec)) 1243 1244 1245 /* Time to check lpstrFileSpec */ 1245 return FALSE; 1246 1247 /* Time to check lpstrFileSpec */ 1246 1248 /* search => contains * or ? */ 1247 1249 /* browse => contains a directory name */ … … 1257 1259 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter); 1258 1260 1259 1260 1261 1262 1261 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFileSpec)+1)*2); 1262 lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, 1263 (LPSTR)strlwr((LPSTR)lpstrFileSpec)); 1264 1263 1265 IShellView_Refresh(fodInfos->Shell.FOIShellView); 1264 1266 1265 1266 1267 if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, 1268 lpstrFileSpec))) 1267 1269 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB,iPos); 1268 1270 … … 1272 1274 /* browse if the user specified a directory */ 1273 1275 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1274 1276 lpstrFileSpec); 1275 1277 if (!browsePidl) /* not a directory check the specified file exists */ 1276 1278 { 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1279 int iExt; 1280 char lpstrFileSpecTemp[MAX_PATH] = ""; 1281 LPSTR lpstrExt; 1282 LPSTR lpOrg; 1283 LPSTR lpBuf; 1284 iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1285 lpOrg = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, iExt); 1286 lpstrExt = lpOrg; 1287 1288 /* 1289 add user specified extentions to the file one by one and 1290 check if the file exists 1291 */ 1292 while(lpOrg) 1293 { 1294 int i; 1295 if ((lpstrExt = strchr(lpOrg, ';'))) 1296 { 1297 i = lpstrExt - lpOrg; 1298 } 1299 else 1300 i = strlen(lpOrg); 1301 lpBuf = MemAlloc(i+1); 1302 strncpy(lpBuf, lpOrg, i); 1303 lpBuf[i] = 0; 1304 strcpy(lpstrFileSpecTemp, lpstrFileSpec); 1305 if (lpstrFileSpecTemp[strlen(lpstrFileSpecTemp)-1] == '.') 1306 { 1307 if (strchr(lpBuf, '.')) 1308 strcat(lpstrFileSpecTemp, (strchr(lpBuf, '.')) + 1); 1309 } else { 1310 if (strchr(lpBuf, '.')) 1311 strcat(lpstrFileSpecTemp, strchr(lpBuf, '.')); 1312 } 1313 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1314 lpstrFileSpecTemp); 1315 MemFree((void *)lpBuf); 1316 if (browsePidl) 1317 { 1318 strcpy(lpstrFileSpec,lpstrFileSpecTemp); 1319 break; 1320 } 1321 if (lpstrExt) 1322 lpOrg = lpstrExt+1; 1323 else 1324 lpOrg = NULL; 1325 } 1324 1326 } 1325 1327 … … 1327 1329 { 1328 1330 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 1329 1330 1331 1332 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1333 1, 1334 &browsePidl, 1335 1336 1337 1338 1339 1340 1341 1342 1331 int nMsgBoxRet; 1332 char lpstrFileExist[MAX_PATH + 50]; 1333 1334 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1335 1, 1336 &browsePidl, 1337 &ulAttr); 1338 1339 /* Browse to directory if it is a folder */ 1340 if (ulAttr & SFGAO_FOLDER) 1341 { 1342 if(FAILED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, 1343 browsePidl, 1344 SBSP_RELATIVE))) 1343 1345 { 1344 1346 if(fodInfos->ofnInfos.Flags & OFN_PATHMUSTEXIST) 1345 1347 { 1346 1347 1348 1349 1350 1351 1348 MessageBoxA(hwnd, 1349 "Path does not exist", 1350 fodInfos->ofnInfos.lpstrTitle, 1351 MB_OK | MB_ICONEXCLAMATION); 1352 COMDLG32_SHFree(browsePidl); 1353 return FALSE; 1352 1354 } 1353 1355 } 1354 1355 1356 COMDLG32_SHFree(browsePidl); 1357 return FALSE; 1356 1358 } 1357 1359 1358 1359 if((fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1360 /* The file does exist, so ask the user if we should overwrite it */ 1361 if((fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && 1362 (fodInfos->ofnInfos.Flags & OFN_OVERWRITEPROMPT)) 1363 { 1364 strcpy(lpstrFileExist, lpstrFileSpec); 1365 strcat(lpstrFileExist, " already exists.\nDo you want to replace it?"); 1366 1367 nMsgBoxRet = MessageBoxA(hwnd, 1368 lpstrFileExist, 1369 fodInfos->ofnInfos.lpstrTitle, 1370 MB_YESNO | MB_ICONEXCLAMATION); 1371 if (nMsgBoxRet == IDNO) 1372 { 1373 COMDLG32_SHFree(browsePidl); 1374 return FALSE; 1375 } 1376 } 1377 COMDLG32_SHFree(browsePidl); 1376 1378 } 1377 1379 else 1378 1380 { 1379 1380 1381 1381 /* File does not exist in current directory */ 1382 1383 /* The selected file does not exist */ 1382 1384 /* Tell the user the selected does not exist */ 1383 1385 if(fodInfos->ofnInfos.Flags & OFN_FILEMUSTEXIST) … … 1387 1389 char tmp[400]; 1388 1390 1389 1390 1391 1392 1393 1394 1395 1396 1391 LoadStringA(COMMDLG_hInstance32, 1392 IDS_FILENOTFOUND, 1393 lpstrNotFound, 1394 100); 1395 LoadStringA(COMMDLG_hInstance32, 1396 IDS_VERIFYFILE, 1397 lpstrMsg, 1398 100); 1397 1399 1398 1400 strcpy(tmp,fodInfos->ofnInfos.lpstrFile); … … 1402 1404 strcat(tmp,lpstrMsg); 1403 1405 1404 1405 1406 1407 1408 1406 MessageBoxA(hwnd, 1407 tmp, 1408 fodInfos->ofnInfos.lpstrTitle, 1409 MB_OK | MB_ICONEXCLAMATION); 1410 return FALSE; 1409 1411 } 1410 1412 /* Ask the user if he wants to create the file*/ … … 1415 1417 LoadStringA(COMMDLG_hInstance32,IDS_CREATEFILE,tmp,100); 1416 1418 1417 1418 1419 if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos.lpstrTitle, 1420 MB_YESNO | MB_ICONQUESTION)) 1419 1421 { 1420 1422 /* Create the file, clean and exit */ … … 1422 1424 return EndDialog(hwnd,TRUE); 1423 1425 } 1424 return FALSE; 1426 return FALSE; 1425 1427 } 1426 1428 } … … 1431 1433 if(!strrchr(lpstrPathAndFile,'.')) 1432 1434 { 1433 1434 1435 int iExt;1436 1437 1438 1439 1440 1441 { 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1435 /* if the file has no extension, append the selected 1436 extension of the filetype combo box */ 1437 int iExt; 1438 LPSTR lpstrExt; 1439 iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1440 lpstrTemp = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iExt); 1441 1442 if((LPSTR)-1 != lpstrTemp) 1443 { 1444 if((lpstrExt = strchr(lpstrTemp,';'))) 1445 { 1446 int i = lpstrExt - lpstrTemp; 1447 lpstrExt = MemAlloc(i); 1448 strncpy(lpstrExt,&lpstrTemp[1],i-1); 1449 } 1450 else 1451 { 1452 lpstrExt = MemAlloc(strlen(lpstrTemp)); 1453 strcpy(lpstrExt,&lpstrTemp[1]); 1454 } 1455 1456 if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt) 1457 { 1458 lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2); 1459 strcat(lpstrExt,"."); 1460 strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt); 1461 } 1462 strcat(lpstrPathAndFile,lpstrExt); 1463 } 1462 1464 } 1463 1465 /* Check that size size of the file does not exceed buffer size */ 1464 1466 if(strlen(lpstrPathAndFile) > fodInfos->ofnInfos.nMaxFile) 1465 1467 { 1466 1467 1468 1468 /* set error FNERR_BUFFERTOSMALL */ 1469 FILEDLG95_Clean(hwnd); 1470 return EndDialog(hwnd,FALSE); 1469 1471 } 1470 1472 strcpy(fodInfos->ofnInfos.lpstrFile,lpstrPathAndFile); … … 1472 1474 /* Set the lpstrFileTitle of the OPENFILENAME structure */ 1473 1475 if(fodInfos->ofnInfos.lpstrFileTitle) 1474 1475 1476 1477 1478 /* Check if the file is to be opened as read only */ 1476 strncpy(fodInfos->ofnInfos.lpstrFileTitle, 1477 lpstrFileSpec, 1478 fodInfos->ofnInfos.nMaxFileTitle); 1479 1480 /* Check if the file is to be opened as read only */ 1479 1481 if(BST_CHECKED == SendDlgItemMessageA(hwnd, 1480 1481 1482 1483 1482 IDC_OPENREADONLY, 1483 BM_GETSTATE,0,0)) 1484 SetFileAttributesA(fodInfos->ofnInfos.lpstrFile, 1485 FILE_ATTRIBUTE_READONLY); 1484 1486 1485 1487 /* nFileExtension and nFileOffset of OPENFILENAME structure */ … … 1489 1491 fodInfos->ofnInfos.nFileExtension = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1; 1490 1492 1491 1493 1492 1494 /* clean and exit */ 1493 1495 FILEDLG95_Clean(hwnd); … … 1510 1512 1511 1513 /* 1512 * Initialisation of the FileOpenDialogInfos structure 1514 * Initialisation of the FileOpenDialogInfos structure 1513 1515 */ 1514 1516 … … 1530 1532 1531 1533 /* Construct the IShellBrowser interface */ 1532 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 1533 1534 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 1535 1534 1536 return NOERROR; 1535 1537 } … … 1550 1552 1551 1553 if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, 1552 1553 1554 1554 SVGIO_BACKGROUND, 1555 &IID_IContextMenu, 1556 (LPVOID*)&pcm))) 1555 1557 { 1556 1558 ci.cbSize = sizeof(CMINVOKECOMMANDINFO); … … 1589 1591 * FILEDLG95_SHELL_NewFolder 1590 1592 * 1591 * Creates a new directory with New folder as name 1593 * Creates a new directory with New folder as name 1592 1594 * If the function succeeds, the return value is nonzero. 1593 1595 * FIXME: let the contextmenu (CMDSTR_NEWFOLDER) do this thing … … 1630 1632 { 1631 1633 bRes = CreateDirectoryA(lpstrNewDir,NULL); 1632 1634 1633 1635 if(bRes) 1634 1636 { … … 1650 1652 char lpstrTempText[128]; 1651 1653 char lpstrCaption[256]; 1652 1654 1653 1655 /* Cannot Create folder because of permissions */ 1654 1656 LoadStringA(COMMDLG_hInstance32, IDS_CREATEFOLDER_DENIED, lpstrTempText, sizeof(lpstrTempText)); … … 1682 1684 * FILEDLG95_FILETYPE_Init 1683 1685 * 1684 * Initialisation of the file type combo box 1686 * Initialisation of the file type combo box 1685 1687 */ 1686 1688 static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) … … 1699 1701 for(;;) 1700 1702 { 1701 /* filter is a list... title\0ext\0......\0\0 1703 /* filter is a list... title\0ext\0......\0\0 1702 1704 * Set the combo item text to the title and the item data 1703 1705 * to the ext … … 1719 1721 if(!lpstrExt) 1720 1722 break; 1721 1723 1722 1724 strcpy(lpstrExt,lpstrExtTmp); 1723 1725 1724 1726 iStrIndex += strlen(lpstrExt) +1; 1725 1727 1726 1728 /* Add the item at the end of the combo */ 1727 1729 CBAddString(fodInfos->DlgInfos.hwndFileTypeCB,lpstrTmp); … … 1729 1731 } 1730 1732 /* Set the current filter to the one specified 1731 * in the initialisation structure 1733 * in the initialisation structure 1732 1734 */ 1733 1735 1734 1736 /* set default filter index */ 1735 1737 if(fodInfos->ofnInfos.nFilterIndex == 0 && fodInfos->ofnInfos.lpstrCustomFilter == NULL) … … 1737 1739 /* First, check to make sure our index isn't out of bounds. */ 1738 1740 if ( fodInfos->ofnInfos.nFilterIndex > iPos ) 1739 1740 1741 1741 fodInfos->ofnInfos.nFilterIndex = iPos; 1742 1743 1742 1744 /* Get the current index selection. */ 1743 1745 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, 1744 1746 fodInfos->ofnInfos.nFilterIndex-1); 1745 1747 1746 1748 /* Get the corresponding text string from the combo box. */ 1747 1749 lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, … … 1772 1774 { 1773 1775 LPSTR lpstrFilter; 1774 1776 //CB: todo: check if selection really changed 1775 1777 /* Get the current item of the filetype combo box */ 1776 1778 int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); … … 1844 1846 1845 1847 } 1846 1848 1847 1849 /*********************************************************************** 1848 1850 * FILEDLG95_LOOKIN_Init 1849 1851 * 1850 * Initialisation of the look in combo box 1852 * Initialisation of the look in combo box 1851 1853 */ 1852 1854 static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo) 1853 1855 { 1854 IShellFolder 1855 IEnumIDList 1856 LPITEMIDLIST 1856 IShellFolder *psfRoot, *psfDrives; 1857 IEnumIDList *lpeRoot, *lpeDrives; 1858 LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp; 1857 1859 1858 1860 LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos)); … … 1881 1883 while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL)) 1882 1884 { 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1885 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND); 1886 1887 /* special handling for CSIDL_DRIVES */ 1888 if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives)) 1889 { 1890 if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives))) 1891 { 1892 /* enumerate the drives */ 1893 if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives))) 1894 { 1895 while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL)) 1896 { 1897 pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1); 1898 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND); 1899 COMDLG32_SHFree(pidlAbsTmp); 1900 COMDLG32_SHFree(pidlTmp1); 1901 } 1902 IEnumIDList_Release(lpeDrives); 1903 } 1904 IShellFolder_Release(psfDrives); 1905 } 1906 } 1905 1907 COMDLG32_SHFree(pidlTmp); 1906 1908 } … … 1927 1929 RECT rectText; 1928 1930 RECT rectIcon; 1929 SHFILEINFOA sfi;1930 HIMAGELIST ilItemImage;1931 1931 int iIndentation; 1932 1932 LPSFOLDER tmpFolder; 1933 1934 1933 1935 1934 LookInInfos *liInfos = (LookInInfos *)GetPropA(pDIStruct->hwndItem,LookInInfosStr); … … 1944 1943 return 0; 1945 1944 1946 1947 if(pDIStruct->itemID == liInfos->uSelectedItem) 1948 { 1949 ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 1950 0, 1951 &sfi, 1952 sizeof (SHFILEINFOA), 1953 SHGFI_PIDL | SHGFI_SMALLICON | 1954 SHGFI_OPENICON | SHGFI_SYSICONINDEX | 1955 SHGFI_DISPLAYNAME ); 1956 } 1957 else 1958 { 1959 ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 1960 0, 1961 &sfi, 1945 if (!tmpFolder->szDisplayName) 1946 { 1947 SHFILEINFOA sfi; 1948 INT len; 1949 1950 tmpFolder->ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR)tmpFolder->pidlItem, 1951 0, 1952 &sfi, 1962 1953 sizeof (SHFILEINFOA), 1963 SHGFI_PIDL | SHGFI_SMALLICON | 1964 SHGFI_SYSICONINDEX | 1965 SHGFI_DISPLAYNAME); 1954 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME); 1955 len = strlen(sfi.szDisplayName)+1; 1956 tmpFolder->szDisplayName = MemAlloc(len); 1957 strcpy(tmpFolder->szDisplayName,sfi.szDisplayName); 1958 tmpFolder->iIcon = sfi.iIcon; 1966 1959 } 1967 1960 … … 1981 1974 1982 1975 /* Do not indent item if drawing in the edit of the combo*/ 1983 if(pDIStruct->itemState & ODS_COMBOBOXEDIT) 1984 { 1976 if (pDIStruct->itemState & ODS_COMBOBOXEDIT) 1985 1977 iIndentation = 0; 1986 ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,1987 0,1988 &sfi,1989 sizeof (SHFILEINFOA),1990 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON1991 | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME );1992 1993 }1994 1978 else 1995 {1996 1979 iIndentation = tmpFolder->m_iIndent; 1997 } 1980 1998 1981 /* Draw text and icon */ 1999 1982 … … 2010 1993 rectText.bottom = pDIStruct->rcItem.bottom; 2011 1994 2012 1995 2013 1996 /* Draw the icon from the image list */ 2014 COMDLG32_ImageList_Draw( ilItemImage,2015 sfi.iIcon,2016 pDIStruct->hDC, 2017 rectIcon.left, 2018 rectIcon.top, 2019 ILD_TRANSPARENT ); 1997 COMDLG32_ImageList_Draw(tmpFolder->ilItemImage, 1998 tmpFolder->iIcon, 1999 pDIStruct->hDC, 2000 rectIcon.left, 2001 rectIcon.top, 2002 ILD_TRANSPARENT ); 2020 2003 2021 2004 /* Draw the associated text */ 2022 if (sfi.szDisplayName)2023 TextOutA(pDIStruct->hDC,rectText.left,rectText.top, sfi.szDisplayName,strlen(sfi.szDisplayName));2005 if (tmpFolder->szDisplayName) 2006 TextOutA(pDIStruct->hDC,rectText.left,rectText.top,tmpFolder->szDisplayName,strlen(tmpFolder->szDisplayName)); 2024 2007 2025 2008 … … 2044 2027 { 2045 2028 LPSFOLDER tmpFolder; 2046 int iItem; 2029 int iItem; 2047 2030 2048 2031 iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB); … … 2050 2033 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB, 2051 2034 iItem))) 2052 2035 return FALSE; 2053 2036 2054 2037 … … 2061 2044 break; 2062 2045 } 2063 2046 2064 2047 } 2065 2048 return FALSE; … … 2083 2066 if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr))) 2084 2067 return -1; 2085 2068 2086 2069 tmpFolder->m_iIndent = 0; 2070 tmpFolder->szDisplayName = NULL; 2087 2071 2088 2072 if(!pidl) … … 2100 2084 if(tmpFolder->m_iIndent > liInfos->iMaxIndentation) 2101 2085 liInfos->iMaxIndentation = tmpFolder->m_iIndent; 2102 2086 2103 2087 COMDLG32_SHGetFileInfoA((LPSTR)pidl, 2104 2088 0, 2105 2089 &sfi, 2106 2090 sizeof(sfi), 2107 SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 2108 | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES); 2109 2091 SHGFI_ATTRIBUTES); 2110 2092 2111 2093 if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM)) 2112 { 2113 int iItemID; 2094 { 2095 int iItemID; 2096 2114 2097 /* Add the item at the end of the list */ 2115 2098 if(iInsertId < 0) 2116 2099 { 2117 iItemID = CBAddString(hwnd, sfi.szDisplayName);2100 iItemID = CBAddString(hwnd,NULL); 2118 2101 } 2119 2102 /* Insert the item at the iInsertId position*/ 2120 2103 else 2121 2104 { 2122 iItemID = CBInsertString(hwnd, sfi.szDisplayName,iInsertId);2105 iItemID = CBInsertString(hwnd,NULL,iInsertId); 2123 2106 } 2124 2107 … … 2134 2117 * FILEDLG95_LOOKIN_InsertItemAfterParent 2135 2118 * 2136 * Insert an item below its parent 2119 * Insert an item below its parent 2137 2120 */ 2138 2121 static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl) 2139 2122 { 2140 2123 2141 2124 LPITEMIDLIST pidlParent = GetParentPidl(pidl); 2142 2125 int iParentPos; … … 2193 2176 } 2194 2177 } 2195 2178 2196 2179 CBSetCurSel(hwnd,iItemPos); 2197 2180 liInfos->uSelectedItem = iItemPos; … … 2220 2203 { 2221 2204 SFOLDER *tmpFolder; 2205 2222 2206 tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos); 2207 if (tmpFolder->szDisplayName) MemFree(tmpFolder->szDisplayName); 2208 MemFree(tmpFolder); 2223 2209 CBDeleteString(hwnd,iItemPos); 2224 2210 liInfos->iMaxIndentation--; … … 2273 2259 for(iPos = iCount-1;iPos>=0;iPos--) 2274 2260 { 2275 MemFree((LPVOID)(CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos))); 2276 CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos); 2261 SFOLDER *tmpFolder = (LPSFOLDER)CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos); 2262 2263 if (tmpFolder->szDisplayName) MemFree(tmpFolder->szDisplayName); 2264 MemFree(tmpFolder); 2265 CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos); 2277 2266 } 2278 2267 /* LookInInfos structure */ … … 2287 2276 * GetName 2288 2277 * 2289 * Get the pidl's display name (relative to folder) and 2278 * Get the pidl's display name (relative to folder) and 2290 2279 * put it in lpstrFileName. 2291 * 2280 * 2292 2281 * Return NOERROR on success, 2293 2282 * E_FAIL otherwise … … 2312 2301 /* Get the display name of the pidl relative to the folder */ 2313 2302 if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, 2314 pidl, 2315 dwFlags, 2303 pidl, 2304 dwFlags, 2316 2305 &str))) 2317 2306 { … … 2324 2313 * GetShellFolderFromPidl 2325 2314 * 2326 * pidlRel is the item pidl relative 2315 * pidlRel is the item pidl relative 2327 2316 * Return the IShellFolder of the absolute pidl 2328 2317 */ … … 2340 2329 if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf))) 2341 2330 { 2342 2331 IShellFolder_Release(psfParent); 2343 2332 return psf; 2344 2333 } … … 2363 2352 pidlParent = COMDLG32_PIDL_ILClone(pidl); 2364 2353 COMDLG32_PIDL_ILRemoveLastID(pidlParent); 2365 2354 2366 2355 return pidlParent; 2367 2356 } … … 2370 2359 * GetPidlFromName 2371 2360 * 2372 * returns the pidl of the file name relative to folder 2361 * returns the pidl of the file name relative to folder 2373 2362 * NULL if an error occured 2374 2363 */ … … 2384 2373 if(!lpcstrFileName) 2385 2374 return NULL; 2386 2375 2387 2376 MultiByteToWideChar(CP_ACP, 2388 MB_PRECOMPOSED, 2389 lpcstrFileName, 2390 -1, 2391 (LPWSTR)lpwstrDirName, 2392 MAX_PATH); 2377 MB_PRECOMPOSED, 2378 lpcstrFileName, 2379 -1, 2380 (LPWSTR)lpwstrDirName, 2381 MAX_PATH); 2393 2382 2394 2383 IShellFolder_ParseDisplayName(psf, 0, … … 2397 2386 &ulEaten, 2398 2387 &pidl, 2399 NULL); 2388 NULL); 2400 2389 2401 2390 return pidl;
Note:
See TracChangeset
for help on using the changeset viewer.