comdlg32: Implement GetFileName and SetFileName for the item dialog.
This commit is contained in:
parent
0a524a0c76
commit
36bf6e1afe
|
@ -80,8 +80,51 @@ typedef struct FileDialogImpl {
|
|||
HWND dlg_hwnd;
|
||||
IExplorerBrowser *peb;
|
||||
DWORD ebevents_cookie;
|
||||
|
||||
LPWSTR set_filename;
|
||||
} FileDialogImpl;
|
||||
|
||||
/**************************************************************************
|
||||
* Helper functions.
|
||||
*/
|
||||
static UINT get_file_name(FileDialogImpl *This, LPWSTR *str)
|
||||
{
|
||||
HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME);
|
||||
UINT len;
|
||||
|
||||
if(!hwnd_edit)
|
||||
{
|
||||
if(This->set_filename)
|
||||
{
|
||||
len = lstrlenW(This->set_filename);
|
||||
*str = CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
|
||||
lstrcpyW(*str, This->set_filename);
|
||||
return len;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
len = SendMessageW(hwnd_edit, WM_GETTEXTLENGTH, 0, 0);
|
||||
*str = CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
|
||||
if(!*str)
|
||||
return FALSE;
|
||||
|
||||
SendMessageW(hwnd_edit, WM_GETTEXT, len+1, (LPARAM)*str);
|
||||
return len;
|
||||
}
|
||||
|
||||
static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str)
|
||||
{
|
||||
HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME);
|
||||
|
||||
if(This->set_filename)
|
||||
LocalFree(This->set_filename);
|
||||
|
||||
This->set_filename = StrDupW(str);
|
||||
|
||||
return SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Window related functions.
|
||||
*/
|
||||
|
@ -320,6 +363,10 @@ static LRESULT on_wm_initdialog(HWND hwnd, LPARAM lParam)
|
|||
else
|
||||
ShowWindow(hitem, SW_HIDE);
|
||||
|
||||
if(This->set_filename &&
|
||||
(hitem = GetDlgItem(This->dlg_hwnd, IDC_FILENAME)) )
|
||||
SendMessageW(hitem, WM_SETTEXT, 0, (LPARAM)This->set_filename);
|
||||
|
||||
init_explorerbrowser(This);
|
||||
update_layout(This);
|
||||
|
||||
|
@ -533,6 +580,8 @@ static ULONG WINAPI IFileDialog2_fnRelease(IFileDialog2 *iface)
|
|||
if(This->psia_selection) IShellItemArray_Release(This->psia_selection);
|
||||
if(This->psia_results) IShellItemArray_Release(This->psia_results);
|
||||
|
||||
LocalFree(This->set_filename);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
|
@ -752,15 +801,26 @@ static HRESULT WINAPI IFileDialog2_fnGetCurrentSelection(IFileDialog2 *iface, IS
|
|||
static HRESULT WINAPI IFileDialog2_fnSetFileName(IFileDialog2 *iface, LPCWSTR pszName)
|
||||
{
|
||||
FileDialogImpl *This = impl_from_IFileDialog2(iface);
|
||||
FIXME("stub - %p (%p)\n", This, pszName);
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p (%p)\n", iface, pszName);
|
||||
|
||||
set_file_name(This, pszName);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IFileDialog2_fnGetFileName(IFileDialog2 *iface, LPWSTR *pszName)
|
||||
{
|
||||
FileDialogImpl *This = impl_from_IFileDialog2(iface);
|
||||
FIXME("stub - %p (%p)\n", This, pszName);
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p (%p)\n", iface, pszName);
|
||||
|
||||
if(!pszName)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*pszName = NULL;
|
||||
if(get_file_name(This, pszName))
|
||||
return S_OK;
|
||||
else
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IFileDialog2_fnSetTitle(IFileDialog2 *iface, LPCWSTR pszTitle)
|
||||
|
@ -1705,6 +1765,8 @@ static HRESULT FileDialog_constructor(IUnknown *pUnkOuter, REFIID riid, void **p
|
|||
fdimpl->dlg_hwnd = NULL;
|
||||
fdimpl->peb = NULL;
|
||||
|
||||
fdimpl->set_filename = NULL;
|
||||
|
||||
/* FIXME: The default folder setting should be restored for the
|
||||
* application if it was previously set. */
|
||||
SHGetDesktopFolder(&psf);
|
||||
|
|
|
@ -371,8 +371,6 @@ static void test_basics(void)
|
|||
}
|
||||
|
||||
/* GetFileName */
|
||||
todo_wine
|
||||
{
|
||||
hr = IFileOpenDialog_GetFileName(pfod, NULL);
|
||||
ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
|
||||
filename = (void*)0xdeadbeef;
|
||||
|
@ -385,7 +383,6 @@ static void test_basics(void)
|
|||
hr = IFileSaveDialog_GetFileName(pfsd, &filename);
|
||||
ok(hr == E_FAIL, "got 0x%08x.\n", hr);
|
||||
ok(filename == NULL, "got %p\n", filename);
|
||||
}
|
||||
|
||||
/* GetFileTypeIndex */
|
||||
hr = IFileOpenDialog_GetFileTypeIndex(pfod, NULL);
|
||||
|
@ -546,14 +543,16 @@ static void test_basics(void)
|
|||
}
|
||||
|
||||
/* SetFileName */
|
||||
todo_wine
|
||||
{
|
||||
hr = IFileOpenDialog_SetFileName(pfod, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
hr = IFileOpenDialog_SetFileName(pfod, null);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
hr = IFileOpenDialog_SetFileName(pfod, txt);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
hr = IFileOpenDialog_GetFileName(pfod, &filename);
|
||||
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
||||
ok(!lstrcmpW(filename, txt), "Strings do not match.\n");
|
||||
CoTaskMemFree(filename);
|
||||
|
||||
hr = IFileSaveDialog_SetFileName(pfsd, NULL);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
@ -561,7 +560,10 @@ static void test_basics(void)
|
|||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
hr = IFileSaveDialog_SetFileName(pfsd, txt);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
}
|
||||
hr = IFileSaveDialog_GetFileName(pfsd, &filename);
|
||||
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
||||
ok(!lstrcmpW(filename, txt), "Strings do not match.\n");
|
||||
CoTaskMemFree(filename);
|
||||
|
||||
/* SetFileNameLabel */
|
||||
todo_wine
|
||||
|
|
Loading…
Reference in New Issue