Corel merge:

Pierre Mageau
Don't update the combo box selection when closing the dialog only when
clicking on OK button.  Adjust file dialog size when help button isn't
present.

Don Kelly.
Fixes problems with open dialog box filters.

Ulrich Czekalla
Prevents the help button from displaying on OpenFile dialogs unless
the proper flag is set in the OPENFILENAME struct.

Yuxi Zhang
Fixed memory leak.

Jean-Claude Batista
Add tooltips to the file Dialog toolbar.

Sylvain Bouchard, Bill Jin
Three new functions
EnumSelectedPidls, GetNumSelected, FILEDLG95_OnOpenUsingView: corrections
Instead of passing in a copy of ofn, passing in the pointer of ofn.

David Golding
A "!" was missing in a check against lpstrInitialDir.

Rick Mutzke
Fixed crash: if dialog has no filetypes appearing in the dropdown list.

Matt Robertson, Ulrich Czekalla
Fixed problems occurring with selection of files inside openfiledlg.
This commit is contained in:
Alexandre Julliard 2000-02-20 18:54:04 +00:00
parent 2972b40048
commit cf1bcc496b
5 changed files with 581 additions and 383 deletions

View File

@ -316,6 +316,13 @@ STRINGTABLE DISCARDABLE
IDS_CREATEFILE "File does not exist\nDo you want to create file"
}
STRINGTABLE DISCARDABLE
{
IDS_UPFOLDER "Up One Level"
IDS_NEWFOLDER "Create New Folder"
IDS_LISTVIEW "List"
IDS_REPORTVIEW "Details"
}
STRINGTABLE DISCARDABLE
{

File diff suppressed because it is too large Load Diff

View File

@ -333,6 +333,7 @@ HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
(LPVOID *)&psvTmp)))
{
HWND hwndView;
HWND hDlgWnd;
/* Get the foldersettings from the old view */
if(fodInfos->Shell.FOIShellView)
{
@ -377,6 +378,11 @@ HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
fodInfos->ShellInfos.hwndView = hwndView;
/* changes the tab order of the ListView to reflect the window's File Dialog */
hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
return NOERROR;
}
}
@ -655,7 +661,7 @@ HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowse
/* Tell the dialog that the user selected a file */
else
{
hRes = FILEDLG95_OnOpen(This->hwndOwner);
hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
}
/* Free memory used by pidl */
@ -747,41 +753,88 @@ HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *
*/
HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
{
LPITEMIDLIST pidl;
FileOpenDlgInfos *fodInfos;
UINT nFileSelected;
UINT nFileToOpen;
UINT nFiles = 0;
char lpstrFileList[MAX_PATH];
char lpstrTemp[MAX_PATH];
LPSTR lpstrCurrFile = lpstrFileList;
_ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
TRACE("(%p)\n", This);
if((pidl = GetSelectedPidl(ppshv)))
nFileSelected = GetNumSelected( fodInfos->Shell.FOIShellView );
/* Count how many files we have */
for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
{
HRESULT hRes = E_FAIL;
char lpstrFileName[MAX_PATH];
LPITEMIDLIST pidlSelection;
ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
if (!ulAttr)
/* get the file selected */
EnumSelectedPidls( fodInfos->Shell.FOIShellView, nFileToOpen, &pidlSelection );
IShellFolder_GetAttributesOf( fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr );
if (!uAttr)
nFiles++;
COMDLG32_SHFree( (LPVOID) pidlSelection );
}
/* Generate the string for the edit control */
ZeroMemory(lpstrFileList, MAX_PATH);
if (nFiles)
{
for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
{
LPITEMIDLIST pidlSelection;
ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
memset( lpstrTemp, 0x0, MAX_PATH * sizeof(char) );
/* get the file selected */
EnumSelectedPidls( fodInfos->Shell.FOIShellView, nFileToOpen, &pidlSelection );
GetName( fodInfos->Shell.FOIShellFolder, pidlSelection, SHGDN_NORMAL, lpstrTemp );
IShellFolder_GetAttributesOf( fodInfos->Shell.FOIShellFolder, 1, &pidlSelection, &uAttr );
if ( uAttr & SFGAO_FOLDER ) /* Ignore folders */
continue;
if (nFiles > 1) /* Quote files if we have more than one */
{
if(SUCCEEDED(hRes = GetName(fodInfos->Shell.FOIShellFolder,pidl,SHGDN_NORMAL,lpstrFileName)))
SetWindowTextA(fodInfos->DlgInfos.hwndFileName,lpstrFileName);
*lpstrCurrFile++ = '\"';
lstrcpyA( lpstrCurrFile, lpstrTemp );
lpstrCurrFile += lstrlenA( lpstrTemp );
lstrcpyA( lpstrCurrFile, "\" " );
lpstrCurrFile += 2;
}
else
{
lstrcpyA( lpstrCurrFile, lpstrTemp );
}
COMDLG32_SHFree( (LPVOID) pidlSelection );
}
SetWindowTextA(fodInfos->DlgInfos.hwndFileName,lpstrFileList);
if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
}
else
SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Open");
fodInfos->DlgInfos.dwDlgProp |= FODPROP_USEVIEW;
COMDLG32_SHFree((LPVOID)pidl);
SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
return hRes;
return S_OK;
}
if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
return E_FAIL;
return nFileSelected ? S_OK : E_FAIL;
}
/***********************************************************************
@ -833,6 +886,111 @@ LPITEMIDLIST GetSelectedPidl(IShellView *ppshv)
return NULL;
}
/***********************************************************************
* EnumSelectedPidls
*
* Return the pidl(s) of the selected item(s) in the view.
*
*/
BOOL EnumSelectedPidls( IShellView *ppshv, /*[in]*/
UINT nPidlIndex, /*[in]*/
LPITEMIDLIST *pidlSelected /*[out]*/ )
{
IDataObject *doSelected;
BOOL retVal = TRUE;
/* Get an IDataObject from the view */
if(SUCCEEDED(IShellView_GetItemObject(ppshv,
SVGIO_SELECTION,
&IID_IDataObject,
(LPVOID *)&doSelected)))
{
STGMEDIUM medium;
FORMATETC formatetc;
/* Set the FORMATETC structure*/
SETDefFormatEtc(formatetc,
RegisterClipboardFormatA(CFSTR_SHELLIDLIST),
TYMED_HGLOBAL);
/* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
{
LPIDA cida = GlobalLock(medium.u.hGlobal);
if(nPidlIndex < cida->cidl)
{
*pidlSelected = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex + 1]]));
}
else
{
retVal = FALSE;
}
if(medium.pUnkForRelease)
{
IUnknown_Release(medium.pUnkForRelease);
}
else
{
GlobalUnlock(medium.u.hGlobal);
GlobalFree(medium.u.hGlobal);
}
}
IDataObject_Release(doSelected);
return retVal;
}
return FALSE;
}
/***********************************************************************
* GetNumSelected
*
* Return the number of selected items in the view.
*
*/
UINT GetNumSelected( IShellView *ppshv )
{
IDataObject *doSelected;
UINT retVal = 0;
/* Get an IDataObject from the view */
if(SUCCEEDED(IShellView_GetItemObject(ppshv,
SVGIO_SELECTION,
&IID_IDataObject,
(LPVOID *)&doSelected)))
{
STGMEDIUM medium;
FORMATETC formatetc;
/* Set the FORMATETC structure*/
SETDefFormatEtc(formatetc,
RegisterClipboardFormatA(CFSTR_SHELLIDLIST),
TYMED_HGLOBAL);
/* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
{
LPIDA cida = GlobalLock(medium.u.hGlobal);
retVal = cida->cidl;
if(medium.pUnkForRelease)
{
IUnknown_Release(medium.pUnkForRelease);
}
else
{
GlobalUnlock(medium.u.hGlobal);
GlobalFree(medium.u.hGlobal);
}
}
IDataObject_Release(doSelected);
return retVal;
}
return 0;
}

View File

@ -41,7 +41,7 @@ typedef struct
typedef struct
{
OPENFILENAMEA ofnInfos;
LPOPENFILENAMEA ofnInfos;
struct {
IShellBrowser *FOIShellBrowser;
IShellFolder *FOIShellFolder;
@ -88,6 +88,13 @@ typedef struct
#define IDS_CREATEFOLDER_DENIED 117
#define IDS_FILEOPEN_CAPTION 118
/* File Dialog Tooltips string IDs */
#define IDS_UPFOLDER 150
#define IDS_NEWFOLDER 151
#define IDS_LISTVIEW 152
#define IDS_REPORTVIEW 153
#define IDC_OPENREADONLY chx1
#define IDC_TOOLBARSTATIC stc1
@ -207,5 +214,7 @@ HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *
LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
BOOL EnumSelectedPidls(IShellView *ppshv, UINT nPidlIndex, LPITEMIDLIST *pidlSelected);
UINT GetNumSelected(IShellView *ppshv);
#endif /*SHBROWSER_H*/

View File

@ -28,7 +28,7 @@ short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
if(lpFile == NULL || (lpTitle == NULL && cbBuf != 0))
if(lpFile == NULL || lpTitle == NULL)
return -1;
len = strlen(lpFile);
@ -62,8 +62,7 @@ short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
if(cbBuf < len)
return len;
/* The lpTitle buffer is big enough, perform a simple copy */
strcpy(lpTitle, &lpFile[i]);
strncpy(lpTitle, &lpFile[i], len);
return 0;
}