- Timestamp:
- Mar 28, 2000, 5:26:48 PM (25 years ago)
- Location:
- trunk/src/comdlg32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/filedlg95.c
r3250 r3256 1 /* $Id: filedlg95.c,v 1. 5 2000-03-27 15:07:22 cbratschi Exp $*/1 /* $Id: filedlg95.c,v 1.6 2000-03-28 15:26:42 cbratschi Exp $*/ 2 2 /* 3 3 * COMMDLG - File Open Dialogs Win95 look and feel … … 1122 1122 if ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST || 1123 1123 !(fodInfos->ofnInfos->Flags & OFN_EXPLORER )) 1124 1124 { 1125 1125 LPSTR lpstrTemp = lpstrFileList; 1126 1126 … … 1129 1129 WIN32_FIND_DATAA findData; 1130 1130 CHAR lpstrFindFile[MAX_PATH]; 1131 HANDLE hFind; 1131 1132 1132 1133 memset( lpstrFindFile, 0x0, MAX_PATH * sizeof(CHAR) ); … … 1136 1137 lstrcatA( lpstrFindFile, lpstrTemp ); 1137 1138 1138 if ( FindFirstFileA( lpstrFindFile, &findData ) == INVALID_HANDLE_VALUE ) 1139 hFind = FindFirstFileA( lpstrFindFile, &findData ); 1140 if (hFind == INVALID_HANDLE_VALUE) 1139 1141 { 1140 1142 CHAR lpstrNotFound[100]; … … 1156 1158 MB_OK | MB_ICONEXCLAMATION); 1157 1159 return FALSE; 1158 }1160 } else FindClose(hFind); 1159 1161 1160 1162 if (!(fodInfos->ofnInfos->Flags & OFN_EXPLORER )) 1161 {1163 { 1162 1164 lstrcatA( lpstrTempFileList, findData.cAlternateFileName); 1163 1165 if ( nCount + 1 < nFileCount) 1164 1166 lstrcatA( lpstrTempFileList, " "); 1165 }1167 } 1166 1168 lpstrTemp += strlen(lpstrFileList) + 1; 1169 } 1167 1170 } 1168 }1169 1171 1170 1172 if ( fodInfos->ofnInfos->Flags & OFN_EXPLORER ) 1171 1173 { 1172 lstrcpyA( lpstrFile, lpstrPathSpec);1173 memcpy( lpstrFile + sizePath + 1, lpstrFileList, sizeof(CHAR) * sizeUsed );1174 lstrcpyA( lpstrFile, lpstrPathSpec); 1175 memcpy( lpstrFile + sizePath + 1, lpstrFileList, sizeof(CHAR) * sizeUsed ); 1174 1176 } 1175 1177 else 1176 1178 { 1177 memcpy( lpstrFile, lpstrTempFileList, sizeof(CHAR) * strlen(lpstrTempFileList));1179 memcpy( lpstrFile, lpstrTempFileList, sizeof(CHAR) * strlen(lpstrTempFileList)); 1178 1180 } 1179 1181 … … 1206 1208 1207 1209 TRACE("\n"); 1208 //CB: optimize this function! 1210 1209 1211 /* If a folder is selected browse folder */ 1210 1212 if (BrowseSelectedFolder(hwnd)) … … 1224 1226 while ((lpstrSpecifiedByUser[nStrCharCount]!='"') && 1225 1227 (nStrCharCount <= nStrLen)) 1226 {1228 { 1227 1229 lpstrFileList[nFileIndex++] = lpstrSpecifiedByUser[nStrCharCount]; 1228 1230 nStrCharCount++; 1229 1231 sizeUsed++; 1230 }1232 } 1231 1233 lpstrFileList[nFileIndex++] = '\0'; 1232 1234 sizeUsed++; … … 1256 1258 if (nFileCount == 0) 1257 1259 { 1258 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser);1259 strcpy(lpstrPathSpec,lpstrSpecifiedByUser);1260 COMDLG32_PathRemoveFileSpecA(lpstrPathSpec);1260 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser); 1261 strcpy(lpstrPathSpec,lpstrSpecifiedByUser); 1262 COMDLG32_PathRemoveFileSpecA(lpstrPathSpec); 1261 1263 } 1262 1264 … … 1303 1305 break; 1304 1306 default: 1305 {1307 { 1306 1308 char lpstrTmp[MAX_PATH] = ""; 1307 1309 if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\")) … … 1366 1368 /* file => contains a file name */ 1367 1369 1368 /* Check if this is a search */1370 /* Check if this is a search */ 1369 1371 if(strchr(lpstrFileSpec,'*') || strchr(lpstrFileSpec,'?')) 1370 {1371 int iPos;1372 1373 /* Set the current filter with the current selection */1374 if(fodInfos->ShellInfos.lpstrCurrentFilter)1375 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);1376 1377 1378 1379 1380 1381 IShellView_Refresh(fodInfos->Shell.FOIShellView);1382 1383 1384 1372 { 1373 int iPos; 1374 1375 /* Set the current filter with the current selection */ 1376 if(fodInfos->ShellInfos.lpstrCurrentFilter) 1377 MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter); 1378 1379 fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFileSpec)+1)*2); 1380 lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, 1381 (LPSTR)strlwr((LPSTR)lpstrFileSpec)); 1382 1383 IShellView_Refresh(fodInfos->Shell.FOIShellView); 1384 1385 if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, 1386 lpstrFileSpec))) 1385 1387 CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB,iPos); 1386 1388 1387 return FALSE;1388 }1389 return FALSE; 1390 } 1389 1391 1390 1392 { 1391 HANDLE hFile; 1392 WIN32_FIND_DATAA stffile; 1393 /* browse if the user specified a directory */ 1394 hFile = FindFirstFileA(lpstrFileSpec, &stffile); 1395 if ( hFile != INVALID_HANDLE_VALUE ) 1396 { 1397 FindClose (hFile); 1398 if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 1399 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1400 lpstrFileSpec); 1393 HANDLE hFile; 1394 WIN32_FIND_DATAA stffile; 1395 //CB: FindFirstFileA bug! 1396 /* browse if the user specified a directory */ 1397 hFile = FindFirstFileA(lpstrFileSpec, &stffile); 1398 if ( hFile != INVALID_HANDLE_VALUE ) 1399 { 1400 FindClose (hFile); 1401 if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 1402 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1403 lpstrFileSpec); 1404 else 1405 { 1406 // if there is an extention, then get the Pidl otherwise 1407 // we are going to need to add the extention 1408 if(strrchr(lpstrFileSpec,'.')) 1409 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1410 lpstrFileSpec); 1411 else 1412 browsePidl=NULL; 1413 } 1414 } 1401 1415 else 1402 {1403 // if there is an extention, then get the Pidl otherwise1404 // we are going to need to add the extention1405 if(strrchr(lpstrFileSpec,'.'))1406 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder,1407 lpstrFileSpec);1408 else1409 1416 browsePidl=NULL; 1410 }1411 }1412 else1413 browsePidl=NULL;1414 1417 } 1415 1418 1416 1419 if (!browsePidl) /* not a directory check the specified file exists */ 1417 1420 { 1418 int i; 1419 int iExt; 1420 char lpstrFileSpecTemp[MAX_PATH] = ""; 1421 LPSTR lpstrExt; 1422 LPSTR lpOrg; 1423 LPSTR lpBuf; 1424 iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1425 lpOrg = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, iExt); 1426 if (lpOrg == (LPSTR)-1) 1427 lpOrg = NULL; // we get -1 if the filetype LB is empty 1428 1429 lpstrExt = lpOrg; 1430 1431 /* 1432 Simply take the first one of the list as default. 1433 Otherwise the user must specify which extention they want. 1434 Also, make sure we don't have a .*, in this case simply 1435 forget about the extention 1436 */ 1437 lpstrExt = strchr(lpOrg, ';'); 1438 if (lpstrExt) 1439 { 1440 i = lpstrExt - lpOrg; 1441 } 1442 else 1443 i = strlen(lpOrg); 1444 lpBuf = MemAlloc(i+1); 1445 strncpy(lpBuf, lpOrg, i); 1446 lpBuf[i] = 0; 1447 strcpy(lpstrFileSpecTemp, lpstrFileSpec); 1448 if (lpstrFileSpecTemp[strlen(lpstrFileSpecTemp)-1] == '.') 1449 { 1450 if (strchr(lpBuf, '.')) 1451 strcat(lpstrFileSpecTemp, (strchr(lpBuf, '.')) + 1); 1452 } 1453 else 1454 strcat(lpstrFileSpecTemp, strchr(lpBuf, '.')); 1455 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1456 lpstrFileSpecTemp); 1457 MemFree((void *)lpBuf); 1458 if (browsePidl) 1459 strcpy(lpstrFileSpec,lpstrFileSpecTemp); 1460 if (lpstrExt) 1461 lpOrg = lpstrExt+1; 1462 else 1463 lpOrg = NULL; 1421 int i; 1422 int iExt; 1423 char lpstrFileSpecTemp[MAX_PATH] = ""; 1424 LPSTR lpstrExt; 1425 LPSTR lpOrg; 1426 LPSTR lpBuf; 1427 1428 iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1429 lpOrg = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, iExt); 1430 if (lpOrg == (LPSTR)-1) 1431 lpOrg = NULL; // we get -1 if the filetype LB is empty 1432 1433 lpstrExt = lpOrg; 1434 1435 /* 1436 Simply take the first one of the list as default. 1437 Otherwise the user must specify which extention they want. 1438 Also, make sure we don't have a .*, in this case simply 1439 forget about the extention 1440 */ 1441 lpstrExt = strchr(lpOrg, ';'); 1442 if (lpstrExt) 1443 { 1444 i = lpstrExt - lpOrg; 1445 } 1446 else 1447 i = strlen(lpOrg); 1448 lpBuf = MemAlloc(i+1); 1449 strncpy(lpBuf, lpOrg, i); 1450 lpBuf[i] = 0; 1451 strcpy(lpstrFileSpecTemp, lpstrFileSpec); 1452 1453 if (lpstrFileSpecTemp[strlen(lpstrFileSpecTemp)-1] == '.') 1454 { 1455 if (strchr(lpBuf, '.')) 1456 strcat(lpstrFileSpecTemp, (strchr(lpBuf, '.')) + 1); 1457 } 1458 else 1459 strcat(lpstrFileSpecTemp, strchr(lpBuf, '.')); 1460 1461 browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, 1462 lpstrFileSpecTemp); 1463 MemFree((void *)lpBuf); 1464 if (browsePidl) 1465 strcpy(lpstrFileSpec,lpstrFileSpecTemp); 1466 if (lpstrExt) 1467 lpOrg = lpstrExt+1; 1468 else 1469 lpOrg = NULL; 1464 1470 } 1465 1471 … … 1481 1487 browsePidl, 1482 1488 SBSP_RELATIVE))) 1483 {1489 { 1484 1490 if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST) 1485 {1491 { 1486 1492 MessageBoxA(hwnd, 1487 1493 "Path does not exist", … … 1490 1496 COMDLG32_SHFree(browsePidl); 1491 1497 return FALSE; 1492 }1493 }1498 } 1499 } 1494 1500 COMDLG32_SHFree(browsePidl); 1495 1501 return FALSE; 1496 }1502 } 1497 1503 1498 1504 /* The file does exist, so ask the user if we should overwrite it */ … … 1516 1522 } 1517 1523 else 1518 {1519 /* File does not exist in current directory */1520 1521 /* The selected file does not exist */1522 /* Tell the user the selected does not exist */1523 if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST)1524 1524 { 1525 char lpstrNotFound[100]; 1526 char lpstrMsg[100]; 1527 char tmp[400]; 1528 1529 LoadStringA(COMMDLG_hInstance32, 1530 IDS_FILENOTFOUND, 1531 lpstrNotFound, 1532 100); 1533 LoadStringA(COMMDLG_hInstance32, 1534 IDS_VERIFYFILE, 1535 lpstrMsg, 1536 100); 1537 1538 strcpy(tmp,fodInfos->ofnInfos->lpstrFile); 1539 strcat(tmp,"\n"); 1540 strcat(tmp,lpstrNotFound); 1541 strcat(tmp,"\n"); 1542 strcat(tmp,lpstrMsg); 1543 1544 MessageBoxA(hwnd, 1545 tmp, 1546 fodInfos->ofnInfos->lpstrTitle, 1547 MB_OK | MB_ICONEXCLAMATION); 1548 return FALSE; 1549 } 1550 /* Ask the user if he wants to create the file*/ 1551 if(fodInfos->ofnInfos->Flags & OFN_CREATEPROMPT) 1552 { 1553 char tmp[100]; 1554 1555 LoadStringA(COMMDLG_hInstance32,IDS_CREATEFILE,tmp,100); 1556 1557 if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos->lpstrTitle, 1558 MB_YESNO | MB_ICONQUESTION)) 1525 /* File does not exist in current directory */ 1526 1527 /* The selected file does not exist */ 1528 /* Tell the user the selected does not exist */ 1529 if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) 1559 1530 { 1531 char lpstrNotFound[100]; 1532 char lpstrMsg[100]; 1533 char tmp[400]; 1534 1535 LoadStringA(COMMDLG_hInstance32, 1536 IDS_FILENOTFOUND, 1537 lpstrNotFound, 1538 100); 1539 LoadStringA(COMMDLG_hInstance32, 1540 IDS_VERIFYFILE, 1541 lpstrMsg, 1542 100); 1543 1544 strcpy(tmp,fodInfos->ofnInfos->lpstrFile); 1545 strcat(tmp,"\n"); 1546 strcat(tmp,lpstrNotFound); 1547 strcat(tmp,"\n"); 1548 strcat(tmp,lpstrMsg); 1549 1550 MessageBoxA(hwnd, 1551 tmp, 1552 fodInfos->ofnInfos->lpstrTitle, 1553 MB_OK | MB_ICONEXCLAMATION); 1554 return FALSE; 1555 } 1556 /* Ask the user if he wants to create the file*/ 1557 if(fodInfos->ofnInfos->Flags & OFN_CREATEPROMPT) 1558 { 1559 char tmp[100]; 1560 1561 LoadStringA(COMMDLG_hInstance32,IDS_CREATEFILE,tmp,100); 1562 1563 if(IDYES == MessageBoxA(hwnd,tmp,fodInfos->ofnInfos->lpstrTitle, 1564 MB_YESNO | MB_ICONQUESTION)) 1565 { 1560 1566 /* Create the file, clean and exit */ 1561 1567 return EndDialog(hwnd,TRUE); 1568 } 1569 return FALSE; 1562 1570 } 1563 return FALSE;1564 1571 } 1565 }1566 1572 /* check the write access to the current directory before opening the selected file */ 1567 1573 if((fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && (fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)) … … 1569 1575 HANDLE hfile; 1570 1576 char testFile[MAX_PATH]; 1571 1577 //CB: I don't like this, what if this file already exists? 1572 1578 strcpy(testFile,lpstrPathSpec); 1573 1579 strcat(testFile,"_tes_13.579"); … … 1971 1977 { 1972 1978 LPSTR lpstrFilter; 1973 //CB: todo: check if selection really changed 1979 1974 1980 /* Get the current item of the filetype combo box */ 1975 1981 int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1982 1983 if (iItem+1 == fodInfos->ofnInfos->nFilterIndex) break; 1976 1984 1977 1985 /* set the current filter index - indexed from 1 */ … … 1993 2001 /* Refresh the actual view to display the included items*/ 1994 2002 IShellView_Refresh(fodInfos->Shell.FOIShellView); 1995 1996 2003 } 1997 2004 } … … 2151 2158 INT len; 2152 2159 2153 //CB: skip A:,B: SHGFI_DISPLAYNAME for faster handling?2154 2155 2160 tmpFolder->ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR)tmpFolder->pidlItem, 2156 2161 0, -
trunk/src/comdlg32/filedlgbrowser.c
r3250 r3256 1 /* $Id: filedlgbrowser.c,v 1. 4 2000-03-27 15:07:23cbratschi Exp $ */1 /* $Id: filedlgbrowser.c,v 1.5 2000-03-28 15:26:48 cbratschi Exp $ */ 2 2 /* 3 3 * Implementation of IShellBrowser for the File Open common dialog … … 762 762 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); 763 763 764 765 764 if( (ulAttr & SFGAO_HIDDEN) /* hidden */ 766 765 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */ … … 775 774 776 775 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_FORPARSING, &str))) 777 { if (SUCCEEDED(StrRetToBufW(&str, pidl,szPathW, MAX_PATH))) 776 { 777 if (SUCCEEDED(StrRetToBufW(&str, pidl,szPathW, MAX_PATH))) 778 778 { 779 779 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter)) 780 return S_OK;780 return S_OK; 781 781 } 782 782 }
Note:
See TracChangeset
for help on using the changeset viewer.