Changeset 1721 for trunk/src/comdlg32/filedlg95.cpp
- Timestamp:
- Nov 13, 1999, 4:41:44 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/filedlg95.cpp
r1677 r1721 1 /* $Id: filedlg95.cpp,v 1. 3 1999-11-09 22:38:57 phallerExp $ */1 /* $Id: filedlg95.cpp,v 1.4 1999-11-13 15:41:44 sandervl Exp $ */ 2 2 /* 3 3 * COMMDLG - File Open Dialogs Win95 look and feel … … 46 46 HIMAGELIST hImgList; 47 47 int m_iIndent; /* Indentation index */ 48 LPITEMIDLIST pidlItem; /* absolute pidl of the item */ 48 LPITEMIDLIST pidlItem; /* absolute pidl of the item */ 49 49 50 50 } SFOLDER,*LPSFOLDER; … … 174 174 * GetOpenFileName95 175 175 * 176 * Creates an Open common dialog box that lets the user select 176 * Creates an Open common dialog box that lets the user select 177 177 * the drive, directory, and the name of a file or set of files to open. 178 178 * … … 211 211 if( lRes == -1) 212 212 return FALSE; 213 213 214 214 return lRes; 215 215 } … … 254 254 if( lRes == -1) 255 255 return FALSE; 256 256 257 257 return lRes; 258 258 } … … 272 272 BOOL ret; 273 273 FileOpenDlgInfos *fodInfos; 274 275 /* Initialise FileOpenDlgInfos structure*/ 274 275 /* Initialise FileOpenDlgInfos structure*/ 276 276 fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos)); 277 277 memset(&fodInfos->ofnInfos,'\0',sizeof(*ofn)); fodInfos->ofnInfos.lStructSize = sizeof(*ofn); … … 339 339 fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook; 340 340 341 if (ofn->lpTemplateName) 341 //SvL: Bugfix; can be resource id 342 if (HIWORD(ofn->lpTemplateName)) 342 343 { 343 344 fodInfos->ofnInfos.lpTemplateName = ofn->lpTemplateName; … … 353 354 /* Initialise the dialog property */ 354 355 fodInfos->DlgInfos.dwDlgProp = 0; 355 356 356 357 switch(iDlgType) 357 358 { … … 382 383 MemFree((LPVOID)(fodInfos->ofnInfos.lpstrCustomFilter)); 383 384 384 if (fodInfos->ofnInfos.lpstrFile) 385 if (fodInfos->ofnInfos.lpstrFile) 385 386 { 386 387 strcpy(ofn->lpstrFile,fodInfos->ofnInfos.lpstrFile); 387 388 MemFree((LPVOID)fodInfos->ofnInfos.lpstrFile); 388 389 } 389 if (fodInfos->ofnInfos.lpstrFileTitle) 390 if (fodInfos->ofnInfos.lpstrFileTitle) 390 391 { 391 392 if (ofn->lpstrFileTitle) … … 427 428 /* filter is a list... title\0ext\0......\0\0 */ 428 429 s = (LPWSTR)ofn->lpstrFilter; 429 430 430 431 while (*s) 431 432 s = s+lstrlenW(s)+1; … … 491 492 fodInfos->ofnInfos.lCustData = ofn->lCustData; 492 493 fodInfos->ofnInfos.lpfnHook = (LPOFNHOOKPROC)ofn->lpfnHook; 493 if (ofn->lpTemplateName) 494 { 494 //SvL: Bugfix 495 if (HIWORD(ofn->lpTemplateName)) 496 { 495 497 fodInfos->ofnInfos.lpTemplateName = (LPSTR)MemAlloc(lstrlenW(ofn->lpTemplateName)+1); 496 498 lstrcpyWtoA((LPSTR)fodInfos->ofnInfos.lpTemplateName,(LPWSTR)ofn->lpTemplateName); … … 498 500 /* Initialise the dialog property */ 499 501 fodInfos->DlgInfos.dwDlgProp = 0; 500 502 501 503 switch(iDlgType) 502 504 { … … 511 513 ret = 0; 512 514 } 513 515 514 516 /* Cleaning */ 515 517 ofn->nFileOffset = fodInfos->ofnInfos.nFileOffset; … … 625 627 if(rectCtrl.top > rectStc32.top) 626 628 { 627 629 628 630 if(ptMoveCtl.x > 0) 629 631 rectCtrl.left += ptMoveCtl.x; 630 632 rectCtrl.top += ptMoveCtl.y; 631 handle = DeferWindowPos(handle, hwndChild, 0, rectCtrl.left, rectCtrl.top, 633 handle = DeferWindowPos(handle, hwndChild, 0, rectCtrl.left, rectCtrl.top, 632 634 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top, 633 635 SWP_NOSIZE | SWP_NOZORDER ); … … 662 664 rectCtrl.top += ptMoveCtl.y; 663 665 664 handle = DeferWindowPos( handle, hwndChild, 0, rectCtrl.left, rectCtrl.top, 666 handle = DeferWindowPos( handle, hwndChild, 0, rectCtrl.left, rectCtrl.top, 665 667 rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top, 666 668 SWP_NOSIZE |SWP_NOZORDER ); … … 682 684 { 683 685 case WM_INITDIALOG: 684 { 686 { 685 687 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *)lParam; 686 688 procUserHook=NULL; … … 694 696 } } 695 697 if(procUserHook) 696 return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam); 697 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 698 return CallWindowProcA(procUserHook,hwnd,uMsg,wParam,lParam); 699 return DefWindowProcA(hwnd,uMsg,wParam,lParam); 698 700 } 699 701 … … 735 737 if(hChildDlg) 736 738 { 737 ShowWindow(hChildDlg,SW_SHOW); 739 ShowWindow(hChildDlg,SW_SHOW); 738 740 return hChildDlg; 739 741 } … … 751 753 tmplate.cx = rectHwnd.right-rectHwnd.left; 752 754 tmplate.cy = rectHwnd.bottom-rectHwnd.top; 753 755 754 756 return CreateDialogIndirectParamA(fodInfos->ofnInfos.hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos); 755 757 } … … 782 784 } 783 785 return FALSE; 784 786 785 787 case WM_GETISHELLBROWSER: 786 788 return FILEDLG95_OnWMGetIShellBrowser(hwnd); … … 806 808 TRACE("\n"); 807 809 808 /* Adds the FileOpenDlgInfos in the property list of the dialog 810 /* Adds the FileOpenDlgInfos in the property list of the dialog 809 811 so it will be easily accessible through a GetPropA(...) */ 810 812 SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos); 811 813 812 814 #ifndef __WIN32OS2__ 813 /* Make sure the common control DLL is loaded */ 815 /* Make sure the common control DLL is loaded */ 814 816 InitCommonControls(); 815 817 #endif … … 910 912 } 911 913 /* Do not use the listview selection anymore */ 912 913 // @@@PH 1999/11/09 914 if (fodInfos != NULL) 915 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW; 916 917 return 0; 914 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW; 915 return 0; 918 916 } 919 917 … … 932 930 SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser); 933 931 934 return TRUE; 932 return TRUE; 935 933 } 936 934 … … 987 985 988 986 /* Initialise the file name edit control */ 989 if(strlen(fodInfos->ofnInfos.lpstrFile)) 987 //SvL: Check pointer before calling strlen! 988 if(fodInfos->ofnInfos.lpstrFile && strlen(fodInfos->ofnInfos.lpstrFile)) 990 989 { 991 990 SetDlgItemTextA(hwnd,IDC_FILENAME,fodInfos->ofnInfos.lpstrFile); … … 1012 1011 * 1013 1012 * Ok button WM_COMMAND message handler 1014 * 1013 * 1015 1014 * If the function succeeds, the return value is nonzero. 1016 1015 */ … … 1044 1043 char lpstrPathAndFile[MAX_PATH] = ""; 1045 1044 1046 /* Separate the file spec from the path spec 1047 e.g.: 1045 /* Separate the file spec from the path spec 1046 e.g.: 1048 1047 lpstrSpecifiedByUser lpstrPathSpec lpstrFileSpec 1049 1048 C:\TEXT1\TEXT2 C:\TEXT1 TEXT2 1050 */ 1049 */ 1051 1050 lpstrFileSpec = (LPSTR)COMDLG32_PathFindFilenameA(lpstrSpecifiedByUser); 1052 1051 strcpy(lpstrPathSpec,lpstrSpecifiedByUser); 1053 1052 COMDLG32_PathRemoveFileSpecA(lpstrPathSpec); 1054 1053 1055 1054 /* Get the current directory name */ 1056 1055 COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, 1057 1056 lpstrCurrentDir); 1058 1057 1059 /* Create an absolute path name */ 1058 /* Create an absolute path name */ 1060 1059 if(lpstrSpecifiedByUser[1] != ':') 1061 1060 { … … 1073 1072 strcpy(lpstrPathSpec,lpstrTmp); 1074 1073 } 1075 break; 1076 /* Go to parent ..\TEXT */ 1074 break; 1075 /* Go to parent ..\TEXT */ 1077 1076 case '.': 1078 1077 { … … 1098 1097 strcpy(lpstrPathSpec,lpstrTmp); 1099 1098 } 1100 1099 1101 1100 } /* end switch */ 1102 1101 } … … 1105 1104 { 1106 1105 /* Browse to the right directory */ 1107 COMDLG32_SHGetDesktopFolder(&psfDesktop); 1106 COMDLG32_SHGetDesktopFolder(&psfDesktop); 1108 1107 if((browsePidl = GetPidlFromName(psfDesktop,lpstrPathSpec))) 1109 1108 { … … 1126 1125 } 1127 1126 } 1128 1127 1129 1128 strcat(lpstrPathAndFile,lpstrPathSpec); 1130 1129 IShellFolder_Release(psfDesktop); … … 1138 1137 COMDLG32_PathAddBackslashA(lpstrPathAndFile); 1139 1138 strcat(lpstrPathAndFile,lpstrFileSpec); 1140 1139 1141 1140 /* Update the edit field */ 1142 1141 SetDlgItemTextA(hwnd,IDC_FILENAME,lpstrFileSpec); 1143 1142 SendDlgItemMessageA(hwnd,IDC_FILENAME,EM_SETSEL,0,-1); 1144 1143 1145 1144 /* Don't go further if we dont have a file spec */ 1146 1145 if(!strlen(lpstrFileSpec) || !strcmp(lpstrFileSpec,lpstrPathSpec)) 1147 1146 return FALSE; 1148 1147 1149 /* Time to check lpstrFileSpec */ 1148 /* Time to check lpstrFileSpec */ 1150 1149 /* search => contains * or ? */ 1151 1150 /* browse => contains a directory name */ … … 1164 1163 lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, 1165 1164 (LPSTR)strlwr((LPSTR)lpstrFileSpec)); 1166 1165 1167 1166 IShellView_Refresh(fodInfos->Shell.FOIShellView); 1168 1167 … … 1179 1178 { 1180 1179 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; 1181 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1182 1, 1183 &browsePidl, 1180 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1181 1, 1182 &browsePidl, 1184 1183 &ulAttr); 1185 1184 … … 1253 1252 return EndDialog(hwnd,TRUE); 1254 1253 } 1255 return FALSE; 1254 return FALSE; 1256 1255 } 1257 1256 } … … 1264 1263 /* if the file has no extension, append the selected 1265 1264 extension of the filetype combo box */ 1266 int iExt; 1265 int iExt; 1267 1266 LPSTR lpstrExt; 1268 1267 iExt = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB); 1269 1268 lpstrTemp = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iExt); 1270 1269 1271 if((lpstrExt = strchr(lpstrTemp,';'))) 1272 { 1273 int i = lpstrExt - lpstrTemp; 1274 lpstrExt = MemAlloc(i); 1275 strncpy(lpstrExt,&lpstrTemp[1],i-1); 1276 } 1277 else 1278 { 1279 lpstrExt = MemAlloc(strlen(lpstrTemp)); 1280 strcpy(lpstrExt,&lpstrTemp[1]); 1281 } 1282 1283 if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt) 1284 { 1285 lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2); 1286 strcat(lpstrExt,"."); 1287 strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt); 1288 } 1289 strcat(lpstrPathAndFile,lpstrExt); 1270 //SvL: Check pointer first 1271 if(lpstrTemp != (LPSTR)-1) { 1272 if((lpstrExt = strchr(lpstrTemp,';'))) 1273 { 1274 int i = lpstrExt - lpstrTemp; 1275 lpstrExt = MemAlloc(i); 1276 strncpy(lpstrExt,&lpstrTemp[1],i-1); 1277 } 1278 else 1279 { 1280 lpstrExt = MemAlloc(strlen(lpstrTemp)); 1281 strcpy(lpstrExt,&lpstrTemp[1]); 1282 } 1283 1284 if(!strcmp(&lpstrExt[1],"*") && fodInfos->ofnInfos.lpstrDefExt) 1285 { 1286 lpstrExt = MemAlloc(strlen(fodInfos->ofnInfos.lpstrDefExt)+2); 1287 strcat(lpstrExt,"."); 1288 strcat(lpstrExt,(LPSTR) fodInfos->ofnInfos.lpstrDefExt); 1289 } 1290 strcat(lpstrPathAndFile,lpstrExt); 1291 } 1290 1292 } 1291 1293 /* Check that size size of the file does not exceed buffer size */ … … 1304 1306 fodInfos->ofnInfos.nMaxFileTitle); 1305 1307 1306 /* Check if the file is to be opened as read only */ 1308 /* Check if the file is to be opened as read only */ 1307 1309 if(BST_CHECKED == SendDlgItemMessageA(hwnd, 1308 1310 IDC_OPENREADONLY, … … 1317 1319 fodInfos->ofnInfos.nFileExtension = lpstrTemp - fodInfos->ofnInfos.lpstrFile + 1; 1318 1320 1319 1321 1320 1322 /* clean and exit */ 1321 1323 FILEDLG95_Clean(hwnd); … … 1338 1340 1339 1341 /* 1340 * Initialisation of the FileOpenDialogInfos structure 1342 * Initialisation of the FileOpenDialogInfos structure 1341 1343 */ 1342 1344 … … 1358 1360 1359 1361 /* Construct the IShellBrowser interface */ 1360 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 1361 1362 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd); 1363 1362 1364 return NOERROR; 1363 1365 } … … 1417 1419 * FILEDLG95_SHELL_NewFolder 1418 1420 * 1419 * Creates a new directory with New folder as name 1421 * Creates a new directory with New folder as name 1420 1422 * If the function succeeds, the return value is nonzero. 1421 1423 * FIXME: let the contextmenu (CMDSTR_NEWFOLDER) do this thing … … 1465 1467 * FILEDLG95_FILETYPE_Init 1466 1468 * 1467 * Initialisation of the file type combo box 1469 * Initialisation of the file type combo box 1468 1470 */ 1469 1471 static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) … … 1500 1502 if(!lpstrExt) 1501 1503 break; 1502 1504 1503 1505 strcpy(lpstrExt,lpstrExtTmp); 1504 1506 1505 1507 iStrIndex += strlen(lpstrExt) +1; 1506 1508 1507 1509 /* Add the item at the end of the combo */ 1508 1510 CBAddString(fodInfos->DlgInfos.hwndFileTypeCB,lpstrTmp); … … 1612 1614 1613 1615 } 1614 1616 1615 1617 /*********************************************************************** 1616 1618 * FILEDLG95_LOOKIN_Init 1617 1619 * 1618 * Initialisation of the look in combo box 1620 * Initialisation of the look in combo box 1619 1621 */ 1620 1622 static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo) … … 1716 1718 { 1717 1719 ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 1718 0, 1719 &sfi, 1720 sizeof (SHFILEINFOA), 1721 SHGFI_PIDL | SHGFI_SMALLICON | 1722 SHGFI_OPENICON | SHGFI_SYSICONINDEX | 1723 SHGFI_DISPLAYNAME ); 1720 0, 1721 &sfi, 1722 sizeof (SHFILEINFOA), 1723 SHGFI_PIDL | SHGFI_SMALLICON | 1724 SHGFI_OPENICON | SHGFI_SYSICONINDEX | 1725 SHGFI_DISPLAYNAME ); 1724 1726 } 1725 1727 else 1726 1728 { 1727 1729 ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 1728 0, 1729 &sfi, 1730 0, 1731 &sfi, 1730 1732 sizeof (SHFILEINFOA), 1731 SHGFI_PIDL | SHGFI_SMALLICON | 1732 SHGFI_SYSICONINDEX | 1733 SHGFI_PIDL | SHGFI_SMALLICON | 1734 SHGFI_SYSICONINDEX | 1733 1735 SHGFI_DISPLAYNAME); 1734 1736 } … … 1753 1755 iIndentation = 0; 1754 1756 ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem, 1755 0, 1756 &sfi, 1757 sizeof (SHFILEINFOA), 1758 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON 1757 0, 1758 &sfi, 1759 sizeof (SHFILEINFOA), 1760 SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON 1759 1761 | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME ); 1760 1762 … … 1778 1780 rectText.bottom = pDIStruct->rcItem.bottom; 1779 1781 1780 1782 1781 1783 /* Draw the icon from the image list */ 1782 1784 COMDLG32_ImageList_Draw(ilItemImage, 1783 1785 sfi.iIcon, 1784 pDIStruct->hDC, 1785 rectIcon.left, 1786 rectIcon.top, 1787 ILD_TRANSPARENT ); 1786 pDIStruct->hDC, 1787 rectIcon.left, 1788 rectIcon.top, 1789 ILD_TRANSPARENT ); 1788 1790 1789 1791 /* Draw the associated text */ … … 1812 1814 { 1813 1815 LPSFOLDER tmpFolder; 1814 int iItem; 1816 int iItem; 1815 1817 1816 1818 iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB); … … 1829 1831 break; 1830 1832 } 1831 1833 1832 1834 } 1833 1835 return FALSE; … … 1851 1853 if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr))) 1852 1854 return -1; 1853 1855 1854 1856 tmpFolder->m_iIndent = 0; 1855 1857 … … 1868 1870 if(tmpFolder->m_iIndent > liInfos->iMaxIndentation) 1869 1871 liInfos->iMaxIndentation = tmpFolder->m_iIndent; 1870 1872 1871 1873 COMDLG32_SHGetFileInfoA((LPSTR)pidl, 1872 1874 0, 1873 1875 &sfi, 1874 1876 sizeof(sfi), 1875 SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 1877 SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX 1876 1878 | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES); 1877 1879 … … 1902 1904 * FILEDLG95_LOOKIN_InsertItemAfterParent 1903 1905 * 1904 * Insert an item below its parent 1906 * Insert an item below its parent 1905 1907 */ 1906 1908 static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl) 1907 1909 { 1908 1910 1909 1911 LPITEMIDLIST pidlParent = GetParentPidl(pidl); 1910 1912 int iParentPos; … … 1961 1963 } 1962 1964 } 1963 1965 1964 1966 CBSetCurSel(hwnd,iItemPos); 1965 1967 liInfos->uSelectedItem = iItemPos; … … 2055 2057 * GetName 2056 2058 * 2057 * Get the pidl's display name (relative to folder) and 2059 * Get the pidl's display name (relative to folder) and 2058 2060 * put it in lpstrFileName. 2059 * 2061 * 2060 2062 * Return NOERROR on success, 2061 2063 * E_FAIL otherwise … … 2080 2082 /* Get the display name of the pidl relative to the folder */ 2081 2083 if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, 2082 pidl, 2083 dwFlags, 2084 pidl, 2085 dwFlags, 2084 2086 &str))) 2085 2087 { … … 2092 2094 * GetShellFolderFromPidl 2093 2095 * 2094 * pidlRel is the item pidl relative 2096 * pidlRel is the item pidl relative 2095 2097 * Return the IShellFolder of the absolute pidl 2096 2098 */ … … 2131 2133 pidlParent = COMDLG32_PIDL_ILClone(pidl); 2132 2134 COMDLG32_PIDL_ILRemoveLastID(pidlParent); 2133 2135 2134 2136 return pidlParent; 2135 2137 } … … 2138 2140 * GetPidlFromName 2139 2141 * 2140 * returns the pidl of the file name relative to folder 2142 * returns the pidl of the file name relative to folder 2141 2143 * NULL if an error occured 2142 2144 */ … … 2152 2154 if(!lpcstrFileName) 2153 2155 return NULL; 2154 2156 2155 2157 MultiByteToWideChar(CP_ACP, 2156 MB_PRECOMPOSED, 2157 lpcstrFileName, 2158 -1, 2159 (LPWSTR)lpwstrDirName, 2160 MAX_PATH); 2158 MB_PRECOMPOSED, 2159 lpcstrFileName, 2160 -1, 2161 (LPWSTR)lpwstrDirName, 2162 MAX_PATH); 2161 2163 2162 2164 IShellFolder_ParseDisplayName(psf, 0, … … 2165 2167 &ulEaten, 2166 2168 &pidl, 2167 NULL); 2169 NULL); 2168 2170 2169 2171 return pidl;
Note:
See TracChangeset
for help on using the changeset viewer.