Changeset 3256 for trunk/src


Ignore:
Timestamp:
Mar 28, 2000, 5:26:48 PM (25 years ago)
Author:
cbratschi
Message:

* empty log message *

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 $*/
    22/*
    33 * COMMDLG - File Open Dialogs Win95 look and feel
     
    11221122  if ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST ||
    11231123          !(fodInfos->ofnInfos->Flags & OFN_EXPLORER ))
    1124           {
     1124  {
    11251125      LPSTR lpstrTemp = lpstrFileList;
    11261126
     
    11291129          WIN32_FIND_DATAA findData;
    11301130          CHAR lpstrFindFile[MAX_PATH];
     1131          HANDLE hFind;
    11311132
    11321133          memset( lpstrFindFile, 0x0, MAX_PATH * sizeof(CHAR) );
     
    11361137          lstrcatA( lpstrFindFile, lpstrTemp );
    11371138
    1138           if ( FindFirstFileA( lpstrFindFile, &findData ) == INVALID_HANDLE_VALUE )
     1139          hFind = FindFirstFileA( lpstrFindFile, &findData );
     1140          if (hFind == INVALID_HANDLE_VALUE)
    11391141          {
    11401142              CHAR lpstrNotFound[100];
     
    11561158                      MB_OK | MB_ICONEXCLAMATION);
    11571159              return FALSE;
    1158   }
     1160          } else FindClose(hFind);
    11591161
    11601162          if (!(fodInfos->ofnInfos->Flags & OFN_EXPLORER ))
    1161   {
     1163          {
    11621164              lstrcatA( lpstrTempFileList, findData.cAlternateFileName);
    11631165              if ( nCount + 1 < nFileCount)
    11641166                  lstrcatA( lpstrTempFileList, " ");
    1165   }
     1167          }
    11661168          lpstrTemp += strlen(lpstrFileList) + 1;
     1169        }
    11671170      }
    1168   }
    11691171
    11701172      if ( fodInfos->ofnInfos->Flags & OFN_EXPLORER )
    11711173      {
    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 );
    11741176      }
    11751177      else
    11761178      {
    1177       memcpy( lpstrFile, lpstrTempFileList, sizeof(CHAR) * strlen(lpstrTempFileList));
     1179        memcpy( lpstrFile, lpstrTempFileList, sizeof(CHAR) * strlen(lpstrTempFileList));
    11781180      }
    11791181
     
    12061208
    12071209  TRACE("\n");
    1208 //CB: optimize this function!
     1210
    12091211  /* If a folder is selected browse folder */
    12101212  if (BrowseSelectedFolder(hwnd))
     
    12241226          while ((lpstrSpecifiedByUser[nStrCharCount]!='"') &&
    12251227              (nStrCharCount <= nStrLen))
    1226   {
     1228          {
    12271229              lpstrFileList[nFileIndex++] = lpstrSpecifiedByUser[nStrCharCount];
    12281230              nStrCharCount++;
    12291231              sizeUsed++;
    1230   }
     1232          }
    12311233          lpstrFileList[nFileIndex++] = '\0';
    12321234          sizeUsed++;
     
    12561258      if (nFileCount == 0)
    12571259      {
    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);
    12611263      }
    12621264
     
    13031305              break;
    13041306          default:
    1305   {
     1307              {
    13061308                  char lpstrTmp[MAX_PATH] = "";
    13071309                  if(strcmp(&lpstrCurrentDir[strlen(lpstrCurrentDir)-1],"\\"))
     
    13661368      /* file   => contains a file name      */
    13671369
    1368     /* Check if this is a search */
     1370      /* Check if this is a search */
    13691371      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           fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFileSpec)+1)*2);
    1378           lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,
    1379                       (LPSTR)strlwr((LPSTR)lpstrFileSpec));
    1380 
    1381       IShellView_Refresh(fodInfos->Shell.FOIShellView);
    1382 
    1383           if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB,
    1384                                                        lpstrFileSpec)))
     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)))
    13851387        CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
    13861388
    1387       return FALSE;
    1388     }
     1389        return FALSE;
     1390      }
    13891391
    13901392      {
    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        }
    14011415        else
    1402         {
    1403          // if there is an extention, then get the Pidl otherwise
    1404          // we are going to need to add the extention
    1405          if(strrchr(lpstrFileSpec,'.'))
    1406           browsePidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder,
    1407                 lpstrFileSpec);
    1408          else
    14091416          browsePidl=NULL;
    1410         }
    1411        }
    1412        else
    1413         browsePidl=NULL;
    14141417      }
    14151418
    14161419      if (!browsePidl) /* not a directory check the specified file exists */
    14171420      {
    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;
    14641470      }
    14651471
     
    14811487                                                   browsePidl,
    14821488                                                   SBSP_RELATIVE)))
    1483         {
     1489              {
    14841490                  if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
    1485         {
     1491                  {
    14861492                      MessageBoxA(hwnd,
    14871493                                  "Path does not exist",
     
    14901496                      COMDLG32_SHFree(browsePidl);
    14911497                      return FALSE;
    1492         }
    1493     }
     1498                  }
     1499              }
    14941500              COMDLG32_SHFree(browsePidl);
    14951501              return FALSE;
    1496     }
     1502          }
    14971503
    14981504          /* The file does exist, so ask the user if we should overwrite it */
     
    15161522      }
    15171523      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)
    15241524      {
    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)
    15591530        {
     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          {
    15601566            /* Create the file, clean and exit */
    15611567            return EndDialog(hwnd,TRUE);
     1568          }
     1569          return FALSE;
    15621570        }
    1563         return FALSE;
    15641571      }
    1565     }
    15661572      /* check the write access to the current directory before opening the selected file */
    15671573      if((fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && (fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST))
     
    15691575          HANDLE hfile;
    15701576          char testFile[MAX_PATH];
    1571 
     1577//CB: I don't like this, what if this file already exists?
    15721578          strcpy(testFile,lpstrPathSpec);
    15731579          strcat(testFile,"_tes_13.579");
     
    19711977    {
    19721978      LPSTR lpstrFilter;
    1973 //CB: todo: check if selection really changed
     1979
    19741980      /* Get the current item of the filetype combo box */
    19751981      int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
     1982
     1983      if (iItem+1 == fodInfos->ofnInfos->nFilterIndex) break;
    19761984
    19771985      /* set the current filter index - indexed from 1 */
     
    19932001      /* Refresh the actual view to display the included items*/
    19942002      IShellView_Refresh(fodInfos->Shell.FOIShellView);
    1995 
    19962003    }
    19972004  }
     
    21512158    INT len;
    21522159
    2153     //CB: skip A:,B: SHGFI_DISPLAYNAME for faster handling?
    2154 
    21552160    tmpFolder->ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR)tmpFolder->pidlItem,
    21562161                                                  0,
  • trunk/src/comdlg32/filedlgbrowser.c

    r3250 r3256  
    1 /* $Id: filedlgbrowser.c,v 1.4 2000-03-27 15:07:23 cbratschi Exp $ */
     1/* $Id: filedlgbrowser.c,v 1.5 2000-03-28 15:26:48 cbratschi Exp $ */
    22/*
    33 *  Implementation of IShellBrowser for the File Open common dialog
     
    762762    IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
    763763
    764 
    765764    if( (ulAttr & SFGAO_HIDDEN)                                         /* hidden */
    766765      | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
     
    775774
    776775    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)))
    778778      {
    779779          if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
    780           return S_OK;
     780            return S_OK;
    781781      }
    782782    }
Note: See TracChangeset for help on using the changeset viewer.