*
*/
+#include "config.h"
+#include "wine/port.h"
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#define COBJMACROS
+#define NONAMELESSUNION
+
+#include "windef.h"
+#include "winbase.h"
+#include "winternl.h"
+#include "winnls.h"
+#include "wingdi.h"
+#ifdef __REACTOS__
+/* RegGetValueW is supported by Win2k3 SP1 but headers need Win Vista */
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#endif
+#include "winreg.h"
+#include "winuser.h"
+#include "commdlg.h"
+#include "dlgs.h"
#include "cdlg.h"
+#include "cderr.h"
+#include "shellapi.h"
+#include "shlobj.h"
+#include "filedlgbrowser.h"
+#include "shlwapi.h"
+
+#include "wine/unicode.h"
+#include "wine/debug.h"
-#include <shellapi.h>
+WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#define UNIMPLEMENTED_FLAGS \
(OFN_DONTADDTORECENT |\
#define CBSetExtendedUI(hwnd,flag) \
SendMessageW(hwnd, CB_SETEXTENDEDUI, (WPARAM)(flag), 0)
-const char FileOpenDlgInfosStr[] = "FileOpenDlgInfos"; /* windows property description string */
static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property */
static SIZE MemDialogSize = { 0, 0}; /* keep size of the (resizable) dialog */
'L','a','s','t','V','i','s','i','t','e','d','M','R','U',0};
static const WCHAR MRUListW[] = {'M','R','U','L','i','s','t',0};
+static const WCHAR filedlg_info_propnameW[] = {'F','i','l','e','O','p','e','n','D','l','g','I','n','f','o','s',0};
+
+FileOpenDlgInfos *get_filedlg_infoptr(HWND hwnd)
+{
+ return GetPropW(hwnd, filedlg_info_propnameW);
+}
+
/***********************************************************************
* Prototypes
*/
static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
static UINT GetNumSelected( IDataObject *doSelected );
+static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
/* Shell memory allocation */
static void *MemAlloc(UINT size);
*/
static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
{
-
LRESULT lRes;
- LPCVOID origTemplate;
- DWORD dwSize;
- LPDLGTEMPLATEW template;
+ void *template;
HRSRC hRes;
HANDLE hDlgTmpl = 0;
- HRESULT hr;
/* test for missing functionality */
if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
return FALSE;
}
- if (!(dwSize = SizeofResource(COMDLG32_hInstance, hRes)) ||
- !(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes)) ||
- !(origTemplate = LockResource(hDlgTmpl)))
+ if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
+ !(template = LockResource( hDlgTmpl )))
{
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
return FALSE;
}
- if (!(template = HeapAlloc(GetProcessHeap(), 0, dwSize)))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
- return FALSE;
- }
- memcpy(template, origTemplate, dwSize);
/* msdn: explorer style dialogs permit sizing by default.
* The OFN_ENABLESIZING flag is only needed when a hook or
- * custom tmeplate is provided */
+ * custom template is provided */
if( (fodInfos->ofnInfos->Flags & OFN_EXPLORER) &&
!(fodInfos->ofnInfos->Flags & ( OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE)))
fodInfos->ofnInfos->Flags |= OFN_ENABLESIZING;
if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
{
- template->style |= WS_SIZEBOX;
fodInfos->sizedlg.cx = fodInfos->sizedlg.cy = 0;
fodInfos->initial_size.x = fodInfos->initial_size.y = 0;
}
- else
- template->style &= ~WS_SIZEBOX;
-
/* old style hook messages */
if (IsHooked(fodInfos))
fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
}
- /* Some shell namespace extensions depend on COM being initialized. */
- hr = OleInitialize(NULL);
-
if (fodInfos->unicode)
lRes = DialogBoxIndirectParamW(COMDLG32_hInstance,
template,
fodInfos->ofnInfos->hwndOwner,
FileOpenDlgProc95,
(LPARAM) fodInfos);
- if (SUCCEEDED(hr))
+ if (fodInfos->ole_initialized)
OleUninitialize();
- HeapFree(GetProcessHeap(), 0, template);
-
/* Unable to create the dialog */
if( lRes == -1)
return FALSE;
return lRes;
}
-/***********************************************************************
- * GetFileDialog95A
- *
- * Call GetFileName95 with this structure and clean the memory.
- *
- * IN : The OPENFILENAMEA initialisation structure passed to
- * GetOpenFileNameA win api function (see filedlg.c)
- */
-static BOOL GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
+static WCHAR *heap_strdupAtoW(const char *str)
{
- BOOL ret;
- FileOpenDlgInfos fodInfos;
- LPSTR lpstrSavDir = NULL;
- LPWSTR title = NULL;
- LPWSTR defext = NULL;
- LPWSTR filter = NULL;
- LPWSTR customfilter = NULL;
- INITCOMMONCONTROLSEX icc;
-
- /* Initialize ComboBoxEx32 */
- icc.dwSize = sizeof(icc);
- icc.dwICC = ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icc);
-
- /* Initialize CommDlgExtendedError() */
- COMDLG32_SetCommDlgExtendedError(0);
-
- /* Initialize FileOpenDlgInfos structure */
- ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
-
- /* Pass in the original ofn */
- fodInfos.ofnInfos = (LPOPENFILENAMEW)ofn;
-
- /* save current directory */
- if (ofn->Flags & OFN_NOCHANGEDIR)
- {
- lpstrSavDir = MemAlloc(MAX_PATH);
- GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
- }
+ WCHAR *ret;
+ INT len;
- fodInfos.unicode = FALSE;
-
- /* convert all the input strings to unicode */
- if(ofn->lpstrInitialDir)
- {
- DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrInitialDir, -1, NULL, 0 );
- fodInfos.initdir = MemAlloc((len+1)*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrInitialDir, -1, fodInfos.initdir, len);
- }
- else
- fodInfos.initdir = NULL;
+ if (!str)
+ return NULL;
- if(ofn->lpstrFile)
- {
- fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFile, -1, fodInfos.filename, ofn->nMaxFile);
- }
- else
- fodInfos.filename = NULL;
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0);
+ ret = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
- if(ofn->lpstrDefExt)
- {
- DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrDefExt, -1, NULL, 0 );
- defext = MemAlloc((len+1)*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrDefExt, -1, defext, len);
- }
- fodInfos.defext = defext;
+ return ret;
+}
- if(ofn->lpstrTitle)
- {
- DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrTitle, -1, NULL, 0 );
- title = MemAlloc((len+1)*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrTitle, -1, title, len);
- }
- fodInfos.title = title;
+static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
+{
+ INITCOMMONCONTROLSEX icc;
- if (ofn->lpstrFilter)
- {
- LPCSTR s;
- int n, len;
-
- /* filter is a list... title\0ext\0......\0\0 */
- s = ofn->lpstrFilter;
- while (*s) s = s+strlen(s)+1;
- s++;
- n = s - ofn->lpstrFilter;
- len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0 );
- filter = MemAlloc(len*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFilter, n, filter, len );
- }
- fodInfos.filter = filter;
+ /* Initialize ComboBoxEx32 */
+ icc.dwSize = sizeof(icc);
+ icc.dwICC = ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icc);
- /* convert lpstrCustomFilter */
- if (ofn->lpstrCustomFilter)
- {
- LPCSTR s;
- int n, len;
-
- /* customfilter contains a pair of strings... title\0ext\0 */
- s = ofn->lpstrCustomFilter;
- if (*s) s = s+strlen(s)+1;
- if (*s) s = s+strlen(s)+1;
- n = s - ofn->lpstrCustomFilter;
- len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0 );
- customfilter = MemAlloc(len*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrCustomFilter, n, customfilter, len );
- }
- fodInfos.customfilter = customfilter;
+ /* Initialize CommDlgExtendedError() */
+ COMDLG32_SetCommDlgExtendedError(0);
- /* Initialize the dialog property */
- fodInfos.DlgInfos.dwDlgProp = 0;
- fodInfos.DlgInfos.hwndCustomDlg = NULL;
+ memset(info, 0, sizeof(*info));
- switch(iDlgType)
- {
- case OPEN_DIALOG :
- ret = GetFileName95(&fodInfos);
- break;
- case SAVE_DIALOG :
- fodInfos.DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
- ret = GetFileName95(&fodInfos);
- break;
- default :
- ret = FALSE;
- }
+ /* Pass in the original ofn */
+ info->ofnInfos = ofn;
- if (lpstrSavDir)
- {
- SetCurrentDirectoryA(lpstrSavDir);
- MemFree(lpstrSavDir);
- }
+ info->title = ofn->lpstrTitle;
+ info->defext = ofn->lpstrDefExt;
+ info->filter = ofn->lpstrFilter;
+ info->customfilter = ofn->lpstrCustomFilter;
- MemFree(title);
- MemFree(defext);
- MemFree(filter);
- MemFree(customfilter);
- MemFree(fodInfos.initdir);
- MemFree(fodInfos.filename);
+ if (ofn->lpstrFile)
+ {
+ info->filename = MemAlloc(ofn->nMaxFile * sizeof(WCHAR));
+ lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile);
+ }
- TRACE("selected file: %s\n",ofn->lpstrFile);
+ if (ofn->lpstrInitialDir)
+ {
+ DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0);
+ if (len)
+ {
+ info->initdir = MemAlloc(len * sizeof(WCHAR));
+ ExpandEnvironmentStringsW(ofn->lpstrInitialDir, info->initdir, len);
+ }
+ }
- return ret;
+ info->unicode = TRUE;
}
-/***********************************************************************
- * GetFileDialog95W
- *
- * Copy the OPENFILENAMEW structure in a FileOpenDlgInfos structure.
- * Call GetFileName95 with this structure and clean the memory.
- *
- */
-static BOOL GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
+static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
{
- BOOL ret;
- FileOpenDlgInfos fodInfos;
- LPWSTR lpstrSavDir = NULL;
- INITCOMMONCONTROLSEX icc;
+ OPENFILENAMEW ofnW;
+ int len;
- /* Initialize ComboBoxEx32 */
- icc.dwSize = sizeof(icc);
- icc.dwICC = ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icc);
+ ofnW = *(OPENFILENAMEW *)ofn;
- /* Initialize CommDlgExtendedError() */
- COMDLG32_SetCommDlgExtendedError(0);
+ ofnW.lpstrInitialDir = heap_strdupAtoW(ofn->lpstrInitialDir);
+ ofnW.lpstrDefExt = heap_strdupAtoW(ofn->lpstrDefExt);
+ ofnW.lpstrTitle = heap_strdupAtoW(ofn->lpstrTitle);
- /* Initialize FileOpenDlgInfos structure */
- ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
+ if (ofn->lpstrFile)
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0);
+ ofnW.lpstrFile = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len);
+ ofnW.nMaxFile = len;
+ }
- /* Pass in the original ofn */
- fodInfos.ofnInfos = ofn;
+ if (ofn->lpstrFilter)
+ {
+ LPCSTR s;
+ int n;
+
+ /* filter is a list... title\0ext\0......\0\0 */
+ s = ofn->lpstrFilter;
+ while (*s) s = s+strlen(s)+1;
+ s++;
+ n = s - ofn->lpstrFilter;
+ len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0);
+ ofnW.lpstrFilter = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, (WCHAR *)ofnW.lpstrFilter, len);
+ }
- fodInfos.title = ofn->lpstrTitle;
- fodInfos.defext = ofn->lpstrDefExt;
- fodInfos.filter = ofn->lpstrFilter;
- fodInfos.customfilter = ofn->lpstrCustomFilter;
+ /* convert lpstrCustomFilter */
+ if (ofn->lpstrCustomFilter)
+ {
+ int n, len;
+ LPCSTR s;
+
+ /* customfilter contains a pair of strings... title\0ext\0 */
+ s = ofn->lpstrCustomFilter;
+ if (*s) s = s+strlen(s)+1;
+ if (*s) s = s+strlen(s)+1;
+ n = s - ofn->lpstrCustomFilter;
+ len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0);
+ ofnW.lpstrCustomFilter = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, ofnW.lpstrCustomFilter, len);
+ }
- /* convert string arguments, save others */
- if(ofn->lpstrFile)
- {
- fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
- lstrcpynW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
- }
- else
- fodInfos.filename = NULL;
+ init_filedlg_infoW(&ofnW, info);
- if(ofn->lpstrInitialDir)
- {
- /* fodInfos.initdir = strdupW(ofn->lpstrInitialDir); */
- DWORD len = lstrlenW(ofn->lpstrInitialDir)+1;
- fodInfos.initdir = MemAlloc(len*sizeof(WCHAR));
- memcpy(fodInfos.initdir,ofn->lpstrInitialDir,len*sizeof(WCHAR));
- }
- else
- fodInfos.initdir = NULL;
+ /* fixup A-specific fields */
+ info->ofnInfos = (OPENFILENAMEW *)ofn;
+ info->unicode = FALSE;
- /* save current directory */
- if (ofn->Flags & OFN_NOCHANGEDIR)
- {
- lpstrSavDir = MemAlloc(MAX_PATH*sizeof(WCHAR));
- GetCurrentDirectoryW(MAX_PATH, lpstrSavDir);
- }
+ /* free what was duplicated */
+ MemFree((WCHAR *)ofnW.lpstrInitialDir);
+ MemFree((WCHAR *)ofnW.lpstrFile);
+}
- fodInfos.unicode = TRUE;
+/***********************************************************************
+ * GetFileDialog95
+ *
+ * Call GetFileName95 with this structure and clean the memory.
+ */
+static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
+{
+ WCHAR *current_dir = NULL;
+ BOOL ret;
- switch(iDlgType)
- {
- case OPEN_DIALOG :
- ret = GetFileName95(&fodInfos);
- break;
- case SAVE_DIALOG :
- fodInfos.DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
- ret = GetFileName95(&fodInfos);
- break;
- default :
- ret = FALSE;
- }
+ /* save current directory */
+ if (info->ofnInfos->Flags & OFN_NOCHANGEDIR)
+ {
+ current_dir = MemAlloc(MAX_PATH * sizeof(WCHAR));
+ GetCurrentDirectoryW(MAX_PATH, current_dir);
+ }
- if (lpstrSavDir)
- {
- SetCurrentDirectoryW(lpstrSavDir);
- MemFree(lpstrSavDir);
- }
+ switch (dlg_type)
+ {
+ case OPEN_DIALOG:
+ ret = GetFileName95(info);
+ break;
+ case SAVE_DIALOG:
+ info->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
+ ret = GetFileName95(info);
+ break;
+ default:
+ ret = FALSE;
+ }
- /* restore saved IN arguments and convert OUT arguments back */
- MemFree(fodInfos.filename);
- MemFree(fodInfos.initdir);
- return ret;
+ /* set the lpstrFileTitle */
+ if (ret && info->ofnInfos->lpstrFile && info->ofnInfos->lpstrFileTitle)
+ {
+ if (info->unicode)
+ {
+ LPOPENFILENAMEW ofn = info->ofnInfos;
+ WCHAR *file_title = PathFindFileNameW(ofn->lpstrFile);
+ lstrcpynW(ofn->lpstrFileTitle, file_title, ofn->nMaxFileTitle);
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)info->ofnInfos;
+ char *file_title = PathFindFileNameA(ofn->lpstrFile);
+ lstrcpynA(ofn->lpstrFileTitle, file_title, ofn->nMaxFileTitle);
+ }
+ }
+
+ if (current_dir)
+ {
+ SetCurrentDirectoryW(current_dir);
+ MemFree(current_dir);
+ }
+
+ if (!info->unicode)
+ {
+ MemFree((WCHAR *)info->defext);
+ MemFree((WCHAR *)info->title);
+ MemFree((WCHAR *)info->filter);
+ MemFree((WCHAR *)info->customfilter);
+ }
+
+ MemFree(info->filename);
+ MemFree(info->initdir);
+ return ret;
}
/******************************************************************************
if ( lpstrEdit[nStrCharCount]=='"' )
{
nStrCharCount++;
- while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))
+ while ((nStrCharCount <= nStrLen) && (lpstrEdit[nStrCharCount]!='"'))
{
(*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
nStrCharCount++;
HANDLE hDlgTmpl = 0;
HWND hChildDlg = 0;
- TRACE("\n");
+ TRACE("%p, %p\n", fodInfos, hwnd);
/*
* If OFN_ENABLETEMPLATEHANDLE is specified, the OPENFILENAME
LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
{
- LRESULT hook_result = 0;
- FileOpenDlgInfos *fodInfos = GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndParentDlg);
+ LRESULT hook_result;
+ OFNOTIFYW ofnNotify;
- TRACE("%p 0x%04x\n",hwndParentDlg, uCode);
+ TRACE("%p %d\n", hwndParentDlg, uCode);
- if(!fodInfos) return 0;
+ if (!fodInfos || !fodInfos->DlgInfos.hwndCustomDlg)
+ return 0;
+
+ TRACE("CALL NOTIFY for %d\n", uCode);
+
+ ofnNotify.hdr.hwndFrom = hwndParentDlg;
+ ofnNotify.hdr.idFrom = 0;
+ ofnNotify.hdr.code = uCode;
+ ofnNotify.lpOFN = fodInfos->ofnInfos;
+ ofnNotify.pszFile = NULL;
+
+ if (fodInfos->unicode)
+ hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
+ else
+ hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
+
+ TRACE("RET NOTIFY retval %#lx\n", hook_result);
- if(fodInfos->DlgInfos.hwndCustomDlg)
- {
- TRACE("CALL NOTIFY for %x\n", uCode);
- if(fodInfos->unicode)
- {
- OFNOTIFYW ofnNotify;
- ofnNotify.hdr.hwndFrom=hwndParentDlg;
- ofnNotify.hdr.idFrom=0;
- ofnNotify.hdr.code = uCode;
- ofnNotify.lpOFN = fodInfos->ofnInfos;
- ofnNotify.pszFile = NULL;
- hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
- }
- else
- {
- OFNOTIFYA ofnNotify;
- ofnNotify.hdr.hwndFrom=hwndParentDlg;
- ofnNotify.hdr.idFrom=0;
- ofnNotify.hdr.code = uCode;
- ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
- ofnNotify.pszFile = NULL;
- hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
- }
- TRACE("RET NOTIFY\n");
- }
- TRACE("Retval: 0x%08lx\n", hook_result);
return hook_result;
}
{
UINT len, total;
WCHAR *p, *buffer;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("CDM_GETFILEPATH:\n");
*/
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
WCHAR lpstrPath[MAX_PATH];
INT_PTR retval;
*/
static LRESULT FILEDLG95_OnWMGetMMI( HWND hwnd, LPMINMAXINFO mmiptr)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
if( fodInfos->initial_size.x || fodInfos->initial_size.y)
{
FileOpenDlgInfos *fodInfos;
if( wParam != SIZE_RESTORED) return FALSE;
- fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ fodInfos = get_filedlg_infoptr(hwnd);
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
/* get the new dialog rectangle */
GetWindowRect( hwnd, &rc);
- TRACE("Size from %d,%d to %d,%d\n", fodInfos->sizedlg.cx, fodInfos->sizedlg.cy,
+ TRACE("%p, size from %d,%d to %d,%d\n", hwnd, fodInfos->sizedlg.cx, fodInfos->sizedlg.cy,
rc.right -rc.left, rc.bottom -rc.top);
/* not initialized yet */
if( (fodInfos->sizedlg.cx == 0 && fodInfos->sizedlg.cy == 0) ||
int gripx = GetSystemMetrics( SM_CYHSCROLL);
int gripy = GetSystemMetrics( SM_CYVSCROLL);
- /* Adds the FileOpenDlgInfos in the property list of the dialog
- so it will be easily accessible through a GetPropA(...) */
- SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos);
+ /* Some shell namespace extensions depend on COM being initialized. */
+ if (SUCCEEDED(OleInitialize(NULL)))
+ fodInfos->ole_initialized = TRUE;
+
+ SetPropW(hwnd, filedlg_info_propnameW, fodInfos);
FILEDLG95_InitControls(hwnd);
if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
{
- GetWindowRect( hwnd, &rc);
+ DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
+ DWORD ex_style = GetWindowLongW(hwnd, GWL_EXSTYLE);
+ RECT client, client_adjusted;
+
+ if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
+ {
+ style |= WS_SIZEBOX;
+ ex_style |= WS_EX_WINDOWEDGE;
+ }
+ else
+ style &= ~WS_SIZEBOX;
+ SetWindowLongW(hwnd, GWL_STYLE, style);
+ SetWindowLongW(hwnd, GWL_EXSTYLE, ex_style);
+
+ GetClientRect( hwnd, &client );
+ GetClientRect( hwnd, &client_adjusted );
+ AdjustWindowRectEx( &client_adjusted, style, FALSE, ex_style );
+
+ GetWindowRect( hwnd, &rc );
+ rc.right += client_adjusted.right - client.right;
+ rc.bottom += client_adjusted.bottom - client.bottom;
+ SetWindowPos(hwnd, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE |
+ SWP_NOZORDER | SWP_NOMOVE);
+
+ GetWindowRect( hwnd, &rc );
fodInfos->DlgInfos.hwndGrip =
CreateWindowExA( 0, "SCROLLBAR", NULL,
WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS |
case WM_DESTROY:
{
- FileOpenDlgInfos * fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos * fodInfos = get_filedlg_infoptr(hwnd);
if (fodInfos && fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
MemDialogSize = fodInfos->sizedlg;
- RemovePropA(hwnd, FileOpenDlgInfosStr);
+ RemovePropW(hwnd, filedlg_info_propnameW);
return FALSE;
}
case WM_NOTIFY:
SHFILEINFOA shFileInfo;
ITEMIDLIST *desktopPidl;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("%p\n", fodInfos);
result = GetFullPathNameW(fodInfos->filename, MAX_PATH, tmpBuf, &nameBit);
if (result) {
- /* nameBit is always shorter than the original filename */
- lstrcpyW(fodInfos->filename,nameBit);
+ /* nameBit is always shorter than the original filename. It may be NULL
+ * when the filename contains only a drive name instead of file name */
+ if (nameBit)
+ {
+ lstrcpyW(fodInfos->filename,nameBit);
+ *nameBit = 0x00;
+ }
+ else
+ *fodInfos->filename = '\0';
- *nameBit = 0x00;
MemFree(fodInfos->initdir);
fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
lstrcpyW(fodInfos->initdir, tmpBuf);
/* 2. (All platforms) If initdir is not null, then use it */
if (!handledPath && fodInfos->initdir && *fodInfos->initdir)
{
- /* Work out the proper path as supplied one might be relative */
- /* (Here because supplying '.' as dir browses to My Computer) */
- if (!handledPath) {
- WCHAR tmpBuf[MAX_PATH];
- WCHAR tmpBuf2[MAX_PATH];
- WCHAR *nameBit;
- DWORD result;
-
- lstrcpyW(tmpBuf, fodInfos->initdir);
- if( PathFileExistsW(tmpBuf) ) {
- /* initdir does not have to be a directory. If a file is
- * specified, the dir part is taken */
- if( PathIsDirectoryW(tmpBuf)) {
- if (tmpBuf[lstrlenW(tmpBuf)-1] != '\\') {
- lstrcatW(tmpBuf, szwSlash);
- }
- lstrcatW(tmpBuf, szwStar);
- }
- result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
- if (result) {
- *nameBit = 0x00;
- MemFree(fodInfos->initdir);
- fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf2) + 1)*sizeof(WCHAR));
- lstrcpyW(fodInfos->initdir, tmpBuf2);
- handledPath = TRUE;
- TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
- }
- }
- else if (fodInfos->initdir)
- {
- MemFree(fodInfos->initdir);
- fodInfos->initdir = NULL;
- TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
- }
- }
+ /* Work out the proper path as supplied one might be relative */
+ /* (Here because supplying '.' as dir browses to My Computer) */
+ WCHAR tmpBuf[MAX_PATH];
+ WCHAR tmpBuf2[MAX_PATH];
+ WCHAR *nameBit;
+ DWORD result;
+
+ lstrcpyW(tmpBuf, fodInfos->initdir);
+ if (PathFileExistsW(tmpBuf)) {
+ /* initdir does not have to be a directory. If a file is
+ * specified, the dir part is taken */
+ if (PathIsDirectoryW(tmpBuf)) {
+ PathAddBackslashW(tmpBuf);
+ lstrcatW(tmpBuf, szwStar);
+ }
+ result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
+ if (result) {
+ *nameBit = 0x00;
+ MemFree(fodInfos->initdir);
+ fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
+ lstrcpyW(fodInfos->initdir, tmpBuf2);
+ handledPath = TRUE;
+ TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
+ }
+ }
+ else if (fodInfos->initdir)
+ {
+ MemFree(fodInfos->initdir);
+ fodInfos->initdir = NULL;
+ TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
+ }
}
if (!handledPath && (!fodInfos->initdir || !*fodInfos->initdir))
*/
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
WORD wNotifyCode = HIWORD(wParam); /* notification code */
WORD wID = LOWORD(wParam); /* item, control, or accelerator identifier */
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
switch(wID)
{
*/
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
*/
BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
WCHAR lpstrPathSpec[MAX_PATH] = {0};
UINT nCount, nSizePath;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("\n");
*/
BOOL FILEDLG95_OnOpen(HWND hwnd)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LPWSTR lpstrFileList;
UINT nFileCount = 0;
UINT sizeUsed = 0;
WCHAR lpstrPathAndFile[MAX_PATH];
LPSHELLFOLDER lpsf = NULL;
int nOpenAction;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("hwnd=%p\n", hwnd);
&& fodInfos->ofnInfos->Flags & OFN_EXPLORER)
{
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
+ SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_SETTEXT, 0, (LPARAM)"");
}
}
else if( nOpenAction == ONOPEN_SEARCH )
COMDLG32_SHFree(pidlCurrent);
if (filename_is_edit( fodInfos ))
SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
+ else
+ {
+ HWND hwnd;
+
+ hwnd = (HWND)SendMessageA(fodInfos->DlgInfos.hwndFileName, CBEM_GETEDITCONTROL, 0, 0);
+ SendMessageW(hwnd, EM_SETSEL, 0, -1);
+ }
}
}
ret = FALSE;
filterSearchIndex[0] = '\0';
}
+ /* find the file extension by searching for the first dot in filterExt */
/* strip the * or anything else from the extension, "*.abc" becomes "abc" */
/* if the extension is invalid or contains a glob, ignore it */
- filterSearchIndex = PathFindExtensionW(filterExt);
- if (*filterSearchIndex++ && !strchrW(filterSearchIndex, '*') && !strchrW(filterSearchIndex, '?'))
+ filterSearchIndex = strchrW(filterExt, '.');
+ if (filterSearchIndex++ && !strchrW(filterSearchIndex, '*') && !strchrW(filterSearchIndex, '?'))
{
strcpyW(filterExt, filterSearchIndex);
}
fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - tempFileA) + 1 : 0;
}
- /* set the lpstrFileTitle */
- if(fodInfos->ofnInfos->lpstrFileTitle)
- {
- LPWSTR lpstrFileTitle = PathFindFileNameW(lpstrPathAndFile);
- if(fodInfos->unicode)
- {
- LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
- lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
- }
- else
- {
- LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
- WideCharToMultiByte(CP_ACP, 0, lpstrFileTitle, -1,
- ofn->lpstrFileTitle, ofn->nMaxFileTitle, NULL, NULL);
- }
- }
-
/* copy currently selected filter to lpstrCustomFilter */
if (fodInfos->ofnInfos->lpstrCustomFilter)
{
*/
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
- TRACE("\n");
+ TRACE("%p\n", hwnd);
/*
* Initialisation of the FileOpenDialogInfos structure
*/
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
IContextMenu * pcm;
TRACE("(%p,%p)\n", hwnd, lpVerb);
*/
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
*/
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LPITEMIDLIST pidl;
HRESULT hres;
*/
static void FILEDLG95_SHELL_Clean(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
IShellView_Release(fodInfos->Shell.FOIShellView);
}
- IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
+ if (fodInfos->Shell.FOIShellFolder)
+ IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
if (fodInfos->Shell.FOIDataObject)
IDataObject_Release(fodInfos->Shell.FOIDataObject);
*/
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
int nFilters = 0; /* number of filters */
int nFilterIndexCB;
- TRACE("\n");
+ TRACE("%p\n", hwnd);
if(fodInfos->customfilter)
{
*/
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
switch(wNotifyCode)
{
*/
static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
int iPos;
int iCount = CBGetCount(fodInfos->DlgInfos.hwndFileTypeCB);
TEXTMETRICW tm;
LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos));
- TRACE("\n");
+ TRACE("%p\n", hwndCombo);
liInfos->iMaxIndentation = 0;
int iIndentation;
TEXTMETRICW tm;
LPSFOLDER tmpFolder;
- LookInInfos *liInfos = GetPropA(pDIStruct->hwndItem,LookInInfosStr);
UINT shgfi_flags = SHGFI_PIDL | SHGFI_OPENICON | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME;
UINT icon_width, icon_height;
shgfi_flags |= SHGFI_SMALLICON;
}
- if(pDIStruct->itemID == liInfos->uSelectedItem)
- {
- ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
- 0, &sfi, sizeof (sfi), shgfi_flags );
- }
- else
- {
- ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
- 0, &sfi, sizeof (sfi), shgfi_flags );
- }
+ ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
+ 0, &sfi, sizeof (sfi), shgfi_flags );
/* Is this item selected ? */
if(pDIStruct->itemState & ODS_SELECTED)
/* Do not indent item if drawing in the edit of the combo */
if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
- {
iIndentation = 0;
- ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
- 0, &sfi, sizeof (sfi), shgfi_flags );
-
- }
else
- {
iIndentation = tmpFolder->m_iIndent;
- }
+
/* Draw text and icon */
/* Initialise the icon display area */
*/
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("%p\n", fodInfos);
SFOLDER *tmpFolder;
LookInInfos *liInfos;
- TRACE("%08x\n", iInsertId);
+ TRACE("%p, %p, %d\n", hwnd, pidl, iInsertId);
if(!pidl)
return -1;
0,
&sfi,
sizeof(sfi),
- SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
- | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
+ SHGFI_DISPLAYNAME | SHGFI_PIDL | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
- TRACE("-- Add %s attr=%08x\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
+ TRACE("-- Add %s attr=0x%08x\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
{
int iItemPos;
LookInInfos *liInfos;
- TRACE("\n");
+ TRACE("%p, %p\n", hwnd, pidl);
iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidl,SEARCH_PIDL);
*/
static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LookInInfos *liInfos = GetPropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
int iPos;
int iCount = CBGetCount(fodInfos->DlgInfos.hwndLookInCB);
RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
}
+/***********************************************************************
+ * get_def_format
+ *
+ * Fill the FORMATETC used in the shell id list
+ */
+static FORMATETC get_def_format(void)
+{
+ static CLIPFORMAT cfFormat;
+ FORMATETC formatetc;
+
+ if (!cfFormat) cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLISTA);
+ formatetc.cfFormat = cfFormat;
+ formatetc.ptd = 0;
+ formatetc.dwAspect = DVASPECT_CONTENT;
+ formatetc.lindex = -1;
+ formatetc.tymed = TYMED_HGLOBAL;
+ return formatetc;
+}
+
/***********************************************************************
* FILEDLG95_FILENAME_FillFromSelection
*
*/
void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
{
- FileOpenDlgInfos *fodInfos;
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LPITEMIDLIST pidl;
- UINT nFiles = 0, nFileToOpen, nFileSelected, nLength = 0;
- WCHAR lpstrTemp[MAX_PATH];
- LPWSTR lpstrAllFile, lpstrCurrFile;
+ LPWSTR lpstrAllFiles, lpstrTmp;
+ UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength;
+ STGMEDIUM medium;
+ LPIDA cida;
+ FORMATETC formatetc = get_def_format();
TRACE("\n");
- fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
-
- /* Count how many files we have */
- nFileSelected = GetNumSelected( fodInfos->Shell.FOIDataObject );
- /* calculate the string length, count files */
- if (nFileSelected >= 1)
- {
- nLength += 3; /* first and last quotes, trailing \0 */
- for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
- {
- pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
-
- if (pidl)
- {
- /* get the total length of the selected file names */
- lpstrTemp[0] = '\0';
- GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp );
+ if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium)))
+ return;
- if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */
- {
- nLength += lstrlenW( lpstrTemp ) + 3;
- nFiles++;
- }
- COMDLG32_SHFree( pidl );
- }
- }
- }
+ cida = GlobalLock(medium.u.hGlobal);
+ nFileSelected = cida->cidl;
- /* allocate the buffer */
- if (nFiles <= 1) nLength = MAX_PATH;
- lpstrAllFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(WCHAR));
+ /* Allocate a buffer */
+ nAllFilesMaxLength = MAX_PATH + 3;
+ lpstrAllFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nAllFilesMaxLength * sizeof(WCHAR));
+ if (!lpstrAllFiles)
+ goto ret;
- /* Generate the string for the edit control */
- if(nFiles >= 1)
+ /* Loop through the selection, handle only files (not folders) */
+ for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++)
{
- lpstrCurrFile = lpstrAllFile;
- for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
- {
- pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
-
+ pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]);
if (pidl)
- {
- /* get the file name */
- lpstrTemp[0] = '\0';
- GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp );
+ {
+ if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl))
+ {
+ if (nAllFilesLength + MAX_PATH + 3 > nAllFilesMaxLength)
+ {
+ nAllFilesMaxLength *= 2;
+ lpstrTmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpstrAllFiles, nAllFilesMaxLength * sizeof(WCHAR));
+ if (!lpstrTmp)
+ goto ret;
+ lpstrAllFiles = lpstrTmp;
+ }
+ nFiles += 1;
+ lpstrAllFiles[nAllFilesLength++] = '"';
+ GetName(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, lpstrAllFiles + nAllFilesLength);
+ nThisFileLength = lstrlenW(lpstrAllFiles + nAllFilesLength);
+ nAllFilesLength += nThisFileLength;
+ lpstrAllFiles[nAllFilesLength++] = '"';
+ lpstrAllFiles[nAllFilesLength++] = ' ';
+ }
+ }
+ }
- if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */
- {
- if ( nFiles > 1)
- {
- *lpstrCurrFile++ = '\"';
- lstrcpyW( lpstrCurrFile, lpstrTemp );
- lpstrCurrFile += lstrlenW( lpstrTemp );
- *lpstrCurrFile++ = '\"';
- *lpstrCurrFile++ = ' ';
- *lpstrCurrFile = 0;
- }
- else
- {
- lstrcpyW( lpstrAllFile, lpstrTemp );
- }
- }
- COMDLG32_SHFree( pidl );
- }
- }
- SetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
-
- /* Select the file name like Windows does */
- if (filename_is_edit( fodInfos ))
- SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
+ if (nFiles != 0)
+ {
+ /* If there's only one file, use the name as-is without quotes */
+ lpstrTmp = lpstrAllFiles;
+ if (nFiles == 1)
+ {
+ lpstrTmp += 1;
+ lpstrTmp[nThisFileLength] = 0;
+ }
+ SetWindowTextW(fodInfos->DlgInfos.hwndFileName, lpstrTmp);
+ /* Select the file name like Windows does */
+ if (filename_is_edit(fodInfos))
+ SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
}
- HeapFree(GetProcessHeap(),0, lpstrAllFile );
+
+ret:
+ HeapFree(GetProcessHeap(), 0, lpstrAllFiles);
+ COMCTL32_ReleaseStgMedium(medium);
}
*/
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
UINT nFileCount = 0; /* number of files */
UINT nStrLen = 0; /* length of string in edit control */
LPWSTR lpstrEdit; /* buffer for string from edit control */
return nFileCount;
}
-#define SETDefFormatEtc(fe,cf,med) \
-{ \
- (fe).cfFormat = cf;\
- (fe).dwAspect = DVASPECT_CONTENT; \
- (fe).ptd =NULL;\
- (fe).tymed = med;\
- (fe).lindex = -1;\
-};
-
/*
* DATAOBJECT Helper functions
*/
{
STGMEDIUM medium;
- FORMATETC formatetc;
+ FORMATETC formatetc = get_def_format();
LPITEMIDLIST pidl = NULL;
TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
if (!doSelected)
return NULL;
-
- /* Set the FORMATETC structure*/
- SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), TYMED_HGLOBAL);
/* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
{
UINT retVal = 0;
STGMEDIUM medium;
- FORMATETC formatetc;
+ FORMATETC formatetc = get_def_format();
TRACE("sv=%p\n", doSelected);
if (!doSelected) return 0;
- /* Set the FORMATETC structure*/
- SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), TYMED_HGLOBAL);
-
/* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
{
*/
static BOOL BrowseSelectedFolder(HWND hwnd)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
BOOL bBrowseSelFolder = FALSE;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("\n");
if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
pidlSelection, SBSP_RELATIVE ) ) )
{
- static const WCHAR notexist[] = {'P','a','t','h',' ','d','o','e','s',
- ' ','n','o','t',' ','e','x','i','s','t',0};
- MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
+ WCHAR buf[64];
+ LoadStringW( COMDLG32_hInstance, IDS_PATHNOTEXISTING, buf, sizeof(buf)/sizeof(WCHAR) );
+ MessageBoxW( hwnd, buf, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
}
bBrowseSelFolder = TRUE;
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
-BOOL WINAPI GetOpenFileNameA(
- LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
+BOOL WINAPI GetOpenFileNameA(OPENFILENAMEA *ofn)
{
- TRACE("flags %08x\n", ofn->Flags);
+ TRACE("flags 0x%08x\n", ofn->Flags);
if (!valid_struct_size( ofn->lStructSize ))
{
if (is_win16_looks(ofn->Flags))
return GetFileName31A(ofn, OPEN_DIALOG);
else
- return GetFileDialog95A(ofn, OPEN_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoA(ofn, &info);
+ return GetFileDialog95(&info, OPEN_DIALOG);
+ }
}
/***********************************************************************
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
-BOOL WINAPI GetOpenFileNameW(
- LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
+BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
{
- TRACE("flags %08x\n", ofn->Flags);
+ TRACE("flags 0x%08x\n", ofn->Flags);
if (!valid_struct_size( ofn->lStructSize ))
{
if (is_win16_looks(ofn->Flags))
return GetFileName31W(ofn, OPEN_DIALOG);
else
- return GetFileDialog95W(ofn, OPEN_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoW(ofn, &info);
+ return GetFileDialog95(&info, OPEN_DIALOG);
+ }
}
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
-BOOL WINAPI GetSaveFileNameA(
- LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
+BOOL WINAPI GetSaveFileNameA(OPENFILENAMEA *ofn)
{
if (!valid_struct_size( ofn->lStructSize ))
{
if (is_win16_looks(ofn->Flags))
return GetFileName31A(ofn, SAVE_DIALOG);
else
- return GetFileDialog95A(ofn, SAVE_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoA(ofn, &info);
+ return GetFileDialog95(&info, SAVE_DIALOG);
+ }
}
/***********************************************************************
if (is_win16_looks(ofn->Flags))
return GetFileName31W(ofn, SAVE_DIALOG);
else
- return GetFileDialog95W(ofn, SAVE_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoW(ofn, &info);
+ return GetFileDialog95(&info, SAVE_DIALOG);
+ }
}
/***********************************************************************