Sync to Wine-20050628:
Juan Lang <juan_lang(a)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(a)codeweavers.com>
- Make some of the OLE interface vtables const.
Michael Jung <mjung(a)iss.tu-darmstadt.de>
- Use IShellFolder::GetDisplayNameOf instead of SHGetPathFromIDList to
be able to browse shell namespace extensions.
Vitaly Lipatov <lav(a)etersoft.ru>
- Add some descriptions for PageSetupDlg functions.
- Implement user paint hook support and PSD_ENABLEPAGEPAINTHOOK
checking.
Huw Davies <huw(a)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.
Modified: trunk/reactos/lib/comdlg32/filedlg.c
Modified: trunk/reactos/lib/comdlg32/filedlgbrowser.c
Modified: trunk/reactos/lib/comdlg32/filedlgbrowser.h
Modified: trunk/reactos/lib/comdlg32/printdlg.c
_____
Modified: trunk/reactos/lib/comdlg32/filedlg.c
--- trunk/reactos/lib/comdlg32/filedlg.c 2005-07-06 22:33:11 UTC
(rev 16472)
+++ trunk/reactos/lib/comdlg32/filedlg.c 2005-07-06 22:40:35 UTC
(rev 16473)
@@ -196,6 +196,9 @@
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 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 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 @@
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 @@
* 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 @@
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 @@
* 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 @@
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
- ret =
SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNo
tify);
+
SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNo
tify);
}
else
{
@@ -820,17 +841,15 @@
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
- ret =
SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNo
tify);
+
SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNo
tify);
}
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 @@
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 @@
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 @@
*
* 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 @@
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 @@
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 @@
*
* 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 @@
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 @@
*/
/* 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 @@
lpstrPathAndFile: cleaned up path
*/
- nOpenAction = ONOPEN_BROWSE;
+ nOpenAction = ONOPEN_OPEN;
/* don't apply any checks with OFN_NOVALIDATE */
{
@@ -1920,6 +1940,7 @@
int iPos;
LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
DWORD len;
+ IPersistFolder2 * ppf2;
/* replace the current filter */
if(fodInfos->ShellInfos.lpstrCurrentFilter)
@@ -1931,12 +1952,7 @@
/* 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 @@
{
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 @@
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 @@
NULL,
SBSP_PARENT)))
{
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
return TRUE;
}
return FALSE;
@@ -2229,6 +2250,7 @@
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 @@
}
} else
fodInfos->ofnInfos->nFilterIndex = 0;
-
- return NOERROR;
+ return S_OK;
}
/***********************************************************************
@@ -2465,7 +2486,7 @@
*
* 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 @@
}
COMDLG32_SHFree(pidlDrives);
- return NOERROR;
}
/***********************************************************************
@@ -2680,6 +2700,7 @@
tmpFolder->pidlItem,
SBSP_ABSOLUTE)))
{
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
return TRUE;
}
break;
@@ -3009,7 +3030,9 @@
}
-/* 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 @@
{
*(LPSTR)dest = '\0';
}
- return(FALSE);
+ return(E_FAIL);
}
return S_OK;
}
@@ -3045,7 +3068,7 @@
* 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 @@
* 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 @@
' ','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 );
}
_____
Modified: trunk/reactos/lib/comdlg32/filedlgbrowser.c
--- trunk/reactos/lib/comdlg32/filedlgbrowser.c 2005-07-06 22:33:11 UTC
(rev 16472)
+++ trunk/reactos/lib/comdlg32/filedlgbrowser.c 2005-07-06 22:40:35 UTC
(rev 16473)
@@ -47,9 +47,9 @@
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 @@
/***********************************************************************
***
* 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 @@
*/
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_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 @@
return E_NOTIMPL;
}
-static IShellBrowserVtbl IShellBrowserImpl_Vtbl =
+static const IShellBrowserVtbl IShellBrowserImpl_Vtbl =
{
/* IUnknown */
IShellBrowserImpl_QueryInterface,
@@ -900,7 +907,7 @@
return S_OK;
}
-static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl =
+static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl
=
{
/* IUnknown */
IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
@@ -989,7 +996,7 @@
}
-static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl =
+static const IServiceProviderVtbl
IShellBrowserImpl_IServiceProvider_Vtbl =
{
/* IUnknown */
IShellBrowserImpl_IServiceProvider_QueryInterface,
_____
Modified: trunk/reactos/lib/comdlg32/filedlgbrowser.h
--- trunk/reactos/lib/comdlg32/filedlgbrowser.h 2005-07-06 22:33:11 UTC
(rev 16472)
+++ trunk/reactos/lib/comdlg32/filedlgbrowser.h 2005-07-06 22:40:35 UTC
(rev 16473)
@@ -161,6 +161,5 @@
/* 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*/
_____
Modified: trunk/reactos/lib/comdlg32/printdlg.c
--- trunk/reactos/lib/comdlg32/printdlg.c 2005-07-06 22:33:11 UTC
(rev 16472)
+++ trunk/reactos/lib/comdlg32/printdlg.c 2005-07-06 22:40:35 UTC
(rev 16473)
@@ -1945,11 +1945,6 @@
* 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 @@
* 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 @@
}
+/**********************************************************************
*
+ * 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)
+{
+ 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
-PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
- if (uMsg == WM_PAINT)
- {
- PAINTSTRUCT ps;
- RECT rcClient;
- HPEN hpen, holdpen;
- HDC hdc;
- HFONT hfont, holdfont;
- LOGFONTW lf;
- HBRUSH hbrush, holdbrush;
- INT oldbkmode;
+ PAINTSTRUCT ps;
+ RECT rcClient, rcMargin;
+ HPEN hpen, holdpen;
+ HDC hdc;
+ HBRUSH hbrush, holdbrush;
+ PageSetupDataA *pda;
+ int papersize=0, orientation=0; /* FIXME: set this values */
- hdc = BeginPaint(hWnd, &ps);
+#define CALLPAINTHOOK(msg,lprc) PRINTDLG_DefaultPagePaintHook( hWnd,
msg, (WPARAM)hdc, (LPARAM)lprc, pda)
- GetClientRect(hWnd, &rcClient);
+ 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) )
+ {
/* fill background */
hbrush = GetSysColorBrush(COLOR_3DHIGHLIGHT);
FillRect(hdc, &rcClient, hbrush);
@@ -2635,6 +2760,7 @@
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 @@
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));
+ DeleteObject(SelectObject(hdc, holdpen));
+ DeleteObject(SelectObject(hdc, holdbrush));
- /* draw dashed rectangle showing margins */
- /* FIXME: use real margin values */
- rcClient.left += 5;
- rcClient.top += 5;
- rcClient.right -= 5;
- rcClient.bottom -= 5;
+ CALLPAINTHOOK(WM_PSD_MARGINRECT, &rcMargin);
- /* 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));
-
- /* 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);
+ CALLPAINTHOOK(WM_PSD_GREEKTEXTRECT, &rcMargin);
+ }
- /* 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;
- }
- 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 @@
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 @@
/***********************************************************************
* 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 @@
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 @@
[truncated at 1000 lines; 17 more skipped]