Sync to Wine-20050628:

Juan Lang <juan_lang@yahoo.com>
- Fix return code abuse (don't use HRESULT when it isn't meant), make
  functions static where possible, remove unused prototypes.
Dmitry Timoshkov <dmitry@codeweavers.com>
- Make some of the OLE interface vtables const.
Michael Jung <mjung@iss.tu-darmstadt.de>
- Use IShellFolder::GetDisplayNameOf instead of SHGetPathFromIDList to
  be able to browse shell namespace extensions.
Vitaly Lipatov <lav@etersoft.ru>
- Add some descriptions for PageSetupDlg functions.
- Implement user paint hook support and PSD_ENABLEPAGEPAINTHOOK
  checking.
Huw Davies <huw@codeweavers.com>
- If a folder is selected on Open then browse into it, otherwise we
  should return the path in the edit box whether that be a folder or a
  file.
- Don't add extensions to a folder.
- Use DWLP_MSGRESULT to return values from the dialog proc.
- Send CDN_FOLDERCHANGE whenever we change folder.

svn path=/trunk/; revision=16473
This commit is contained in:
Gé van Geldorp 2005-07-06 22:40:35 +00:00
parent 8a79bd9b46
commit 8322ac0d33
4 changed files with 361 additions and 209 deletions

View file

@ -196,6 +196,9 @@ static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb);
static void FILEDLG95_SHELL_Clean(HWND hwnd);
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd);
/* Functions used by the EDIT box */
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator);
/* Functions used by the filetype combo box */
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode);
@ -203,7 +206,7 @@ static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt);
static void FILEDLG95_FILETYPE_Clean(HWND hwnd);
/* Functions used by the Look In combo box */
static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo);
static void FILEDLG95_LOOKIN_Init(HWND hwndCombo);
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);
@ -214,8 +217,7 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd);
static void FILEDLG95_LOOKIN_Clean(HWND hwnd);
/* Miscellaneous tool functions */
HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
@ -224,11 +226,10 @@ LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
static void *MemAlloc(UINT size);
static void MemFree(void *mem);
BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos);
INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
static BOOL BrowseSelectedFolder(HWND hwnd);
/***********************************************************************
@ -241,7 +242,7 @@ static BOOL BrowseSelectedFolder(HWND hwnd);
* OUT : TRUE on success
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*/
BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)
static BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)
{
LRESULT lRes;
@ -511,6 +512,27 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
return ret;
}
/******************************************************************************
* 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));
}
/***********************************************************************
* ArrangeCtrlPositions [internal]
*
@ -790,17 +812,16 @@ HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
*/
HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
TRACE("%p 0x%04x\n",hwndParentDlg, uCode);
if(!fodInfos) return 0;
if(!fodInfos) return;
if(fodInfos->DlgInfos.hwndCustomDlg)
{
HRESULT ret;
TRACE("CALL NOTIFY for %x\n", uCode);
if(fodInfos->unicode)
{
@ -810,7 +831,7 @@ HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
ret = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
else
{
@ -820,17 +841,15 @@ HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
TRACE("RET NOTIFY\n");
return ret;
}
return TRUE;
}
HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
{
UINT sizeUsed = 0, n, total;
INT_PTR sizeUsed = 0, n, total;
LPWSTR lpstrFileList = NULL;
WCHAR lpstrCurrentDir[MAX_PATH];
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
@ -841,7 +860,7 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
return -1;
/* get path and filenames */
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir);
n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');
TRACE("path >%s< filespec >%s< %d files\n",
@ -890,9 +909,9 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
return total;
}
HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
static INT_PTR FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
{
UINT sizeUsed = 0;
INT_PTR sizeUsed = 0;
LPWSTR lpstrFileList = NULL;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
@ -922,37 +941,37 @@ HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
*
* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
*/
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
if(!fodInfos) return -1;
WCHAR lpstrPath[MAX_PATH];
INT_PTR retval;
if(!fodInfos) return FALSE;
switch(uMsg)
{
case CDM_GETFILEPATH:
return FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);
retval = FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);
break;
case CDM_GETFOLDERPATH:
TRACE("CDM_GETFOLDERPATH:\n");
if( fodInfos->unicode )
COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
if (lParam)
{
WCHAR lpstrPath[MAX_PATH], *bufW = (LPWSTR)lParam;
SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufW)
lstrcpynW(bufW,lpstrPath,(int)wParam);
return strlenW(lpstrPath);
}
else
{
char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam;
SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufA)
lstrcpynA(bufA,lpstrPath,(int)wParam);
return strlen(lpstrPath);
}
if (fodInfos->unicode)
lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
else
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
(LPSTR)lParam, (int)wParam, NULL, NULL);
}
retval = strlenW(lpstrPath);
break;
case CDM_GETSPEC:
return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
retval = FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
break;
case CDM_SETCONTROLTEXT:
TRACE("CDM_SETCONTROLTEXT:\n");
@ -963,13 +982,19 @@ HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam
else
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
}
return TRUE;
retval = TRUE;
break;
case CDM_HIDECONTROL:
case CDM_SETDEFEXT:
FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n");
return -1;
retval = -1;
break;
default:
return FALSE;
}
SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, retval);
return TRUE;
}
@ -1597,7 +1622,7 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo
ofn->lpstrFile[0] = '\0';
}
SHGetPathFromIDListW( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
@ -1685,9 +1710,8 @@ BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCo
*
* If the function succeeds, the return value is nonzero.
*/
#define ONOPEN_BROWSE 1
#define ONOPEN_OPEN 2
#define ONOPEN_SEARCH 3
#define ONOPEN_OPEN 1
#define ONOPEN_SEARCH 2
static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
{
WCHAR strMsgTitle[MAX_PATH];
@ -1714,15 +1738,15 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
TRACE("hwnd=%p\n", hwnd);
if(BrowseSelectedFolder(hwnd))
return FALSE;
/* get the files from the edit control */
nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, '\0');
/* try if the user selected a folder in the shellview */
if(nFileCount == 0)
{
BrowseSelectedFolder(hwnd);
return FALSE;
}
if(nFileCount > 1)
{
@ -1742,14 +1766,10 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
*/
/* Get the current directory name */
if (!SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
{
/* we are in a special folder, default to desktop */
if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))
{
/* last fallback */
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
}
/* last fallback */
GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
}
PathAddBackslashW(lpstrPathAndFile);
@ -1787,7 +1807,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
lpstrPathAndFile: cleaned up path
*/
nOpenAction = ONOPEN_BROWSE;
nOpenAction = ONOPEN_OPEN;
/* don't apply any checks with OFN_NOVALIDATE */
{
@ -1920,6 +1940,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
int iPos;
LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
DWORD len;
IPersistFolder2 * ppf2;
/* replace the current filter */
if(fodInfos->ShellInfos.lpstrCurrentFilter)
@ -1931,12 +1952,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
/* set the filter cb to the extension when possible */
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos);
}
/* fall through */
case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
TRACE("ONOPEN_BROWSE\n");
{
IPersistFolder2 * ppf2;
if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
{
LPITEMIDLIST pidlCurrent;
@ -1946,10 +1962,11 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
{
IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
}
else if( nOpenAction == ONOPEN_SEARCH )
else
{
IShellView_Refresh(fodInfos->Shell.FOIShellView);
}
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
COMDLG32_SHFree(pidlCurrent);
}
}
@ -1967,48 +1984,51 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
/* Attach the file extension with file name*/
ext = PathFindExtensionW(lpstrPathAndFile);
if (! *ext)
if(!PathIsDirectoryW(lpstrPathAndFile))
{
/* if no extension is specified with file name, then */
/* attach the extension from file filter or default one */
if((ext = PathFindExtensionW(lpstrPathAndFile)) == NULL)
{
/* if no extension is specified with file name, then */
/* attach the extension from file filter or default one */
WCHAR *filterExt = NULL;
LPWSTR lpstrFilter = NULL;
static const WCHAR szwDot[] = {'.',0};
int PathLength = strlenW(lpstrPathAndFile);
WCHAR *filterExt = NULL;
LPWSTR lpstrFilter = NULL;
static const WCHAR szwDot[] = {'.',0};
int PathLength = strlenW(lpstrPathAndFile);
/* Attach the dot*/
strcatW(lpstrPathAndFile, szwDot);
/* Attach the dot*/
strcatW(lpstrPathAndFile, szwDot);
/*Get the file extension from file type filter*/
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
fodInfos->ofnInfos->nFilterIndex-1);
/*Get the file extension from file type filter*/
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
fodInfos->ofnInfos->nFilterIndex-1);
if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
filterExt = PathFindExtensionW(lpstrFilter);
if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
filterExt = PathFindExtensionW(lpstrFilter);
if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/
strcatW(lpstrPathAndFile, filterExt + 1);
else if ( fodInfos->defext ) /* attach the default file extension*/
strcatW(lpstrPathAndFile, fodInfos->defext);
if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/
strcatW(lpstrPathAndFile, filterExt + 1);
else if ( fodInfos->defext ) /* attach the default file extension*/
strcatW(lpstrPathAndFile, fodInfos->defext);
/* In Open dialog: if file does not exist try without extension */
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
lpstrPathAndFile[PathLength] = '\0';
/* In Open dialog: if file does not exist try without extension */
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
lpstrPathAndFile[PathLength] = '\0';
}
if (fodInfos->defext) /* add default extension */
{
/* 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;
}
}
if (fodInfos->defext) /* add default extension */
{
/* 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;
}
/* In Save dialog: check if the file already exists */
if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG
&& fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT
@ -2208,6 +2228,7 @@ static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
NULL,
SBSP_PARENT)))
{
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
return TRUE;
}
return FALSE;
@ -2229,6 +2250,7 @@ static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
COMDLG32_SHFree(pidl);
return SUCCEEDED(hres);
}
@ -2361,8 +2383,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
}
} else
fodInfos->ofnInfos->nFilterIndex = 0;
return NOERROR;
return S_OK;
}
/***********************************************************************
@ -2465,7 +2486,7 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
*
* Initialisation of the look in combo box
*/
static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
{
IShellFolder *psfRoot, *psfDrives;
IEnumIDList *lpeRoot, *lpeDrives;
@ -2532,7 +2553,6 @@ static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
}
COMDLG32_SHFree(pidlDrives);
return NOERROR;
}
/***********************************************************************
@ -2680,6 +2700,7 @@ static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
tmpFolder->pidlItem,
SBSP_ABSOLUTE)))
{
SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
return TRUE;
}
break;
@ -3009,7 +3030,9 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
}
/* copied from shell32 to avoid linking to it */
/* copied from shell32 to avoid linking to it
* FIXME: why? shell32 is already linked
*/
static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
{
switch (src->uType)
@ -3033,7 +3056,7 @@ static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPI
{
*(LPSTR)dest = '\0';
}
return(FALSE);
return(E_FAIL);
}
return S_OK;
}
@ -3045,7 +3068,7 @@ static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPI
* The delimiter is specified by the parameter 'separator',
* usually either a space or a nul
*/
int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator)
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
UINT nStrCharCount = 0; /* index in src buffer */
@ -3211,7 +3234,7 @@ UINT GetNumSelected( IDataObject *doSelected )
* E_FAIL otherwise
*/
HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)
static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)
{
STRRET str;
HRESULT hRes;
@ -3351,8 +3374,8 @@ static BOOL BrowseSelectedFolder(HWND hwnd)
' ','n','o','t',' ','e','x','i','s','t',0};
MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
}
bBrowseSelFolder = TRUE;
bBrowseSelFolder = TRUE;
SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
}
COMDLG32_SHFree( pidlSelection );
}

View file

@ -47,9 +47,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
typedef struct
{
IShellBrowserVtbl * lpVtbl;
ICommDlgBrowserVtbl * lpVtblCommDlgBrowser;
IServiceProviderVtbl* lpVtblServiceProvider;
const IShellBrowserVtbl *lpVtbl;
const ICommDlgBrowserVtbl *lpVtblCommDlgBrowser;
const IServiceProviderVtbl *lpVtblServiceProvider;
DWORD ref; /* Reference counter */
HWND hwndOwner; /* Owner dialog of the interface */
@ -58,9 +58,9 @@ typedef struct
/**************************************************************************
* vtable
*/
static IShellBrowserVtbl IShellBrowserImpl_Vtbl;
static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
static const IShellBrowserVtbl IShellBrowserImpl_Vtbl;
static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl;
static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl;
/**************************************************************************
* Local Prototypes
@ -76,19 +76,12 @@ LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
*/
extern const char *FileOpenDlgInfosStr;
extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
LPITEMIDLIST pidlCurrentFolder,
LPSTR lpstrMask);
extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
extern BOOL FILEDLG95_OnOpen(HWND hwnd);
extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
extern void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
/*
@ -140,11 +133,25 @@ static void COMDLG32_DumpSBSPFlags(UINT uflags)
static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos)
{
char lpstrPath[MAX_PATH];
if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) {
SetCurrentDirectoryA(lpstrPath);
TRACE("new current folder %s\n", lpstrPath);
LPSHELLFOLDER psfDesktop;
STRRET strret;
HRESULT res;
res = SHGetDesktopFolder(&psfDesktop);
if (FAILED(res))
return;
res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent,
SHGDN_FORPARSING, &strret);
if (SUCCEEDED(res)) {
WCHAR wszCurrentDir[MAX_PATH];
res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH);
if (SUCCEEDED(res))
SetCurrentDirectoryW(wszCurrentDir);
}
IShellFolder_Release(psfDesktop);
}
/* copied from shell32 to avoid linking to it */
@ -675,7 +682,7 @@ HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
return E_NOTIMPL;
}
static IShellBrowserVtbl IShellBrowserImpl_Vtbl =
static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
{
/* IUnknown */
IShellBrowserImpl_QueryInterface,
@ -900,7 +907,7 @@ HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IS
return S_OK;
}
static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
{
/* IUnknown */
IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
@ -989,7 +996,7 @@ HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
}
static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
{
/* IUnknown */
IShellBrowserImpl_IServiceProvider_QueryInterface,

View file

@ -161,6 +161,5 @@ BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
/* Functions used by the EDIT box */
void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd);
int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator);
#endif /*SHBROWSER_H*/

View file

@ -1945,11 +1945,6 @@ static BOOL PRINTDLG_CreateDCW(LPPRINTDLGW lppd)
* PrintDlg:
* * The Collate Icons do not display, even though they are in the code.
* * The Properties Button(s) should call DocumentPropertiesA().
* PrintSetupDlg:
* * The Paper Orientation Icons are not implemented yet.
* * The Properties Button(s) should call DocumentPropertiesA().
* * Settings are not yet taken from a provided DevMode or
* default printer settings.
*/
BOOL WINAPI PrintDlgA(
@ -2266,6 +2261,7 @@ BOOL WINAPI PrintDlgW(
* PageSetupDlg
* rad1 - portrait
* rad2 - landscape
* cmb1 - printer select (not in standart dialog template)
* cmb2 - paper size
* cmb3 - source (tray?)
* edt4 - border left
@ -2609,24 +2605,153 @@ PRINTDLG_PS_WMCommandW(
}
static LRESULT CALLBACK
PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/***********************************************************************
* DefaultPagePaintHook
* Default hook paint procedure that receives WM_PSD_* messages from the dialog box
* whenever the sample page is redrawn.
*/
static UINT_PTR
PRINTDLG_DefaultPagePaintHook(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PageSetupDataA *pda)
{
if (uMsg == WM_PAINT)
LPRECT lprc = (LPRECT) lParam;
HDC hdc = (HDC) wParam;
HPEN hpen, holdpen;
LOGFONTW lf;
HFONT hfont, holdfont;
INT oldbkmode;
TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER);
/* Call user paint hook if enable */
if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK)
if (pda->dlga->lpfnPagePaintHook(hwndDlg, uMsg, wParam, lParam))
return TRUE;
switch (uMsg) {
/* LPPAGESETUPDLG in lParam */
case WM_PSD_PAGESETUPDLG:
/* Inform about the sample page rectangle */
case WM_PSD_FULLPAGERECT:
/* Inform about the margin rectangle */
case WM_PSD_MINMARGINRECT:
return FALSE;
/* Draw dashed rectangle showing margins */
case WM_PSD_MARGINRECT:
hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW));
holdpen = SelectObject(hdc, hpen);
Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom);
DeleteObject(SelectObject(hdc, holdpen));
return TRUE;
/* Draw the fake document */
case WM_PSD_GREEKTEXTRECT:
/* select a nice scalable font, because we want the text really small */
SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
lf.lfHeight = 6; /* value chosen based on visual effect */
hfont = CreateFontIndirectW(&lf);
holdfont = SelectObject(hdc, hfont);
/* if text not loaded, then do so now */
if (wszFakeDocumentText[0] == '\0')
LoadStringW(COMDLG32_hInstance,
IDS_FAKEDOCTEXT,
wszFakeDocumentText,
sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0]));
oldbkmode = SetBkMode(hdc, TRANSPARENT);
DrawTextW(hdc, wszFakeDocumentText, -1, lprc, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);
SetBkMode(hdc, oldbkmode);
DeleteObject(SelectObject(hdc, holdfont));
return TRUE;
/* Envelope stamp */
case WM_PSD_ENVSTAMPRECT:
/* Return address */
case WM_PSD_YAFULLPAGERECT:
FIXME("envelope/stamp is not implemented\n");
return FALSE;
default:
FIXME("Unknown message %x\n",uMsg);
return FALSE;
}
return TRUE;
}
/***********************************************************************
* PagePaintProc
* The main paint procedure for the PageSetupDlg function.
* The Page Setup dialog box includes an image of a sample page that shows how
* the user's selections affect the appearance of the printed output.
* The image consists of a rectangle that represents the selected paper
* or envelope type, with a dotted-line rectangle representing
* the current margins, and partial (Greek text) characters
* to show how text looks on the printed page.
*
* The following messages in the order sends to user hook procedure:
* WM_PSD_PAGESETUPDLG Draw the contents of the sample page
* WM_PSD_FULLPAGERECT Inform about the bounding rectangle
* WM_PSD_MINMARGINRECT Inform about the margin rectangle (min margin?)
* WM_PSD_MARGINRECT Draw the margin rectangle
* WM_PSD_GREEKTEXTRECT Draw the Greek text inside the margin rectangle
* If any of first three messages returns TRUE, painting done.
*
* PARAMS:
* hWnd [in] Handle to the Page Setup dialog box
* uMsg [in] Received message
*
* TODO:
* WM_PSD_ENVSTAMPRECT Draw in the envelope-stamp rectangle (for envelopes only)
* WM_PSD_YAFULLPAGERECT Draw the return address portion (for envelopes and other paper sizes)
*
* RETURNS:
* FALSE if all done correctly
*
*/
static LRESULT CALLBACK
PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
RECT rcClient, rcMargin;
HPEN hpen, holdpen;
HDC hdc;
HBRUSH hbrush, holdbrush;
PageSetupDataA *pda;
int papersize=0, orientation=0; /* FIXME: set this values */
#define CALLPAINTHOOK(msg,lprc) PRINTDLG_DefaultPagePaintHook( hWnd, msg, (WPARAM)hdc, (LPARAM)lprc, pda)
if (uMsg != WM_PAINT)
return CallWindowProcA(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam);
/* Processing WM_PAINT message */
pda = (PageSetupDataA*)GetPropA(hWnd, "__WINE_PAGESETUPDLGDATA");
if (!pda) {
WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
return FALSE;
}
if (PRINTDLG_DefaultPagePaintHook(hWnd, WM_PSD_PAGESETUPDLG, MAKELONG(papersize, orientation), (LPARAM)pda->dlga, pda))
return FALSE;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rcClient);
/* FIXME: use real margin values */
rcMargin = rcClient;
rcMargin.left += 5;
rcMargin.top += 5;
rcMargin.right -= 5;
rcMargin.bottom -= 5;
/* if the space is too small then we make sure to not draw anything */
rcMargin.left = min(rcMargin.left, rcMargin.right);
rcMargin.top = min(rcMargin.top, rcMargin.bottom);
if (!CALLPAINTHOOK(WM_PSD_FULLPAGERECT, &rcClient) &&
!CALLPAINTHOOK(WM_PSD_MINMARGINRECT, &rcMargin) )
{
PAINTSTRUCT ps;
RECT rcClient;
HPEN hpen, holdpen;
HDC hdc;
HFONT hfont, holdfont;
LOGFONTW lf;
HBRUSH hbrush, holdbrush;
INT oldbkmode;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rcClient);
/* fill background */
hbrush = GetSysColorBrush(COLOR_3DHIGHLIGHT);
FillRect(hdc, &rcClient, hbrush);
@ -2635,6 +2760,7 @@ PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
holdpen = SelectObject(hdc, hpen);
/* paint left edge */
MoveToEx(hdc, rcClient.left, rcClient.top, NULL);
LineTo(hdc, rcClient.left, rcClient.bottom-1);
@ -2654,79 +2780,51 @@ PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
MoveToEx(hdc, rcClient.left, rcClient.bottom-1, NULL);
LineTo(hdc, rcClient.right, rcClient.bottom-1);
hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW));
DeleteObject(SelectObject(hdc, hpen));
/* draw dashed rectangle showing margins */
/* FIXME: use real margin values */
rcClient.left += 5;
rcClient.top += 5;
rcClient.right -= 5;
rcClient.bottom -= 5;
/* if the space is too small then we make sure to not draw anything */
rcClient.left = min(rcClient.left,rcClient.right);
rcClient.top = min(rcClient.top,rcClient.bottom);
Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
DeleteObject(SelectObject(hdc, holdpen));
DeleteObject(SelectObject(hdc, holdbrush));
CALLPAINTHOOK(WM_PSD_MARGINRECT, &rcMargin);
/* draw the fake document */
/* give text a bit of a space from the frame */
rcClient.left += 2;
rcClient.top += 2;
rcClient.right -= 2;
rcClient.bottom -= 2;
rcMargin.left += 2;
rcMargin.top += 2;
rcMargin.right -= 2;
rcMargin.bottom -= 2;
/* if the space is too small then we make sure to not draw anything */
rcClient.left = min(rcClient.left,rcClient.right);
rcClient.top = min(rcClient.top,rcClient.bottom);
rcMargin.left = min(rcMargin.left, rcMargin.right);
rcMargin.top = min(rcMargin.top, rcMargin.bottom);
/* select a nice scalable font, because we want the text really small */
SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
lf.lfHeight = 6; /* value chosen based on visual effect */
hfont = CreateFontIndirectW(&lf);
holdfont = SelectObject(hdc, hfont);
/* if text not loaded, then do so now */
if (wszFakeDocumentText[0] == '\0')
LoadStringW(COMDLG32_hInstance,
IDS_FAKEDOCTEXT,
wszFakeDocumentText,
sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0]));
oldbkmode = SetBkMode(hdc, TRANSPARENT);
DrawTextW(hdc, wszFakeDocumentText, -1, &rcClient, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);
SetBkMode(hdc, oldbkmode);
DeleteObject(SelectObject(hdc, holdfont));
SelectObject(hdc, holdbrush);
EndPaint(hWnd, &ps);
return 0;
CALLPAINTHOOK(WM_PSD_GREEKTEXTRECT, &rcMargin);
}
else
return CallWindowProcW(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam);
EndPaint(hWnd, &ps);
return FALSE;
#undef CALLPAINTHOOK
}
/***********************************************************************
* PRINTDLG_PageDlgProcA
* Message handler
*/
static INT_PTR CALLBACK
PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
PRINTDLG_PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PageSetupDataA *pda;
INT_PTR res = FALSE;
if (uMsg==WM_INITDIALOG) {
if (uMsg == WM_INITDIALOG) {
pda = (PageSetupDataA*)lParam;
TRACE("set property to %p", pda);
SetPropA(hDlg, "__WINE_PAGESETUPDLGDATA", pda);
SetPropA(GetDlgItem(hDlg, rct1), "__WINE_PAGESETUPDLGDATA", pda);
lpfnStaticWndProc = (WNDPROC)SetWindowLongPtrW(
GetDlgItem(hDlg, rct1),
GWLP_WNDPROC,
(ULONG_PTR)PagePaintProc);
(ULONG_PTR)PRINTDLG_PagePaintProc);
res = TRUE;
pda = (PageSetupDataA*)lParam;
SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",pda);
if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {
res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,(LPARAM)pda->dlga);
if (!res) {
@ -2734,9 +2832,7 @@ PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
res = TRUE;
}
}
if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {
FIXME("PagePaintHook not yet implemented!\n");
}
if (pda->dlga->Flags & PSD_DISABLEPRINTER)
EnableWindow(GetDlgItem(hDlg, psh3), FALSE);
if (pda->dlga->Flags & PSD_DISABLEMARGINS) {
@ -2886,7 +2982,29 @@ PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
/***********************************************************************
* PageSetupDlgA (COMDLG32.@)
*
* Displays the the PAGE SETUP dialog box, which enables the user to specify
* specific properties of a printed page such as
* size, source, orientation and the width of the page margins.
*
* PARAMS
* setupdlg [in] PAGESETUPDLGA struct
*
* RETURNS
* TRUE if the user pressed the OK button
* FALSE if the user cancelled the window or an error occurred
*
* NOTES
* The values of hDevMode and hDevNames are filled on output and can be
* changed in PAGESETUPDLG when they are passed in PageSetupDlg.
* BUGS
* PrintSetupDlg:
* * The Paper Orientation Icons are not implemented yet.
* * The Properties Button(s) should call DocumentPropertiesA().
* * Settings are not yet taken from a provided DevMode or
* default printer settings.
*/
BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
HGLOBAL hDlgTmpl;
LPVOID ptr;
@ -2909,6 +3027,11 @@ BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
setupdlg->hDevNames,
setupdlg->hInstance, setupdlg->Flags, flagstr);
}
if (setupdlg->Flags & PSD_ENABLEPAGEPAINTHOOK)
if (setupdlg->lpfnPagePaintHook == NULL) {
COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
return FALSE;
}
/* First get default printer data, we need it right after that. */
memset(&pdlg,0,sizeof(pdlg));
@ -2945,7 +3068,7 @@ BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
setupdlg->hInstance,
ptr,
setupdlg->hwndOwner,
PageDlgProcA,
PRINTDLG_PageDlgProcA,
(LPARAM)pda)
);
return bRet;
@ -2959,7 +3082,7 @@ BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg) {
BOOL bRet;
PageSetupDataW *pdw;
PRINTDLGW pdlg;
FIXME("Unicode implementation is not done yet\n");
if(TRACE_ON(commdlg)) {
char flagstr[1000] = "";
struct pd_flags *pflag = psd_flags;