1999-02-28 21:05:11 +01:00
|
|
|
/*
|
2003-10-16 02:16:40 +02:00
|
|
|
* COMMDLG - File Open Dialogs Win95 look and feel
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
2003-10-16 02:16:40 +02:00
|
|
|
* Copyright 1999 Francois Boisvert
|
|
|
|
* Copyright 1999, 2000 Juergen Schmied
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-10-16 02:16:40 +02:00
|
|
|
*
|
|
|
|
* FIXME: The whole concept of handling unicode is badly broken.
|
|
|
|
* many hook-messages expect a pointer to a
|
|
|
|
* OPENFILENAMEA or W structure. With the current architecture
|
|
|
|
* we would have to convert the beast at every call to a hook.
|
|
|
|
* we have to find a better solution but it would likely cause
|
|
|
|
* a complete rewrite after which we should handle the
|
|
|
|
* OPENFILENAME structure without any converting (jsch).
|
|
|
|
*
|
|
|
|
* FIXME: any hook gets a OPENFILENAMEA structure
|
|
|
|
*
|
|
|
|
* FIXME: CDN_FILEOK is wrong implemented, other CDN_ messages likely too
|
|
|
|
*
|
|
|
|
* FIXME: old style hook messages are not implemented (except FILEOKSTRING)
|
|
|
|
*
|
|
|
|
* FIXME: algorithm for selecting the initial directory is too simple
|
|
|
|
*
|
|
|
|
* FIXME: add to recent docs
|
|
|
|
*
|
2007-11-02 21:04:46 +01:00
|
|
|
* FIXME: flags not implemented: OFN_DONTADDTORECENT,
|
2003-10-16 02:16:40 +02:00
|
|
|
* OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
|
2004-01-02 02:47:52 +01:00
|
|
|
* OFN_NOTESTFILECREATE, OFN_USEMONIKERS
|
2003-10-16 02:16:40 +02:00
|
|
|
*
|
|
|
|
* FIXME: lCustData for lpfnHook (WM_INITDIALOG)
|
|
|
|
*
|
|
|
|
*
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <string.h>
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-10-16 02:16:40 +02:00
|
|
|
#define NONAMELESSUNION
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "winbase.h"
|
2003-10-16 02:16:40 +02:00
|
|
|
#include "winternl.h"
|
2003-08-20 20:22:31 +02:00
|
|
|
#include "winnls.h"
|
2003-10-16 02:16:40 +02:00
|
|
|
#include "wingdi.h"
|
2005-06-28 21:14:03 +02:00
|
|
|
#include "winreg.h"
|
2007-11-19 01:42:20 +01:00
|
|
|
#include "winuser.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "commdlg.h"
|
2003-10-16 02:16:40 +02:00
|
|
|
#include "dlgs.h"
|
|
|
|
#include "cdlg.h"
|
1999-03-13 18:07:56 +01:00
|
|
|
#include "cderr.h"
|
2003-10-16 02:16:40 +02:00
|
|
|
#include "shellapi.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "filedlgbrowser.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
#include "wine/debug.h"
|
2018-03-20 08:37:47 +01:00
|
|
|
#include "wine/heap.h"
|
2007-03-07 14:18:40 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
|
|
|
|
|
|
|
#define UNIMPLEMENTED_FLAGS \
|
2009-04-30 08:06:50 +02:00
|
|
|
(OFN_DONTADDTORECENT |\
|
2003-10-16 02:16:40 +02:00
|
|
|
OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
|
2004-01-02 02:47:52 +01:00
|
|
|
OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Data structure and global variables
|
|
|
|
*/
|
|
|
|
typedef struct SFolder
|
|
|
|
{
|
|
|
|
int m_iImageIndex; /* Index of picture in image list */
|
|
|
|
HIMAGELIST hImgList;
|
|
|
|
int m_iIndent; /* Indentation index */
|
|
|
|
LPITEMIDLIST pidlItem; /* absolute pidl of the item */
|
|
|
|
|
|
|
|
} SFOLDER,*LPSFOLDER;
|
|
|
|
|
|
|
|
typedef struct tagLookInInfo
|
|
|
|
{
|
|
|
|
int iMaxIndentation;
|
|
|
|
UINT uSelectedItem;
|
|
|
|
} LookInInfos;
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Defines and global variables
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Draw item constant */
|
|
|
|
#define XTEXTOFFSET 3
|
|
|
|
|
|
|
|
/* AddItem flags*/
|
|
|
|
#define LISTEND -1
|
|
|
|
|
|
|
|
/* SearchItem methods */
|
|
|
|
#define SEARCH_PIDL 1
|
|
|
|
#define SEARCH_EXP 2
|
|
|
|
#define ITEM_NOTFOUND -1
|
|
|
|
|
|
|
|
/* Undefined windows message sent by CreateViewObject*/
|
|
|
|
#define WM_GETISHELLBROWSER WM_USER+7
|
|
|
|
|
2018-03-21 06:59:41 +01:00
|
|
|
#define TBPLACES_CMDID_PLACE0 0xa064
|
|
|
|
#define TBPLACES_CMDID_PLACE1 0xa065
|
|
|
|
#define TBPLACES_CMDID_PLACE2 0xa066
|
|
|
|
#define TBPLACES_CMDID_PLACE3 0xa067
|
|
|
|
#define TBPLACES_CMDID_PLACE4 0xa068
|
2018-03-16 13:55:43 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* NOTE
|
|
|
|
* Those macros exist in windowsx.h. However, you can't really use them since
|
|
|
|
* they rely on the UNICODE defines and can't be used inside Wine itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Combo box macros */
|
|
|
|
#define CBGetItemDataPtr(hwnd,iItemId) \
|
2007-03-07 14:18:40 +01:00
|
|
|
SendMessageW(hwnd, CB_GETITEMDATA, (WPARAM)(iItemId), 0)
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2006-11-29 11:04:52 +01:00
|
|
|
static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property */
|
2009-07-10 10:07:48 +02:00
|
|
|
static SIZE MemDialogSize = { 0, 0}; /* keep size of the (resizable) dialog */
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *get_filedlg_infoptr(HWND hwnd)
|
|
|
|
{
|
2020-11-23 00:15:51 +01:00
|
|
|
return GetPropW(hwnd, L"FileOpenDlgInfos");
|
2017-02-21 13:35:17 +01:00
|
|
|
}
|
|
|
|
|
2018-03-20 08:37:50 +01:00
|
|
|
static BOOL is_dialog_hooked(const FileOpenDlgInfos *info)
|
|
|
|
{
|
|
|
|
return (info->ofnInfos->Flags & OFN_ENABLEHOOK) && info->ofnInfos->lpfnHook;
|
|
|
|
}
|
|
|
|
|
2018-03-25 17:51:17 +02:00
|
|
|
static BOOL filedialog_is_readonly_hidden(const FileOpenDlgInfos *info)
|
|
|
|
{
|
|
|
|
return (info->ofnInfos->Flags & OFN_HIDEREADONLY) || (info->DlgInfos.dwDlgProp & FODPROP_SAVEDLG);
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Prototypes
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Internal functions used by the dialog */
|
2007-06-14 10:29:16 +02:00
|
|
|
static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
|
2003-10-16 02:16:40 +02:00
|
|
|
static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
|
2010-03-06 14:49:41 +01:00
|
|
|
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam);
|
2003-10-16 02:16:40 +02:00
|
|
|
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd);
|
2007-01-01 15:59:58 +01:00
|
|
|
static BOOL FILEDLG95_OnOpen(HWND hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
static LRESULT FILEDLG95_InitControls(HWND hwnd);
|
|
|
|
static void FILEDLG95_Clean(HWND hwnd);
|
|
|
|
|
|
|
|
/* Functions used by the shell navigation */
|
|
|
|
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd);
|
|
|
|
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd);
|
|
|
|
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb);
|
|
|
|
static void FILEDLG95_SHELL_Clean(HWND hwnd);
|
|
|
|
|
2005-06-07 22:03:30 +02:00
|
|
|
/* Functions used by the EDIT box */
|
2008-04-16 18:05:25 +02:00
|
|
|
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed);
|
2005-06-07 22:03:30 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Functions used by the filetype combo box */
|
|
|
|
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);
|
|
|
|
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode);
|
|
|
|
static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt);
|
|
|
|
static void FILEDLG95_FILETYPE_Clean(HWND hwnd);
|
|
|
|
|
|
|
|
/* Functions used by the Look In combo box */
|
2005-06-07 22:03:30 +02:00
|
|
|
static void FILEDLG95_LOOKIN_Init(HWND hwndCombo);
|
2003-10-16 02:16:40 +02:00
|
|
|
static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct);
|
|
|
|
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode);
|
|
|
|
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId);
|
|
|
|
static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod);
|
|
|
|
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl);
|
|
|
|
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd);
|
|
|
|
int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
|
|
|
|
static void FILEDLG95_LOOKIN_Clean(HWND hwnd);
|
|
|
|
|
2010-07-23 20:13:04 +02:00
|
|
|
/* Functions for dealing with the most-recently-used registry keys */
|
|
|
|
static void FILEDLG95_MRU_load_filename(LPWSTR stored_path);
|
|
|
|
static WCHAR FILEDLG95_MRU_get_slot(LPCWSTR module_name, LPWSTR stored_path, PHKEY hkey_ret);
|
|
|
|
static void FILEDLG95_MRU_save_filename(LPCWSTR filename);
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Miscellaneous tool functions */
|
2007-03-07 14:19:19 +01:00
|
|
|
static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPWSTR lpstrFileName);
|
2003-10-16 02:16:40 +02:00
|
|
|
IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
|
|
|
|
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
|
2006-11-30 15:15:46 +01:00
|
|
|
static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
|
2008-12-03 12:12:52 +01:00
|
|
|
static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
|
|
|
|
static UINT GetNumSelected( IDataObject *doSelected );
|
2016-07-06 12:27:44 +02:00
|
|
|
static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2007-01-03 14:47:44 +01:00
|
|
|
static INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
2005-06-07 22:03:30 +02:00
|
|
|
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);
|
2003-10-16 02:16:40 +02:00
|
|
|
static BOOL BrowseSelectedFolder(HWND hwnd);
|
|
|
|
|
2018-03-21 06:59:41 +01:00
|
|
|
static BOOL get_config_key_as_dword(HKEY hkey, const WCHAR *name, DWORD *value)
|
|
|
|
{
|
|
|
|
DWORD type, data, size;
|
|
|
|
|
|
|
|
size = sizeof(data);
|
|
|
|
if (hkey && !RegQueryValueExW(hkey, name, 0, &type, (BYTE *)&data, &size))
|
|
|
|
{
|
|
|
|
*value = data;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_config_key_dword(HKEY hkey, const WCHAR *name, DWORD *value)
|
|
|
|
{
|
|
|
|
DWORD type, data, size;
|
|
|
|
|
|
|
|
size = sizeof(data);
|
|
|
|
if (hkey && !RegQueryValueExW(hkey, name, 0, &type, (BYTE *)&data, &size) && type == REG_DWORD)
|
|
|
|
{
|
|
|
|
*value = data;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_config_key_string(HKEY hkey, const WCHAR *name, WCHAR **value)
|
|
|
|
{
|
|
|
|
DWORD type, size;
|
|
|
|
WCHAR *str;
|
|
|
|
|
2020-05-08 16:41:12 +02:00
|
|
|
if (RegQueryValueExW(hkey, name, 0, &type, NULL, &size))
|
|
|
|
return FALSE;
|
|
|
|
if (type != REG_SZ && type != REG_EXPAND_SZ)
|
|
|
|
return FALSE;
|
2018-03-21 06:59:41 +01:00
|
|
|
|
|
|
|
str = heap_alloc(size);
|
|
|
|
if (RegQueryValueExW(hkey, name, 0, &type, (BYTE *)str, &size))
|
|
|
|
{
|
|
|
|
heap_free(str);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*value = str;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-16 13:55:43 +01:00
|
|
|
static BOOL is_places_bar_enabled(const FileOpenDlgInfos *fodInfos)
|
|
|
|
{
|
2018-03-21 06:59:41 +01:00
|
|
|
DWORD value;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (fodInfos->ofnInfos->lStructSize != sizeof(*fodInfos->ofnInfos) ||
|
|
|
|
(fodInfos->ofnInfos->FlagsEx & OFN_EX_NOPLACESBAR) ||
|
|
|
|
!(fodInfos->ofnInfos->Flags & OFN_EXPLORER))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32", &hkey))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
value = 0;
|
2020-11-23 00:15:51 +01:00
|
|
|
get_config_key_as_dword(hkey, L"NoPlacesBar", &value);
|
2018-03-21 06:59:41 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return value == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void filedlg_collect_places_pidls(FileOpenDlgInfos *fodInfos)
|
|
|
|
{
|
|
|
|
static const int default_places[] =
|
|
|
|
{
|
|
|
|
CSIDL_DESKTOP,
|
|
|
|
CSIDL_MYDOCUMENTS,
|
|
|
|
CSIDL_DRIVES,
|
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32\\Placesbar",
|
|
|
|
&hkey))
|
|
|
|
{
|
|
|
|
for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
|
|
|
|
{
|
|
|
|
WCHAR nameW[8];
|
|
|
|
DWORD value;
|
2018-04-01 10:32:23 +02:00
|
|
|
HRESULT hr;
|
2018-03-21 06:59:41 +01:00
|
|
|
WCHAR *str;
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
swprintf(nameW, ARRAY_SIZE(nameW), L"Place%d", i);
|
2018-03-21 06:59:41 +01:00
|
|
|
if (get_config_key_dword(hkey, nameW, &value))
|
2018-04-01 10:32:23 +02:00
|
|
|
{
|
|
|
|
hr = SHGetSpecialFolderLocation(NULL, value, &fodInfos->places[i]);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WARN("Unrecognized special folder %u.\n", value);
|
|
|
|
}
|
2018-03-21 06:59:41 +01:00
|
|
|
else if (get_config_key_string(hkey, nameW, &str))
|
|
|
|
{
|
2018-04-01 10:32:23 +02:00
|
|
|
hr = SHParseDisplayName(str, NULL, &fodInfos->places[i], 0, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WARN("Failed to parse custom places location, %s.\n", debugstr_w(str));
|
2018-03-21 06:59:41 +01:00
|
|
|
heap_free(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: eliminate duplicates. */
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(default_places); i++)
|
|
|
|
SHGetSpecialFolderLocation(NULL, default_places[i], &fodInfos->places[i]);
|
2018-03-16 13:55:43 +01:00
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetFileName95
|
|
|
|
*
|
|
|
|
* Creates an Open common dialog box that lets the user select
|
|
|
|
* the drive, directory, and the name of a file or set of files to open.
|
|
|
|
*
|
|
|
|
* IN : The FileOpenDlgInfos structure associated with the dialog
|
|
|
|
* OUT : TRUE on success
|
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*/
|
2008-11-24 00:28:25 +01:00
|
|
|
static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
LRESULT lRes;
|
2017-01-25 20:56:09 +01:00
|
|
|
void *template;
|
2003-10-16 02:16:40 +02:00
|
|
|
HRSRC hRes;
|
|
|
|
HANDLE hDlgTmpl = 0;
|
2018-03-16 13:55:43 +01:00
|
|
|
WORD templateid;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* test for missing functionality */
|
|
|
|
if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
|
|
|
|
{
|
2006-10-13 15:04:43 +02:00
|
|
|
FIXME("Flags 0x%08x not yet implemented\n",
|
2003-10-16 02:16:40 +02:00
|
|
|
fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the dialog from a template */
|
|
|
|
|
2018-03-16 13:55:43 +01:00
|
|
|
if (is_places_bar_enabled(fodInfos))
|
|
|
|
templateid = NEWFILEOPENV2ORD;
|
|
|
|
else
|
|
|
|
templateid = NEWFILEOPENORD;
|
|
|
|
|
|
|
|
if (!(hRes = FindResourceW(COMDLG32_hInstance, MAKEINTRESOURCEW(templateid), (LPCWSTR)RT_DIALOG)))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-01-25 20:56:09 +01:00
|
|
|
if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
|
|
|
|
!(template = LockResource( hDlgTmpl )))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-10-07 11:17:05 +02:00
|
|
|
/* msdn: explorer style dialogs permit sizing by default.
|
|
|
|
* The OFN_ENABLESIZING flag is only needed when a hook or
|
2017-01-25 20:56:09 +01:00
|
|
|
* custom template is provided */
|
2009-10-07 11:17:05 +02:00
|
|
|
if( (fodInfos->ofnInfos->Flags & OFN_EXPLORER) &&
|
|
|
|
!(fodInfos->ofnInfos->Flags & ( OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE)))
|
|
|
|
fodInfos->ofnInfos->Flags |= OFN_ENABLESIZING;
|
|
|
|
|
2009-04-30 08:06:50 +02:00
|
|
|
if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
|
|
|
|
{
|
|
|
|
fodInfos->sizedlg.cx = fodInfos->sizedlg.cy = 0;
|
|
|
|
fodInfos->initial_size.x = fodInfos->initial_size.y = 0;
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* old style hook messages */
|
2018-03-20 08:37:50 +01:00
|
|
|
if (is_dialog_hooked(fodInfos))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2007-03-07 14:19:19 +01:00
|
|
|
fodInfos->HookMsg.fileokstring = RegisterWindowMessageW(FILEOKSTRINGW);
|
|
|
|
fodInfos->HookMsg.lbselchstring = RegisterWindowMessageW(LBSELCHSTRINGW);
|
|
|
|
fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageW(HELPMSGSTRINGW);
|
|
|
|
fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2006-07-24 14:45:32 +02:00
|
|
|
if (fodInfos->unicode)
|
|
|
|
lRes = DialogBoxIndirectParamW(COMDLG32_hInstance,
|
|
|
|
template,
|
|
|
|
fodInfos->ofnInfos->hwndOwner,
|
|
|
|
FileOpenDlgProc95,
|
|
|
|
(LPARAM) fodInfos);
|
|
|
|
else
|
|
|
|
lRes = DialogBoxIndirectParamA(COMDLG32_hInstance,
|
2009-01-13 23:30:08 +01:00
|
|
|
template,
|
2006-07-24 14:45:32 +02:00
|
|
|
fodInfos->ofnInfos->hwndOwner,
|
|
|
|
FileOpenDlgProc95,
|
|
|
|
(LPARAM) fodInfos);
|
2017-02-02 16:10:06 +01:00
|
|
|
if (fodInfos->ole_initialized)
|
2005-11-23 15:14:25 +01:00
|
|
|
OleUninitialize();
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Unable to create the dialog */
|
|
|
|
if( lRes == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
static WCHAR *heap_strdupAtoW(const char *str)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2017-02-21 13:35:16 +01:00
|
|
|
WCHAR *ret;
|
|
|
|
INT len;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
if (!str)
|
|
|
|
return NULL;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0);
|
2018-03-20 08:37:47 +01:00
|
|
|
ret = heap_alloc(len * sizeof(WCHAR));
|
2017-02-21 13:35:16 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
|
|
|
|
{
|
|
|
|
INITCOMMONCONTROLSEX icc;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
/* Initialize ComboBoxEx32 */
|
|
|
|
icc.dwSize = sizeof(icc);
|
|
|
|
icc.dwICC = ICC_USEREX_CLASSES;
|
|
|
|
InitCommonControlsEx(&icc);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
/* Initialize CommDlgExtendedError() */
|
|
|
|
COMDLG32_SetCommDlgExtendedError(0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
memset(info, 0, sizeof(*info));
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
/* Pass in the original ofn */
|
|
|
|
info->ofnInfos = ofn;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
info->title = ofn->lpstrTitle;
|
|
|
|
info->defext = ofn->lpstrDefExt;
|
|
|
|
info->filter = ofn->lpstrFilter;
|
|
|
|
info->customfilter = ofn->lpstrCustomFilter;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
if (ofn->lpstrFile)
|
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
info->filename = heap_alloc(ofn->nMaxFile * sizeof(WCHAR));
|
2017-02-21 13:35:16 +01:00
|
|
|
lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile);
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
if (ofn->lpstrInitialDir)
|
|
|
|
{
|
|
|
|
DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0);
|
|
|
|
if (len)
|
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
info->initdir = heap_alloc(len * sizeof(WCHAR));
|
2017-02-21 13:35:16 +01:00
|
|
|
ExpandEnvironmentStringsW(ofn->lpstrInitialDir, info->initdir, len);
|
|
|
|
}
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
info->unicode = TRUE;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2017-02-21 13:35:16 +01:00
|
|
|
OPENFILENAMEW ofnW;
|
2017-03-12 19:18:40 +01:00
|
|
|
int len;
|
2013-05-05 21:04:24 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
ofnW = *(OPENFILENAMEW *)ofn;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
ofnW.lpstrInitialDir = heap_strdupAtoW(ofn->lpstrInitialDir);
|
|
|
|
ofnW.lpstrDefExt = heap_strdupAtoW(ofn->lpstrDefExt);
|
|
|
|
ofnW.lpstrTitle = heap_strdupAtoW(ofn->lpstrTitle);
|
2007-04-23 23:20:37 +02:00
|
|
|
|
2017-03-12 19:18:40 +01:00
|
|
|
if (ofn->lpstrFile)
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0);
|
2018-03-20 08:37:47 +01:00
|
|
|
ofnW.lpstrFile = heap_alloc(len * sizeof(WCHAR));
|
2017-03-12 19:18:40 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len);
|
|
|
|
ofnW.nMaxFile = len;
|
|
|
|
}
|
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
if (ofn->lpstrFilter)
|
|
|
|
{
|
|
|
|
LPCSTR s;
|
2017-03-12 19:18:40 +01:00
|
|
|
int n;
|
2017-02-21 13:35:16 +01:00
|
|
|
|
|
|
|
/* 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);
|
2018-03-20 08:37:47 +01:00
|
|
|
ofnW.lpstrFilter = heap_alloc(len * sizeof(WCHAR));
|
2017-02-21 13:35:16 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, (WCHAR *)ofnW.lpstrFilter, len);
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
/* 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);
|
2018-03-20 08:37:47 +01:00
|
|
|
ofnW.lpstrCustomFilter = heap_alloc(len * sizeof(WCHAR));
|
2017-02-21 13:35:16 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, ofnW.lpstrCustomFilter, len);
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
init_filedlg_infoW(&ofnW, info);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
/* fixup A-specific fields */
|
|
|
|
info->ofnInfos = (OPENFILENAMEW *)ofn;
|
|
|
|
info->unicode = FALSE;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
/* free what was duplicated */
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free((void *)ofnW.lpstrInitialDir);
|
|
|
|
heap_free(ofnW.lpstrFile);
|
2017-02-21 13:35:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetFileDialog95
|
|
|
|
*
|
|
|
|
* Call GetFileName95 with this structure and clean the memory.
|
|
|
|
*/
|
|
|
|
static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
|
|
|
|
{
|
|
|
|
WCHAR *current_dir = NULL;
|
2018-03-21 06:59:41 +01:00
|
|
|
unsigned int i;
|
2017-02-21 13:35:16 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* save current directory */
|
|
|
|
if (info->ofnInfos->Flags & OFN_NOCHANGEDIR)
|
2017-02-21 13:35:15 +01:00
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
current_dir = heap_alloc(MAX_PATH * sizeof(WCHAR));
|
2017-02-21 13:35:16 +01:00
|
|
|
GetCurrentDirectoryW(MAX_PATH, current_dir);
|
2017-02-21 13:35:15 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
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;
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
if (current_dir)
|
|
|
|
{
|
|
|
|
SetCurrentDirectoryW(current_dir);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(current_dir);
|
2017-02-21 13:35:16 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
if (!info->unicode)
|
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free((void *)info->defext);
|
|
|
|
heap_free((void *)info->title);
|
|
|
|
heap_free((void *)info->filter);
|
|
|
|
heap_free((void *)info->customfilter);
|
2017-02-21 13:35:16 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(info->filename);
|
|
|
|
heap_free(info->initdir);
|
2018-03-21 06:59:41 +01:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(info->places); i++)
|
|
|
|
ILFree(info->places[i]);
|
|
|
|
|
2017-02-21 13:35:16 +01:00
|
|
|
return ret;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2005-05-26 14:23:57 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* COMDLG32_GetDisplayNameOf [internal]
|
|
|
|
*
|
|
|
|
* Helper function to get the display name for a pidl.
|
|
|
|
*/
|
|
|
|
static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) {
|
|
|
|
LPSHELLFOLDER psfDesktop;
|
|
|
|
STRRET strret;
|
|
|
|
|
|
|
|
if (FAILED(SHGetDesktopFolder(&psfDesktop)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) {
|
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));
|
|
|
|
}
|
|
|
|
|
2011-04-01 05:52:29 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* COMDLG32_GetCanonicalPath [internal]
|
|
|
|
*
|
|
|
|
* Helper function to get the canonical path.
|
|
|
|
*/
|
|
|
|
void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent,
|
|
|
|
LPWSTR lpstrFile, LPWSTR lpstrPathAndFile)
|
|
|
|
{
|
|
|
|
WCHAR lpstrTemp[MAX_PATH];
|
|
|
|
|
|
|
|
/* Get the current directory name */
|
|
|
|
if (!COMDLG32_GetDisplayNameOf(pidlAbsCurrent, lpstrPathAndFile))
|
|
|
|
{
|
|
|
|
/* last fallback */
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
|
|
|
|
}
|
|
|
|
PathAddBackslashW(lpstrPathAndFile);
|
|
|
|
|
2018-12-20 15:17:22 +01:00
|
|
|
TRACE("current directory=%s, file=%s\n", debugstr_w(lpstrPathAndFile), debugstr_w(lpstrFile));
|
2011-04-01 05:52:29 +02:00
|
|
|
|
|
|
|
/* if the user specified a fully qualified path use it */
|
|
|
|
if(PathIsRelativeW(lpstrFile))
|
|
|
|
{
|
|
|
|
lstrcatW(lpstrPathAndFile, lpstrFile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* does the path have a drive letter? */
|
|
|
|
if (PathGetDriveNumberW(lpstrFile) == -1)
|
|
|
|
lstrcpyW(lpstrPathAndFile+2, lpstrFile);
|
|
|
|
else
|
|
|
|
lstrcpyW(lpstrPathAndFile, lpstrFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* resolve "." and ".." */
|
|
|
|
PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
|
|
|
|
lstrcpyW(lpstrPathAndFile, lpstrTemp);
|
|
|
|
TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
|
|
|
|
}
|
|
|
|
|
2011-04-01 05:52:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* COMDLG32_SplitFileNames [internal]
|
|
|
|
*
|
|
|
|
* Creates a delimited list of filenames.
|
|
|
|
*/
|
|
|
|
int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed)
|
|
|
|
{
|
|
|
|
UINT nStrCharCount = 0; /* index in src buffer */
|
|
|
|
UINT nFileIndex = 0; /* index in dest buffer */
|
|
|
|
UINT nFileCount = 0; /* number of files */
|
|
|
|
|
|
|
|
/* we might get single filename without any '"',
|
|
|
|
* so we need nStrLen + terminating \0 + end-of-list \0 */
|
2018-03-20 08:37:47 +01:00
|
|
|
*lpstrFileList = heap_alloc((nStrLen + 2) * sizeof(WCHAR));
|
2011-04-01 05:52:31 +02:00
|
|
|
*sizeUsed = 0;
|
|
|
|
|
|
|
|
/* build delimited file list from filenames */
|
|
|
|
while ( nStrCharCount <= nStrLen )
|
|
|
|
{
|
|
|
|
if ( lpstrEdit[nStrCharCount]=='"' )
|
|
|
|
{
|
|
|
|
nStrCharCount++;
|
2016-05-01 17:22:44 +02:00
|
|
|
while ((nStrCharCount <= nStrLen) && (lpstrEdit[nStrCharCount]!='"'))
|
2011-04-01 05:52:31 +02:00
|
|
|
{
|
|
|
|
(*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
|
|
|
|
nStrCharCount++;
|
|
|
|
}
|
|
|
|
(*lpstrFileList)[nFileIndex++] = 0;
|
|
|
|
nFileCount++;
|
|
|
|
}
|
|
|
|
nStrCharCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* single, unquoted string */
|
|
|
|
if ((nStrLen > 0) && (nFileIndex == 0) )
|
|
|
|
{
|
|
|
|
lstrcpyW(*lpstrFileList, lpstrEdit);
|
|
|
|
nFileIndex = lstrlenW(lpstrEdit) + 1;
|
|
|
|
nFileCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* trailing \0 */
|
|
|
|
(*lpstrFileList)[nFileIndex++] = '\0';
|
|
|
|
|
|
|
|
*sizeUsed = nFileIndex;
|
|
|
|
return nFileCount;
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ArrangeCtrlPositions [internal]
|
|
|
|
*
|
2009-08-06 07:32:08 +02:00
|
|
|
* NOTE: Make sure to add testcases for any changes made here.
|
2003-10-16 02:16:40 +02:00
|
|
|
*/
|
|
|
|
static void ArrangeCtrlPositions(HWND hwndChildDlg, HWND hwndParentDlg, BOOL hide_help)
|
|
|
|
{
|
|
|
|
HWND hwndChild, hwndStc32;
|
|
|
|
RECT rectParent, rectChild, rectStc32;
|
2009-08-06 07:32:08 +02:00
|
|
|
INT help_fixup = 0;
|
|
|
|
int chgx, chgy;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Take into account if open as read only checkbox and help button
|
|
|
|
* are hidden
|
|
|
|
*/
|
|
|
|
if (hide_help)
|
|
|
|
{
|
|
|
|
RECT rectHelp, rectCancel;
|
|
|
|
GetWindowRect(GetDlgItem(hwndParentDlg, pshHelp), &rectHelp);
|
|
|
|
GetWindowRect(GetDlgItem(hwndParentDlg, 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
|
|
|
|
*/
|
|
|
|
help_fixup = rectHelp.bottom - rectCancel.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
There are two possibilities to add components to the default file dialog box.
|
|
|
|
|
|
|
|
By default, all the new components are added below the standard dialog box (the else case).
|
|
|
|
|
|
|
|
However, if there is a static text component with the stc32 id, a special case happens.
|
|
|
|
The x and y coordinates of stc32 indicate the top left corner where to place the standard file dialog box
|
|
|
|
in the window and the cx and cy indicate how to size the window.
|
|
|
|
Moreover, if the new component's coordinates are on the left of the stc32 , it is placed on the left
|
|
|
|
of the standard file dialog box. If they are above the stc32 component, it is placed above and so on....
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
GetClientRect(hwndParentDlg, &rectParent);
|
|
|
|
|
|
|
|
/* when arranging controls we have to use fixed parent size */
|
|
|
|
rectParent.bottom -= help_fixup;
|
|
|
|
|
|
|
|
hwndStc32 = GetDlgItem(hwndChildDlg, stc32);
|
|
|
|
if (hwndStc32)
|
|
|
|
{
|
|
|
|
GetWindowRect(hwndStc32, &rectStc32);
|
|
|
|
MapWindowPoints(0, hwndChildDlg, (LPPOINT)&rectStc32, 2);
|
|
|
|
|
|
|
|
/* set the size of the stc32 control according to the size of
|
|
|
|
* client area of the parent dialog
|
|
|
|
*/
|
|
|
|
SetWindowPos(hwndStc32, 0,
|
|
|
|
0, 0,
|
|
|
|
rectParent.right, rectParent.bottom,
|
|
|
|
SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetRectEmpty(&rectStc32);
|
|
|
|
|
|
|
|
/* this part moves controls of the child dialog */
|
|
|
|
hwndChild = GetWindow(hwndChildDlg, GW_CHILD);
|
|
|
|
while (hwndChild)
|
|
|
|
{
|
|
|
|
if (hwndChild != hwndStc32)
|
|
|
|
{
|
|
|
|
GetWindowRect(hwndChild, &rectChild);
|
|
|
|
MapWindowPoints(0, hwndChildDlg, (LPPOINT)&rectChild, 2);
|
|
|
|
|
|
|
|
/* move only if stc32 exist */
|
|
|
|
if (hwndStc32 && rectChild.left > rectStc32.right)
|
|
|
|
{
|
|
|
|
/* move to the right of visible controls of the parent dialog */
|
|
|
|
rectChild.left += rectParent.right;
|
|
|
|
rectChild.left -= rectStc32.right;
|
|
|
|
}
|
|
|
|
/* move even if stc32 doesn't exist */
|
2004-08-23 00:26:22 +02:00
|
|
|
if (rectChild.top >= rectStc32.bottom)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
/* move below visible controls of the parent dialog */
|
|
|
|
rectChild.top += rectParent.bottom;
|
|
|
|
rectChild.top -= rectStc32.bottom - rectStc32.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowPos(hwndChild, 0, rectChild.left, rectChild.top,
|
|
|
|
0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this part moves controls of the parent dialog */
|
|
|
|
hwndChild = GetWindow(hwndParentDlg, GW_CHILD);
|
|
|
|
while (hwndChild)
|
|
|
|
{
|
|
|
|
if (hwndChild != hwndChildDlg)
|
|
|
|
{
|
|
|
|
GetWindowRect(hwndChild, &rectChild);
|
|
|
|
MapWindowPoints(0, hwndParentDlg, (LPPOINT)&rectChild, 2);
|
|
|
|
|
|
|
|
/* left,top of stc32 marks the position of controls
|
|
|
|
* from the parent dialog
|
|
|
|
*/
|
|
|
|
rectChild.left += rectStc32.left;
|
|
|
|
rectChild.top += rectStc32.top;
|
|
|
|
|
|
|
|
SetWindowPos(hwndChild, 0, rectChild.left, rectChild.top,
|
|
|
|
0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate the size of the resulting dialog */
|
|
|
|
|
|
|
|
/* here we have to use original parent size */
|
|
|
|
GetClientRect(hwndParentDlg, &rectParent);
|
|
|
|
GetClientRect(hwndChildDlg, &rectChild);
|
2009-08-06 07:32:08 +02:00
|
|
|
TRACE( "parent %s child %s stc32 %s\n", wine_dbgstr_rect( &rectParent),
|
|
|
|
wine_dbgstr_rect( &rectChild), wine_dbgstr_rect( &rectStc32));
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if (hwndStc32)
|
|
|
|
{
|
2009-08-06 07:32:08 +02:00
|
|
|
/* width */
|
|
|
|
if (rectParent.right > rectStc32.right - rectStc32.left)
|
|
|
|
chgx = rectChild.right - ( rectStc32.right - rectStc32.left);
|
2003-10-16 02:16:40 +02:00
|
|
|
else
|
2009-08-06 07:32:08 +02:00
|
|
|
chgx = rectChild.right - rectParent.right;
|
|
|
|
/* height */
|
|
|
|
if (rectParent.bottom > rectStc32.bottom - rectStc32.top)
|
|
|
|
chgy = rectChild.bottom - ( rectStc32.bottom - rectStc32.top) - help_fixup;
|
2003-10-16 02:16:40 +02:00
|
|
|
else
|
2009-08-06 07:32:08 +02:00
|
|
|
/* Unconditionally set new dialog
|
|
|
|
* height to that of the child
|
2004-08-16 23:12:13 +02:00
|
|
|
*/
|
2009-08-06 07:32:08 +02:00
|
|
|
chgy = rectChild.bottom - rectParent.bottom;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-06 07:32:08 +02:00
|
|
|
chgx = 0;
|
|
|
|
chgy = rectChild.bottom - help_fixup;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
/* set the size of the parent dialog */
|
2009-08-06 07:32:08 +02:00
|
|
|
GetWindowRect(hwndParentDlg, &rectParent);
|
2003-10-16 02:16:40 +02:00
|
|
|
SetWindowPos(hwndParentDlg, 0,
|
|
|
|
0, 0,
|
2009-08-06 07:32:08 +02:00
|
|
|
rectParent.right - rectParent.left + chgx,
|
|
|
|
rectParent.bottom - rectParent.top + chgy,
|
2003-10-16 02:16:40 +02:00
|
|
|
SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
|
2005-06-28 21:19:07 +02:00
|
|
|
static INT_PTR CALLBACK FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2004-01-19 22:51:29 +01:00
|
|
|
switch(uMsg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return TRUE;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2004-01-19 22:51:29 +01:00
|
|
|
return FALSE;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2005-06-28 21:19:07 +02:00
|
|
|
static HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
LPCVOID template;
|
|
|
|
HRSRC hRes;
|
|
|
|
HANDLE hDlgTmpl = 0;
|
|
|
|
HWND hChildDlg = 0;
|
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p, %p\n", fodInfos, hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If OFN_ENABLETEMPLATEHANDLE is specified, the OPENFILENAME
|
|
|
|
* structure's hInstance parameter is not a HINSTANCE, but
|
|
|
|
* instead a pointer to a template resource to use.
|
|
|
|
*/
|
|
|
|
if (fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE))
|
|
|
|
{
|
|
|
|
HINSTANCE hinst;
|
|
|
|
if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
|
|
|
|
{
|
2006-02-02 13:20:23 +01:00
|
|
|
hinst = COMDLG32_hInstance;
|
2003-10-16 02:16:40 +02:00
|
|
|
if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hinst = fodInfos->ofnInfos->hInstance;
|
|
|
|
if(fodInfos->unicode)
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
hRes = FindResourceW( hinst, ofn->lpTemplateName, (LPWSTR)RT_DIALOG);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
hRes = FindResourceA( hinst, ofn->lpTemplateName, (LPSTR)RT_DIALOG);
|
|
|
|
}
|
|
|
|
if (!hRes)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource( hinst, hRes )) ||
|
|
|
|
!(template = LockResource( hDlgTmpl )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2006-07-24 14:45:32 +02:00
|
|
|
if (fodInfos->unicode)
|
|
|
|
hChildDlg = CreateDialogIndirectParamW(hinst, template, hwnd,
|
2018-03-20 08:37:50 +01:00
|
|
|
is_dialog_hooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
|
2006-07-24 14:45:32 +02:00
|
|
|
(LPARAM)fodInfos->ofnInfos);
|
|
|
|
else
|
|
|
|
hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd,
|
2018-03-20 08:37:50 +01:00
|
|
|
is_dialog_hooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate,
|
2006-07-24 14:45:32 +02:00
|
|
|
(LPARAM)fodInfos->ofnInfos);
|
2009-07-02 13:32:28 +02:00
|
|
|
return hChildDlg;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2018-03-20 08:37:50 +01:00
|
|
|
else if (is_dialog_hooked(fodInfos))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
RECT rectHwnd;
|
|
|
|
struct {
|
|
|
|
DLGTEMPLATE tmplate;
|
|
|
|
WORD menu,class,title;
|
|
|
|
} temp;
|
|
|
|
GetClientRect(hwnd,&rectHwnd);
|
|
|
|
temp.tmplate.style = WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | DS_CONTROL | DS_3DLOOK;
|
|
|
|
temp.tmplate.dwExtendedStyle = 0;
|
|
|
|
temp.tmplate.cdit = 0;
|
|
|
|
temp.tmplate.x = 0;
|
|
|
|
temp.tmplate.y = 0;
|
|
|
|
temp.tmplate.cx = 0;
|
|
|
|
temp.tmplate.cy = 0;
|
|
|
|
temp.menu = temp.class = temp.title = 0;
|
|
|
|
|
|
|
|
hChildDlg = CreateDialogIndirectParamA(COMDLG32_hInstance, &temp.tmplate,
|
2004-01-19 22:51:29 +01:00
|
|
|
hwnd, (DLGPROC)fodInfos->ofnInfos->lpfnHook, (LPARAM)fodInfos->ofnInfos);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
return hChildDlg;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SendCustomDlgNotificationMessage
|
|
|
|
*
|
|
|
|
* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
|
|
|
|
*/
|
|
|
|
|
2006-01-12 13:30:11 +01:00
|
|
|
LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndParentDlg);
|
2017-05-31 05:16:01 +02:00
|
|
|
LRESULT hook_result;
|
|
|
|
OFNOTIFYW ofnNotify;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-05-31 05:16:01 +02:00
|
|
|
TRACE("%p %d\n", hwndParentDlg, uCode);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-05-31 05:16:01 +02:00
|
|
|
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);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2006-01-12 13:30:11 +01:00
|
|
|
return hook_result;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2008-04-16 18:05:25 +02:00
|
|
|
static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2008-04-16 18:05:25 +02:00
|
|
|
UINT len, total;
|
|
|
|
WCHAR *p, *buffer;
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("CDM_GETFILEPATH:\n");
|
|
|
|
|
|
|
|
if ( ! (fodInfos->ofnInfos->Flags & OFN_EXPLORER ) )
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* get path and filenames */
|
2008-04-16 18:05:25 +02:00
|
|
|
len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 );
|
2018-03-20 08:37:47 +01:00
|
|
|
buffer = heap_alloc( (len + 2 + MAX_PATH) * sizeof(WCHAR) );
|
2008-04-16 18:05:25 +02:00
|
|
|
COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer );
|
|
|
|
if (len)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2019-05-29 08:48:52 +02:00
|
|
|
p = buffer + lstrlenW(buffer);
|
2008-04-16 18:05:25 +02:00
|
|
|
*p++ = '\\';
|
|
|
|
SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, len + 1, (LPARAM)p );
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2008-04-16 18:05:25 +02:00
|
|
|
if (fodInfos->unicode)
|
2004-07-21 23:16:19 +02:00
|
|
|
{
|
2019-05-29 08:48:52 +02:00
|
|
|
total = lstrlenW( buffer) + 1;
|
2008-04-16 18:05:25 +02:00
|
|
|
if (result) lstrcpynW( result, buffer, size );
|
|
|
|
TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_w(result));
|
2004-07-21 23:16:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-16 18:05:25 +02:00
|
|
|
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));
|
2004-07-21 23:16:19 +02:00
|
|
|
}
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free( buffer );
|
2008-04-16 18:05:25 +02:00
|
|
|
return total;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_HandleCustomDialogMessages
|
|
|
|
*
|
|
|
|
* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
|
|
|
|
*/
|
2005-06-07 22:03:30 +02:00
|
|
|
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2005-05-26 14:23:57 +02:00
|
|
|
WCHAR lpstrPath[MAX_PATH];
|
2005-06-07 22:03:30 +02:00
|
|
|
INT_PTR retval;
|
2005-06-04 11:49:22 +02:00
|
|
|
|
|
|
|
if(!fodInfos) return FALSE;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case CDM_GETFILEPATH:
|
2005-06-04 11:49:22 +02:00
|
|
|
retval = FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);
|
|
|
|
break;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
case CDM_GETFOLDERPATH:
|
|
|
|
TRACE("CDM_GETFOLDERPATH:\n");
|
2005-05-26 14:23:57 +02:00
|
|
|
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
|
|
|
|
if (lParam)
|
2004-07-21 23:16:19 +02:00
|
|
|
{
|
2005-05-26 14:23:57 +02:00
|
|
|
if (fodInfos->unicode)
|
|
|
|
lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
|
|
|
|
else
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
|
|
|
|
(LPSTR)lParam, (int)wParam, NULL, NULL);
|
|
|
|
}
|
2009-09-16 11:51:36 +02:00
|
|
|
retval = lstrlenW(lpstrPath) + 1;
|
2005-06-04 11:49:22 +02:00
|
|
|
break;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2008-06-19 15:31:35 +02:00
|
|
|
case CDM_GETFOLDERIDLIST:
|
2018-03-21 06:59:42 +01:00
|
|
|
retval = ILGetSize(fodInfos->ShellInfos.pidlAbsCurrent);
|
2008-06-19 15:31:35 +02:00
|
|
|
if (retval <= wParam)
|
|
|
|
memcpy((void*)lParam, fodInfos->ShellInfos.pidlAbsCurrent, retval);
|
|
|
|
break;
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
case CDM_GETSPEC:
|
2008-04-16 18:05:25 +02:00
|
|
|
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);
|
|
|
|
}
|
2005-06-04 11:49:22 +02:00
|
|
|
break;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
case CDM_SETCONTROLTEXT:
|
|
|
|
TRACE("CDM_SETCONTROLTEXT:\n");
|
2004-07-21 23:16:19 +02:00
|
|
|
if ( lParam )
|
|
|
|
{
|
|
|
|
if( fodInfos->unicode )
|
|
|
|
SetDlgItemTextW( hwnd, (UINT) wParam, (LPWSTR) lParam );
|
|
|
|
else
|
|
|
|
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
|
|
|
|
}
|
2005-06-04 11:49:22 +02:00
|
|
|
retval = TRUE;
|
|
|
|
break;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
case CDM_HIDECONTROL:
|
2006-02-03 12:28:42 +01:00
|
|
|
/* 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;
|
2005-06-04 11:49:22 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-02-03 12:28:42 +01:00
|
|
|
if (uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
|
|
|
|
FIXME("message CDM_FIRST+%04x not implemented\n", uMsg - CDM_FIRST);
|
2005-06-04 11:49:22 +02:00
|
|
|
return FALSE;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2005-06-04 11:49:22 +02:00
|
|
|
SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, retval);
|
2003-10-16 02:16:40 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-04-30 08:06:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnWMGetMMI
|
|
|
|
*
|
|
|
|
* WM_GETMINMAXINFO message handler for resizable dialogs
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_OnWMGetMMI( HWND hwnd, LPMINMAXINFO mmiptr)
|
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2009-04-30 08:06:50 +02:00
|
|
|
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
|
|
|
|
if( fodInfos->initial_size.x || fodInfos->initial_size.y)
|
|
|
|
{
|
|
|
|
mmiptr->ptMinTrackSize = fodInfos->initial_size;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnWMSize
|
|
|
|
*
|
|
|
|
* WM_SIZE message handler, resize the dialog. Re-arrange controls.
|
|
|
|
*
|
|
|
|
* FIXME: this could be made more elaborate. Now use a simple scheme
|
|
|
|
* where the file view is enlarged and the controls are either moved
|
|
|
|
* vertically or horizontally to get out of the way. Only the "grip"
|
|
|
|
* is moved in both directions to stay in the corner.
|
|
|
|
*/
|
2010-03-06 14:49:41 +01:00
|
|
|
static LRESULT FILEDLG95_OnWMSize(HWND hwnd, WPARAM wParam)
|
2009-04-30 08:06:50 +02:00
|
|
|
{
|
|
|
|
RECT rc, rcview;
|
|
|
|
int chgx, chgy;
|
|
|
|
HWND ctrl;
|
|
|
|
HDWP hdwp;
|
|
|
|
FileOpenDlgInfos *fodInfos;
|
|
|
|
|
|
|
|
if( wParam != SIZE_RESTORED) return FALSE;
|
2017-02-21 13:35:17 +01:00
|
|
|
fodInfos = get_filedlg_infoptr(hwnd);
|
2009-04-30 08:06:50 +02:00
|
|
|
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
|
|
|
|
/* get the new dialog rectangle */
|
|
|
|
GetWindowRect( hwnd, &rc);
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p, size from %d,%d to %d,%d\n", hwnd, fodInfos->sizedlg.cx, fodInfos->sizedlg.cy,
|
2009-07-07 08:11:55 +02:00
|
|
|
rc.right -rc.left, rc.bottom -rc.top);
|
2009-04-30 08:06:50 +02:00
|
|
|
/* not initialized yet */
|
|
|
|
if( (fodInfos->sizedlg.cx == 0 && fodInfos->sizedlg.cy == 0) ||
|
|
|
|
((fodInfos->sizedlg.cx == rc.right -rc.left) && /* no change */
|
|
|
|
(fodInfos->sizedlg.cy == rc.bottom -rc.top)))
|
|
|
|
return FALSE;
|
|
|
|
chgx = rc.right - rc.left - fodInfos->sizedlg.cx;
|
|
|
|
chgy = rc.bottom - rc.top - fodInfos->sizedlg.cy;
|
|
|
|
fodInfos->sizedlg.cx = rc.right - rc.left;
|
|
|
|
fodInfos->sizedlg.cy = rc.bottom - rc.top;
|
|
|
|
/* change the size of the view window */
|
|
|
|
GetWindowRect( fodInfos->ShellInfos.hwndView, &rcview);
|
|
|
|
MapWindowPoints( NULL, hwnd, (LPPOINT) &rcview, 2);
|
|
|
|
hdwp = BeginDeferWindowPos( 10);
|
|
|
|
DeferWindowPos( hdwp, fodInfos->ShellInfos.hwndView, NULL, 0, 0,
|
|
|
|
rcview.right - rcview.left + chgx,
|
|
|
|
rcview.bottom - rcview.top + chgy,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
/* change position and sizes of the controls */
|
|
|
|
for( ctrl = GetWindow( hwnd, GW_CHILD); ctrl ; ctrl = GetWindow( ctrl, GW_HWNDNEXT))
|
|
|
|
{
|
2009-07-07 08:11:55 +02:00
|
|
|
int ctrlid = GetDlgCtrlID( ctrl);
|
2009-04-30 08:06:50 +02:00
|
|
|
GetWindowRect( ctrl, &rc);
|
|
|
|
MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
|
|
|
|
if( ctrl == fodInfos->DlgInfos.hwndGrip)
|
|
|
|
{
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
|
|
|
|
0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
2009-06-30 16:30:45 +02:00
|
|
|
}
|
2009-04-30 08:06:50 +02:00
|
|
|
else if( rc.top > rcview.bottom)
|
|
|
|
{
|
|
|
|
/* if it was below the shell view
|
|
|
|
* move to bottom */
|
2009-07-07 08:11:55 +02:00
|
|
|
switch( ctrlid)
|
|
|
|
{
|
2012-09-25 13:40:19 +02:00
|
|
|
/* file name (edit or comboboxex) and file types combo change also width */
|
2009-07-07 08:11:55 +02:00
|
|
|
case edt1:
|
2012-09-25 13:40:19 +02:00
|
|
|
case cmb13:
|
2009-07-07 08:11:55 +02:00
|
|
|
case cmb1:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
|
|
|
|
rc.right - rc.left + chgx, rc.bottom - rc.top,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
break;
|
|
|
|
/* then these buttons must move out of the way */
|
|
|
|
case IDOK:
|
|
|
|
case IDCANCEL:
|
|
|
|
case pshHelp:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
|
|
|
|
0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
|
|
|
|
0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
}
|
2009-04-30 08:06:50 +02:00
|
|
|
}
|
|
|
|
else if( rc.left > rcview.right)
|
|
|
|
{
|
|
|
|
/* if it was to the right of the shell view
|
|
|
|
* move to right */
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
|
2009-07-07 08:11:55 +02:00
|
|
|
0, 0,
|
2009-04-30 08:06:50 +02:00
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
}
|
2009-07-07 08:11:55 +02:00
|
|
|
else
|
|
|
|
/* special cases */
|
|
|
|
{
|
|
|
|
switch( ctrlid)
|
|
|
|
{
|
|
|
|
#if 0 /* this is Win2k, Win XP. Vista and Higher don't move/size these controls */
|
|
|
|
case IDC_LOOKIN:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
|
|
|
|
rc.right - rc.left + chgx, rc.bottom - rc.top,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
break;
|
|
|
|
case IDC_TOOLBARSTATIC:
|
|
|
|
case IDC_TOOLBAR:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
|
|
|
|
0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
/* not resized in windows. Since wine uses this invisible control
|
|
|
|
* to size the browser view it needs to be resized */
|
|
|
|
case IDC_SHELLSTATIC:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
|
|
|
|
rc.right - rc.left + chgx,
|
|
|
|
rc.bottom - rc.top + chgy,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
break;
|
2018-07-05 13:39:23 +02:00
|
|
|
case IDC_TOOLBARPLACES:
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top + chgy,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
break;
|
2009-07-07 08:11:55 +02:00
|
|
|
}
|
|
|
|
}
|
2009-04-30 08:06:50 +02:00
|
|
|
}
|
|
|
|
if(fodInfos->DlgInfos.hwndCustomDlg &&
|
|
|
|
(fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE)))
|
|
|
|
{
|
|
|
|
for( ctrl = GetWindow( fodInfos->DlgInfos.hwndCustomDlg, GW_CHILD);
|
|
|
|
ctrl ; ctrl = GetWindow( ctrl, GW_HWNDNEXT))
|
|
|
|
{
|
|
|
|
GetWindowRect( ctrl, &rc);
|
|
|
|
MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
|
|
|
|
if( rc.top > rcview.bottom)
|
|
|
|
{
|
|
|
|
/* if it was below the shell view
|
|
|
|
* move to bottom */
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
|
|
|
|
rc.right - rc.left, rc.bottom - rc.top,
|
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
else if( rc.left > rcview.right)
|
|
|
|
{
|
|
|
|
/* if it was to the right of the shell view
|
|
|
|
* move to right */
|
|
|
|
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
|
|
|
|
rc.right - rc.left, rc.bottom - rc.top,
|
|
|
|
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
}
|
2009-07-09 09:36:04 +02:00
|
|
|
/* size the custom dialog at the end: some applications do some
|
|
|
|
* control re-arranging at this point */
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
DeferWindowPos( hdwp,fodInfos->DlgInfos.hwndCustomDlg, NULL,
|
|
|
|
0, 0, rc.right, rc.bottom, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
2009-04-30 08:06:50 +02:00
|
|
|
}
|
|
|
|
EndDeferWindowPos( hdwp);
|
|
|
|
/* should not be needed */
|
|
|
|
RedrawWindow( hwnd, NULL, 0, RDW_ALLCHILDREN | RDW_INVALIDATE );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FileOpenDlgProc95
|
|
|
|
*
|
|
|
|
* File open dialog procedure
|
|
|
|
*/
|
|
|
|
INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
#if 0
|
2009-06-16 08:17:09 +02:00
|
|
|
TRACE("%p 0x%04x\n", hwnd, uMsg);
|
2003-10-16 02:16:40 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
|
2009-08-08 11:19:42 +02:00
|
|
|
RECT rc, rcstc;
|
2009-04-30 08:06:50 +02:00
|
|
|
int gripx = GetSystemMetrics( SM_CYHSCROLL);
|
|
|
|
int gripy = GetSystemMetrics( SM_CYVSCROLL);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-02-02 16:10:06 +01:00
|
|
|
/* Some shell namespace extensions depend on COM being initialized. */
|
|
|
|
if (SUCCEEDED(OleInitialize(NULL)))
|
|
|
|
fodInfos->ole_initialized = TRUE;
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
SetPropW(hwnd, L"FileOpenDlgInfos", fodInfos);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2007-06-07 21:27:11 +02:00
|
|
|
FILEDLG95_InitControls(hwnd);
|
|
|
|
|
2009-04-30 08:06:50 +02:00
|
|
|
if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
|
|
|
|
{
|
2017-01-25 20:56:09 +01:00
|
|
|
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 );
|
2009-04-30 08:06:50 +02:00
|
|
|
fodInfos->DlgInfos.hwndGrip =
|
|
|
|
CreateWindowExA( 0, "SCROLLBAR", NULL,
|
|
|
|
WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS |
|
|
|
|
SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN,
|
|
|
|
rc.right - gripx, rc.bottom - gripy,
|
|
|
|
gripx, gripy, hwnd, (HMENU) -1, COMDLG32_hInstance, NULL);
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
fodInfos->DlgInfos.hwndCustomDlg =
|
|
|
|
CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
|
|
|
|
|
2007-06-14 10:29:16 +02:00
|
|
|
FILEDLG95_ResizeControls(hwnd, wParam, lParam);
|
2003-10-16 02:16:40 +02:00
|
|
|
FILEDLG95_FillControls(hwnd, wParam, lParam);
|
|
|
|
|
2009-07-02 13:32:28 +02:00
|
|
|
if( fodInfos->DlgInfos.hwndCustomDlg)
|
|
|
|
ShowWindow( fodInfos->DlgInfos.hwndCustomDlg, SW_SHOW);
|
|
|
|
|
2009-07-10 10:07:48 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER) {
|
2009-06-16 08:17:09 +02:00
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
|
2009-07-10 10:07:48 +02:00
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
|
|
|
|
}
|
2009-06-16 08:17:09 +02:00
|
|
|
|
2009-08-08 11:19:42 +02:00
|
|
|
/* if the app has changed the position of the invisible listbox,
|
|
|
|
* change that of the listview (browser) as well */
|
|
|
|
GetWindowRect( fodInfos->ShellInfos.hwndView, &rc);
|
|
|
|
GetWindowRect( GetDlgItem( hwnd, IDC_SHELLSTATIC ), &rcstc);
|
|
|
|
if( !EqualRect( &rc, &rcstc))
|
|
|
|
{
|
|
|
|
MapWindowPoints( NULL, hwnd, (LPPOINT) &rcstc, 2);
|
|
|
|
SetWindowPos( fodInfos->ShellInfos.hwndView, NULL,
|
|
|
|
rcstc.left, rcstc.top, rcstc.right - rcstc.left, rcstc.bottom - rcstc.top,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
|
2009-04-30 08:06:50 +02:00
|
|
|
if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
|
|
|
|
{
|
|
|
|
GetWindowRect( hwnd, &rc);
|
|
|
|
fodInfos->sizedlg.cx = rc.right - rc.left;
|
|
|
|
fodInfos->sizedlg.cy = rc.bottom - rc.top;
|
|
|
|
fodInfos->initial_size.x = fodInfos->sizedlg.cx;
|
|
|
|
fodInfos->initial_size.y = fodInfos->sizedlg.cy;
|
|
|
|
GetClientRect( hwnd, &rc);
|
|
|
|
SetWindowPos( fodInfos->DlgInfos.hwndGrip, NULL,
|
|
|
|
rc.right - gripx, rc.bottom - gripy,
|
|
|
|
0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
|
2009-07-10 10:07:48 +02:00
|
|
|
/* resize the dialog to the previous invocation */
|
|
|
|
if( MemDialogSize.cx && MemDialogSize.cy)
|
|
|
|
SetWindowPos( hwnd, NULL,
|
|
|
|
0, 0, MemDialogSize.cx, MemDialogSize.cy,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
2009-04-30 08:06:50 +02:00
|
|
|
}
|
|
|
|
|
2009-05-05 12:38:34 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
|
2009-07-10 10:07:48 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2009-04-30 08:06:50 +02:00
|
|
|
case WM_SIZE:
|
2010-03-06 14:49:41 +01:00
|
|
|
return FILEDLG95_OnWMSize(hwnd, wParam);
|
2009-04-30 08:06:50 +02:00
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
return FILEDLG95_OnWMGetMMI( hwnd, (LPMINMAXINFO)lParam);
|
2003-10-16 02:16:40 +02:00
|
|
|
case WM_COMMAND:
|
2010-03-06 14:49:41 +01:00
|
|
|
return FILEDLG95_OnWMCommand(hwnd, wParam);
|
2003-10-16 02:16:40 +02:00
|
|
|
case WM_DRAWITEM:
|
|
|
|
{
|
|
|
|
switch(((LPDRAWITEMSTRUCT)lParam)->CtlID)
|
|
|
|
{
|
|
|
|
case IDC_LOOKIN:
|
|
|
|
FILEDLG95_LOOKIN_DrawItem((LPDRAWITEMSTRUCT) lParam);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case WM_GETISHELLBROWSER:
|
|
|
|
return FILEDLG95_OnWMGetIShellBrowser(hwnd);
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
2009-07-10 10:07:48 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos * fodInfos = get_filedlg_infoptr(hwnd);
|
2018-03-16 13:55:43 +01:00
|
|
|
HWND places_bar = GetDlgItem(hwnd, IDC_TOOLBARPLACES);
|
|
|
|
HIMAGELIST himl;
|
|
|
|
|
2009-07-10 10:07:48 +02:00
|
|
|
if (fodInfos && fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
|
|
|
|
MemDialogSize = fodInfos->sizedlg;
|
2018-03-16 13:55:43 +01:00
|
|
|
|
|
|
|
if (places_bar)
|
|
|
|
{
|
|
|
|
himl = (HIMAGELIST)SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_GETIMAGELIST, 0, 0);
|
|
|
|
SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETIMAGELIST, 0, 0);
|
|
|
|
ImageList_Destroy(himl);
|
|
|
|
}
|
2009-07-10 10:07:48 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2018-03-20 08:37:48 +01:00
|
|
|
|
|
|
|
case WM_NCDESTROY:
|
2020-11-23 00:15:51 +01:00
|
|
|
RemovePropW(hwnd, L"FileOpenDlgInfos");
|
2018-03-20 08:37:48 +01:00
|
|
|
return 0;
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR lpnmh = (LPNMHDR)lParam;
|
|
|
|
UINT stringId = -1;
|
|
|
|
|
|
|
|
/* set up the button tooltips strings */
|
|
|
|
if(TTN_GETDISPINFOA == lpnmh->code )
|
|
|
|
{
|
|
|
|
LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
|
|
|
switch(lpnmh->idFrom )
|
|
|
|
{
|
|
|
|
/* Up folder button */
|
|
|
|
case FCIDM_TB_UPFOLDER:
|
|
|
|
stringId = IDS_UPFOLDER;
|
|
|
|
break;
|
|
|
|
/* New folder button */
|
|
|
|
case FCIDM_TB_NEWFOLDER:
|
|
|
|
stringId = IDS_NEWFOLDER;
|
|
|
|
break;
|
|
|
|
/* List option button */
|
|
|
|
case FCIDM_TB_SMALLICON:
|
|
|
|
stringId = IDS_LISTVIEW;
|
|
|
|
break;
|
|
|
|
/* Details option button */
|
|
|
|
case FCIDM_TB_REPORTVIEW:
|
|
|
|
stringId = IDS_REPORTVIEW;
|
|
|
|
break;
|
|
|
|
/* Desktop button */
|
|
|
|
case FCIDM_TB_DESKTOP:
|
|
|
|
stringId = IDS_TODESKTOP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stringId = 0;
|
|
|
|
}
|
|
|
|
lpdi->hinst = COMDLG32_hInstance;
|
2005-09-02 13:32:17 +02:00
|
|
|
lpdi->lpszText = MAKEINTRESOURCEA(stringId);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
default :
|
|
|
|
if(uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
|
|
|
|
return FILEDLG95_HandleCustomDialogMessages(hwnd, uMsg, wParam, lParam);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-25 13:40:19 +02:00
|
|
|
static inline BOOL filename_is_edit( const FileOpenDlgInfos *info )
|
|
|
|
{
|
|
|
|
return (info->ofnInfos->lStructSize == OPENFILENAME_SIZE_VERSION_400W) &&
|
|
|
|
(info->ofnInfos->Flags & (OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE));
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_InitControls
|
|
|
|
*
|
|
|
|
* WM_INITDIALOG message handler (before hook notification)
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_InitControls(HWND hwnd)
|
|
|
|
{
|
2013-10-10 21:52:41 +02:00
|
|
|
BOOL win2000plus = FALSE;
|
|
|
|
BOOL win98plus = FALSE;
|
|
|
|
BOOL handledPath = FALSE;
|
2007-03-07 14:19:19 +01:00
|
|
|
OSVERSIONINFOW osVi;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2007-03-07 14:19:19 +01:00
|
|
|
static const TBBUTTON tbb[] =
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2004-02-09 22:01:10 +01:00
|
|
|
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
|
|
|
|
{VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
|
|
|
|
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
|
|
|
|
{VIEW_NEWFOLDER+1, FCIDM_TB_DESKTOP, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
|
|
|
|
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
|
|
|
|
{VIEW_NEWFOLDER, FCIDM_TB_NEWFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
|
|
|
|
{0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
|
|
|
|
{VIEW_LIST, FCIDM_TB_SMALLICON, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
|
|
|
|
{VIEW_DETAILS, FCIDM_TB_REPORTVIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0 },
|
2003-10-16 02:16:40 +02:00
|
|
|
};
|
2009-10-03 11:12:55 +02:00
|
|
|
static const TBADDBITMAP tba = {HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR};
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
RECT rectTB;
|
|
|
|
RECT rectlook;
|
|
|
|
|
2009-10-03 11:12:55 +02:00
|
|
|
HIMAGELIST toolbarImageList;
|
|
|
|
ITEMIDLIST *desktopPidl;
|
2018-03-16 13:55:43 +01:00
|
|
|
SHFILEINFOW fileinfo;
|
2009-10-03 11:12:55 +02:00
|
|
|
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("%p\n", fodInfos);
|
|
|
|
|
|
|
|
/* Get windows version emulating */
|
2007-03-07 14:19:19 +01:00
|
|
|
osVi.dwOSVersionInfoSize = sizeof(osVi);
|
|
|
|
GetVersionExW(&osVi);
|
2003-10-16 02:16:40 +02:00
|
|
|
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) {
|
|
|
|
win2000plus = (osVi.dwMajorVersion > 4);
|
|
|
|
if (win2000plus) win98plus = TRUE;
|
|
|
|
}
|
|
|
|
TRACE("Running on 2000+ %d, 98+ %d\n", win2000plus, win98plus);
|
|
|
|
|
2012-09-25 13:40:19 +02:00
|
|
|
|
|
|
|
/* Use either the edit or the comboboxex for the filename control */
|
|
|
|
if (filename_is_edit( fodInfos ))
|
|
|
|
{
|
|
|
|
DestroyWindow( GetDlgItem( hwnd, cmb13 ) );
|
|
|
|
fodInfos->DlgInfos.hwndFileName = GetDlgItem( hwnd, edt1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DestroyWindow( GetDlgItem( hwnd, edt1 ) );
|
|
|
|
fodInfos->DlgInfos.hwndFileName = GetDlgItem( hwnd, cmb13 );
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Get the hwnd of the controls */
|
|
|
|
fodInfos->DlgInfos.hwndFileTypeCB = GetDlgItem(hwnd,IDC_FILETYPE);
|
|
|
|
fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
|
|
|
|
|
|
|
|
GetWindowRect( fodInfos->DlgInfos.hwndLookInCB,&rectlook);
|
|
|
|
MapWindowPoints( 0, hwnd,(LPPOINT)&rectlook,2);
|
|
|
|
|
|
|
|
/* construct the toolbar */
|
|
|
|
GetWindowRect(GetDlgItem(hwnd,IDC_TOOLBARSTATIC),&rectTB);
|
|
|
|
MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
|
|
|
|
|
|
|
|
rectTB.right = rectlook.right + rectTB.right - rectTB.left;
|
|
|
|
rectTB.bottom = rectlook.top - 1 + rectTB.bottom - rectTB.top;
|
|
|
|
rectTB.left = rectlook.right;
|
|
|
|
rectTB.top = rectlook.top-1;
|
|
|
|
|
2006-07-24 14:45:32 +02:00
|
|
|
if (fodInfos->unicode)
|
|
|
|
fodInfos->DlgInfos.hwndTB = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
|
2018-03-21 06:59:40 +01:00
|
|
|
WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_NODIVIDER | CCS_NORESIZE,
|
2006-07-24 14:45:32 +02:00
|
|
|
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,
|
2018-03-21 06:59:40 +01:00
|
|
|
WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_NODIVIDER | CCS_NORESIZE,
|
2006-07-24 14:45:32 +02:00
|
|
|
rectTB.left, rectTB.top,
|
|
|
|
rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
|
|
|
|
hwnd, (HMENU)IDC_TOOLBAR, COMDLG32_hInstance, NULL);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2007-03-07 14:19:19 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* FIXME: use TB_LOADIMAGES when implemented */
|
2007-03-07 14:19:19 +01:00
|
|
|
/* SendMessageW(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
|
2009-07-28 12:19:20 +02:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndTB, TB_SETMAXTEXTROWS, 0, 0);
|
2009-10-03 11:12:55 +02:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, 12, (LPARAM) &tba);
|
|
|
|
|
|
|
|
/* Retrieve and add desktop icon to the toolbar */
|
|
|
|
toolbarImageList = (HIMAGELIST)SendMessageW(fodInfos->DlgInfos.hwndTB, TB_GETIMAGELIST, 0, 0L);
|
|
|
|
SHGetSpecialFolderLocation(hwnd, CSIDL_DESKTOP, &desktopPidl);
|
2018-03-16 13:55:43 +01:00
|
|
|
SHGetFileInfoW((const WCHAR *)desktopPidl, 0, &fileinfo, sizeof(fileinfo),
|
2009-10-03 11:12:55 +02:00
|
|
|
SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON);
|
2018-03-16 13:55:43 +01:00
|
|
|
ImageList_AddIcon(toolbarImageList, fileinfo.hIcon);
|
2009-10-03 11:12:55 +02:00
|
|
|
|
2018-03-16 13:55:43 +01:00
|
|
|
DestroyIcon(fileinfo.hIcon);
|
2009-10-03 11:12:55 +02:00
|
|
|
CoTaskMemFree(desktopPidl);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2009-10-03 11:12:55 +02:00
|
|
|
/* Finish Toolbar Construction */
|
2008-07-09 21:36:41 +02:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSW, 9, (LPARAM) tbb);
|
2007-03-07 14:19:19 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-16 13:55:43 +01:00
|
|
|
if (is_places_bar_enabled(fodInfos))
|
|
|
|
{
|
|
|
|
TBBUTTON tb = { 0 };
|
|
|
|
HIMAGELIST himl;
|
|
|
|
RECT rect;
|
|
|
|
int i, cx;
|
|
|
|
|
|
|
|
SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_BUTTONSTRUCTSIZE, 0, 0);
|
|
|
|
GetClientRect(GetDlgItem(hwnd, IDC_TOOLBARPLACES), &rect);
|
|
|
|
cx = rect.right - rect.left;
|
|
|
|
|
|
|
|
SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETBUTTONWIDTH, 0, MAKELPARAM(cx, cx));
|
|
|
|
himl = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), ILC_COLOR32, 4, 1);
|
2018-03-21 06:59:41 +01:00
|
|
|
|
|
|
|
filedlg_collect_places_pidls(fodInfos);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
|
2018-03-16 13:55:43 +01:00
|
|
|
{
|
2018-03-21 06:59:41 +01:00
|
|
|
int index;
|
|
|
|
|
|
|
|
if (!fodInfos->places[i])
|
|
|
|
continue;
|
2018-03-16 13:55:43 +01:00
|
|
|
|
|
|
|
memset(&fileinfo, 0, sizeof(fileinfo));
|
2018-03-21 06:59:41 +01:00
|
|
|
SHGetFileInfoW((const WCHAR *)fodInfos->places[i], 0, &fileinfo, sizeof(fileinfo),
|
2018-03-16 13:55:43 +01:00
|
|
|
SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_ICON);
|
2018-03-21 06:59:41 +01:00
|
|
|
index = ImageList_AddIcon(himl, fileinfo.hIcon);
|
2018-03-16 13:55:43 +01:00
|
|
|
|
2018-03-21 06:59:41 +01:00
|
|
|
tb.iBitmap = index;
|
2018-03-16 13:55:43 +01:00
|
|
|
tb.iString = (INT_PTR)fileinfo.szDisplayName;
|
|
|
|
tb.fsState = TBSTATE_ENABLED | TBSTATE_WRAP;
|
2018-03-21 06:59:41 +01:00
|
|
|
tb.idCommand = TBPLACES_CMDID_PLACE0 + i;
|
2018-03-16 13:55:43 +01:00
|
|
|
SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_ADDBUTTONSW, 1, (LPARAM)&tb);
|
|
|
|
|
|
|
|
DestroyIcon(fileinfo.hIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETIMAGELIST, 0, (LPARAM)himl);
|
|
|
|
SendDlgItemMessageW(hwnd, IDC_TOOLBARPLACES, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, cx * 3 / 4));
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Set the window text with the text specified in the OPENFILENAME structure */
|
|
|
|
if(fodInfos->title)
|
|
|
|
{
|
|
|
|
SetWindowTextW(hwnd,fodInfos->title);
|
|
|
|
}
|
|
|
|
else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
|
|
|
|
{
|
2011-12-16 08:48:01 +01:00
|
|
|
WCHAR buf[64];
|
2018-03-29 17:14:12 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, IDS_SAVE_AS, buf, ARRAY_SIZE(buf));
|
2005-01-09 17:31:36 +01:00
|
|
|
SetWindowTextW(hwnd, buf);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialise the file name edit control */
|
|
|
|
handledPath = FALSE;
|
2011-07-30 12:03:08 +02:00
|
|
|
TRACE("Before manipulation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if(fodInfos->filename)
|
|
|
|
{
|
|
|
|
/* 1. If win2000 or higher and filename contains a path, use it
|
|
|
|
in preference over the lpstrInitialDir */
|
2020-11-23 00:15:51 +01:00
|
|
|
if (win2000plus && *fodInfos->filename && wcspbrk(fodInfos->filename, L"\\")) {
|
2003-10-16 02:16:40 +02:00
|
|
|
WCHAR tmpBuf[MAX_PATH];
|
|
|
|
WCHAR *nameBit;
|
|
|
|
DWORD result;
|
|
|
|
|
|
|
|
result = GetFullPathNameW(fodInfos->filename, MAX_PATH, tmpBuf, &nameBit);
|
|
|
|
if (result) {
|
|
|
|
|
2016-10-27 08:53:27 +02:00
|
|
|
/* 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';
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->initdir);
|
|
|
|
fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(fodInfos->initdir, tmpBuf);
|
2003-10-16 02:16:40 +02:00
|
|
|
handledPath = TRUE;
|
|
|
|
TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
|
|
|
|
debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
|
|
|
|
}
|
2012-09-25 13:40:18 +02:00
|
|
|
SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
} else {
|
2012-09-25 13:40:18 +02:00
|
|
|
SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 2. (All platforms) If initdir is not null, then use it */
|
2013-10-10 21:52:41 +02:00
|
|
|
if (!handledPath && fodInfos->initdir && *fodInfos->initdir)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2014-11-26 12:08:37 +01:00
|
|
|
/* 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);
|
2020-11-23 00:15:51 +01:00
|
|
|
lstrcatW(tmpBuf, L"*");
|
2014-11-26 12:08:37 +01:00
|
|
|
}
|
|
|
|
result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
|
|
|
|
if (result) {
|
|
|
|
*nameBit = 0x00;
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->initdir);
|
|
|
|
fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
|
2014-11-26 12:08:37 +01:00
|
|
|
lstrcpyW(fodInfos->initdir, tmpBuf2);
|
|
|
|
handledPath = TRUE;
|
|
|
|
TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fodInfos->initdir)
|
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->initdir);
|
2014-11-26 12:08:37 +01:00
|
|
|
fodInfos->initdir = NULL;
|
|
|
|
TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2013-10-10 21:52:41 +02:00
|
|
|
if (!handledPath && (!fodInfos->initdir || !*fodInfos->initdir))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
/* 3. All except w2k+: if filename contains a path use it */
|
2020-11-23 00:15:51 +01:00
|
|
|
if (!win2000plus && fodInfos->filename && *fodInfos->filename &&
|
|
|
|
wcspbrk(fodInfos->filename, L"\\")) {
|
2003-10-16 02:16:40 +02:00
|
|
|
WCHAR tmpBuf[MAX_PATH];
|
|
|
|
WCHAR *nameBit;
|
|
|
|
DWORD result;
|
|
|
|
|
|
|
|
result = GetFullPathNameW(fodInfos->filename, MAX_PATH,
|
|
|
|
tmpBuf, &nameBit);
|
|
|
|
if (result) {
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* nameBit is always shorter than the original filename */
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(fodInfos->filename, nameBit);
|
2003-10-16 02:16:40 +02:00
|
|
|
*nameBit = 0x00;
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
len = lstrlenW(tmpBuf);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->initdir);
|
|
|
|
fodInfos->initdir = heap_alloc((len+1)*sizeof(WCHAR));
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(fodInfos->initdir, tmpBuf);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
handledPath = TRUE;
|
|
|
|
TRACE("Value in Filename includes path, overriding initdir: %s, %s\n",
|
|
|
|
debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
|
|
|
|
}
|
2012-09-25 13:40:18 +02:00
|
|
|
SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2010-07-23 20:13:04 +02:00
|
|
|
/* 4. Win2000+: Recently used */
|
2013-10-10 21:52:41 +02:00
|
|
|
if (!handledPath && win2000plus) {
|
2018-03-20 08:37:47 +01:00
|
|
|
fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
|
2010-07-23 20:13:04 +02:00
|
|
|
fodInfos->initdir[0] = '\0';
|
|
|
|
|
|
|
|
FILEDLG95_MRU_load_filename(fodInfos->initdir);
|
|
|
|
|
|
|
|
if (fodInfos->initdir[0] && PathFileExistsW(fodInfos->initdir)){
|
|
|
|
handledPath = TRUE;
|
|
|
|
}else{
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->initdir);
|
2010-07-23 20:13:04 +02:00
|
|
|
fodInfos->initdir = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 5. win98+ and win2000+ if any files of specified filter types in
|
2003-10-16 02:16:40 +02:00
|
|
|
current directory, use it */
|
2013-10-10 21:52:41 +02:00
|
|
|
if (win98plus && !handledPath && fodInfos->filter && *fodInfos->filter) {
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
LPCWSTR lpstrPos = fodInfos->filter;
|
|
|
|
WIN32_FIND_DATAW FindFileData;
|
|
|
|
HANDLE hFind;
|
|
|
|
|
2009-12-10 00:01:59 +01:00
|
|
|
while (1)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
/* filter is a list... title\0ext\0......\0\0 */
|
|
|
|
|
|
|
|
/* Skip the title */
|
|
|
|
if(! *lpstrPos) break; /* end */
|
2007-03-07 14:18:40 +01:00
|
|
|
lpstrPos += lstrlenW(lpstrPos) + 1;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* See if any files exist in the current dir with this extension */
|
|
|
|
if(! *lpstrPos) break; /* end */
|
|
|
|
|
|
|
|
hFind = FindFirstFileW(lpstrPos, &FindFileData);
|
|
|
|
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE) {
|
|
|
|
/* None found - continue search */
|
2007-03-07 14:18:40 +01:00
|
|
|
lpstrPos += lstrlenW(lpstrPos) + 1;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->initdir);
|
|
|
|
fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
|
2003-10-16 02:16:40 +02:00
|
|
|
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
|
|
|
|
|
|
|
|
handledPath = TRUE;
|
|
|
|
TRACE("No initial dir specified, but files of type %s found in current, so using it\n",
|
|
|
|
debugstr_w(lpstrPos));
|
2009-12-10 00:01:59 +01:00
|
|
|
FindClose(hFind);
|
2003-10-16 02:16:40 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 6. Win98+ and 2000+: Use personal files dir, others use current dir */
|
2013-10-10 21:52:41 +02:00
|
|
|
if (!handledPath && (win2000plus || win98plus)) {
|
2018-03-20 08:37:47 +01:00
|
|
|
fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
if (SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir) == S_OK)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2018-03-21 06:59:42 +01:00
|
|
|
if (SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, fodInfos->initdir) == S_OK)
|
|
|
|
{
|
|
|
|
/* last fallback */
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
|
|
|
|
TRACE("No personal or desktop dir, using cwd as failsafe: %s\n", debugstr_w(fodInfos->initdir));
|
|
|
|
}
|
|
|
|
else
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("No personal dir, using desktop instead: %s\n", debugstr_w(fodInfos->initdir));
|
|
|
|
}
|
2018-03-21 06:59:42 +01:00
|
|
|
else
|
|
|
|
TRACE("No initial dir specified, using personal files dir of %s\n", debugstr_w(fodInfos->initdir));
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
handledPath = TRUE;
|
2013-10-10 21:52:41 +02:00
|
|
|
} else if (!handledPath) {
|
2018-03-20 08:37:47 +01:00
|
|
|
fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
|
2003-10-16 02:16:40 +02:00
|
|
|
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
|
|
|
|
handledPath = TRUE;
|
|
|
|
TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir));
|
|
|
|
}
|
|
|
|
}
|
2012-09-25 13:40:18 +02:00
|
|
|
SetFocus( fodInfos->DlgInfos.hwndFileName );
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("After manipulation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
|
|
|
|
|
|
|
|
/* Must the open as read only check box be checked ?*/
|
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_READONLY)
|
|
|
|
{
|
2007-03-07 14:19:19 +01:00
|
|
|
SendDlgItemMessageW(hwnd,IDC_OPENREADONLY,BM_SETCHECK,TRUE,0);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Must the open as read only check box be hidden? */
|
2018-03-25 17:51:17 +02:00
|
|
|
if (filedialog_is_readonly_hidden(fodInfos))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_OPENREADONLY), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must the help button be hidden? */
|
|
|
|
if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP))
|
|
|
|
{
|
|
|
|
ShowWindow(GetDlgItem(hwnd, pshHelp), SW_HIDE);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, pshHelp), FALSE);
|
|
|
|
}
|
|
|
|
|
2005-01-09 17:31:36 +01:00
|
|
|
/* change Open to Save */
|
2003-10-16 02:16:40 +02:00
|
|
|
if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
|
|
|
|
{
|
2005-01-09 17:31:36 +01:00
|
|
|
WCHAR buf[16];
|
2018-03-29 17:14:12 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, IDS_SAVE_BUTTON, buf, ARRAY_SIZE(buf));
|
2005-01-09 17:31:36 +01:00
|
|
|
SetDlgItemTextW(hwnd, IDOK, buf);
|
2018-03-29 17:14:12 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, IDS_SAVE_IN, buf, ARRAY_SIZE(buf));
|
2005-01-09 17:31:36 +01:00
|
|
|
SetDlgItemTextW(hwnd, IDC_LOOKINSTATIC, buf);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2008-10-21 20:11:23 +02:00
|
|
|
|
|
|
|
/* Initialize the filter combo box */
|
|
|
|
FILEDLG95_FILETYPE_Init(hwnd);
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-14 10:29:16 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* 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,
|
2018-03-25 17:51:17 +02:00
|
|
|
filedialog_is_readonly_hidden(fodInfos) && !(fodInfos->ofnInfos->Flags & OFN_SHOWHELP));
|
2007-06-14 10:29:16 +02:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
2012-12-15 15:43:22 +01:00
|
|
|
SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
|
|
|
|
0, 0, rc.right, rc.bottom, flags);
|
2007-06-14 10:29:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-30 15:42:10 +02:00
|
|
|
/* Resize the height; if opened as read-only, checkbox and help button are
|
2007-06-14 10:29:16 +02:00
|
|
|
* hidden and we are not using a custom template nor a customDialog
|
|
|
|
*/
|
2018-03-25 17:51:17 +02:00
|
|
|
if (filedialog_is_readonly_hidden(fodInfos) &&
|
2007-06-14 10:29:16 +02:00
|
|
|
(!(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;
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FillControls
|
|
|
|
*
|
|
|
|
* WM_INITDIALOG message handler (after hook notification)
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlItemId = NULL;
|
|
|
|
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
|
|
|
|
|
|
|
|
TRACE("dir=%s file=%s\n",
|
|
|
|
debugstr_w(fodInfos->initdir), debugstr_w(fodInfos->filename));
|
|
|
|
|
|
|
|
/* Get the initial directory pidl */
|
|
|
|
|
|
|
|
if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->initdir)))
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
|
|
|
|
GetCurrentDirectoryW(MAX_PATH,path);
|
|
|
|
pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialise shell objects */
|
|
|
|
FILEDLG95_SHELL_Init(hwnd);
|
|
|
|
|
|
|
|
/* Initialize the Look In combo box */
|
|
|
|
FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB);
|
|
|
|
|
|
|
|
/* Browse to the initial directory */
|
|
|
|
IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId, SBSP_ABSOLUTE);
|
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlItemId);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_Clean
|
|
|
|
*
|
|
|
|
* Regroups all the cleaning functions of the filedlg
|
|
|
|
*/
|
|
|
|
void FILEDLG95_Clean(HWND hwnd)
|
|
|
|
{
|
|
|
|
FILEDLG95_FILETYPE_Clean(hwnd);
|
|
|
|
FILEDLG95_LOOKIN_Clean(hwnd);
|
|
|
|
FILEDLG95_SHELL_Clean(hwnd);
|
|
|
|
}
|
2018-03-16 13:55:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2018-03-21 06:59:41 +01:00
|
|
|
* Browse to arbitrary pidl
|
2018-03-16 13:55:43 +01:00
|
|
|
*/
|
2018-03-21 06:59:41 +01:00
|
|
|
static void filedlg_browse_to_pidl(const FileOpenDlgInfos *info, LPITEMIDLIST pidl)
|
2018-03-16 13:55:43 +01:00
|
|
|
{
|
2018-03-21 06:59:41 +01:00
|
|
|
TRACE("%p, %p\n", info->ShellInfos.hwndOwner, pidl);
|
2018-03-16 13:55:43 +01:00
|
|
|
|
|
|
|
IShellBrowser_BrowseObject(info->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
|
|
|
|
if (info->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
SendCustomDlgNotificationMessage(info->ShellInfos.hwndOwner, CDN_FOLDERCHANGE);
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnWMCommand
|
|
|
|
*
|
|
|
|
* WM_COMMAND message handler
|
|
|
|
*/
|
2010-03-06 14:49:41 +01:00
|
|
|
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
WORD wNotifyCode = HIWORD(wParam); /* notification code */
|
2018-03-21 06:59:41 +01:00
|
|
|
WORD id = LOWORD(wParam); /* item, control, or accelerator identifier */
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-21 06:59:41 +01:00
|
|
|
switch (id)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
/* OK button */
|
|
|
|
case IDOK:
|
|
|
|
FILEDLG95_OnOpen(hwnd);
|
|
|
|
break;
|
|
|
|
/* Cancel button */
|
|
|
|
case IDCANCEL:
|
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
EndDialog(hwnd, FALSE);
|
|
|
|
break;
|
|
|
|
/* Filetype combo box */
|
|
|
|
case IDC_FILETYPE:
|
|
|
|
FILEDLG95_FILETYPE_OnCommand(hwnd,wNotifyCode);
|
|
|
|
break;
|
|
|
|
/* LookIn combo box */
|
|
|
|
case IDC_LOOKIN:
|
|
|
|
FILEDLG95_LOOKIN_OnCommand(hwnd,wNotifyCode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* --- toolbar --- */
|
|
|
|
/* Up folder button */
|
|
|
|
case FCIDM_TB_UPFOLDER:
|
|
|
|
FILEDLG95_SHELL_UpFolder(hwnd);
|
|
|
|
break;
|
|
|
|
/* New folder button */
|
|
|
|
case FCIDM_TB_NEWFOLDER:
|
|
|
|
FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_NEWFOLDERA);
|
|
|
|
break;
|
|
|
|
/* List option button */
|
|
|
|
case FCIDM_TB_SMALLICON:
|
|
|
|
FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWLISTA);
|
|
|
|
break;
|
|
|
|
/* Details option button */
|
|
|
|
case FCIDM_TB_REPORTVIEW:
|
|
|
|
FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILSA);
|
|
|
|
break;
|
2018-03-16 13:55:43 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
case FCIDM_TB_DESKTOP:
|
2018-03-21 06:59:41 +01:00
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
2018-03-16 13:55:43 +01:00
|
|
|
|
2018-03-21 06:59:41 +01:00
|
|
|
SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidl);
|
|
|
|
filedlg_browse_to_pidl(fodInfos, pidl);
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidl);
|
2018-03-16 13:55:43 +01:00
|
|
|
break;
|
2018-03-21 06:59:41 +01:00
|
|
|
}
|
2018-03-16 13:55:43 +01:00
|
|
|
|
2018-03-21 06:59:41 +01:00
|
|
|
/* Places bar */
|
|
|
|
case TBPLACES_CMDID_PLACE0:
|
|
|
|
case TBPLACES_CMDID_PLACE1:
|
|
|
|
case TBPLACES_CMDID_PLACE2:
|
|
|
|
case TBPLACES_CMDID_PLACE3:
|
|
|
|
case TBPLACES_CMDID_PLACE4:
|
|
|
|
filedlg_browse_to_pidl(fodInfos, fodInfos->places[id - TBPLACES_CMDID_PLACE0]);
|
2003-10-16 02:16:40 +02:00
|
|
|
break;
|
|
|
|
|
2012-09-25 13:40:19 +02:00
|
|
|
case edt1:
|
|
|
|
case cmb13:
|
2003-10-16 02:16:40 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* Do not use the listview selection anymore */
|
|
|
|
fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnWMGetIShellBrowser
|
|
|
|
*
|
|
|
|
* WM_GETISHELLBROWSER message handler
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
|
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2005-02-15 22:51:06 +01:00
|
|
|
SetWindowLongPtrW(hwnd,DWLP_MSGRESULT,(LONG_PTR)fodInfos->Shell.FOIShellBrowser);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_SendFileOK
|
|
|
|
*
|
|
|
|
* Sends the CDN_FILEOK notification if required
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if the dialog should close
|
|
|
|
* FALSE if the dialog should not be closed
|
|
|
|
*/
|
|
|
|
static BOOL FILEDLG95_SendFileOK( HWND hwnd, FileOpenDlgInfos *fodInfos )
|
|
|
|
{
|
|
|
|
/* ask the hook if we can close */
|
2018-03-20 08:37:50 +01:00
|
|
|
if (is_dialog_hooked(fodInfos))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2009-05-05 12:38:34 +02:00
|
|
|
LRESULT retval = 0;
|
2006-01-12 13:30:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("---\n");
|
|
|
|
/* First send CDN_FILEOK as MSDN doc says */
|
2009-05-05 12:38:34 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
retval = SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
|
2009-06-30 08:41:10 +02:00
|
|
|
if( retval)
|
2004-01-19 22:51:29 +01:00
|
|
|
{
|
|
|
|
TRACE("canceled\n");
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
2004-01-19 22:51:29 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* fodInfos->ofnInfos points to an ASCII or UNICODE structure as appropriate */
|
2006-01-12 13:30:11 +01:00
|
|
|
retval = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,
|
|
|
|
fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
|
2009-06-30 08:41:10 +02:00
|
|
|
if( retval)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
TRACE("canceled\n");
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnOpenMultipleFiles
|
|
|
|
*
|
|
|
|
* Handles the opening of multiple files.
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* check destination buffer size
|
|
|
|
*/
|
|
|
|
BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
|
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
WCHAR lpstrPathSpec[MAX_PATH] = {0};
|
|
|
|
UINT nCount, nSizePath;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(fodInfos->unicode)
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
ofn->lpstrFile[0] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEA ofn = (LPOPENFILENAMEA) fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
ofn->lpstrFile[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2005-05-26 14:23:57 +02:00
|
|
|
COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
|
|
|
|
( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
|
|
|
|
! ( fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG ) )
|
|
|
|
{
|
|
|
|
LPWSTR lpstrTemp = lpstrFileList;
|
|
|
|
|
|
|
|
for ( nCount = 0; nCount < nFileCount; nCount++ )
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
|
|
|
|
pidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrTemp);
|
|
|
|
if (!pidl)
|
|
|
|
{
|
|
|
|
WCHAR lpstrNotFound[100];
|
|
|
|
WCHAR lpstrMsg[100];
|
|
|
|
WCHAR tmp[400];
|
|
|
|
|
|
|
|
LoadStringW(COMDLG32_hInstance, IDS_FILENOTFOUND, lpstrNotFound, 100);
|
|
|
|
LoadStringW(COMDLG32_hInstance, IDS_VERIFYFILE, lpstrMsg, 100);
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(tmp, lpstrTemp);
|
2020-11-23 00:15:51 +01:00
|
|
|
lstrcatW(tmp, L"\n");
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcatW(tmp, lpstrNotFound);
|
2020-11-23 00:15:51 +01:00
|
|
|
lstrcatW(tmp, L"\n");
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcatW(tmp, lpstrMsg);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
MessageBoxW(hwnd, tmp, fodInfos->title, MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* move to the next file in the list of files */
|
2007-03-07 14:18:40 +01:00
|
|
|
lpstrTemp += lstrlenW(lpstrTemp) + 1;
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidl);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
nSizePath = lstrlenW(lpstrPathSpec) + 1;
|
2003-10-16 02:16:40 +02:00
|
|
|
if ( !(fodInfos->ofnInfos->Flags & OFN_EXPLORER) )
|
|
|
|
{
|
|
|
|
/* For "oldstyle" dialog the components have to
|
2004-01-27 01:01:43 +01:00
|
|
|
be separated by blanks (not '\0'!) and short
|
2003-10-16 02:16:40 +02:00
|
|
|
filenames have to be used! */
|
2004-01-27 01:01:43 +01:00
|
|
|
FIXME("Components have to be separated by blanks\n");
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
if(fodInfos->unicode)
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW( ofn->lpstrFile, lpstrPathSpec);
|
2003-10-16 02:16:40 +02:00
|
|
|
memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if (ofn->lpstrFile != NULL)
|
|
|
|
{
|
2004-11-24 19:10:24 +01:00
|
|
|
nSizePath = WideCharToMultiByte(CP_ACP, 0, lpstrPathSpec, -1,
|
2003-10-16 02:16:40 +02:00
|
|
|
ofn->lpstrFile, ofn->nMaxFile, NULL, NULL);
|
|
|
|
if (ofn->nMaxFile > nSizePath)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
|
|
|
|
ofn->lpstrFile + nSizePath,
|
|
|
|
ofn->nMaxFile - nSizePath, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-24 19:10:24 +01:00
|
|
|
fodInfos->ofnInfos->nFileOffset = nSizePath;
|
2003-10-16 02:16:40 +02:00
|
|
|
fodInfos->ofnInfos->nFileExtension = 0;
|
|
|
|
|
|
|
|
if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* clean and exit */
|
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
return EndDialog(hwnd,TRUE);
|
|
|
|
}
|
|
|
|
|
2010-07-23 20:13:04 +02:00
|
|
|
/* Returns the 'slot name' of the given module_name in the registry's
|
|
|
|
* most-recently-used list. This will be an ASCII value in the
|
|
|
|
* range ['a','z'). Returns zero on error.
|
|
|
|
*
|
|
|
|
* The slot's value in the registry has the form:
|
|
|
|
* module_name\0mru_path\0
|
|
|
|
*
|
|
|
|
* If stored_path is given, then stored_path will contain the path name
|
|
|
|
* stored in the registry's MRU list for the given module_name.
|
|
|
|
*
|
|
|
|
* If hkey_ret is given, then hkey_ret will be a handle to the registry's
|
|
|
|
* MRU list key for the given module_name.
|
|
|
|
*/
|
|
|
|
static WCHAR FILEDLG95_MRU_get_slot(LPCWSTR module_name, LPWSTR stored_path, PHKEY hkey_ret)
|
|
|
|
{
|
|
|
|
WCHAR mru_list[32], *cur_mru_slot;
|
|
|
|
BOOL taken[25] = {0};
|
|
|
|
DWORD mru_list_size = sizeof(mru_list), key_type = -1, i;
|
|
|
|
HKEY hkey_tmp, *hkey;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
if(hkey_ret)
|
|
|
|
hkey = hkey_ret;
|
|
|
|
else
|
|
|
|
hkey = &hkey_tmp;
|
|
|
|
|
|
|
|
if(stored_path)
|
|
|
|
*stored_path = '\0';
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
ret = RegCreateKeyW(HKEY_CURRENT_USER,
|
|
|
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", hkey);
|
2010-07-23 20:13:04 +02:00
|
|
|
if(ret){
|
|
|
|
WARN("Unable to create MRU key: %d\n", ret);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
ret = RegGetValueW(*hkey, NULL, L"MRUList", RRF_RT_REG_SZ, &key_type,
|
2010-07-23 20:13:04 +02:00
|
|
|
(LPBYTE)mru_list, &mru_list_size);
|
|
|
|
if(ret || key_type != REG_SZ){
|
|
|
|
if(ret == ERROR_FILE_NOT_FOUND)
|
|
|
|
return 'a';
|
|
|
|
|
|
|
|
WARN("Error getting MRUList data: type: %d, ret: %d\n", key_type, ret);
|
|
|
|
RegCloseKey(*hkey);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(cur_mru_slot = mru_list; *cur_mru_slot; ++cur_mru_slot){
|
|
|
|
WCHAR value_data[MAX_PATH], value_name[2] = {0};
|
|
|
|
DWORD value_data_size = sizeof(value_data);
|
|
|
|
|
|
|
|
*value_name = *cur_mru_slot;
|
|
|
|
|
|
|
|
ret = RegGetValueW(*hkey, NULL, value_name, RRF_RT_REG_BINARY,
|
|
|
|
&key_type, (LPBYTE)value_data, &value_data_size);
|
|
|
|
if(ret || key_type != REG_BINARY){
|
|
|
|
WARN("Error getting MRU slot data: type: %d, ret: %d\n", key_type, ret);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-05-29 08:48:52 +02:00
|
|
|
if(!wcsicmp(module_name, value_data)){
|
2010-07-23 20:13:04 +02:00
|
|
|
if(!hkey_ret)
|
|
|
|
RegCloseKey(*hkey);
|
|
|
|
if(stored_path)
|
|
|
|
lstrcpyW(stored_path, value_data + lstrlenW(value_data) + 1);
|
|
|
|
return *value_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!hkey_ret)
|
|
|
|
RegCloseKey(*hkey);
|
|
|
|
|
|
|
|
/* the module name isn't in the registry, so find the next open slot */
|
|
|
|
for(cur_mru_slot = mru_list; *cur_mru_slot; ++cur_mru_slot)
|
|
|
|
taken[*cur_mru_slot - 'a'] = TRUE;
|
|
|
|
for(i = 0; i < 25; ++i){
|
|
|
|
if(!taken[i])
|
|
|
|
return i + 'a';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all slots are taken, so return the last one in MRUList */
|
|
|
|
--cur_mru_slot;
|
|
|
|
return *cur_mru_slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save the given filename as most-recently-used path for this module */
|
|
|
|
static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
|
|
|
|
{
|
|
|
|
WCHAR module_path[MAX_PATH], *module_name, slot, slot_name[2] = {0};
|
|
|
|
LONG ret;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
/* get the current executable's name */
|
2018-03-29 17:14:12 +02:00
|
|
|
if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
|
|
|
|
{
|
2010-07-23 20:13:04 +02:00
|
|
|
WARN("GotModuleFileName failed: %d\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
2019-05-29 08:48:52 +02:00
|
|
|
module_name = wcsrchr(module_path, '\\');
|
2010-07-23 20:13:04 +02:00
|
|
|
if(!module_name)
|
|
|
|
module_name = module_path;
|
|
|
|
else
|
|
|
|
module_name += 1;
|
|
|
|
|
|
|
|
slot = FILEDLG95_MRU_get_slot(module_name, NULL, &hkey);
|
|
|
|
if(!slot)
|
|
|
|
return;
|
|
|
|
*slot_name = slot;
|
|
|
|
|
|
|
|
{ /* update the slot's info */
|
|
|
|
WCHAR *path_ends, *final;
|
|
|
|
DWORD path_len, final_len;
|
|
|
|
|
|
|
|
/* use only the path segment of `filename' */
|
2019-05-29 08:48:52 +02:00
|
|
|
path_ends = wcsrchr(filename, '\\');
|
2010-07-23 20:13:04 +02:00
|
|
|
path_len = path_ends - filename;
|
|
|
|
|
|
|
|
final_len = path_len + lstrlenW(module_name) + 2;
|
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
final = heap_alloc(final_len * sizeof(WCHAR));
|
2010-07-23 20:13:04 +02:00
|
|
|
if(!final)
|
|
|
|
return;
|
|
|
|
lstrcpyW(final, module_name);
|
|
|
|
memcpy(final + lstrlenW(final) + 1, filename, path_len * sizeof(WCHAR));
|
|
|
|
final[final_len-1] = '\0';
|
|
|
|
|
|
|
|
ret = RegSetValueExW(hkey, slot_name, 0, REG_BINARY, (LPBYTE)final,
|
|
|
|
final_len * sizeof(WCHAR));
|
|
|
|
if(ret){
|
|
|
|
WARN("Error saving MRU data to slot %s: %d\n", wine_dbgstr_w(slot_name), ret);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(final);
|
2010-07-23 20:13:04 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(final);
|
2010-07-23 20:13:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{ /* update MRUList value */
|
|
|
|
WCHAR old_mru_list[32], new_mru_list[32];
|
|
|
|
WCHAR *old_mru_slot, *new_mru_slot = new_mru_list;
|
|
|
|
DWORD mru_list_size = sizeof(old_mru_list), key_type;
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
ret = RegGetValueW(hkey, NULL, L"MRUList", RRF_RT_ANY, &key_type,
|
2010-07-23 20:13:04 +02:00
|
|
|
(LPBYTE)old_mru_list, &mru_list_size);
|
|
|
|
if(ret || key_type != REG_SZ){
|
|
|
|
if(ret == ERROR_FILE_NOT_FOUND){
|
|
|
|
new_mru_list[0] = slot;
|
|
|
|
new_mru_list[1] = '\0';
|
|
|
|
}else{
|
|
|
|
WARN("Error getting MRUList data: type: %d, ret: %d\n", key_type, ret);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
/* copy old list data over so that the new slot is at the start
|
|
|
|
* of the list */
|
|
|
|
*new_mru_slot++ = slot;
|
|
|
|
for(old_mru_slot = old_mru_list; *old_mru_slot; ++old_mru_slot){
|
|
|
|
if(*old_mru_slot != slot)
|
|
|
|
*new_mru_slot++ = *old_mru_slot;
|
|
|
|
}
|
|
|
|
*new_mru_slot = '\0';
|
|
|
|
}
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
ret = RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)new_mru_list,
|
2010-07-23 20:13:04 +02:00
|
|
|
(lstrlenW(new_mru_list) + 1) * sizeof(WCHAR));
|
|
|
|
if(ret){
|
|
|
|
WARN("Error saving MRUList data: %d\n", ret);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load the most-recently-used path for this module */
|
|
|
|
static void FILEDLG95_MRU_load_filename(LPWSTR stored_path)
|
|
|
|
{
|
|
|
|
WCHAR module_path[MAX_PATH], *module_name;
|
|
|
|
|
|
|
|
/* get the current executable's name */
|
2018-03-29 17:14:12 +02:00
|
|
|
if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
|
|
|
|
{
|
2010-07-23 20:13:04 +02:00
|
|
|
WARN("GotModuleFileName failed: %d\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
2019-05-29 08:48:52 +02:00
|
|
|
module_name = wcsrchr(module_path, '\\');
|
2010-07-23 20:13:04 +02:00
|
|
|
if(!module_name)
|
|
|
|
module_name = module_path;
|
|
|
|
else
|
|
|
|
module_name += 1;
|
|
|
|
|
|
|
|
FILEDLG95_MRU_get_slot(module_name, stored_path, NULL);
|
|
|
|
TRACE("got MRU path: %s\n", wine_dbgstr_w(stored_path));
|
|
|
|
}
|
|
|
|
|
2011-05-24 21:09:50 +02:00
|
|
|
void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2005-01-09 17:31:36 +01:00
|
|
|
WCHAR strMsgTitle[MAX_PATH];
|
|
|
|
WCHAR strMsgText [MAX_PATH];
|
2003-10-16 02:16:40 +02:00
|
|
|
if (idCaption)
|
2018-03-29 17:14:12 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, idCaption, strMsgTitle, ARRAY_SIZE(strMsgTitle));
|
2003-10-16 02:16:40 +02:00
|
|
|
else
|
|
|
|
strMsgTitle[0] = '\0';
|
2018-03-29 17:14:12 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, idText, strMsgText, ARRAY_SIZE(strMsgText));
|
2005-01-09 17:31:36 +01:00
|
|
|
MessageBoxW(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 05:52:30 +02:00
|
|
|
int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf,
|
|
|
|
HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction)
|
|
|
|
{
|
|
|
|
int nOpenAction = defAction;
|
|
|
|
LPWSTR lpszTemp, lpszTemp1;
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
|
|
|
|
|
|
|
/* check for invalid chars */
|
2020-11-23 00:15:51 +01:00
|
|
|
if((wcspbrk(lpstrPathAndFile+3, L"/:<>|") != NULL) && !(flags & OFN_NOVALIDATE))
|
2011-04-01 05:52:30 +02:00
|
|
|
{
|
|
|
|
FILEDLG95_OnOpenMessage(hwnd, IDS_INVALID_FILENAME_TITLE, IDS_INVALID_FILENAME);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED (SHGetDesktopFolder(ppsf))) return FALSE;
|
|
|
|
|
|
|
|
lpszTemp1 = lpszTemp = lpstrPathAndFile;
|
|
|
|
while (lpszTemp1)
|
|
|
|
{
|
|
|
|
LPSHELLFOLDER lpsfChild;
|
|
|
|
WCHAR lpwstrTemp[MAX_PATH];
|
|
|
|
DWORD dwEaten, dwAttributes;
|
|
|
|
LPWSTR p;
|
|
|
|
|
|
|
|
lstrcpyW(lpwstrTemp, lpszTemp);
|
|
|
|
p = PathFindNextComponentW(lpwstrTemp);
|
|
|
|
|
|
|
|
if (!p) break; /* end of path */
|
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
lpszTemp = lpszTemp + lstrlenW(lpwstrTemp);
|
|
|
|
|
|
|
|
/* There are no wildcards when OFN_NOVALIDATE is set */
|
|
|
|
if(*lpszTemp==0 && !(flags & OFN_NOVALIDATE))
|
|
|
|
{
|
|
|
|
/* if the last element is a wildcard do a search */
|
2020-11-23 00:15:51 +01:00
|
|
|
if(wcspbrk(lpszTemp1, L"*?") != NULL)
|
2011-04-01 05:52:30 +02:00
|
|
|
{
|
|
|
|
nOpenAction = ONOPEN_SEARCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lpszTemp1 = lpszTemp;
|
|
|
|
|
|
|
|
TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_w(lpszTemp), *ppsf);
|
|
|
|
|
|
|
|
/* append a backslash to drive letters */
|
|
|
|
if(lstrlenW(lpwstrTemp)==2 && lpwstrTemp[1] == ':' &&
|
|
|
|
((lpwstrTemp[0] >= 'a' && lpwstrTemp[0] <= 'z') ||
|
|
|
|
(lpwstrTemp[0] >= 'A' && lpwstrTemp[0] <= 'Z')))
|
|
|
|
{
|
|
|
|
PathAddBackslashW(lpwstrTemp);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwAttributes = SFGAO_FOLDER;
|
|
|
|
if(SUCCEEDED(IShellFolder_ParseDisplayName(*ppsf, 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%08x pidl=%p\n", dwAttributes, pidl);
|
|
|
|
if(dwAttributes & SFGAO_FOLDER)
|
|
|
|
{
|
|
|
|
if(FAILED(IShellFolder_BindToObject(*ppsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild)))
|
|
|
|
{
|
|
|
|
ERR("bind to failed\n"); /* should not fail */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IShellFolder_Release(*ppsf);
|
|
|
|
*ppsf = lpsfChild;
|
|
|
|
lpsfChild = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("value\n");
|
|
|
|
|
|
|
|
/* end dialog, return value */
|
|
|
|
nOpenAction = ONOPEN_OPEN;
|
|
|
|
break;
|
|
|
|
}
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidl);
|
2011-04-01 05:52:30 +02:00
|
|
|
pidl = NULL;
|
|
|
|
}
|
|
|
|
else if (!(flags & OFN_NOVALIDATE))
|
|
|
|
{
|
|
|
|
if(*lpszTemp || /* points to trailing null for last path element */
|
2019-05-29 08:48:52 +02:00
|
|
|
(lpwstrTemp[lstrlenW(lpwstrTemp)-1] == '\\')) /* or if last element ends in '\' */
|
2011-04-01 05:52:30 +02:00
|
|
|
{
|
|
|
|
if(flags & OFN_PATHMUSTEXIST)
|
|
|
|
{
|
|
|
|
FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (flags & OFN_FILEMUSTEXIST) && !isSaveDlg )
|
|
|
|
{
|
|
|
|
FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* change to the current folder */
|
|
|
|
nOpenAction = ONOPEN_OPEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nOpenAction = ONOPEN_OPEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidl);
|
2011-04-01 05:52:30 +02:00
|
|
|
|
|
|
|
return nOpenAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnOpen
|
|
|
|
*
|
|
|
|
* Ok button WM_COMMAND message handler
|
|
|
|
*
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
BOOL FILEDLG95_OnOpen(HWND hwnd)
|
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
LPWSTR lpstrFileList;
|
|
|
|
UINT nFileCount = 0;
|
|
|
|
UINT sizeUsed = 0;
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
WCHAR lpstrPathAndFile[MAX_PATH];
|
|
|
|
LPSHELLFOLDER lpsf = NULL;
|
|
|
|
int nOpenAction;
|
|
|
|
|
|
|
|
TRACE("hwnd=%p\n", hwnd);
|
|
|
|
|
2010-02-15 14:48:11 +01:00
|
|
|
/* try to browse the selected item */
|
|
|
|
if(BrowseSelectedFolder(hwnd))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* get the files from the edit control */
|
2008-04-16 18:05:25 +02:00
|
|
|
nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if(nFileCount == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(nFileCount > 1)
|
|
|
|
{
|
|
|
|
ret = FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed);
|
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("count=%u len=%u file=%s\n", nFileCount, sizeUsed, debugstr_w(lpstrFileList));
|
|
|
|
|
|
|
|
/*
|
|
|
|
Step 1: Build a complete path name from the current folder and
|
|
|
|
the filename or path in the edit box.
|
|
|
|
Special cases:
|
|
|
|
- the path in the edit box is a root path
|
|
|
|
(with or without drive letter)
|
|
|
|
- the edit box contains ".." (or a path with ".." in it)
|
|
|
|
*/
|
|
|
|
|
2011-04-01 05:52:29 +02:00
|
|
|
COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(lpstrFileList);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Step 2: here we have a cleaned up path
|
|
|
|
|
|
|
|
We have to parse the path step by step to see if we have to browse
|
|
|
|
to a folder if the path points to a directory or the last
|
|
|
|
valid element is a directory.
|
|
|
|
|
|
|
|
valid variables:
|
|
|
|
lpstrPathAndFile: cleaned up path
|
|
|
|
*/
|
|
|
|
|
2005-08-10 11:50:29 +02:00
|
|
|
if (nFileCount &&
|
|
|
|
(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
|
|
|
|
!(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
|
|
|
|
nOpenAction = ONOPEN_OPEN;
|
|
|
|
else
|
|
|
|
nOpenAction = ONOPEN_BROWSE;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2011-04-01 05:52:30 +02:00
|
|
|
nOpenAction = FILEDLG95_ValidatePathAction(lpstrPathAndFile, &lpsf, hwnd,
|
|
|
|
fodInfos->ofnInfos->Flags,
|
|
|
|
fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG,
|
|
|
|
nOpenAction);
|
|
|
|
if(!nOpenAction)
|
2003-10-16 02:16:40 +02:00
|
|
|
goto ret;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/*
|
|
|
|
Step 3: here we have a cleaned up and validated path
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
valid variables:
|
|
|
|
lpsf: ShellFolder bound to the rightmost valid path component
|
|
|
|
lpstrPathAndFile: cleaned up path
|
|
|
|
nOpenAction: action to do
|
|
|
|
*/
|
|
|
|
TRACE("end validate sf=%p\n", lpsf);
|
|
|
|
|
|
|
|
switch(nOpenAction)
|
|
|
|
{
|
|
|
|
case ONOPEN_SEARCH: /* set the current filter to the file mask and refresh */
|
|
|
|
TRACE("ONOPEN_SEARCH %s\n", debugstr_w(lpstrPathAndFile));
|
|
|
|
{
|
|
|
|
int iPos;
|
|
|
|
LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* replace the current filter */
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
|
2007-03-07 14:18:40 +01:00
|
|
|
len = lstrlenW(lpszTemp)+1;
|
2018-03-20 08:37:47 +01:00
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc(len * sizeof(WCHAR));
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* set the filter cb to the extension when possible */
|
|
|
|
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, iPos, 0);
|
2005-08-10 11:50:29 +02:00
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
|
|
|
|
TRACE("ONOPEN_BROWSE\n");
|
|
|
|
{
|
|
|
|
IPersistFolder2 * ppf2;
|
2003-10-16 02:16:40 +02:00
|
|
|
if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlCurrent;
|
|
|
|
IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
|
|
|
|
IPersistFolder2_Release(ppf2);
|
2018-03-21 06:59:42 +01:00
|
|
|
if (!ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2009-05-05 12:38:34 +02:00
|
|
|
if (SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE))
|
|
|
|
&& fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
2006-08-29 10:20:16 +02:00
|
|
|
{
|
|
|
|
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
|
2016-08-30 10:00:09 +02:00
|
|
|
SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_SETTEXT, 0, (LPARAM)"");
|
2006-08-29 10:20:16 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2005-08-10 11:50:29 +02:00
|
|
|
else if( nOpenAction == ONOPEN_SEARCH )
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2007-06-07 21:28:32 +02:00
|
|
|
if (fodInfos->Shell.FOIShellView)
|
|
|
|
IShellView_Refresh(fodInfos->Shell.FOIShellView);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlCurrent);
|
2012-09-25 13:40:19 +02:00
|
|
|
if (filename_is_edit( fodInfos ))
|
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
|
2016-08-30 10:00:21 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
hwnd = (HWND)SendMessageA(fodInfos->DlgInfos.hwndFileName, CBEM_GETEDITCONTROL, 0, 0);
|
|
|
|
SendMessageW(hwnd, EM_SETSEL, 0, -1);
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
|
|
|
|
TRACE("ONOPEN_OPEN %s\n", debugstr_w(lpstrPathAndFile));
|
|
|
|
{
|
2004-07-14 23:47:11 +02:00
|
|
|
WCHAR *ext = NULL;
|
|
|
|
|
2004-05-06 01:49:39 +02:00
|
|
|
/* update READONLY check box flag */
|
2007-03-07 14:19:19 +01:00
|
|
|
if ((SendMessageW(GetDlgItem(hwnd,IDC_OPENREADONLY),BM_GETCHECK,0,0) & 0x03) == BST_CHECKED)
|
2004-05-06 01:49:39 +02:00
|
|
|
fodInfos->ofnInfos->Flags |= OFN_READONLY;
|
|
|
|
else
|
|
|
|
fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
|
|
|
|
|
2004-07-14 23:47:11 +02:00
|
|
|
/* Attach the file extension with file name*/
|
2005-08-10 11:50:29 +02:00
|
|
|
ext = PathFindExtensionW(lpstrPathAndFile);
|
2012-01-20 22:52:18 +01:00
|
|
|
if (! *ext && fodInfos->defext)
|
2004-07-14 23:47:11 +02:00
|
|
|
{
|
2005-08-10 11:50:29 +02:00
|
|
|
/* if no extension is specified with file name, then */
|
|
|
|
/* attach the extension from file filter or default one */
|
2004-07-14 23:47:11 +02:00
|
|
|
|
2012-01-20 22:52:18 +01:00
|
|
|
WCHAR *filterExt = NULL;
|
2005-08-10 11:50:29 +02:00
|
|
|
LPWSTR lpstrFilter = NULL;
|
2007-03-07 14:18:40 +01:00
|
|
|
int PathLength = lstrlenW(lpstrPathAndFile);
|
2004-07-14 23:47:11 +02:00
|
|
|
|
2005-08-10 11:50:29 +02:00
|
|
|
/*Get the file extension from file type filter*/
|
|
|
|
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
|
|
|
|
fodInfos->ofnInfos->nFilterIndex-1);
|
2004-07-14 23:47:11 +02:00
|
|
|
|
2005-08-10 11:50:29 +02:00
|
|
|
if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
|
2012-01-20 22:52:18 +01:00
|
|
|
{
|
2012-01-24 22:34:43 +01:00
|
|
|
WCHAR* filterSearchIndex;
|
2018-03-20 08:37:47 +01:00
|
|
|
filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
|
2019-05-29 08:48:52 +02:00
|
|
|
lstrcpyW(filterExt, lpstrFilter);
|
2012-01-20 22:52:18 +01:00
|
|
|
|
|
|
|
/* if a semicolon-separated list of file extensions was given, do not include the
|
|
|
|
semicolon or anything after it in the extension.
|
|
|
|
example: if filterExt was "*.abc;*.def", it will become "*.abc" */
|
2019-05-29 08:48:52 +02:00
|
|
|
filterSearchIndex = wcschr(filterExt, ';');
|
2012-01-24 22:34:43 +01:00
|
|
|
if (filterSearchIndex)
|
2012-01-20 22:52:18 +01:00
|
|
|
{
|
2012-01-24 22:34:43 +01:00
|
|
|
filterSearchIndex[0] = '\0';
|
2012-01-20 22:52:18 +01:00
|
|
|
}
|
|
|
|
|
2015-06-03 00:14:08 +02:00
|
|
|
/* find the file extension by searching for the first dot in filterExt */
|
2012-01-20 22:52:18 +01:00
|
|
|
/* strip the * or anything else from the extension, "*.abc" becomes "abc" */
|
2012-01-24 22:34:43 +01:00
|
|
|
/* if the extension is invalid or contains a glob, ignore it */
|
2019-05-29 08:48:52 +02:00
|
|
|
filterSearchIndex = wcschr(filterExt, '.');
|
|
|
|
if (filterSearchIndex++ && !wcschr(filterSearchIndex, '*') && !wcschr(filterSearchIndex, '?'))
|
2012-01-24 22:34:43 +01:00
|
|
|
{
|
2019-05-29 08:48:52 +02:00
|
|
|
lstrcpyW(filterExt, filterSearchIndex);
|
2012-01-24 22:34:43 +01:00
|
|
|
}
|
|
|
|
else
|
2012-01-20 22:52:18 +01:00
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(filterExt);
|
2012-01-20 22:52:18 +01:00
|
|
|
filterExt = NULL;
|
|
|
|
}
|
|
|
|
}
|
2004-07-14 23:47:11 +02:00
|
|
|
|
2012-01-20 22:52:18 +01:00
|
|
|
if (!filterExt)
|
|
|
|
{
|
|
|
|
/* use the default file extension */
|
2018-03-20 08:37:47 +01:00
|
|
|
filterExt = heap_alloc((lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR));
|
2019-05-29 08:48:52 +02:00
|
|
|
lstrcpyW(filterExt, fodInfos->defext);
|
2012-01-20 22:52:18 +01:00
|
|
|
}
|
2010-11-01 12:35:43 +01:00
|
|
|
|
2012-01-20 22:52:18 +01:00
|
|
|
if (*filterExt) /* ignore filterExt="" */
|
2010-11-01 12:35:43 +01:00
|
|
|
{
|
|
|
|
/* Attach the dot*/
|
2020-11-23 00:15:51 +01:00
|
|
|
lstrcatW(lpstrPathAndFile, L".");
|
2010-11-01 12:35:43 +01:00
|
|
|
/* Attach the extension */
|
2012-01-24 22:34:43 +01:00
|
|
|
lstrcatW(lpstrPathAndFile, filterExt);
|
2010-11-01 12:35:43 +01:00
|
|
|
}
|
2004-07-14 23:47:11 +02:00
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(filterExt);
|
2012-01-20 22:52:18 +01:00
|
|
|
|
2005-08-10 11:50:29 +02:00
|
|
|
/* In Open dialog: if file does not exist try without extension */
|
|
|
|
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
|
|
|
|
lpstrPathAndFile[PathLength] = '\0';
|
2004-01-02 02:47:52 +01:00
|
|
|
|
2012-01-20 22:52:18 +01:00
|
|
|
/* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
|
|
|
|
if (*ext)
|
|
|
|
ext++;
|
|
|
|
if (!lstrcmpiW(fodInfos->defext, ext))
|
|
|
|
fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;
|
|
|
|
else
|
|
|
|
fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT;
|
2005-08-10 11:50:29 +02:00
|
|
|
}
|
|
|
|
|
2004-01-02 02:47:52 +01:00
|
|
|
/* In Save dialog: check if the file already exists */
|
|
|
|
if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG
|
|
|
|
&& fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT
|
|
|
|
&& PathFileExistsW(lpstrPathAndFile))
|
|
|
|
{
|
|
|
|
WCHAR lpstrOverwrite[100];
|
|
|
|
int answer;
|
|
|
|
|
|
|
|
LoadStringW(COMDLG32_hInstance, IDS_OVERWRITEFILE, lpstrOverwrite, 100);
|
|
|
|
answer = MessageBoxW(hwnd, lpstrOverwrite, fodInfos->title,
|
|
|
|
MB_YESNO | MB_ICONEXCLAMATION);
|
2010-06-02 19:10:07 +02:00
|
|
|
if (answer == IDNO || answer == IDCANCEL)
|
2004-01-02 02:47:52 +01:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto ret;
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2007-11-02 21:04:46 +01:00
|
|
|
/* 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);
|
2010-06-02 19:10:07 +02:00
|
|
|
if (answer == IDNO || answer == IDCANCEL)
|
2007-11-02 21:04:46 +01:00
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Check that the size of the file does not exceed buffer size.
|
|
|
|
(Allow for extra \0 if OFN_MULTISELECT is set.) */
|
2007-03-07 14:18:40 +01:00
|
|
|
if(lstrlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
|
2003-10-16 02:16:40 +02:00
|
|
|
((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
|
|
|
|
{
|
|
|
|
|
|
|
|
/* fill destination buffer */
|
|
|
|
if (fodInfos->ofnInfos->lpstrFile)
|
|
|
|
{
|
|
|
|
if(fodInfos->unicode)
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
|
2003-10-16 02:16:40 +02:00
|
|
|
if (ofn->Flags & OFN_ALLOWMULTISELECT)
|
|
|
|
ofn->lpstrFile[lstrlenW(ofn->lpstrFile) + 1] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
|
|
|
|
ofn->lpstrFile, ofn->nMaxFile, NULL, NULL);
|
|
|
|
if (ofn->Flags & OFN_ALLOWMULTISELECT)
|
|
|
|
ofn->lpstrFile[lstrlenA(ofn->lpstrFile) + 1] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-03 12:24:23 +01:00
|
|
|
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
|
|
|
|
{
|
2012-06-15 05:51:34 +02:00
|
|
|
LPSTR lpszTemp;
|
|
|
|
CHAR tempFileA[MAX_PATH];
|
|
|
|
|
|
|
|
/* avoid using fodInfos->ofnInfos->lpstrFile since it can be NULL */
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
|
|
|
|
tempFileA, sizeof(tempFileA), NULL, NULL);
|
2007-12-03 12:24:23 +01:00
|
|
|
|
|
|
|
/* set filename offset */
|
2012-06-15 05:51:34 +02:00
|
|
|
lpszTemp = PathFindFileNameA(tempFileA);
|
|
|
|
fodInfos->ofnInfos->nFileOffset = (lpszTemp - tempFileA);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2007-12-03 12:24:23 +01:00
|
|
|
/* set extension offset */
|
2012-06-15 05:51:34 +02:00
|
|
|
lpszTemp = PathFindExtensionA(tempFileA);
|
|
|
|
fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - tempFileA) + 1 : 0;
|
2007-12-03 12:24:23 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* set the lpstrFileTitle */
|
|
|
|
if(fodInfos->ofnInfos->lpstrFileTitle)
|
|
|
|
{
|
|
|
|
LPWSTR lpstrFileTitle = PathFindFileNameW(lpstrPathAndFile);
|
|
|
|
if(fodInfos->unicode)
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
|
2003-10-16 02:16:40 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpstrFileTitle, -1,
|
|
|
|
ofn->lpstrFileTitle, ofn->nMaxFileTitle, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-12 02:12:04 +02:00
|
|
|
/* copy currently selected filter to lpstrCustomFilter */
|
|
|
|
if (fodInfos->ofnInfos->lpstrCustomFilter)
|
|
|
|
{
|
2005-01-10 14:22:35 +01:00
|
|
|
LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
|
2004-05-12 02:12:04 +02:00
|
|
|
int len = WideCharToMultiByte(CP_ACP, 0, fodInfos->ShellInfos.lpstrCurrentFilter, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (len + strlen(ofn->lpstrCustomFilter) + 1 <= ofn->nMaxCustFilter)
|
|
|
|
{
|
|
|
|
LPSTR s = ofn->lpstrCustomFilter;
|
|
|
|
s += strlen(ofn->lpstrCustomFilter)+1;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, fodInfos->ShellInfos.lpstrCurrentFilter, -1,
|
|
|
|
s, len, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
|
|
|
|
goto ret;
|
|
|
|
|
2010-07-23 20:13:04 +02:00
|
|
|
FILEDLG95_MRU_save_filename(lpstrPathAndFile);
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("close\n");
|
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
ret = EndDialog(hwnd, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-05-03 22:09:09 +02:00
|
|
|
WORD size;
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
size = lstrlenW(lpstrPathAndFile) + 1;
|
2004-05-03 22:09:09 +02:00
|
|
|
if (fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)
|
|
|
|
size += 1;
|
|
|
|
/* return needed size in first two bytes of lpstrFile */
|
2012-06-15 05:51:34 +02:00
|
|
|
if(fodInfos->ofnInfos->lpstrFile)
|
|
|
|
*(WORD *)fodInfos->ofnInfos->lpstrFile = size;
|
2003-10-16 02:16:40 +02:00
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
ret = EndDialog(hwnd, FALSE);
|
2004-05-03 22:09:09 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(FNERR_BUFFERTOOSMALL);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
ret:
|
|
|
|
if(lpsf) IShellFolder_Release(lpsf);
|
|
|
|
return ret;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_SHELL_Init
|
1999-07-27 18:20:36 +02:00
|
|
|
*
|
2003-10-16 02:16:40 +02:00
|
|
|
* Initialisation of the shell objects
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
2004-10-20 01:55:15 +02:00
|
|
|
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p\n", hwnd);
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/*
|
|
|
|
* Initialisation of the FileOpenDialogInfos structure
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Shell */
|
|
|
|
|
|
|
|
/*ShellInfos */
|
|
|
|
fodInfos->ShellInfos.hwndOwner = hwnd;
|
|
|
|
|
|
|
|
/* Disable multi-select if flag not set */
|
|
|
|
if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
|
|
|
|
{
|
|
|
|
fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
|
|
|
|
}
|
|
|
|
fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
|
|
|
|
fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Construct the IShellBrowser interface */
|
|
|
|
fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_SHELL_ExecuteCommand
|
|
|
|
*
|
|
|
|
* Change the folder option and refresh the view
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
IContextMenu * pcm;
|
2008-10-30 22:31:35 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("(%p,%p)\n", hwnd, lpVerb);
|
|
|
|
|
|
|
|
if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
|
|
|
|
SVGIO_BACKGROUND,
|
|
|
|
&IID_IContextMenu,
|
|
|
|
(LPVOID*)&pcm)))
|
|
|
|
{
|
|
|
|
CMINVOKECOMMANDINFO ci;
|
|
|
|
ZeroMemory(&ci, sizeof(CMINVOKECOMMANDINFO));
|
|
|
|
ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
|
|
|
|
ci.lpVerb = lpVerb;
|
|
|
|
ci.hwnd = hwnd;
|
|
|
|
|
|
|
|
IContextMenu_InvokeCommand(pcm, &ci);
|
|
|
|
IContextMenu_Release(pcm);
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-07-24 12:27:58 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_SHELL_UpFolder
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
2003-10-16 02:16:40 +02:00
|
|
|
* Browse to the specified object
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
|
|
|
|
NULL,
|
|
|
|
SBSP_PARENT)))
|
|
|
|
{
|
2009-05-05 12:38:34 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
|
2000-08-02 01:33:37 +02:00
|
|
|
return TRUE;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_SHELL_Clean
|
|
|
|
*
|
|
|
|
* Cleans the memory used by shell objects
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static void FILEDLG95_SHELL_Clean(HWND hwnd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(fodInfos->ShellInfos.pidlAbsCurrent);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* clean Shell interfaces */
|
2007-06-07 21:28:32 +02:00
|
|
|
if (fodInfos->Shell.FOIShellView)
|
|
|
|
{
|
|
|
|
IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
|
|
|
|
IShellView_Release(fodInfos->Shell.FOIShellView);
|
|
|
|
}
|
2017-02-14 08:00:48 +01:00
|
|
|
if (fodInfos->Shell.FOIShellFolder)
|
|
|
|
IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
|
2003-10-16 02:16:40 +02:00
|
|
|
IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
|
|
|
|
if (fodInfos->Shell.FOIDataObject)
|
|
|
|
IDataObject_Release(fodInfos->Shell.FOIDataObject);
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_FILETYPE_Init
|
2000-08-02 01:33:37 +02:00
|
|
|
*
|
2003-10-16 02:16:40 +02:00
|
|
|
* Initialisation of the file type combo box
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2004-05-12 02:12:04 +02:00
|
|
|
int nFilters = 0; /* number of filters */
|
|
|
|
int nFilterIndexCB;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p\n", hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2004-05-12 02:12:04 +02:00
|
|
|
if(fodInfos->customfilter)
|
|
|
|
{
|
|
|
|
/* customfilter has one entry... title\0ext\0
|
|
|
|
* Set first entry of combo box item with customfilter
|
|
|
|
*/
|
|
|
|
LPWSTR lpstrExt;
|
|
|
|
LPCWSTR lpstrPos = fodInfos->customfilter;
|
|
|
|
|
|
|
|
/* Get the title */
|
2007-03-07 14:18:40 +01:00
|
|
|
lpstrPos += lstrlenW(fodInfos->customfilter) + 1;
|
2004-05-12 02:12:04 +02:00
|
|
|
|
|
|
|
/* Copy the extensions */
|
|
|
|
if (! *lpstrPos) return E_FAIL; /* malformed filter */
|
2018-03-20 08:37:47 +01:00
|
|
|
if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(lpstrExt,lpstrPos);
|
2004-05-12 02:12:04 +02:00
|
|
|
|
|
|
|
/* Add the item at the end of the combo */
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)fodInfos->customfilter);
|
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters, (LPARAM)lpstrExt);
|
|
|
|
|
2004-05-12 02:12:04 +02:00
|
|
|
nFilters++;
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
if(fodInfos->filter)
|
|
|
|
{
|
|
|
|
LPCWSTR lpstrPos = fodInfos->filter;
|
|
|
|
|
|
|
|
for(;;)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
/* filter is a list... title\0ext\0......\0\0
|
|
|
|
* Set the combo item text to the title and the item data
|
|
|
|
* to the ext
|
|
|
|
*/
|
|
|
|
LPCWSTR lpstrDisplay;
|
|
|
|
LPWSTR lpstrExt;
|
|
|
|
|
|
|
|
/* Get the title */
|
|
|
|
if(! *lpstrPos) break; /* end */
|
|
|
|
lpstrDisplay = lpstrPos;
|
2007-03-07 14:18:40 +01:00
|
|
|
lpstrPos += lstrlenW(lpstrPos) + 1;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)lpstrDisplay);
|
2006-03-26 04:35:52 +02:00
|
|
|
|
|
|
|
nFilters++;
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Copy the extensions */
|
2018-03-20 08:37:47 +01:00
|
|
|
if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(lpstrExt,lpstrPos);
|
|
|
|
lpstrPos += lstrlenW(lpstrPos) + 1;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Add the item at the end of the combo */
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters - 1, (LPARAM)lpstrExt);
|
2006-05-30 08:54:03 +02:00
|
|
|
|
|
|
|
/* malformed filters are added anyway... */
|
|
|
|
if (!*lpstrExt) break;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2004-05-12 02:12:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the current filter to the one specified
|
|
|
|
* in the initialisation structure
|
|
|
|
*/
|
|
|
|
if (fodInfos->filter || fodInfos->customfilter)
|
|
|
|
{
|
|
|
|
LPWSTR lpstrFilter;
|
|
|
|
|
|
|
|
/* Check to make sure our index isn't out of bounds. */
|
|
|
|
if ( fodInfos->ofnInfos->nFilterIndex >
|
|
|
|
nFilters - (fodInfos->customfilter == NULL ? 0 : 1) )
|
|
|
|
fodInfos->ofnInfos->nFilterIndex = (fodInfos->customfilter == NULL ? 1 : 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* set default filter index */
|
|
|
|
if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->customfilter == NULL)
|
|
|
|
fodInfos->ofnInfos->nFilterIndex = 1;
|
|
|
|
|
2004-05-12 02:12:04 +02:00
|
|
|
/* calculate index of Combo Box item */
|
|
|
|
nFilterIndexCB = fodInfos->ofnInfos->nFilterIndex;
|
|
|
|
if (fodInfos->customfilter == NULL)
|
|
|
|
nFilterIndexCB--;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Set the current index selection. */
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, nFilterIndexCB, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Get the corresponding text string from the combo box. */
|
|
|
|
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
|
2004-05-12 02:12:04 +02:00
|
|
|
nFilterIndexCB);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2005-09-02 13:32:17 +02:00
|
|
|
if ((INT_PTR)lpstrFilter == CB_ERR) /* control is empty */
|
2003-10-16 02:16:40 +02:00
|
|
|
lpstrFilter = NULL;
|
|
|
|
|
|
|
|
if(lpstrFilter)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
DWORD len;
|
|
|
|
CharLowerW(lpstrFilter); /* lowercase */
|
2007-03-07 14:18:40 +01:00
|
|
|
len = lstrlenW(lpstrFilter)+1;
|
2018-03-20 08:37:47 +01:00
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2004-05-12 02:12:04 +02:00
|
|
|
} else
|
|
|
|
fodInfos->ofnInfos->nFilterIndex = 0;
|
2005-06-07 22:03:30 +02:00
|
|
|
return S_OK;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_FILETYPE_OnCommand
|
|
|
|
*
|
|
|
|
* WM_COMMAND of the file type combo box
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
switch(wNotifyCode)
|
|
|
|
{
|
|
|
|
case CBN_SELENDOK:
|
|
|
|
{
|
|
|
|
LPWSTR lpstrFilter;
|
|
|
|
|
|
|
|
/* Get the current item of the filetype combo box */
|
2018-03-20 08:37:51 +01:00
|
|
|
int iItem = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCURSEL, 0, 0);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2004-05-12 02:12:04 +02:00
|
|
|
/* set the current filter index */
|
|
|
|
fodInfos->ofnInfos->nFilterIndex = iItem +
|
|
|
|
(fodInfos->customfilter == NULL ? 1 : 0);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Set the current filter with the current selection */
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
|
|
|
|
iItem);
|
2005-09-02 13:32:17 +02:00
|
|
|
if((INT_PTR)lpstrFilter != CB_ERR)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
CharLowerW(lpstrFilter); /* lowercase */
|
2007-03-07 14:18:40 +01:00
|
|
|
len = lstrlenW(lpstrFilter)+1;
|
2018-03-20 08:37:47 +01:00
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
|
2009-05-05 12:38:34 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Refresh the actual view to display the included items*/
|
2007-06-07 21:28:32 +02:00
|
|
|
if (fodInfos->Shell.FOIShellView)
|
|
|
|
IShellView_Refresh(fodInfos->Shell.FOIShellView);
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILETYPE_SearchExt
|
|
|
|
*
|
2005-03-23 14:15:18 +01:00
|
|
|
* searches for an extension in the filetype box
|
2003-10-16 02:16:40 +02:00
|
|
|
*/
|
|
|
|
static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt)
|
|
|
|
{
|
2018-03-20 08:37:51 +01:00
|
|
|
int i, iCount;
|
|
|
|
|
|
|
|
iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(lpstrExt));
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(iCount != CB_ERR)
|
|
|
|
{
|
|
|
|
for(i=0;i<iCount;i++)
|
|
|
|
{
|
|
|
|
if(!lstrcmpiW(lpstrExt,(LPWSTR)CBGetItemDataPtr(hwnd,i)))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2000-08-19 01:03:44 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_FILETYPE_Clean
|
|
|
|
*
|
|
|
|
* Clean the memory used by the filetype combo box
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
int iPos;
|
2018-03-20 08:37:51 +01:00
|
|
|
int iCount;
|
|
|
|
|
|
|
|
iCount = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCOUNT, 0, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/* Delete each string of the combo and their associated data */
|
|
|
|
if(iCount != CB_ERR)
|
|
|
|
{
|
|
|
|
for(iPos = iCount-1;iPos>=0;iPos--)
|
|
|
|
{
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_DELETESTRING, iPos, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
/* Current filter */
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_Init
|
|
|
|
*
|
|
|
|
* Initialisation of the look in combo box
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2005-06-28 21:14:03 +02:00
|
|
|
|
|
|
|
/* Small helper function, to determine if the unixfs shell extension is rooted
|
|
|
|
* at the desktop. Copied from dlls/shell32/shfldr_unixfs.c.
|
|
|
|
*/
|
|
|
|
static inline BOOL FILEDLG95_unixfs_is_rooted_at_desktop(void) {
|
|
|
|
HKEY hKey;
|
2020-11-23 00:15:51 +01:00
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\"
|
|
|
|
"{9D20AAE8-0625-44B0-9CA7-71889C2254D9}", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
2005-06-28 21:14:03 +02:00
|
|
|
return FALSE;
|
2020-11-23 00:15:51 +01:00
|
|
|
|
2005-06-28 21:14:03 +02:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-07 22:03:30 +02:00
|
|
|
static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
IShellFolder *psfRoot, *psfDrives;
|
|
|
|
IEnumIDList *lpeRoot, *lpeDrives;
|
|
|
|
LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
|
2013-05-29 16:17:48 +02:00
|
|
|
HDC hdc;
|
|
|
|
TEXTMETRICW tm;
|
2018-03-20 08:37:47 +01:00
|
|
|
LookInInfos *liInfos = heap_alloc_zero(sizeof(*liInfos));
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p\n", hwndCombo);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
liInfos->iMaxIndentation = 0;
|
1999-03-13 19:10:43 +01:00
|
|
|
|
2009-01-13 23:30:08 +01:00
|
|
|
SetPropA(hwndCombo, LookInInfosStr, liInfos);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
2013-05-29 16:17:48 +02:00
|
|
|
hdc = GetDC( hwndCombo );
|
|
|
|
SelectObject( hdc, (HFONT)SendMessageW( hwndCombo, WM_GETFONT, 0, 0 ));
|
|
|
|
GetTextMetricsW( hdc, &tm );
|
|
|
|
ReleaseDC( hwndCombo, hdc );
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* set item height for both text field and listbox */
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(hwndCombo, CB_SETITEMHEIGHT, -1, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
|
|
|
|
SendMessageW(hwndCombo, CB_SETITEMHEIGHT, 0, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
|
2013-05-29 16:17:48 +02:00
|
|
|
|
2004-01-02 02:47:52 +01:00
|
|
|
/* Turn on the extended UI for the combo box like Windows does */
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(hwndCombo, CB_SETEXTENDEDUI, TRUE, 0);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Initialise data of Desktop folder */
|
|
|
|
SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
|
|
|
|
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlTmp);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
SHGetDesktopFolder(&psfRoot);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if (psfRoot)
|
|
|
|
{
|
|
|
|
/* enumerate the contents of the desktop */
|
|
|
|
if(SUCCEEDED(IShellFolder_EnumObjects(psfRoot, hwndCombo, SHCONTF_FOLDERS, &lpeRoot)))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
|
|
|
|
{
|
|
|
|
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
2005-06-28 21:14:03 +02:00
|
|
|
/* If the unixfs extension is rooted, we don't expand the drives by default */
|
|
|
|
if (!FILEDLG95_unixfs_is_rooted_at_desktop())
|
1999-03-13 19:10:43 +01:00
|
|
|
{
|
2005-06-28 21:14:03 +02:00
|
|
|
/* special handling for CSIDL_DRIVES */
|
2018-03-21 06:59:42 +01:00
|
|
|
if (ILIsEqual(pidlTmp, pidlDrives))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2005-06-28 21:14:03 +02:00
|
|
|
if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2005-06-28 21:14:03 +02:00
|
|
|
/* enumerate the drives */
|
|
|
|
if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2005-06-28 21:14:03 +02:00
|
|
|
while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
|
|
|
|
{
|
2018-03-21 06:59:42 +01:00
|
|
|
pidlAbsTmp = ILCombine(pidlTmp, pidlTmp1);
|
2005-06-28 21:14:03 +02:00
|
|
|
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlAbsTmp);
|
|
|
|
ILFree(pidlTmp1);
|
2005-06-28 21:14:03 +02:00
|
|
|
}
|
|
|
|
IEnumIDList_Release(lpeDrives);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2005-06-28 21:14:03 +02:00
|
|
|
IShellFolder_Release(psfDrives);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
}
|
1999-03-13 19:10:43 +01:00
|
|
|
}
|
2005-06-28 21:14:03 +02:00
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlTmp);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
IEnumIDList_Release(lpeRoot);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2004-03-20 20:22:17 +01:00
|
|
|
IShellFolder_Release(psfRoot);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlDrives);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_DrawItem
|
|
|
|
*
|
|
|
|
* WM_DRAWITEM message handler
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
COLORREF crWin = GetSysColor(COLOR_WINDOW);
|
|
|
|
COLORREF crHighLight = GetSysColor(COLOR_HIGHLIGHT);
|
|
|
|
COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
RECT rectText;
|
|
|
|
RECT rectIcon;
|
2007-03-07 14:18:40 +01:00
|
|
|
SHFILEINFOW sfi;
|
2003-10-16 02:16:40 +02:00
|
|
|
HIMAGELIST ilItemImage;
|
|
|
|
int iIndentation;
|
2007-03-07 14:18:40 +01:00
|
|
|
TEXTMETRICW tm;
|
2003-10-16 02:16:40 +02:00
|
|
|
LPSFOLDER tmpFolder;
|
2013-05-29 16:17:48 +02:00
|
|
|
UINT shgfi_flags = SHGFI_PIDL | SHGFI_OPENICON | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME;
|
|
|
|
UINT icon_width, icon_height;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(pDIStruct->itemID == -1)
|
|
|
|
return 0;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem,
|
|
|
|
pDIStruct->itemID)))
|
|
|
|
return 0;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2013-05-29 16:17:48 +02:00
|
|
|
icon_width = GetSystemMetrics(SM_CXICON);
|
|
|
|
icon_height = GetSystemMetrics(SM_CYICON);
|
|
|
|
if (pDIStruct->rcItem.bottom - pDIStruct->rcItem.top < icon_height)
|
|
|
|
{
|
|
|
|
icon_width = GetSystemMetrics(SM_CXSMICON);
|
|
|
|
icon_height = GetSystemMetrics(SM_CYSMICON);
|
|
|
|
shgfi_flags |= SHGFI_SMALLICON;
|
|
|
|
}
|
|
|
|
|
2014-10-28 00:02:11 +01:00
|
|
|
ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
|
|
|
|
0, &sfi, sizeof (sfi), shgfi_flags );
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Is this item selected ? */
|
|
|
|
if(pDIStruct->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
SetTextColor(pDIStruct->hDC,(0x00FFFFFF & ~(crText)));
|
|
|
|
SetBkColor(pDIStruct->hDC,crHighLight);
|
|
|
|
FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_HIGHLIGHT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetTextColor(pDIStruct->hDC,crText);
|
|
|
|
SetBkColor(pDIStruct->hDC,crWin);
|
|
|
|
FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_WINDOW));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do not indent item if drawing in the edit of the combo */
|
|
|
|
if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
|
|
|
|
iIndentation = 0;
|
|
|
|
else
|
|
|
|
iIndentation = tmpFolder->m_iIndent;
|
2014-10-28 00:02:11 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Draw text and icon */
|
|
|
|
|
|
|
|
/* Initialise the icon display area */
|
2013-05-29 16:17:48 +02:00
|
|
|
rectIcon.left = pDIStruct->rcItem.left + 1 + icon_width/2 * iIndentation;
|
|
|
|
rectIcon.top = (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - icon_height) / 2;
|
|
|
|
rectIcon.right = rectIcon.left + icon_width + XTEXTOFFSET;
|
|
|
|
rectIcon.bottom = (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + icon_height) / 2;
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Initialise the text display area */
|
2007-03-07 14:18:40 +01:00
|
|
|
GetTextMetricsW(pDIStruct->hDC, &tm);
|
2003-10-16 02:16:40 +02:00
|
|
|
rectText.left = rectIcon.right;
|
|
|
|
rectText.top =
|
|
|
|
(pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
|
2013-05-29 16:17:48 +02:00
|
|
|
rectText.right = pDIStruct->rcItem.right;
|
2003-10-16 02:16:40 +02:00
|
|
|
rectText.bottom =
|
|
|
|
(pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
|
|
|
|
|
|
|
|
/* Draw the icon from the image list */
|
|
|
|
ImageList_Draw(ilItemImage,
|
|
|
|
sfi.iIcon,
|
|
|
|
pDIStruct->hDC,
|
|
|
|
rectIcon.left,
|
|
|
|
rectIcon.top,
|
|
|
|
ILD_TRANSPARENT );
|
|
|
|
|
|
|
|
/* Draw the associated text */
|
2011-03-15 02:26:04 +01:00
|
|
|
TextOutW(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,lstrlenW(sfi.szDisplayName));
|
2003-10-16 02:16:40 +02:00
|
|
|
return NOERROR;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_OnCommand
|
|
|
|
*
|
|
|
|
* LookIn combo box WM_COMMAND message handler
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("%p\n", fodInfos);
|
|
|
|
|
|
|
|
switch(wNotifyCode)
|
|
|
|
{
|
|
|
|
case CBN_SELENDOK:
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPSFOLDER tmpFolder;
|
|
|
|
int iItem;
|
|
|
|
|
2018-03-20 08:37:51 +01:00
|
|
|
iItem = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCURSEL, 0, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2009-04-23 08:25:13 +02:00
|
|
|
if( iItem == CB_ERR) return FALSE;
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
|
|
|
|
iItem)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
|
|
|
|
tmpFolder->pidlItem,
|
|
|
|
SBSP_ABSOLUTE)))
|
|
|
|
{
|
2009-05-05 12:38:34 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
|
2003-10-16 02:16:40 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_AddItem
|
|
|
|
*
|
|
|
|
* Adds an absolute pidl item to the lookin combo box
|
|
|
|
* returns the index of the inserted item
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST pidlNext;
|
2007-03-07 14:18:40 +01:00
|
|
|
SHFILEINFOW sfi;
|
2003-10-16 02:16:40 +02:00
|
|
|
SFOLDER *tmpFolder;
|
|
|
|
LookInInfos *liInfos;
|
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p, %p, %d\n", hwnd, pidl, iInsertId);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if(!pidl)
|
|
|
|
return -1;
|
|
|
|
|
2008-10-30 22:31:35 +01:00
|
|
|
if(!(liInfos = GetPropA(hwnd,LookInInfosStr)))
|
2003-10-16 02:16:40 +02:00
|
|
|
return -1;
|
|
|
|
|
2018-03-20 08:37:47 +01:00
|
|
|
tmpFolder = heap_alloc_zero(sizeof(*tmpFolder));
|
2003-10-16 02:16:40 +02:00
|
|
|
tmpFolder->m_iIndent = 0;
|
|
|
|
|
|
|
|
/* Calculate the indentation of the item in the lookin*/
|
|
|
|
pidlNext = pidl;
|
2018-03-21 06:59:42 +01:00
|
|
|
while ((pidlNext = ILGetNext(pidlNext)))
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
tmpFolder->m_iIndent++;
|
|
|
|
}
|
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
tmpFolder->pidlItem = ILClone(pidl);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
|
|
|
|
liInfos->iMaxIndentation = tmpFolder->m_iIndent;
|
|
|
|
|
|
|
|
sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
|
2007-03-07 14:18:40 +01:00
|
|
|
SHGetFileInfoW((LPCWSTR)pidl,
|
2003-10-16 02:16:40 +02:00
|
|
|
0,
|
|
|
|
&sfi,
|
|
|
|
sizeof(sfi),
|
2017-04-25 10:04:57 +02:00
|
|
|
SHGFI_DISPLAYNAME | SHGFI_PIDL | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("-- Add %s attr=0x%08x\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
|
|
|
|
{
|
|
|
|
int iItemID;
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
TRACE("-- Add %s at %u\n", debugstr_w(sfi.szDisplayName), tmpFolder->m_iIndent);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
/* Add the item at the end of the list */
|
|
|
|
if(iInsertId < 0)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
2018-03-20 08:37:51 +01:00
|
|
|
iItemID = SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)sfi.szDisplayName);
|
2000-11-28 23:40:56 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Insert the item at the iInsertId position*/
|
|
|
|
else
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
2018-03-20 08:37:51 +01:00
|
|
|
iItemID = SendMessageW(hwnd, CB_INSERTSTRING, iInsertId, (LPARAM)sfi.szDisplayName);
|
2000-11-28 23:40:56 +01:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(hwnd, CB_SETITEMDATA, iItemID, (LPARAM)tmpFolder);
|
2003-10-16 02:16:40 +02:00
|
|
|
return iItemID;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree( tmpFolder->pidlItem );
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free( tmpFolder );
|
2003-10-16 02:16:40 +02:00
|
|
|
return -1;
|
2000-08-19 01:03:44 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2000-08-19 01:03:44 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_InsertItemAfterParent
|
|
|
|
*
|
|
|
|
* Insert an item below its parent
|
2000-08-19 01:03:44 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
|
2000-08-19 01:03:44 +02:00
|
|
|
{
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST pidlParent = GetParentPidl(pidl);
|
|
|
|
int iParentPos;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2010-10-08 07:21:23 +02:00
|
|
|
if (pidl == pidlParent)
|
|
|
|
return -1;
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
iParentPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidlParent,SEARCH_PIDL);
|
|
|
|
|
|
|
|
if(iParentPos < 0)
|
|
|
|
{
|
|
|
|
iParentPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidlParent);
|
|
|
|
}
|
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(pidlParent);
|
2000-08-19 01:03:44 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
|
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_SelectItem
|
|
|
|
*
|
|
|
|
* Adds an absolute pidl item to the lookin combo box
|
|
|
|
* returns the index of the inserted item
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
int iItemPos;
|
|
|
|
LookInInfos *liInfos;
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("%p, %p\n", hwnd, pidl);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidl,SEARCH_PIDL);
|
|
|
|
|
2008-10-30 22:31:35 +01:00
|
|
|
liInfos = GetPropA(hwnd,LookInInfosStr);
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
if(iItemPos < 0)
|
|
|
|
{
|
|
|
|
while(FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd) > -1);
|
|
|
|
iItemPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
|
|
|
|
while(liInfos->iMaxIndentation > tmpFolder->m_iIndent)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
int iRemovedItem;
|
|
|
|
|
|
|
|
if(-1 == (iRemovedItem = FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd)))
|
|
|
|
break;
|
|
|
|
if(iRemovedItem < iItemPos)
|
|
|
|
iItemPos--;
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(hwnd, CB_SETCURSEL, iItemPos, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
liInfos->uSelectedItem = iItemPos;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_RemoveMostExpandedItem
|
|
|
|
*
|
|
|
|
* Remove the item with an expansion level over iExpansionLevel
|
2000-10-23 01:46:21 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
int iItemPos;
|
2008-10-30 22:31:35 +01:00
|
|
|
LookInInfos *liInfos = GetPropA(hwnd,LookInInfosStr);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(liInfos->iMaxIndentation <= 2)
|
|
|
|
return -1;
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2009-12-27 23:53:05 +01:00
|
|
|
if((iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,liInfos->iMaxIndentation,SEARCH_EXP)) >=0)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(tmpFolder->pidlItem);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(tmpFolder);
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(hwnd, CB_DELETESTRING, iItemPos, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
liInfos->iMaxIndentation--;
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return iItemPos;
|
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_SearchItem
|
|
|
|
*
|
|
|
|
* Search for pidl in the lookin combo box
|
|
|
|
* returns the index of the found item
|
|
|
|
*/
|
|
|
|
static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod)
|
|
|
|
{
|
|
|
|
int i = 0;
|
2018-03-20 08:37:51 +01:00
|
|
|
int iCount;
|
|
|
|
|
|
|
|
iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("0x%08lx 0x%x\n",searchArg, iSearchMethod);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if (iCount != CB_ERR)
|
|
|
|
{
|
|
|
|
for(;i<iCount;i++)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
if (iSearchMethod == SEARCH_PIDL && ILIsEqual((LPITEMIDLIST)searchArg, tmpFolder->pidlItem))
|
2003-10-16 02:16:40 +02:00
|
|
|
return i;
|
|
|
|
if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
|
|
|
|
return i;
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_LOOKIN_Clean
|
|
|
|
*
|
|
|
|
* Clean the memory used by the lookin combo box
|
2000-10-23 01:46:21 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2009-12-09 23:35:42 +01:00
|
|
|
LookInInfos *liInfos = GetPropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
|
2018-03-20 08:37:51 +01:00
|
|
|
int iPos, iCount;
|
|
|
|
|
|
|
|
iCount = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCOUNT, 0, 0);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Delete each string of the combo and their associated data */
|
|
|
|
if (iCount != CB_ERR)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
for(iPos = iCount-1;iPos>=0;iPos--)
|
|
|
|
{
|
|
|
|
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree(tmpFolder->pidlItem);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(tmpFolder);
|
2018-03-20 08:37:51 +01:00
|
|
|
SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_DELETESTRING, iPos, 0);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* LookInInfos structure */
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(liInfos);
|
2003-10-16 02:16:40 +02:00
|
|
|
RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2009-12-09 23:35:42 +01:00
|
|
|
|
2016-07-06 12:27:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_FILENAME_FillFromSelection
|
|
|
|
*
|
|
|
|
* fills the edit box from the cached DataObject
|
2000-10-23 01:46:21 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST pidl;
|
2016-07-06 12:27:43 +02:00
|
|
|
LPWSTR lpstrAllFiles, lpstrTmp;
|
|
|
|
UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength;
|
2016-07-06 12:27:44 +02:00
|
|
|
STGMEDIUM medium;
|
|
|
|
LPIDA cida;
|
|
|
|
FORMATETC formatetc = get_def_format();
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2016-07-06 12:27:44 +02:00
|
|
|
if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
cida = GlobalLock(medium.u.hGlobal);
|
|
|
|
nFileSelected = cida->cidl;
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2016-07-06 12:27:43 +02:00
|
|
|
/* Allocate a buffer */
|
|
|
|
nAllFilesMaxLength = MAX_PATH + 3;
|
2018-03-20 08:37:47 +01:00
|
|
|
lpstrAllFiles = heap_alloc_zero(nAllFilesMaxLength * sizeof(WCHAR));
|
2016-07-06 12:27:43 +02:00
|
|
|
if (!lpstrAllFiles)
|
|
|
|
goto ret;
|
|
|
|
|
|
|
|
/* Loop through the selection, handle only files (not folders) */
|
|
|
|
for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2016-07-06 12:27:44 +02:00
|
|
|
pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]);
|
2003-10-16 02:16:40 +02:00
|
|
|
if (pidl)
|
2016-07-06 12:27:43 +02:00
|
|
|
{
|
|
|
|
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++] = ' ';
|
|
|
|
}
|
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2016-07-06 12:27:43 +02:00
|
|
|
if (nFiles != 0)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
2016-07-06 12:27:43 +02:00
|
|
|
/* 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);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2016-07-06 12:27:43 +02:00
|
|
|
|
|
|
|
ret:
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(lpstrAllFiles);
|
2016-07-06 12:27:44 +02:00
|
|
|
COMCTL32_ReleaseStgMedium(medium);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2005-06-07 22:03:30 +02:00
|
|
|
/* copied from shell32 to avoid linking to it
|
2007-03-07 14:19:19 +01:00
|
|
|
* Although shell32 is already linked the behaviour of exported StrRetToStrN
|
|
|
|
* is dependent on whether emulated OS is unicode or not.
|
2005-06-07 22:03:30 +02:00
|
|
|
*/
|
2009-06-09 23:41:27 +02:00
|
|
|
static HRESULT COMDLG32_StrRetToStrNW (LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
2007-03-07 14:19:19 +01:00
|
|
|
lstrcpynW(dest, src->u.pOleStr, len);
|
2018-03-21 06:59:42 +01:00
|
|
|
CoTaskMemFree(src->u.pOleStr);
|
2003-10-16 02:16:40 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTR:
|
2007-03-07 14:19:19 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
|
|
|
|
dest[len-1] = 0;
|
2003-10-16 02:16:40 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSET:
|
2007-03-07 14:19:19 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
|
|
|
|
dest[len-1] = 0;
|
2003-10-16 02:16:40 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-03-07 14:19:19 +01:00
|
|
|
FIXME("unknown type %x!\n", src->uType);
|
|
|
|
if (len) *dest = '\0';
|
|
|
|
return E_FAIL;
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
return S_OK;
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* FILEDLG95_FILENAME_GetFileNames
|
|
|
|
*
|
2004-11-29 17:59:14 +01:00
|
|
|
* Copies the filenames to a delimited string list.
|
2000-10-23 01:46:21 +02:00
|
|
|
*/
|
2008-04-16 18:05:25 +02:00
|
|
|
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
UINT nFileCount = 0; /* number of files */
|
|
|
|
UINT nStrLen = 0; /* length of string in edit control */
|
|
|
|
LPWSTR lpstrEdit; /* buffer for string from edit control */
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2012-09-25 13:40:18 +02:00
|
|
|
/* get the filenames from the filename control */
|
|
|
|
nStrLen = GetWindowTextLengthW( fodInfos->DlgInfos.hwndFileName );
|
2018-03-20 08:37:47 +01:00
|
|
|
lpstrEdit = heap_alloc( (nStrLen+1)*sizeof(WCHAR) );
|
2012-09-25 13:40:18 +02:00
|
|
|
GetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrEdit, nStrLen+1);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit));
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2011-04-01 05:52:31 +02:00
|
|
|
nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed);
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free(lpstrEdit);
|
2003-10-16 02:16:40 +02:00
|
|
|
return nFileCount;
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/*
|
|
|
|
* DATAOBJECT Helper functions
|
|
|
|
*/
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* COMCTL32_ReleaseStgMedium
|
|
|
|
*
|
|
|
|
* like ReleaseStgMedium from ole32
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static void COMCTL32_ReleaseStgMedium (STGMEDIUM medium)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
if(medium.pUnkForRelease)
|
|
|
|
{
|
|
|
|
IUnknown_Release(medium.pUnkForRelease);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GlobalUnlock(medium.u.hGlobal);
|
|
|
|
GlobalFree(medium.u.hGlobal);
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetPidlFromDataObject
|
|
|
|
*
|
|
|
|
* Return pidl(s) by number from the cached DataObject
|
|
|
|
*
|
|
|
|
* nPidlIndex=0 gets the fully qualified root path
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
STGMEDIUM medium;
|
2016-07-06 12:27:42 +02:00
|
|
|
FORMATETC formatetc = get_def_format();
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST pidl = NULL;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2005-08-12 12:33:06 +02:00
|
|
|
if (!doSelected)
|
|
|
|
return NULL;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* Get the pidls from IDataObject */
|
|
|
|
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPIDA cida = GlobalLock(medium.u.hGlobal);
|
|
|
|
if(nPidlIndex <= cida->cidl)
|
|
|
|
{
|
2018-03-21 06:59:42 +01:00
|
|
|
pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex]]));
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
COMCTL32_ReleaseStgMedium(medium);
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
return pidl;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2000-11-28 23:40:56 +01:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNumSelected
|
|
|
|
*
|
|
|
|
* Return the number of selected items in the DataObject.
|
|
|
|
*
|
|
|
|
*/
|
2008-12-03 12:12:52 +01:00
|
|
|
static UINT GetNumSelected( IDataObject *doSelected )
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
UINT retVal = 0;
|
|
|
|
STGMEDIUM medium;
|
2016-07-06 12:27:42 +02:00
|
|
|
FORMATETC formatetc = get_def_format();
|
2003-10-16 02:16:40 +02:00
|
|
|
|
|
|
|
TRACE("sv=%p\n", doSelected);
|
|
|
|
|
|
|
|
if (!doSelected) return 0;
|
|
|
|
|
|
|
|
/* Get the pidls from IDataObject */
|
|
|
|
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPIDA cida = GlobalLock(medium.u.hGlobal);
|
|
|
|
retVal = cida->cidl;
|
|
|
|
COMCTL32_ReleaseStgMedium(medium);
|
|
|
|
return retVal;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
return 0;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/*
|
|
|
|
* TOOLS
|
|
|
|
*/
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetName
|
|
|
|
*
|
|
|
|
* Get the pidl's display name (relative to folder) and
|
|
|
|
* put it in lpstrFileName.
|
|
|
|
*
|
|
|
|
* Return NOERROR on success,
|
|
|
|
* E_FAIL otherwise
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
|
2007-03-07 14:19:19 +01:00
|
|
|
static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPWSTR lpstrFileName)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
STRRET str;
|
|
|
|
HRESULT hRes;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("sf=%p pidl=%p\n", lpsf, pidl);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(!lpsf)
|
|
|
|
{
|
|
|
|
SHGetDesktopFolder(&lpsf);
|
|
|
|
hRes = GetName(lpsf,pidl,dwFlags,lpstrFileName);
|
|
|
|
IShellFolder_Release(lpsf);
|
|
|
|
return hRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the display name of the pidl relative to the folder */
|
|
|
|
if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, pidl, dwFlags, &str)))
|
|
|
|
{
|
2007-03-07 14:19:19 +01:00
|
|
|
return COMDLG32_StrRetToStrNW(lpstrFileName, MAX_PATH, &str, pidl);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
return E_FAIL;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetShellFolderFromPidl
|
|
|
|
*
|
|
|
|
* pidlRel is the item pidl relative
|
|
|
|
* Return the IShellFolder of the absolute pidl
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
IShellFolder *GetShellFolderFromPidl(LPITEMIDLIST pidlAbs)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
IShellFolder *psf = NULL,*psfParent;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("%p\n", pidlAbs);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(SUCCEEDED(SHGetDesktopFolder(&psfParent)))
|
|
|
|
{
|
|
|
|
psf = psfParent;
|
|
|
|
if(pidlAbs && pidlAbs->mkid.cb)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
|
|
|
|
{
|
|
|
|
IShellFolder_Release(psfParent);
|
|
|
|
return psf;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
/* return the desktop */
|
|
|
|
return psfParent;
|
|
|
|
}
|
|
|
|
return NULL;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* GetParentPidl
|
2000-08-02 01:33:37 +02:00
|
|
|
*
|
2003-10-16 02:16:40 +02:00
|
|
|
* Return the LPITEMIDLIST to the parent of the pidl in the list
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST pidlParent;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("%p\n", pidl);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2018-03-21 06:59:42 +01:00
|
|
|
pidlParent = ILClone(pidl);
|
|
|
|
ILRemoveLastID(pidlParent);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return pidlParent;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* GetPidlFromName
|
2000-08-02 01:33:37 +02:00
|
|
|
*
|
2003-10-16 02:16:40 +02:00
|
|
|
* returns the pidl of the file name relative to folder
|
|
|
|
* NULL if an error occurred
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2006-11-30 15:15:46 +01:00
|
|
|
static LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPWSTR lpcstrFileName)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2003-10-16 02:16:40 +02:00
|
|
|
LPITEMIDLIST pidl = NULL;
|
|
|
|
ULONG ulEaten;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("sf=%p file=%s\n", lpsf, debugstr_w(lpcstrFileName));
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if(!lpcstrFileName) return NULL;
|
|
|
|
if(!*lpcstrFileName) return NULL;
|
|
|
|
|
|
|
|
if(!lpsf)
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(SHGetDesktopFolder(&lpsf))) {
|
|
|
|
IShellFolder_ParseDisplayName(lpsf, 0, NULL, lpcstrFileName, &ulEaten, &pidl, NULL);
|
|
|
|
IShellFolder_Release(lpsf);
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IShellFolder_ParseDisplayName(lpsf, 0, NULL, lpcstrFileName, &ulEaten, &pidl, NULL);
|
|
|
|
}
|
|
|
|
return pidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2008-12-03 12:12:52 +01:00
|
|
|
static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl)
|
2003-10-16 02:16:40 +02:00
|
|
|
{
|
|
|
|
ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
TRACE("%p, %p\n", psf, pidl);
|
|
|
|
|
|
|
|
ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2006-10-13 15:04:43 +02:00
|
|
|
TRACE("-- 0x%08x 0x%08x\n", uAttr, ret);
|
2003-10-16 02:16:40 +02:00
|
|
|
/* see documentation shell 4.1*/
|
|
|
|
return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-10-16 02:16:40 +02:00
|
|
|
* BrowseSelectedFolder
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2003-10-16 02:16:40 +02:00
|
|
|
static BOOL BrowseSelectedFolder(HWND hwnd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-02-21 13:35:17 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
|
2003-10-16 02:16:40 +02:00
|
|
|
BOOL bBrowseSelFolder = FALSE;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
TRACE("\n");
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
if (GetNumSelected(fodInfos->Shell.FOIDataObject) == 1)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlSelection;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
/* get the file selected */
|
|
|
|
pidlSelection = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 1);
|
|
|
|
if (IsPidlFolder (fodInfos->Shell.FOIShellFolder, pidlSelection))
|
|
|
|
{
|
|
|
|
if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
|
|
|
|
pidlSelection, SBSP_RELATIVE ) ) )
|
|
|
|
{
|
2017-02-14 08:00:47 +01:00
|
|
|
WCHAR buf[64];
|
2018-03-29 17:14:12 +02:00
|
|
|
LoadStringW( COMDLG32_hInstance, IDS_PATHNOTEXISTING, buf, ARRAY_SIZE(buf));
|
2017-02-14 08:00:47 +01:00
|
|
|
MessageBoxW( hwnd, buf, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2005-06-04 11:36:37 +02:00
|
|
|
bBrowseSelFolder = TRUE;
|
2009-05-05 12:38:34 +02:00
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
|
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2018-03-21 06:59:42 +01:00
|
|
|
ILFree( pidlSelection );
|
2003-10-16 02:16:40 +02:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2003-10-16 02:16:40 +02:00
|
|
|
return bBrowseSelFolder;
|
|
|
|
}
|
|
|
|
|
2012-09-21 14:22:51 +02:00
|
|
|
static inline BOOL valid_struct_size( DWORD size )
|
|
|
|
{
|
|
|
|
return (size == OPENFILENAME_SIZE_VERSION_400W) ||
|
|
|
|
(size == sizeof( OPENFILENAMEW ));
|
|
|
|
}
|
|
|
|
|
2012-07-27 14:13:15 +02:00
|
|
|
static inline BOOL is_win16_looks(DWORD flags)
|
|
|
|
{
|
|
|
|
return (flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE) &&
|
|
|
|
!(flags & OFN_EXPLORER));
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* ------------------ APIs ---------------------- */
|
2000-08-02 01:33:37 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetOpenFileNameA (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to open.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
2017-02-21 13:35:16 +01:00
|
|
|
BOOL WINAPI GetOpenFileNameA(OPENFILENAMEA *ofn)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("flags 0x%08x\n", ofn->Flags);
|
2005-11-18 17:52:35 +01:00
|
|
|
|
2012-09-21 14:22:51 +02:00
|
|
|
if (!valid_struct_size( ofn->lStructSize ))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError( CDERR_STRUCTSIZE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-02-03 20:39:26 +01:00
|
|
|
/* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
|
|
|
|
if (ofn->Flags & OFN_FILEMUSTEXIST)
|
|
|
|
ofn->Flags |= OFN_PATHMUSTEXIST;
|
|
|
|
|
2012-07-27 14:13:15 +02:00
|
|
|
if (is_win16_looks(ofn->Flags))
|
2004-04-13 00:03:55 +02:00
|
|
|
return GetFileName31A(ofn, OPEN_DIALOG);
|
|
|
|
else
|
2017-02-21 13:35:16 +01:00
|
|
|
{
|
|
|
|
FileOpenDlgInfos info;
|
|
|
|
|
|
|
|
init_filedlg_infoA(ofn, &info);
|
|
|
|
return GetFileDialog95(&info, OPEN_DIALOG);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetOpenFileNameW (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to open.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
2017-02-21 13:35:16 +01:00
|
|
|
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2017-05-31 05:16:02 +02:00
|
|
|
TRACE("flags 0x%08x\n", ofn->Flags);
|
2005-11-18 17:52:35 +01:00
|
|
|
|
2012-09-21 14:22:51 +02:00
|
|
|
if (!valid_struct_size( ofn->lStructSize ))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError( CDERR_STRUCTSIZE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-18 17:52:35 +01:00
|
|
|
/* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
|
|
|
|
if (ofn->Flags & OFN_FILEMUSTEXIST)
|
|
|
|
ofn->Flags |= OFN_PATHMUSTEXIST;
|
|
|
|
|
2012-07-27 14:13:15 +02:00
|
|
|
if (is_win16_looks(ofn->Flags))
|
2004-04-13 00:03:55 +02:00
|
|
|
return GetFileName31W(ofn, OPEN_DIALOG);
|
|
|
|
else
|
2017-02-21 13:35:16 +01:00
|
|
|
{
|
|
|
|
FileOpenDlgInfos info;
|
|
|
|
|
|
|
|
init_filedlg_infoW(ofn, &info);
|
|
|
|
return GetFileDialog95(&info, OPEN_DIALOG);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2004-04-13 00:03:55 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetSaveFileNameA (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to save.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
2017-02-21 13:35:16 +01:00
|
|
|
BOOL WINAPI GetSaveFileNameA(OPENFILENAMEA *ofn)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2012-09-21 14:22:51 +02:00
|
|
|
if (!valid_struct_size( ofn->lStructSize ))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError( CDERR_STRUCTSIZE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-27 14:13:15 +02:00
|
|
|
if (is_win16_looks(ofn->Flags))
|
2004-04-13 00:03:55 +02:00
|
|
|
return GetFileName31A(ofn, SAVE_DIALOG);
|
|
|
|
else
|
2017-02-21 13:35:16 +01:00
|
|
|
{
|
|
|
|
FileOpenDlgInfos info;
|
|
|
|
|
|
|
|
init_filedlg_infoA(ofn, &info);
|
|
|
|
return GetFileDialog95(&info, SAVE_DIALOG);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetSaveFileNameW (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to save.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetSaveFileNameW(
|
2000-12-02 00:58:28 +01:00
|
|
|
LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2012-09-21 14:22:51 +02:00
|
|
|
if (!valid_struct_size( ofn->lStructSize ))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError( CDERR_STRUCTSIZE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-27 14:13:15 +02:00
|
|
|
if (is_win16_looks(ofn->Flags))
|
2004-04-13 00:03:55 +02:00
|
|
|
return GetFileName31W(ofn, SAVE_DIALOG);
|
|
|
|
else
|
2017-02-21 13:35:16 +01:00
|
|
|
{
|
|
|
|
FileOpenDlgInfos info;
|
|
|
|
|
|
|
|
init_filedlg_infoW(ofn, &info);
|
|
|
|
return GetFileDialog95(&info, SAVE_DIALOG);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2007-01-12 00:05:58 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetFileTitleA (COMDLG32.@)
|
|
|
|
*
|
|
|
|
* See GetFileTitleW.
|
|
|
|
*/
|
|
|
|
short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
UNICODE_STRING strWFile;
|
|
|
|
LPWSTR lpWTitle;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
|
2018-03-20 08:37:47 +01:00
|
|
|
lpWTitle = heap_alloc(cbBuf * sizeof(WCHAR));
|
2007-01-12 00:05:58 +01:00
|
|
|
ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf);
|
|
|
|
if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL );
|
|
|
|
RtlFreeUnicodeString( &strWFile );
|
2018-03-20 08:37:47 +01:00
|
|
|
heap_free( lpWTitle );
|
2007-01-12 00:05:58 +01:00
|
|
|
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;
|
|
|
|
TRACE("(%p %p %d);\n", lpFile, lpTitle, cbBuf);
|
|
|
|
|
|
|
|
if(lpFile == NULL || lpTitle == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
len = lstrlenW(lpFile);
|
2007-01-12 00:05:58 +01:00
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return -1;
|
|
|
|
|
2020-11-23 00:15:51 +01:00
|
|
|
if(wcspbrk(lpFile, L"*[]"))
|
2007-01-12 00:05:58 +01:00
|
|
|
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++;
|
|
|
|
|
2007-01-18 11:40:15 +01:00
|
|
|
TRACE("---> %s\n", debugstr_w(&lpFile[i]));
|
2007-01-12 00:05:58 +01:00
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
len = lstrlenW(lpFile+i)+1;
|
2007-01-12 00:05:58 +01:00
|
|
|
if(cbBuf < len)
|
|
|
|
return len;
|
|
|
|
|
2007-03-07 14:18:40 +01:00
|
|
|
lstrcpyW(lpTitle, &lpFile[i]);
|
2007-01-12 00:05:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|