*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* FIXME: The whole concept of handling unicode is badly broken.
* many hook-messages expect a pointer to a
*
* FIXME: add to recent docs
*
- * FIXME: flags not implemented: OFN_CREATEPROMPT, OFN_DONTADDTORECENT,
+ * FIXME: flags not implemented: OFN_DONTADDTORECENT,
* OFN_ENABLEINCLUDENOTIFY, OFN_ENABLESIZING,
* OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
* OFN_NOTESTFILECREATE, OFN_USEMONIKERS
#include "windef.h"
#include "winbase.h"
-#include "winreg.h"
#include "winternl.h"
#include "winnls.h"
-#include "wine/unicode.h"
#include "wingdi.h"
-#include "winuser.h"
#include "winreg.h"
+#include "winuser.h"
#include "commdlg.h"
#include "dlgs.h"
#include "cdlg.h"
#include "filedlg31.h"
-#include "wine/debug.h"
#include "cderr.h"
#include "shellapi.h"
-#include "shlguid.h"
#include "shlobj.h"
#include "filedlgbrowser.h"
#include "shlwapi.h"
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#define UNIMPLEMENTED_FLAGS \
-(OFN_CREATEPROMPT | OFN_DONTADDTORECENT |\
+(OFN_DONTADDTORECENT |\
OFN_ENABLEINCLUDENOTIFY | OFN_ENABLESIZING |\
OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
/* Combo box macros */
#define CBAddString(hwnd,str) \
- SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str);
-#define CBAddStringW(hwnd,str) \
- SendMessageW(hwnd,CB_ADDSTRING,0,(LPARAM)str);
+ SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)(str));
#define CBInsertString(hwnd,str,pos) \
- SendMessageA(hwnd,CB_INSERTSTRING,(WPARAM)pos,(LPARAM)str);
+ SendMessageW(hwnd, CB_INSERTSTRING, (WPARAM)(pos), (LPARAM)(str));
#define CBDeleteString(hwnd,pos) \
- SendMessageA(hwnd,CB_DELETESTRING,(WPARAM)pos,0);
+ SendMessageW(hwnd, CB_DELETESTRING, (WPARAM)(pos), 0);
#define CBSetItemDataPtr(hwnd,iItemId,dataPtr) \
- SendMessageA(hwnd,CB_SETITEMDATA,(WPARAM)iItemId,(LPARAM)dataPtr);
+ SendMessageW(hwnd, CB_SETITEMDATA, (WPARAM)(iItemId), (LPARAM)(dataPtr));
#define CBGetItemDataPtr(hwnd,iItemId) \
- SendMessageA(hwnd,CB_GETITEMDATA,(WPARAM)iItemId,0)
+ SendMessageW(hwnd, CB_GETITEMDATA, (WPARAM)(iItemId), 0)
#define CBGetLBText(hwnd,iItemId,str) \
- SendMessageA(hwnd,CB_GETLBTEXT,(WPARAM)iItemId,(LPARAM)str);
+ SendMessageW(hwnd, CB_GETLBTEXT, (WPARAM)(iItemId), (LPARAM)(str));
#define CBGetCurSel(hwnd) \
- SendMessageA(hwnd,CB_GETCURSEL,0,0);
+ SendMessageW(hwnd, CB_GETCURSEL, 0, 0);
#define CBSetCurSel(hwnd,pos) \
- SendMessageA(hwnd,CB_SETCURSEL,(WPARAM)pos,0);
+ SendMessageW(hwnd, CB_SETCURSEL, (WPARAM)(pos), 0);
#define CBGetCount(hwnd) \
- SendMessageA(hwnd,CB_GETCOUNT,0,0);
+ SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
#define CBShowDropDown(hwnd,show) \
- SendMessageA(hwnd,CB_SHOWDROPDOWN,(WPARAM)show,0);
+ SendMessageW(hwnd, CB_SHOWDROPDOWN, (WPARAM)(show), 0);
#define CBSetItemHeight(hwnd,index,height) \
- SendMessageA(hwnd,CB_SETITEMHEIGHT,(WPARAM)index,(LPARAM)height);
+ SendMessageW(hwnd, CB_SETITEMHEIGHT, (WPARAM)(index), (LPARAM)(height));
#define CBSetExtendedUI(hwnd,flag) \
- SendMessageA(hwnd,CB_SETEXTENDEDUI,(WPARAM)(flag),0)
+ SendMessageW(hwnd, CB_SETEXTENDEDUI, (WPARAM)(flag), 0)
-const char *FileOpenDlgInfosStr = "FileOpenDlgInfos"; /* windows property description string */
-const char *LookInInfosStr = "LookInInfos"; /* LOOKIN combo box property */
+const char FileOpenDlgInfosStr[] = "FileOpenDlgInfos"; /* windows property description string */
+static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property */
/***********************************************************************
* Prototypes
*/
/* Internal functions used by the dialog */
+static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd);
- BOOL FILEDLG95_OnOpen(HWND hwnd);
+static BOOL FILEDLG95_OnOpen(HWND hwnd);
static LRESULT FILEDLG95_InitControls(HWND hwnd);
static void FILEDLG95_Clean(HWND hwnd);
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd);
/* Functions used by the EDIT box */
-static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator);
+static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed);
/* Functions used by the filetype combo box */
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);
static void FILEDLG95_LOOKIN_Clean(HWND hwnd);
/* Miscellaneous tool functions */
-static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
+static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPWSTR lpstrFileName);
IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
-LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
+static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
/* Shell memory allocation */
static void *MemAlloc(UINT size);
static void MemFree(void *mem);
-INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
+static INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
static BOOL BrowseSelectedFolder(HWND hwnd);
/* test for missing functionality */
if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
{
- FIXME("Flags 0x%08lx not yet implemented\n",
+ FIXME("Flags 0x%08x not yet implemented\n",
fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS);
}
/* Create the dialog from a template */
- if(!(hRes = FindResourceA(COMDLG32_hInstance,MAKEINTRESOURCEA(NEWFILEOPENORD),(LPSTR)RT_DIALOG)))
+ if(!(hRes = FindResourceW(COMDLG32_hInstance,MAKEINTRESOURCEW(NEWFILEOPENORD),(LPCWSTR)RT_DIALOG)))
{
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
return FALSE;
/* old style hook messages */
if (IsHooked(fodInfos))
{
- fodInfos->HookMsg.fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
- fodInfos->HookMsg.lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
- fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageA(HELPMSGSTRINGA);
- fodInfos->HookMsg.sharevistring = RegisterWindowMessageA(SHAREVISTRINGA);
+ fodInfos->HookMsg.fileokstring = RegisterWindowMessageW(FILEOKSTRINGW);
+ fodInfos->HookMsg.lbselchstring = RegisterWindowMessageW(LBSELCHSTRINGW);
+ fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageW(HELPMSGSTRINGW);
+ fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
}
/* Some shell namespace extensions depend on COM being initialized. */
hr = OleInitialize(NULL);
- lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
- (LPDLGTEMPLATEA) template,
- fodInfos->ofnInfos->hwndOwner,
- FileOpenDlgProc95,
- (LPARAM) fodInfos);
+ if (fodInfos->unicode)
+ lRes = DialogBoxIndirectParamW(COMDLG32_hInstance,
+ template,
+ fodInfos->ofnInfos->hwndOwner,
+ FileOpenDlgProc95,
+ (LPARAM) fodInfos);
+ else
+ lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
+ (LPCDLGTEMPLATEA) template,
+ fodInfos->ofnInfos->hwndOwner,
+ FileOpenDlgProc95,
+ (LPARAM) fodInfos);
if (SUCCEEDED(hr))
OleUninitialize();
LPWSTR filter = NULL;
LPWSTR customfilter = NULL;
+ /* Initialize CommDlgExtendedError() */
+ COMDLG32_SetCommDlgExtendedError(0);
+
/* Initialize FileOpenDlgInfos structure */
ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
MemFree(lpstrSavDir);
}
- if(title)
- MemFree(title);
- if(defext)
- MemFree(defext);
- if(filter)
- MemFree(filter);
- if(customfilter)
- MemFree(customfilter);
- if(fodInfos.initdir)
- MemFree(fodInfos.initdir);
-
- if(fodInfos.filename)
- MemFree(fodInfos.filename);
+ MemFree(title);
+ MemFree(defext);
+ MemFree(filter);
+ MemFree(customfilter);
+ MemFree(fodInfos.initdir);
+ MemFree(fodInfos.filename);
TRACE("selected file: %s\n",ofn->lpstrFile);
FileOpenDlgInfos fodInfos;
LPWSTR lpstrSavDir = NULL;
+ /* Initialize CommDlgExtendedError() */
+ COMDLG32_SetCommDlgExtendedError(0);
+
/* Initialize FileOpenDlgInfos structure */
ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
if(ofn->lpstrInitialDir)
{
/* fodInfos.initdir = strdupW(ofn->lpstrInitialDir); */
- DWORD len = strlenW(ofn->lpstrInitialDir)+1;
+ DWORD len = lstrlenW(ofn->lpstrInitialDir)+1;
fodInfos.initdir = MemAlloc(len*sizeof(WCHAR));
memcpy(fodInfos.initdir,ofn->lpstrInitialDir,len*sizeof(WCHAR));
}
HINSTANCE hinst;
if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
{
- hinst = 0;
+ hinst = COMDLG32_hInstance;
if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
{
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
return NULL;
}
}
- hChildDlg = CreateDialogIndirectParamA(COMDLG32_hInstance, template, hwnd,
- IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
- (LPARAM)fodInfos->ofnInfos);
+ if (fodInfos->unicode)
+ hChildDlg = CreateDialogIndirectParamW(hinst, template, hwnd,
+ IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
+ (LPARAM)fodInfos->ofnInfos);
+ else
+ hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd,
+ IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
+ (LPARAM)fodInfos->ofnInfos);
if(hChildDlg)
{
ShowWindow(hChildDlg,SW_SHOW);
* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
*/
-void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
+LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
{
+ LRESULT hook_result = 0;
+
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
TRACE("%p 0x%04x\n",hwndParentDlg, uCode);
- if(!fodInfos) return;
+ if(!fodInfos) return 0;
if(fodInfos->DlgInfos.hwndCustomDlg)
{
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
- SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+ hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
else
{
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
- SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+ 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;
}
-static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
+static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result)
{
- UINT sizeUsed = 0, n, total;
- LPWSTR lpstrFileList = NULL;
- WCHAR lpstrCurrentDir[MAX_PATH];
+ UINT len, total;
+ WCHAR *p, *buffer;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("CDM_GETFILEPATH:\n");
return -1;
/* get path and filenames */
- COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir);
- n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
-
- TRACE("path >%s< filespec >%s< %d files\n",
- debugstr_w(lpstrCurrentDir),debugstr_w(lpstrFileList),n);
-
- if( fodInfos->unicode )
+ len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 );
+ buffer = HeapAlloc( GetProcessHeap(), 0, (len + 2 + MAX_PATH) * sizeof(WCHAR) );
+ COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer );
+ if (len)
{
- LPWSTR bufW = buffer;
- total = strlenW(lpstrCurrentDir) + 1 + sizeUsed;
-
- /* Prepend the current path */
- n = strlenW(lpstrCurrentDir) + 1;
- memcpy( bufW, lpstrCurrentDir, min(n,size) * sizeof(WCHAR));
- if(n<size)
- {
- /* 'n' includes trailing \0 */
- bufW[n-1] = '\\';
- memcpy( &bufW[n], lpstrFileList, (size-n)*sizeof(WCHAR) );
- }
- TRACE("returned -> %s\n",debugstr_wn(bufW, total));
+ p = buffer + strlenW(buffer);
+ *p++ = '\\';
+ SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, len + 1, (LPARAM)p );
}
- else
+ if (fodInfos->unicode)
{
- LPSTR bufA = buffer;
- total = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
- NULL, 0, NULL, NULL);
- total += WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
- NULL, 0, NULL, NULL);
-
- /* Prepend the current path */
- n = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
- bufA, size, NULL, NULL);
-
- if(n<size)
- {
- /* 'n' includes trailing \0 */
- bufA[n-1] = '\\';
- WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
- &bufA[n], size-n, NULL, NULL);
- }
-
- TRACE("returned -> %s\n",debugstr_an(bufA, total));
- }
- MemFree(lpstrFileList);
-
- return total;
-}
-
-static INT_PTR FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
-{
- UINT sizeUsed = 0;
- LPWSTR lpstrFileList = NULL;
- FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
-
- TRACE("CDM_GETSPEC:\n");
-
- FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
- if( fodInfos->unicode )
- {
- LPWSTR bufW = buffer;
- memcpy( bufW, lpstrFileList, sizeof(WCHAR)*sizeUsed );
+ total = strlenW( buffer) + 1;
+ if (result) lstrcpynW( result, buffer, size );
+ TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_w(result));
}
else
{
- LPSTR bufA = buffer;
- sizeUsed = WideCharToMultiByte( CP_ACP, 0, lpstrFileList, sizeUsed,
- NULL, 0, NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
- bufA, size, NULL, NULL);
+ total = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
+ if (total <= size) WideCharToMultiByte( CP_ACP, 0, buffer, -1, result, size, NULL, NULL );
+ TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_a(result));
}
- MemFree(lpstrFileList);
-
- return sizeUsed;
+ HeapFree( GetProcessHeap(), 0, buffer );
+ return total;
}
/***********************************************************************
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
(LPSTR)lParam, (int)wParam, NULL, NULL);
}
- retval = strlenW(lpstrPath);
+ retval = lstrlenW(lpstrPath);
+ break;
+
+ case CDM_GETFOLDERIDLIST:
+ retval = COMDLG32_PIDL_ILGetSize(fodInfos->ShellInfos.pidlAbsCurrent);
+ if (retval <= wParam)
+ memcpy((void*)lParam, fodInfos->ShellInfos.pidlAbsCurrent, retval);
break;
case CDM_GETSPEC:
- retval = FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
+ TRACE("CDM_GETSPEC:\n");
+ retval = SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0) + 1;
+ if (lParam)
+ {
+ if (fodInfos->unicode)
+ SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, wParam, lParam);
+ else
+ SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, wParam, lParam);
+ }
break;
case CDM_SETCONTROLTEXT:
break;
case CDM_HIDECONTROL:
- case CDM_SETDEFEXT:
- FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n");
- retval = -1;
+ /* MSDN states that it should fail for not OFN_EXPLORER case */
+ if (fodInfos->ofnInfos->Flags & OFN_EXPLORER)
+ {
+ HWND control = GetDlgItem( hwnd, wParam );
+ if (control) ShowWindow( control, SW_HIDE );
+ retval = TRUE;
+ }
+ else retval = FALSE;
break;
default:
+ if (uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
+ FIXME("message CDM_FIRST+%04x not implemented\n", uMsg - CDM_FIRST);
return FALSE;
}
SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, retval);
so it will be easily accessible through a GetPropA(...) */
SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
- fodInfos->DlgInfos.hwndCustomDlg =
- CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
-
FILEDLG95_InitControls(hwnd);
- if (fodInfos->DlgInfos.hwndCustomDlg)
- {
- RECT rc;
- UINT flags = SWP_NOACTIVATE;
-
- ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
- (fodInfos->ofnInfos->Flags & (OFN_HIDEREADONLY | OFN_SHOWHELP)) == OFN_HIDEREADONLY);
-
- /* resize the custom dialog to the parent size */
- if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
- GetClientRect(hwnd, &rc);
- else
- {
- /* our own fake template is zero sized and doesn't have
- * children, so there is no need to resize it.
- * Picasa depends on it.
- */
- flags |= SWP_NOSIZE;
- SetRectEmpty(&rc);
- }
- SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
- 0, 0, rc.right, rc.bottom, flags);
- }
+ fodInfos->DlgInfos.hwndCustomDlg =
+ CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
+ FILEDLG95_ResizeControls(hwnd, wParam, lParam);
FILEDLG95_FillControls(hwnd, wParam, lParam);
SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
int win2000plus = 0;
int win98plus = 0;
int handledPath = FALSE;
- OSVERSIONINFOA osVi;
+ OSVERSIONINFOW osVi;
static const WCHAR szwSlash[] = { '\\', 0 };
static const WCHAR szwStar[] = { '*',0 };
- TBBUTTON tbb[] =
+ static const TBBUTTON tbb[] =
{
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
{VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
TRACE("%p\n", fodInfos);
/* Get windows version emulating */
- osVi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
- GetVersionExA(&osVi);
+ osVi.dwOSVersionInfoSize = sizeof(osVi);
+ GetVersionExW(&osVi);
if (osVi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
win98plus = ((osVi.dwMajorVersion > 4) || ((osVi.dwMajorVersion == 4) && (osVi.dwMinorVersion > 0)));
} else if (osVi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
rectTB.left = rectlook.right;
rectTB.top = rectlook.top-1;
- fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL,
- WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
- rectTB.left, rectTB.top,
- rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
- hwnd, (HMENU)IDC_TOOLBAR, COMDLG32_hInstance, NULL);
+ if (fodInfos->unicode)
+ fodInfos->DlgInfos.hwndTB = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
+ WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
+ rectTB.left, rectTB.top,
+ rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
+ hwnd, (HMENU)IDC_TOOLBAR, COMDLG32_hInstance, NULL);
+ else
+ fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL,
+ WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
+ rectTB.left, rectTB.top,
+ rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
+ hwnd, (HMENU)IDC_TOOLBAR, COMDLG32_hInstance, NULL);
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
+ SendMessageW(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
/* FIXME: use TB_LOADIMAGES when implemented */
-/* SendMessageA(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, (WPARAM) IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 12, (LPARAM) &tba[0]);
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 1, (LPARAM) &tba[1]);
+/* SendMessageW(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
+ SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, 12, (LPARAM) &tba[0]);
+ SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, 1, (LPARAM) &tba[1]);
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 9,(LPARAM) &tbb);
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
+ SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSW, 9, (LPARAM) &tbb);
+ SendMessageW(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
/* Set the window text with the text specified in the OPENFILENAME structure */
if(fodInfos->title)
if (result) {
/* nameBit is always shorter than the original filename */
- strcpyW(fodInfos->filename,nameBit);
+ lstrcpyW(fodInfos->filename,nameBit);
*nameBit = 0x00;
if (fodInfos->initdir == NULL)
MemFree(fodInfos->initdir);
- fodInfos->initdir = MemAlloc((strlenW(tmpBuf) + 1)*sizeof(WCHAR));
- strcpyW(fodInfos->initdir, tmpBuf);
+ fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
+ lstrcpyW(fodInfos->initdir, tmpBuf);
handledPath = TRUE;
TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
WCHAR *nameBit;
DWORD result;
- strcpyW(tmpBuf, fodInfos->initdir);
+ 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[strlenW(tmpBuf)-1] != '\\') {
- strcatW(tmpBuf, szwSlash);
+ if (tmpBuf[lstrlenW(tmpBuf)-1] != '\\') {
+ lstrcatW(tmpBuf, szwSlash);
}
- strcatW(tmpBuf, szwStar);
+ lstrcatW(tmpBuf, szwStar);
}
result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
if (result) {
*nameBit = 0x00;
- if (fodInfos->initdir)
- MemFree(fodInfos->initdir);
- fodInfos->initdir = MemAlloc((strlenW(tmpBuf2) + 1)*sizeof(WCHAR));
- strcpyW(fodInfos->initdir, tmpBuf2);
+ 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));
}
int len;
/* nameBit is always shorter than the original filename */
- strcpyW(fodInfos->filename, nameBit);
+ lstrcpyW(fodInfos->filename, nameBit);
*nameBit = 0x00;
- len = strlenW(tmpBuf);
- if(fodInfos->initdir)
- MemFree(fodInfos->initdir);
+ len = lstrlenW(tmpBuf);
+ MemFree(fodInfos->initdir);
fodInfos->initdir = MemAlloc((len+1)*sizeof(WCHAR));
- strcpyW(fodInfos->initdir, tmpBuf);
+ lstrcpyW(fodInfos->initdir, tmpBuf);
handledPath = TRUE;
TRACE("Value in Filename includes path, overriding initdir: %s, %s\n",
/* Skip the title */
if(! *lpstrPos) break; /* end */
- lpstrPos += strlenW(lpstrPos) + 1;
+ lpstrPos += lstrlenW(lpstrPos) + 1;
/* See if any files exist in the current dir with this extension */
if(! *lpstrPos) break; /* end */
if (hFind == INVALID_HANDLE_VALUE) {
/* None found - continue search */
- lpstrPos += strlenW(lpstrPos) + 1;
+ lpstrPos += lstrlenW(lpstrPos) + 1;
} else {
searchMore = FALSE;
- if(fodInfos->initdir)
- MemFree(fodInfos->initdir);
+ MemFree(fodInfos->initdir);
fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
if (handledPath == FALSE && (win2000plus || win98plus)) {
fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
- if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir)))
+ if(!COMDLG32_SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir))
{
- if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, fodInfos->initdir)))
+ if(!COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, fodInfos->initdir))
{
/* last fallback */
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
/* Must the open as read only check box be checked ?*/
if(fodInfos->ofnInfos->Flags & OFN_READONLY)
{
- SendDlgItemMessageA(hwnd,IDC_OPENREADONLY,BM_SETCHECK,(WPARAM)TRUE,0);
+ SendDlgItemMessageW(hwnd,IDC_OPENREADONLY,BM_SETCHECK,TRUE,0);
}
/* Must the open as read only check box be hidden? */
EnableWindow(GetDlgItem(hwnd, pshHelp), FALSE);
}
- /* Resize the height, if open as read only checkbox ad help button
- are hidden and we are not using a custom template nor a customDialog
- */
- if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
- (!(fodInfos->ofnInfos->Flags &
- (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))) &&
- (!fodInfos->DlgInfos.hwndCustomDlg ))
- {
- RECT rectDlg, rectHelp, rectCancel;
- GetWindowRect(hwnd, &rectDlg);
- GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
- GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
- /* subtract the height of the help button plus the space between
- the help button and the cancel button to the height of the dialog */
- SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
- (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
- SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
- }
/* change Open to Save */
if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
{
return 0;
}
+/***********************************************************************
+ * FILEDLG95_ResizeControls
+ *
+ * WM_INITDIALOG message handler (after hook notification)
+ */
+static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+ FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
+
+ if (fodInfos->DlgInfos.hwndCustomDlg)
+ {
+ RECT rc;
+ UINT flags = SWP_NOACTIVATE;
+
+ ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
+ (fodInfos->ofnInfos->Flags & (OFN_HIDEREADONLY | OFN_SHOWHELP)) == OFN_HIDEREADONLY);
+
+ /* resize the custom dialog to the parent size */
+ if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
+ GetClientRect(hwnd, &rc);
+ else
+ {
+ /* our own fake template is zero sized and doesn't have children, so
+ * there is no need to resize it. Picasa depends on it.
+ */
+ flags |= SWP_NOSIZE;
+ SetRectEmpty(&rc);
+ }
+ SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
+ 0, 0, rc.right, rc.bottom, flags);
+ }
+ else
+ {
+ /* Resize the height, if open as read only checkbox ad help button are
+ * hidden and we are not using a custom template nor a customDialog
+ */
+ if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
+ (!(fodInfos->ofnInfos->Flags &
+ (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))))
+ {
+ RECT rectDlg, rectHelp, rectCancel;
+ GetWindowRect(hwnd, &rectDlg);
+ GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
+ GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
+ /* subtract the height of the help button plus the space between the help
+ * button and the cancel button to the height of the dialog
+ */
+ SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
+ (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
+ SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
+ }
+ }
+ return TRUE;
+}
+
/***********************************************************************
* FILEDLG95_FillControls
*
/* ask the hook if we can close */
if(IsHooked(fodInfos))
{
+ LRESULT retval;
+
TRACE("---\n");
/* First send CDN_FILEOK as MSDN doc says */
- SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
+ retval = SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
if (GetWindowLongPtrW(fodInfos->DlgInfos.hwndCustomDlg, DWLP_MSGRESULT))
{
TRACE("canceled\n");
- return FALSE;
+ return (retval == 0);
}
/* fodInfos->ofnInfos points to an ASCII or UNICODE structure as appropriate */
- SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,
- fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
+ retval = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,
+ fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
if (GetWindowLongPtrW(fodInfos->DlgInfos.hwndCustomDlg, DWLP_MSGRESULT))
{
TRACE("canceled\n");
- return FALSE;
+ return (retval == 0);
}
}
return TRUE;
LoadStringW(COMDLG32_hInstance, IDS_FILENOTFOUND, lpstrNotFound, 100);
LoadStringW(COMDLG32_hInstance, IDS_VERIFYFILE, lpstrMsg, 100);
- strcpyW(tmp, lpstrTemp);
- strcatW(tmp, nl);
- strcatW(tmp, lpstrNotFound);
- strcatW(tmp, nl);
- strcatW(tmp, lpstrMsg);
+ lstrcpyW(tmp, lpstrTemp);
+ lstrcatW(tmp, nl);
+ lstrcatW(tmp, lpstrNotFound);
+ lstrcatW(tmp, nl);
+ lstrcatW(tmp, lpstrMsg);
MessageBoxW(hwnd, tmp, fodInfos->title, MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
/* move to the next file in the list of files */
- lpstrTemp += strlenW(lpstrTemp) + 1;
+ lpstrTemp += lstrlenW(lpstrTemp) + 1;
COMDLG32_SHFree(pidl);
}
}
- nSizePath = strlenW(lpstrPathSpec) + 1;
+ nSizePath = lstrlenW(lpstrPathSpec) + 1;
if ( !(fodInfos->ofnInfos->Flags & OFN_EXPLORER) )
{
/* For "oldstyle" dialog the components have to
if(fodInfos->unicode)
{
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
- strcpyW( ofn->lpstrFile, lpstrPathSpec);
+ lstrcpyW( ofn->lpstrFile, lpstrPathSpec);
memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) );
}
else
TRACE("hwnd=%p\n", hwnd);
/* get the files from the edit control */
- nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, '\0');
+ nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
/* try if the user selected a folder in the shellview */
if(nFileCount == 0)
TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile));
- /* if the user specifyed a fully qualified path use it */
+ /* if the user specified a fully qualified path use it */
if(PathIsRelativeW(lpstrFileList))
{
- strcatW(lpstrPathAndFile, lpstrFileList);
+ lstrcatW(lpstrPathAndFile, lpstrFileList);
}
else
{
/* does the path have a drive letter? */
if (PathGetDriveNumberW(lpstrFileList) == -1)
- strcpyW(lpstrPathAndFile+2, lpstrFileList);
+ lstrcpyW(lpstrPathAndFile+2, lpstrFileList);
else
- strcpyW(lpstrPathAndFile, lpstrFileList);
+ lstrcpyW(lpstrPathAndFile, lpstrFileList);
}
/* resolve "." and ".." */
PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
- strcpyW(lpstrPathAndFile, lpstrTemp);
+ lstrcpyW(lpstrPathAndFile, lpstrTemp);
TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
MemFree(lpstrFileList);
DWORD dwEaten, dwAttributes;
LPWSTR p;
- strcpyW(lpwstrTemp, lpszTemp);
+ lstrcpyW(lpwstrTemp, lpszTemp);
p = PathFindNextComponentW(lpwstrTemp);
if (!p) break; /* end of path */
*p = 0;
- lpszTemp = lpszTemp + strlenW(lpwstrTemp);
+ lpszTemp = lpszTemp + lstrlenW(lpwstrTemp);
/* There are no wildcards when OFN_NOVALIDATE is set */
if(*lpszTemp==0 && !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
if(SUCCEEDED(IShellFolder_ParseDisplayName(lpsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
{
/* the path component is valid, we have a pidl of the next path component */
- TRACE("parse OK attr=0x%08lx pidl=%p\n", dwAttributes, pidl);
+ TRACE("parse OK attr=0x%08x pidl=%p\n", dwAttributes, pidl);
if(dwAttributes & SFGAO_FOLDER)
{
if(FAILED(IShellFolder_BindToObject(lpsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild)))
}
else if (!(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
{
- if(*lpszTemp) /* points to trailing null for last path element */
+ if(*lpszTemp || /* points to trailing null for last path element */
+ (lpwstrTemp[strlenW(lpwstrTemp)-1] == '\\')) /* or if last element ends in '\' */
{
if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
{
DWORD len;
/* replace the current filter */
- if(fodInfos->ShellInfos.lpstrCurrentFilter)
- MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
- len = strlenW(lpszTemp)+1;
+ MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
+ len = lstrlenW(lpszTemp)+1;
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR));
- strcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
+ lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
/* set the filter cb to the extension when possible */
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
IPersistFolder2_Release(ppf2);
if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
{
- IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
+ if (SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE)))
+ {
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
+ }
}
else if( nOpenAction == ONOPEN_SEARCH )
{
- IShellView_Refresh(fodInfos->Shell.FOIShellView);
+ if (fodInfos->Shell.FOIShellView)
+ IShellView_Refresh(fodInfos->Shell.FOIShellView);
}
COMDLG32_SHFree(pidlCurrent);
+ SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
}
}
ret = FALSE;
WCHAR *ext = NULL;
/* update READONLY check box flag */
- if ((SendMessageA(GetDlgItem(hwnd,IDC_OPENREADONLY),BM_GETCHECK,0,0) & 0x03) == BST_CHECKED)
+ if ((SendMessageW(GetDlgItem(hwnd,IDC_OPENREADONLY),BM_GETCHECK,0,0) & 0x03) == BST_CHECKED)
fodInfos->ofnInfos->Flags |= OFN_READONLY;
else
fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
WCHAR *filterExt = NULL;
LPWSTR lpstrFilter = NULL;
static const WCHAR szwDot[] = {'.',0};
- int PathLength = strlenW(lpstrPathAndFile);
+ int PathLength = lstrlenW(lpstrPathAndFile);
/* Attach the dot*/
- strcatW(lpstrPathAndFile, szwDot);
+ lstrcatW(lpstrPathAndFile, szwDot);
/*Get the file extension from file type filter*/
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
filterExt = PathFindExtensionW(lpstrFilter);
if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/
- strcatW(lpstrPathAndFile, filterExt + 1);
+ lstrcatW(lpstrPathAndFile, filterExt + 1);
else if ( fodInfos->defext ) /* attach the default file extension*/
- strcatW(lpstrPathAndFile, fodInfos->defext);
+ lstrcatW(lpstrPathAndFile, fodInfos->defext);
/* In Open dialog: if file does not exist try without extension */
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
}
}
+ /* In Open dialog: check if it should be created if it doesn't exist */
+ if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
+ && fodInfos->ofnInfos->Flags & OFN_CREATEPROMPT
+ && !PathFileExistsW(lpstrPathAndFile))
+ {
+ WCHAR lpstrCreate[100];
+ int answer;
+
+ LoadStringW(COMDLG32_hInstance, IDS_CREATEFILE, lpstrCreate, 100);
+ answer = MessageBoxW(hwnd, lpstrCreate, fodInfos->title,
+ MB_YESNO | MB_ICONEXCLAMATION);
+ if (answer == IDNO)
+ {
+ ret = FALSE;
+ goto ret;
+ }
+ }
+
/* Check that the size of the file does not exceed buffer size.
(Allow for extra \0 if OFN_MULTISELECT is set.) */
- if(strlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
+ if(lstrlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
{
- LPWSTR lpszTemp;
/* fill destination buffer */
if (fodInfos->ofnInfos->lpstrFile)
}
}
- /* set filename offset */
- lpszTemp = PathFindFileNameW(lpstrPathAndFile);
- fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+ if(fodInfos->unicode)
+ {
+ LPWSTR lpszTemp;
+
+ /* set filename offset */
+ lpszTemp = PathFindFileNameW(lpstrPathAndFile);
+ fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+
+ /* set extension offset */
+ lpszTemp = PathFindExtensionW(lpstrPathAndFile);
+ fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+ }
+ else
+ {
+ LPSTR lpszTemp;
+ LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
- /* set extension offset */
- lpszTemp = PathFindExtensionW(lpstrPathAndFile);
- fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+ /* set filename offset */
+ lpszTemp = PathFindFileNameA(ofn->lpstrFile);
+ fodInfos->ofnInfos->nFileOffset = (lpszTemp - ofn->lpstrFile);
+
+ /* set extension offset */
+ lpszTemp = PathFindExtensionA(ofn->lpstrFile);
+ fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - ofn->lpstrFile) + 1 : 0;
+ }
/* set the lpstrFileTitle */
if(fodInfos->ofnInfos->lpstrFileTitle)
{
WORD size;
- size = strlenW(lpstrPathAndFile) + 1;
+ size = lstrlenW(lpstrPathAndFile) + 1;
if (fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)
size += 1;
/* return needed size in first two bytes of lpstrFile */
COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
/* clean Shell interfaces */
- IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
- IShellView_Release(fodInfos->Shell.FOIShellView);
+ if (fodInfos->Shell.FOIShellView)
+ {
+ IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
+ IShellView_Release(fodInfos->Shell.FOIShellView);
+ }
IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
if (fodInfos->Shell.FOIDataObject)
LPCWSTR lpstrPos = fodInfos->customfilter;
/* Get the title */
- lpstrPos += strlenW(fodInfos->customfilter) + 1;
+ lpstrPos += lstrlenW(fodInfos->customfilter) + 1;
/* Copy the extensions */
if (! *lpstrPos) return E_FAIL; /* malformed filter */
- if (!(lpstrExt = MemAlloc((strlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
- strcpyW(lpstrExt,lpstrPos);
+ if (!(lpstrExt = MemAlloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
+ lstrcpyW(lpstrExt,lpstrPos);
/* Add the item at the end of the combo */
- CBAddStringW(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->customfilter);
+ CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->customfilter);
CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters, lpstrExt);
nFilters++;
}
/* Get the title */
if(! *lpstrPos) break; /* end */
lpstrDisplay = lpstrPos;
- lpstrPos += strlenW(lpstrPos) + 1;
+ lpstrPos += lstrlenW(lpstrPos) + 1;
+
+ CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
+
+ nFilters++;
/* Copy the extensions */
- if (! *lpstrPos) return E_FAIL; /* malformed filter */
- if (!(lpstrExt = MemAlloc((strlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
- strcpyW(lpstrExt,lpstrPos);
- lpstrPos += strlenW(lpstrPos) + 1;
+ if (!(lpstrExt = MemAlloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
+ lstrcpyW(lpstrExt,lpstrPos);
+ lpstrPos += lstrlenW(lpstrPos) + 1;
/* Add the item at the end of the combo */
- CBAddStringW(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
- CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters, lpstrExt);
- nFilters++;
+ CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters-1, lpstrExt);
+
+ /* malformed filters are added anyway... */
+ if (!*lpstrExt) break;
}
}
{
DWORD len;
CharLowerW(lpstrFilter); /* lowercase */
- len = strlenW(lpstrFilter)+1;
+ len = lstrlenW(lpstrFilter)+1;
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
- strcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
+ lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
}
} else
fodInfos->ofnInfos->nFilterIndex = 0;
(fodInfos->customfilter == NULL ? 1 : 0);
/* Set the current filter with the current selection */
- if(fodInfos->ShellInfos.lpstrCurrentFilter)
- MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
+ MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
iItem);
{
DWORD len;
CharLowerW(lpstrFilter); /* lowercase */
- len = strlenW(lpstrFilter)+1;
+ len = lstrlenW(lpstrFilter)+1;
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
- strcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
+ lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
}
/* Refresh the actual view to display the included items*/
- IShellView_Refresh(fodInfos->Shell.FOIShellView);
+ if (fodInfos->Shell.FOIShellView)
+ IShellView_Refresh(fodInfos->Shell.FOIShellView);
}
}
return FALSE;
}
}
/* Current filter */
- if(fodInfos->ShellInfos.lpstrCurrentFilter)
- MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
+ MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
}
COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
RECT rectText;
RECT rectIcon;
- SHFILEINFOA sfi;
+ SHFILEINFOW sfi;
HIMAGELIST ilItemImage;
int iIndentation;
- TEXTMETRICA tm;
+ TEXTMETRICW tm;
LPSFOLDER tmpFolder;
if(pDIStruct->itemID == liInfos->uSelectedItem)
{
- ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
+ ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
0,
&sfi,
- sizeof (SHFILEINFOA),
+ sizeof (sfi),
SHGFI_PIDL | SHGFI_SMALLICON |
SHGFI_OPENICON | SHGFI_SYSICONINDEX |
SHGFI_DISPLAYNAME );
}
else
{
- ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
+ ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
0,
&sfi,
- sizeof (SHFILEINFOA),
+ sizeof (sfi),
SHGFI_PIDL | SHGFI_SMALLICON |
SHGFI_SYSICONINDEX |
SHGFI_DISPLAYNAME);
if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
{
iIndentation = 0;
- ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
+ ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
0,
&sfi,
- sizeof (SHFILEINFOA),
+ sizeof (sfi),
SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
| SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME );
rectIcon.bottom = pDIStruct->rcItem.bottom;
/* Initialise the text display area */
- GetTextMetricsA(pDIStruct->hDC, &tm);
+ GetTextMetricsW(pDIStruct->hDC, &tm);
rectText.left = rectIcon.right;
rectText.top =
(pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
/* Draw the associated text */
if(sfi.szDisplayName)
- TextOutA(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,strlen(sfi.szDisplayName));
+ TextOutW(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,lstrlenW(sfi.szDisplayName));
return NOERROR;
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
{
LPITEMIDLIST pidlNext;
- SHFILEINFOA sfi;
+ SHFILEINFOW sfi;
SFOLDER *tmpFolder;
LookInInfos *liInfos;
liInfos->iMaxIndentation = tmpFolder->m_iIndent;
sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
- SHGetFileInfoA((LPSTR)pidl,
+ SHGetFileInfoW((LPCWSTR)pidl,
0,
&sfi,
sizeof(sfi),
SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
| SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
- TRACE("-- Add %s attr=%08lx\n", sfi.szDisplayName, sfi.dwAttributes);
+ TRACE("-- Add %s attr=%08x\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
{
int iItemID;
- TRACE("-- Add %s at %u\n", sfi.szDisplayName, tmpFolder->m_iIndent);
+ TRACE("-- Add %s at %u\n", debugstr_w(sfi.szDisplayName), tmpFolder->m_iIndent);
/* Add the item at the end of the list */
if(iInsertId < 0)
int i = 0;
int iCount = CBGetCount(hwnd);
- TRACE("0x%08x 0x%x\n",searchArg, iSearchMethod);
+ TRACE("0x%08lx 0x%x\n",searchArg, iSearchMethod);
if (iCount != CB_ERR)
{
FileOpenDlgInfos *fodInfos;
LPITEMIDLIST pidl;
UINT nFiles = 0, nFileToOpen, nFileSelected, nLength = 0;
- char lpstrTemp[MAX_PATH];
- LPSTR lpstrAllFile = NULL, lpstrCurrFile = NULL;
+ WCHAR lpstrTemp[MAX_PATH];
+ LPWSTR lpstrAllFile, lpstrCurrFile;
TRACE("\n");
fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */
{
- nLength += strlen( lpstrTemp ) + 3;
+ nLength += lstrlenW( lpstrTemp ) + 3;
nFiles++;
}
COMDLG32_SHFree( pidl );
/* allocate the buffer */
if (nFiles <= 1) nLength = MAX_PATH;
- lpstrAllFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength);
- lpstrAllFile[0] = '\0';
+ lpstrAllFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(WCHAR));
/* Generate the string for the edit control */
if(nFiles >= 1)
if ( nFiles > 1)
{
*lpstrCurrFile++ = '\"';
- strcpy( lpstrCurrFile, lpstrTemp );
- lpstrCurrFile += strlen( lpstrTemp );
- strcpy( lpstrCurrFile, "\" " );
- lpstrCurrFile += 2;
+ lstrcpyW( lpstrCurrFile, lpstrTemp );
+ lpstrCurrFile += lstrlenW( lpstrTemp );
+ *lpstrCurrFile++ = '\"';
+ *lpstrCurrFile++ = ' ';
+ *lpstrCurrFile = 0;
}
else
{
- strcpy( lpstrAllFile, lpstrTemp );
+ lstrcpyW( lpstrAllFile, lpstrTemp );
}
}
COMDLG32_SHFree( (LPVOID) pidl );
}
}
- SetWindowTextA( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
+ SetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
/* Select the file name like Windows does */
- SendMessageA(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
+ SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, (LPARAM)-1);
}
HeapFree(GetProcessHeap(),0, lpstrAllFile );
}
/* copied from shell32 to avoid linking to it
- * FIXME: why? shell32 is already linked
+ * Although shell32 is already linked the behaviour of exported StrRetToStrN
+ * is dependent on whether emulated OS is unicode or not.
*/
-static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
+static HRESULT COMDLG32_StrRetToStrNW (LPWSTR dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
{
switch (src->uType)
{
case STRRET_WSTR:
- WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
+ lstrcpynW(dest, src->u.pOleStr, len);
COMDLG32_SHFree(src->u.pOleStr);
break;
case STRRET_CSTR:
- lstrcpynA((LPSTR)dest, src->u.cStr, len);
+ if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
+ dest[len-1] = 0;
break;
case STRRET_OFFSET:
- lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
+ if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
+ dest[len-1] = 0;
break;
default:
- FIXME("unknown type!\n");
- if (len)
- {
- *(LPSTR)dest = '\0';
- }
- return(E_FAIL);
+ FIXME("unknown type %x!\n", src->uType);
+ if (len) *dest = '\0';
+ return E_FAIL;
}
return S_OK;
}
* The delimiter is specified by the parameter 'separator',
* usually either a space or a nul
*/
-static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator)
+static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
UINT nStrCharCount = 0; /* index in src buffer */
while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))
{
(*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
- (*sizeUsed)++;
nStrCharCount++;
}
- (*lpstrFileList)[nFileIndex++] = separator;
- (*sizeUsed)++;
+ (*lpstrFileList)[nFileIndex++] = 0;
nFileCount++;
}
nStrCharCount++;
}
/* single, unquoted string */
- if ((nStrLen > 0) && (*sizeUsed == 0) )
+ if ((nStrLen > 0) && (nFileIndex == 0) )
{
- strcpyW(*lpstrFileList, lpstrEdit);
- nFileIndex = strlenW(lpstrEdit) + 1;
- (*sizeUsed) = nFileIndex;
+ lstrcpyW(*lpstrFileList, lpstrEdit);
+ nFileIndex = lstrlenW(lpstrEdit) + 1;
nFileCount = 1;
}
- /* trailing \0 */
- (*lpstrFileList)[nFileIndex] = '\0';
- (*sizeUsed)++;
+ /* trailing \0 */
+ (*lpstrFileList)[nFileIndex++] = '\0';
+ *sizeUsed = nFileIndex;
MemFree(lpstrEdit);
return nFileCount;
}
* E_FAIL otherwise
*/
-static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)
+static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPWSTR lpstrFileName)
{
STRRET str;
HRESULT hRes;
/* Get the display name of the pidl relative to the folder */
if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, pidl, dwFlags, &str)))
{
- return COMDLG32_StrRetToStrNA(lpstrFileName, MAX_PATH, &str, pidl);
+ return COMDLG32_StrRetToStrNW(lpstrFileName, MAX_PATH, &str, pidl);
}
return E_FAIL;
}
* returns the pidl of the file name relative to folder
* NULL if an error occurred
*/
-LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPWSTR lpcstrFileName)
+static LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPWSTR lpcstrFileName)
{
LPITEMIDLIST pidl = NULL;
ULONG ulEaten;
ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
- TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);
+ TRACE("-- 0x%08x 0x%08x\n", uAttr, ret);
/* see documentation shell 4.1*/
return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
}
*
* called from the common 16/32 code to call the appropriate hook
*/
-static BOOL CALLBACK FD32_CallWindowProc(PFD31_DATA lfs, UINT wMsg, WPARAM wParam,
+static BOOL CALLBACK FD32_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
BOOL ret;
if (priv->ofnA)
{
- TRACE("Call hookA %p (%p, %04x, %08x, %08lx)\n",
+ TRACE("Call hookA %p (%p, %04x, %08lx, %08lx)\n",
priv->ofnA->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
ret = priv->ofnA->lpfnHook(lfs->hwnd, wMsg, wParam, lParam);
- TRACE("ret hookA %p (%p, %04x, %08x, %08lx)\n",
+ TRACE("ret hookA %p (%p, %04x, %08lx, %08lx)\n",
priv->ofnA->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
return ret;
}
- TRACE("Call hookW %p (%p, %04x, %08x, %08lx)\n",
+ TRACE("Call hookW %p (%p, %04x, %08lx, %08lx)\n",
lfs->ofnW->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
ret = lfs->ofnW->lpfnHook(lfs->hwnd, wMsg, wParam, lParam);
- TRACE("Ret hookW %p (%p, %04x, %08x, %08lx)\n",
+ TRACE("Ret hookW %p (%p, %04x, %08lx, %08lx)\n",
lfs->ofnW->lpfnHook, lfs->hwnd, wMsg, wParam, lParam);
return ret;
}
* FD32_UpdateResult [internal]
* update the real client structures if any
*/
-static void CALLBACK FD32_UpdateResult(PFD31_DATA lfs)
+static void CALLBACK FD32_UpdateResult(const FD31_DATA *lfs)
{
PFD32_PRIVATE priv = (PFD32_PRIVATE) lfs->private1632;
LPOPENFILENAMEW ofnW = lfs->ofnW;
if (priv->ofnA)
{
+ LPSTR lpszTemp;
if (ofnW->nMaxFile &&
!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
priv->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
priv->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
- priv->ofnA->nFileOffset = ofnW->nFileOffset;
- priv->ofnA->nFileExtension = ofnW->nFileExtension;
+
+ /* offsets are not guaranteed to be the same in WCHAR to MULTIBYTE conversion */
+ /* set filename offset */
+ lpszTemp = PathFindFileNameA(priv->ofnA->lpstrFile);
+ priv->ofnA->nFileOffset = (lpszTemp - priv->ofnA->lpstrFile);
+
+ /* set extension offset */
+ lpszTemp = PathFindExtensionA(priv->ofnA->lpstrFile);
+ priv->ofnA->nFileExtension = (*lpszTemp) ? (lpszTemp - priv->ofnA->lpstrFile) + 1 : 0;
}
}
* FD32_UpdateFileTitle [internal]
* update the real client structures if any
*/
-static void CALLBACK FD32_UpdateFileTitle(PFD31_DATA lfs)
+static void CALLBACK FD32_UpdateFileTitle(const FD31_DATA *lfs)
{
PFD32_PRIVATE priv = (PFD32_PRIVATE) lfs->private1632;
LPOPENFILENAMEW ofnW = lfs->ofnW;
* FD32_SendLbGetCurSel [internal]
* retrieve selected listbox item
*/
-static LRESULT CALLBACK FD32_SendLbGetCurSel(PFD31_DATA lfs)
+static LRESULT CALLBACK FD32_SendLbGetCurSel(const FD31_DATA *lfs)
{
return SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
}
* FD32_Destroy [internal]
* called from the common 16/32 code to cleanup 32 bit data
*/
-static void CALLBACK FD32_Destroy(PFD31_DATA lfs)
+static void CALLBACK FD32_Destroy(const FD31_DATA *lfs)
{
PFD32_PRIVATE priv = (PFD32_PRIVATE) lfs->private1632;
{
PFD31_DATA lfs = (PFD31_DATA)GetPropA(hWnd,FD31_OFN_PROP);
- TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
+ TRACE("msg=%x wparam=%lx lParam=%lx\n", wMsg, wParam, lParam);
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
{
INT_PTR lRet;
*
* Creates a win31 style dialog box for the user to select a file to open/save.
*/
-static BOOL GetFileName31A(LPOPENFILENAMEA lpofn, /* addess of structure with data*/
+static BOOL GetFileName31A(LPOPENFILENAMEA lpofn, /* address of structure with data*/
UINT dlgType /* type dialogue : open/save */
)
{
if (!lpofn || !FD31_Init()) return FALSE;
- TRACE("ofn flags %08lx\n", lpofn->Flags);
+ TRACE("ofn flags %08x\n", lpofn->Flags);
FD32_SetupCallbacks(&callbacks);
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, &callbacks, (DWORD) FALSE);
if (lfs)
{
- hInst = (HINSTANCE)GetWindowLongPtrA( lpofn->hwndOwner, GWLP_HINSTANCE );
+ hInst = (HINSTANCE)GetWindowLongPtrW( lpofn->hwndOwner, GWLP_HINSTANCE );
bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner,
FD32_FileOpenDlgProc, (LPARAM)lfs);
FD31_DestroyPrivate(lfs);
*
* Creates a win31 style dialog box for the user to select a file to open/save
*/
-static BOOL GetFileName31W(LPOPENFILENAMEW lpofn, /* addess of structure with data*/
+static BOOL GetFileName31W(LPOPENFILENAMEW lpofn, /* address of structure with data*/
UINT dlgType /* type dialogue : open/save */
)
{
{
BOOL win16look = FALSE;
- TRACE("flags %08lx\n", ofn->Flags);
+ TRACE("flags %08x\n", ofn->Flags);
/* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
if (ofn->Flags & OFN_FILEMUSTEXIST)
{
BOOL win16look = FALSE;
- TRACE("flags %08lx\n", ofn->Flags);
+ TRACE("flags %08x\n", ofn->Flags);
/* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
if (ofn->Flags & OFN_FILEMUSTEXIST)
else
return GetFileDialog95W(ofn, SAVE_DIALOG);
}
+
+/***********************************************************************
+ * GetFileTitleA (COMDLG32.@)
+ *
+ * See GetFileTitleW.
+ */
+short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
+{
+ int ret;
+ UNICODE_STRING strWFile;
+ LPWSTR lpWTitle;
+
+ RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
+ lpWTitle = RtlAllocateHeap( GetProcessHeap(), 0, cbBuf*sizeof(WCHAR));
+ ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf);
+ if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL );
+ RtlFreeUnicodeString( &strWFile );
+ RtlFreeHeap( GetProcessHeap(), 0, lpWTitle );
+ return ret;
+}
+
+
+/***********************************************************************
+ * GetFileTitleW (COMDLG32.@)
+ *
+ * Get the name of a file.
+ *
+ * PARAMS
+ * lpFile [I] name and location of file
+ * lpTitle [O] returned file name
+ * cbBuf [I] buffer size of lpTitle
+ *
+ * RETURNS
+ * Success: zero
+ * Failure: negative number.
+ */
+short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
+{
+ int i, len;
+ static const WCHAR brkpoint[] = {'*','[',']',0};
+ TRACE("(%p %p %d);\n", lpFile, lpTitle, cbBuf);
+
+ if(lpFile == NULL || lpTitle == NULL)
+ return -1;
+
+ len = lstrlenW(lpFile);
+
+ if (len == 0)
+ return -1;
+
+ if(strpbrkW(lpFile, brkpoint))
+ return -1;
+
+ len--;
+
+ if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
+ return -1;
+
+ for(i = len; i >= 0; i--)
+ {
+ if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
+ {
+ i++;
+ break;
+ }
+ }
+
+ if(i == -1)
+ i++;
+
+ TRACE("---> %s\n", debugstr_w(&lpFile[i]));
+
+ len = lstrlenW(lpFile+i)+1;
+ if(cbBuf < len)
+ return len;
+
+ lstrcpyW(lpTitle, &lpFile[i]);
+ return 0;
+}