/*
* COMMDLG - File Open Dialogs Win95 look and feel
*
- * FIXME: lpstrCustomFilter not handeled
+ * Copyright 1999 Francois Boisvert
+ * Copyright 1999, 2000 Juergen Schmied
*
- * FIXME: if the size of lpstrFile (nMaxFile) is to small the first
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * FIXME: The whole concept of handling unicode is badly broken.
+ * many hook-messages expecting 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 if would likely cause
+ * a complete rewrite with after we shouldhandle 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: lpstrCustomFilter not handled
+ *
+ * FIXME: if the size of lpstrFile (nMaxFile) is too small the first
* two bytes of lpstrFile should contain the needed size
*
- * FIXME: algorithm for selecting the initial directory is to simple
+ * FIXME: algorithm for selecting the initial directory is too simple
*
* FIXME: add to recent docs
*
* FIXME: flags not implemented: OFN_CREATEPROMPT, OFN_DONTADDTORECENT,
* OFN_ENABLEINCLUDENOTIFY, OFN_ENABLESIZING, OFN_EXTENSIONDIFFERENT,
- * OFN_NOCHANGEDIR, OFN_NODEREFERENCELINKS, OFN_READONLYRETURN,
+ * OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
* OFN_NOTESTFILECREATE, OFN_OVERWRITEPROMPT, OFN_USEMONIKERS
*
* FIXME: lCustData for lpfnHook (WM_INITDIALOG)
*
*
*/
+
+#include "config.h"
+#include "wine/port.h"
+
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "winbase.h"
-#include "ldt.h"
-#include "heap.h"
+#include "winternl.h"
+#include "winnls.h"
+#include "wine/unicode.h"
#include "commdlg.h"
#include "dlgs.h"
#include "cdlg.h"
-#include "debugtools.h"
+#include "wine/debug.h"
#include "cderr.h"
-#include "tweak.h"
-#include "winnls.h"
#include "shellapi.h"
+#include "shlguid.h"
#include "filedlgbrowser.h"
#include "shlwapi.h"
#include "wine/obj_contextmenu.h"
-DEFAULT_DEBUG_CHANNEL(commdlg);
+WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
+
+#define UNIMPLEMENTED_FLAGS \
+(OFN_CREATEPROMPT | OFN_DONTADDTORECENT |\
+OFN_ENABLEINCLUDENOTIFY | OFN_ENABLESIZING | OFN_EXTENSIONDIFFERENT |\
+OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
+OFN_NOTESTFILECREATE | OFN_OVERWRITEPROMPT /*| OFN_USEMONIKERS*/)
+#define IsHooked(fodInfos) \
+ ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
/***********************************************************************
* Data structure and global variables
*/
int m_iImageIndex; /* Index of picture in image list */
HIMAGELIST hImgList;
int m_iIndent; /* Indentation index */
- LPITEMIDLIST pidlItem; /* absolute pidl of the item */
+ LPITEMIDLIST pidlItem; /* absolute pidl of the item */
} SFOLDER,*LPSFOLDER;
/* Draw item constant */
#define ICONWIDTH 18
-#define YTEXTOFFSET 2
#define XTEXTOFFSET 3
/* AddItem flags*/
/* 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 use inside Wine itself.
+ * they rely on the UNICODE defines and can't be used inside Wine itself.
*/
/* Combo box macros */
#define CBAddString(hwnd,str) \
SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str);
+#define CBAddStringW(hwnd,str) \
+ SendMessageW(hwnd,CB_ADDSTRING,0,(LPARAM)str);
#define CBInsertString(hwnd,str,pos) \
SendMessageA(hwnd,CB_INSERTSTRING,(WPARAM)pos,(LPARAM)str);
const char *FileOpenDlgInfosStr = "FileOpenDlgInfos"; /* windows property description string */
const char *LookInInfosStr = "LookInInfos"; /* LOOKIN combo box property */
-static const char defaultFilter[] = "*.*";
-
/***********************************************************************
* Prototypes
*/
/* Internal functions used by the dialog */
-static LRESULT FILEDLG95_OnWMInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam);
+static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd);
BOOL FILEDLG95_OnOpen(HWND hwnd);
-static LRESULT FILEDLG95_InitUI(HWND hwnd);
+static LRESULT FILEDLG95_InitControls(HWND hwnd);
static void FILEDLG95_Clean(HWND hwnd);
/* Functions used by the shell navigation */
/* 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,LPCSTR lpstrExt);
+static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt);
static void FILEDLG95_FILETYPE_Clean(HWND hwnd);
/* Functions used by the Look In combo box */
HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
-LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
+LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
/* Shell memory allocation */
static void *MemAlloc(UINT size);
HRESULT WINAPI 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, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
+BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
static BOOL BrowseSelectedFolder(HWND hwnd);
-extern LPSTR _strlwr( LPSTR str );
+LPWSTR strpbrkW(LPWSTR str, LPCWSTR clist)
+{
+ LPCWSTR p;
+
+ while(str && *str)
+ {
+ for(p = clist; *p; p++ )
+ if(*p == *str)
+ return str;
+ str++;
+ }
+ return NULL;
+}
/***********************************************************************
* GetFileName95
*
- * Creates an Open common dialog box that lets the user select
+ * 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
HRSRC hRes;
HANDLE hDlgTmpl = 0;
+ /* test for missing functionality */
+ if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
+ {
+ FIXME("Flags 0x%08lx not yet implemented\n",
+ fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS);
+ }
+
/* Create the dialog from a template */
if(!(hRes = FindResourceA(COMMDLG_hInstance32,MAKEINTRESOURCEA(NEWFILEOPENORD),RT_DIALOGA)))
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
return FALSE;
}
+
+ /* old style hook messages */
+ if (IsHooked(fodInfos))
+ {
+ fodInfos->HookMsg.fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
+ fodInfos->HookMsg.lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
+ fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageA(HELPMSGSTRINGA);
+ fodInfos->HookMsg.sharevistring = RegisterWindowMessageA(SHAREVISTRINGA);
+ }
+
lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32,
(LPDLGTEMPLATEA) template,
fodInfos->ofnInfos->hwndOwner,
(DLGPROC) FileOpenDlgProc95,
(LPARAM) fodInfos);
- /* Unable to create the dialog*/
+ /* Unable to create the dialog */
if( lRes == -1)
return FALSE;
-
+
return lRes;
}
*/
BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
{
-
BOOL ret;
- FileOpenDlgInfos *fodInfos;
- HINSTANCE hInstance;
- LPCSTR lpstrInitialDir = NULL;
- DWORD dwFlags = 0;
-
- /* Initialise FileOpenDlgInfos structure*/
- fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
- ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
-
+ FileOpenDlgInfos fodInfos;
+ LPSTR lpstrSavDir = NULL;
+ LPWSTR title = NULL;
+ LPWSTR defext = NULL;
+ LPWSTR filter = NULL;
+ LPWSTR customfilter = NULL;
+
+ /* Initialize FileOpenDlgInfos structure */
+ ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
+
/* Pass in the original ofn */
- fodInfos->ofnInfos = ofn;
-
- /* Save original hInstance value */
- hInstance = ofn->hInstance;
- fodInfos->ofnInfos->hInstance = MapHModuleLS(ofn->hInstance);
+ fodInfos.ofnInfos = ofn;
+
+ /* save current directory */
+ if (ofn->Flags & OFN_NOCHANGEDIR)
+ {
+ lpstrSavDir = MemAlloc(MAX_PATH);
+ GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
+ }
+
+ fodInfos.unicode = FALSE;
+
+ /* convert all the input strings to unicode */
+ if(ofn->lpstrInitialDir)
+ {
+ DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrInitialDir, -1, NULL, 0 );
+ fodInfos.initdir = MemAlloc((len+1)*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, ofn->lpstrInitialDir, -1, fodInfos.initdir, len);
+ }
+ else
+ fodInfos.initdir = NULL;
+
+ if(ofn->lpstrFile)
+ {
+ fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFile, -1, fodInfos.filename, ofn->nMaxFile);
+ }
+ else
+ fodInfos.filename = NULL;
- dwFlags = ofn->Flags;
- ofn->Flags = ofn->Flags|OFN_WINE;
+ if(ofn->lpstrDefExt)
+ {
+ DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrDefExt, -1, NULL, 0 );
+ defext = MemAlloc((len+1)*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, ofn->lpstrDefExt, -1, defext, len);
+ }
+ fodInfos.defext = defext;
- /* Replace the NULL lpstrInitialDir by the current folder */
- if(!ofn->lpstrInitialDir)
+ if(ofn->lpstrTitle)
{
- lpstrInitialDir = ofn->lpstrInitialDir;
- ofn->lpstrInitialDir = MemAlloc(MAX_PATH);
- GetCurrentDirectoryA(MAX_PATH,(LPSTR)ofn->lpstrInitialDir);
+ DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrTitle, -1, NULL, 0 );
+ title = MemAlloc((len+1)*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, ofn->lpstrTitle, -1, title, len);
}
+ fodInfos.title = title;
+
+ if (ofn->lpstrFilter)
+ {
+ LPCSTR s;
+ int n, len;
+
+ /* filter is a list... title\0ext\0......\0\0 */
+ s = ofn->lpstrFilter;
+ while (*s) s = s+strlen(s)+1;
+ s++;
+ n = s - ofn->lpstrFilter;
+ len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0 );
+ filter = MemAlloc(len*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFilter, n, filter, len );
+ }
+ fodInfos.filter = filter;
+
+ /* convert lpstrCustomFilter */
+ if (ofn->lpstrCustomFilter)
+ {
+ LPCSTR s;
+ int n, len;
+
+ /* filter is a list... title\0ext\0......\0\0 */
+ s = ofn->lpstrCustomFilter;
+ while (*s) s = s+strlen(s)+1;
+ s++;
+ n = s - ofn->lpstrCustomFilter;
+ len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0 );
+ customfilter = MemAlloc(len*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, ofn->lpstrCustomFilter, n, customfilter, len );
+ }
+ fodInfos.customfilter = customfilter;
+
+ /* Initialize the dialog property */
+ fodInfos.DlgInfos.dwDlgProp = 0;
+ fodInfos.DlgInfos.hwndCustomDlg = (HWND)NULL;
- /* Initialise the dialog property */
- fodInfos->DlgInfos.dwDlgProp = 0;
- fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL;
-
switch(iDlgType)
{
case OPEN_DIALOG :
- ret = GetFileName95(fodInfos);
+ ret = GetFileName95(&fodInfos);
break;
case SAVE_DIALOG :
- fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
- ret = GetFileName95(fodInfos);
+ fodInfos.DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
+ ret = GetFileName95(&fodInfos);
break;
default :
ret = 0;
}
- if (lpstrInitialDir)
+ if (lpstrSavDir)
{
- MemFree((LPVOID)(ofn->lpstrInitialDir));
- ofn->lpstrInitialDir = lpstrInitialDir;
+ SetCurrentDirectoryA(lpstrSavDir);
+ MemFree(lpstrSavDir);
}
- ofn->Flags = dwFlags;
- ofn->hInstance = hInstance;
- MemFree((LPVOID)(fodInfos));
+ if(title)
+ MemFree(title);
+ if(defext)
+ MemFree(defext);
+ if(filter)
+ MemFree(filter);
+ if(customfilter)
+ MemFree(customfilter);
+ if(fodInfos.initdir)
+ MemFree(fodInfos.initdir);
+
+ if(fodInfos.filename)
+ MemFree(fodInfos.filename);
+
+ TRACE("selected file: %s\n",ofn->lpstrFile);
+
return ret;
}
* Copy the OPENFILENAMEW structure in a FileOpenDlgInfos structure.
* Call GetFileName95 with this structure and clean the memory.
*
- * IN : The OPENFILENAMEW initialisation structure passed to
- * GetOpenFileNameW win api function (see filedlg.c)
+ * FIXME: lpstrCustomFilter has to be converted back
*
- * FIXME:
- * some more strings are needing to be convertet AtoW
*/
BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
{
BOOL ret;
- FileOpenDlgInfos *fodInfos;
- HINSTANCE hInstance;
- LPCSTR lpstrFilter = NULL;
- LPSTR lpstrCustomFilter = NULL;
- LPWSTR lpstrFile = NULL;
- DWORD dwFlags;
+ FileOpenDlgInfos fodInfos;
+ LPSTR lpstrSavDir = NULL;
- /* Initialise FileOpenDlgInfos structure*/
- fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
- ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
+ /* Initialize FileOpenDlgInfos structure */
+ ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
/* Pass in the original ofn */
- fodInfos->ofnInfos = (LPOPENFILENAMEA) ofn;
+ fodInfos.ofnInfos = (LPOPENFILENAMEA) ofn;
- /* Save hInstance */
- hInstance = fodInfos->ofnInfos->hInstance;
- fodInfos->ofnInfos->hInstance = MapHModuleLS(ofn->hInstance);
+ fodInfos.title = ofn->lpstrTitle;
+ fodInfos.defext = ofn->lpstrDefExt;
+ fodInfos.filter = ofn->lpstrFilter;
+ fodInfos.customfilter = ofn->lpstrCustomFilter;
- /* Save lpstrFilter */
- if (ofn->lpstrFilter)
+ /* convert string arguments, save others */
+ if(ofn->lpstrFile)
{
- LPWSTR s;
- LPSTR x,y;
- int n;
-
- lpstrFilter = fodInfos->ofnInfos->lpstrFilter;
-
- /* filter is a list... title\0ext\0......\0\0 */
- s = (LPWSTR)ofn->lpstrFilter;
-
- while (*s)
- s = s+lstrlenW(s)+1;
- s++;
- n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
- x = y = (LPSTR)MemAlloc(n);
- s = (LPWSTR)ofn->lpstrFilter;
- while (*s) {
- lstrcpyWtoA(x,s);
- x+=lstrlenA(x)+1;
- s+=lstrlenW(s)+1;
- }
- *x=0;
- fodInfos->ofnInfos->lpstrFilter = (LPSTR)y;
+ fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
+ strncpyW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
}
- /* Save lpstrCustomFilter */
- if (ofn->lpstrCustomFilter)
+ else
+ fodInfos.filename = NULL;
+
+ if(ofn->lpstrInitialDir)
{
- LPWSTR s;
- LPSTR x,y;
- int n;
+ DWORD len = strlenW(ofn->lpstrInitialDir);
+ fodInfos.initdir = MemAlloc((len+1)*sizeof(WCHAR));
+ strcpyW(fodInfos.initdir,ofn->lpstrInitialDir);
+ }
+ else
+ fodInfos.initdir = NULL;
- lpstrCustomFilter = fodInfos->ofnInfos->lpstrCustomFilter;
- /* filter is a list... title\0ext\0......\0\0 */
- s = (LPWSTR)ofn->lpstrCustomFilter;
- while (*s)
- s = s+lstrlenW(s)+1;
- s++;
- n = s - ofn->lpstrCustomFilter;
- x = y = (LPSTR)MemAlloc(n);
- s = (LPWSTR)ofn->lpstrCustomFilter;
- while (*s) {
- lstrcpyWtoA(x,s);
- x+=lstrlenA(x)+1;
- s+=lstrlenW(s)+1;
- }
- *x=0;
- fodInfos->ofnInfos->lpstrCustomFilter = (LPSTR)y;
+ /* save current directory */
+ if (ofn->Flags & OFN_NOCHANGEDIR)
+ {
+ lpstrSavDir = MemAlloc(MAX_PATH);
+ GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
}
- /* Save Flags */
- dwFlags = fodInfos->ofnInfos->Flags;
- fodInfos->ofnInfos->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
+ fodInfos.unicode = TRUE;
- /* Initialise the dialog property */
- fodInfos->DlgInfos.dwDlgProp = 0;
-
- /* allocate ansi filename buffer */
- lpstrFile = ofn->lpstrFile;
- ofn->lpstrFile = MemAlloc(ofn->nMaxFile);
-
switch(iDlgType)
{
case OPEN_DIALOG :
- ret = GetFileName95(fodInfos);
+ ret = GetFileName95(&fodInfos);
break;
case SAVE_DIALOG :
- fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
- ret = GetFileName95(fodInfos);
+ fodInfos.DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
+ ret = GetFileName95(&fodInfos);
break;
default :
ret = 0;
}
-
- /* Cleaning */
- /* Restore Flags */
- fodInfos->ofnInfos->Flags = dwFlags;
- /* Restore lpstrFilter */
- if (fodInfos->ofnInfos->lpstrFilter)
+ if (lpstrSavDir)
{
- MemFree((LPVOID)(fodInfos->ofnInfos->lpstrFilter));
- fodInfos->ofnInfos->lpstrFilter = lpstrFilter;
+ SetCurrentDirectoryA(lpstrSavDir);
+ MemFree(lpstrSavDir);
}
- if (fodInfos->ofnInfos->lpstrCustomFilter)
- {
- MemFree((LPVOID)(fodInfos->ofnInfos->lpstrCustomFilter));
- fodInfos->ofnInfos->lpstrCustomFilter = lpstrCustomFilter;
- }
-
- /* Restore hInstance */
- fodInfos->ofnInfos->hInstance = hInstance;
- MemFree((LPVOID)(fodInfos));
-
- /* filename */
- lstrcpynAtoW(lpstrFile, (LPCSTR)ofn->lpstrFile, ofn->nMaxFile);
- MemFree(ofn->lpstrFile);
- ofn->lpstrFile = lpstrFile;
+ /* restore saved IN arguments and convert OUT arguments back */
+ MemFree(fodInfos.filename);
+ MemFree(fodInfos.initdir);
return ret;
}
void ArrangeCtrlPositions( HWND hwndChildDlg, HWND hwndParentDlg)
{
+ HWND hwndChild,hwndStc32;
+ RECT rectParent, rectChild, rectCtrl, rectStc32, rectTemp;
+ POINT ptMoveCtl;
+ POINT ptParentClient;
- HWND hwndChild,hwndStc32;
- RECT rectParent, rectChild, rectCtrl, rectStc32, rectTemp;
- POINT ptMoveCtl;
- POINT ptParentClient;
+ TRACE("\n");
- ptMoveCtl.x = ptMoveCtl.y = 0;
- hwndStc32=GetDlgItem(hwndChildDlg,stc32);
- GetClientRect(hwndParentDlg,&rectParent);
- GetClientRect(hwndChildDlg,&rectChild);
- if(hwndStc32)
- {
- GetWindowRect(hwndStc32,&rectStc32);
- MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
- CopyRect(&rectTemp,&rectStc32);
-
- SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
- SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
-
- if(rectStc32.right < rectTemp.right)
- {
- ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
- ptMoveCtl.x = 0;
- }
- else
- {
- ptMoveCtl.x = (rectStc32.right - rectTemp.right);
- ptParentClient.x = max((rectParent.right-rectParent.left),((rectChild.right-rectChild.left)+rectStc32.right-rectTemp.right));
- }
- if(rectStc32.bottom < rectTemp.bottom)
- {
- ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
- ptMoveCtl.y = 0;
- }
- else
- {
- ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
- ptParentClient.y = max((rectParent.bottom-rectParent.top),((rectChild.bottom-rectChild.top)+rectStc32.bottom-rectTemp.bottom));
- }
- }
- else
- {
- if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL)
- return;
- SetRectEmpty(&rectTemp);
- ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
- ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top);
- ptMoveCtl.y = rectParent.bottom-rectParent.top;
- ptMoveCtl.x=0;
- }
- SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
- AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
-
- SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y,
- SWP_NOZORDER );
- SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
- (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
-
- hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
- if(hwndStc32)
- {
- GetWindowRect(hwndStc32,&rectStc32);
- MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
- }
- else
- SetRect(&rectStc32,0,0,0,0);
+ ptMoveCtl.x = ptMoveCtl.y = 0;
+ hwndStc32=GetDlgItem(hwndChildDlg,stc32);
+ GetClientRect(hwndParentDlg,&rectParent);
+ GetClientRect(hwndChildDlg,&rectChild);
- if (hwndChild )
- {
- do
- {
- if(hwndChild != hwndStc32)
- {
- if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
+ if(hwndStc32)
+ {
+ GetWindowRect(hwndStc32,&rectStc32);
+ MapWindowPoints(0, hwndChildDlg,(LPPOINT)&rectStc32,2);
+ CopyRect(&rectTemp,&rectStc32);
+
+ SetRect(&rectStc32,rectStc32.left,rectStc32.top,rectStc32.left + (rectParent.right-rectParent.left),rectStc32.top+(rectParent.bottom-rectParent.top));
+ SetWindowPos(hwndStc32,0,rectStc32.left,rectStc32.top,rectStc32.right-rectStc32.left,rectStc32.bottom-rectStc32.top,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
+
+ ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
+ if(rectStc32.right < rectTemp.right)
+ ptMoveCtl.x = 0;
+ else
+ ptMoveCtl.x = (rectStc32.right - rectTemp.right);
+
+ ptParentClient.y = max((rectParent.bottom-rectParent.top),(rectChild.bottom-rectChild.top));
+ if(rectStc32.bottom < rectTemp.bottom)
+ ptMoveCtl.y = 0;
+ else
+ ptMoveCtl.y = (rectStc32.bottom - rectTemp.bottom);
+ }
+ else
+ {
+ if( (GetWindow(hwndChildDlg,GW_CHILD)) == (HWND) NULL) return;
+
+ SetRectEmpty(&rectTemp);
+ ptParentClient.x = max((rectParent.right-rectParent.left),(rectChild.right-rectChild.left));
+ ptParentClient.y = (rectParent.bottom-rectParent.top) + (rectChild.bottom-rectChild.top);
+ ptMoveCtl.y = rectParent.bottom-rectParent.top;
+ ptMoveCtl.x=0;
+ }
+ SetRect(&rectParent,rectParent.left,rectParent.top,rectParent.left+ptParentClient.x,rectParent.top+ptParentClient.y);
+ AdjustWindowRectEx( &rectParent,GetWindowLongA(hwndParentDlg,GWL_STYLE),FALSE,GetWindowLongA(hwndParentDlg,GWL_EXSTYLE));
+
+ SetWindowPos(hwndChildDlg, 0, 0,0, ptParentClient.x,ptParentClient.y, SWP_NOZORDER );
+ SetWindowPos(hwndParentDlg, 0, rectParent.left,rectParent.top, (rectParent.right- rectParent.left),
+ (rectParent.bottom-rectParent.top),SWP_NOMOVE | SWP_NOZORDER);
+
+ hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
+ if(hwndStc32)
+ {
+ GetWindowRect(hwndStc32,&rectStc32);
+ MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
+ }
+ else
+ SetRect(&rectStc32,0,0,0,0);
+
+ if (hwndChild )
+ {
+ do
+ {
+ if(hwndChild != hwndStc32)
+ {
+ if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
continue;
- GetWindowRect(hwndChild,&rectCtrl);
- MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
-
- /*
- Check the initial position of the controls relative to the initial
- position and size of stc32 (before it is expanded).
- */
- if (rectCtrl.left >= rectTemp.right && rectCtrl.top >= rectTemp.bottom)
- {
- rectCtrl.left += ptMoveCtl.x;
- rectCtrl.top += ptMoveCtl.y;
- }
- else if (rectCtrl.left >= rectTemp.right)
- rectCtrl.left += ptMoveCtl.x;
- else if (rectCtrl.top >= rectTemp.bottom)
- rectCtrl.top += ptMoveCtl.y;
-
- SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
+ GetWindowRect(hwndChild,&rectCtrl);
+ MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
+
+ /*
+ Check the initial position of the controls relative to the initial
+ position and size of stc32 (before it is expanded).
+ */
+ if (rectCtrl.left >= rectTemp.right && rectCtrl.top >= rectTemp.bottom)
+ {
+ rectCtrl.left += ptMoveCtl.x;
+ rectCtrl.top += ptMoveCtl.y;
+ }
+ else if (rectCtrl.left >= rectTemp.right)
+ {
+ rectCtrl.left += ptMoveCtl.x;
+ }
+ else if (rectCtrl.top >= rectTemp.bottom)
+ {
+ rectCtrl.top += ptMoveCtl.y;
+ }
+
+ SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
SWP_NOSIZE | SWP_NOZORDER );
- }
- }
- while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
- }
- hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
-
- if(hwndStc32)
- {
- GetWindowRect(hwndStc32,&rectStc32);
- MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
- ptMoveCtl.x = rectStc32.left - 0;
- ptMoveCtl.y = rectStc32.top - 0;
- if (hwndChild )
- {
- do
- {
- if(hwndChild != hwndChildDlg)
- {
-
- if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
- continue;
- GetWindowRect(hwndChild,&rectCtrl);
- MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
-
- rectCtrl.left += ptMoveCtl.x;
- rectCtrl.top += ptMoveCtl.y;
-
- SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
- rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
- SWP_NOSIZE |SWP_NOZORDER );
- }
- }
- while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
- }
- }
+ }
+ } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
+ }
+ hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
+
+ if(hwndStc32)
+ {
+ GetWindowRect(hwndStc32,&rectStc32);
+ MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
+ ptMoveCtl.x = rectStc32.left - 0;
+ ptMoveCtl.y = rectStc32.top - 0;
+ if (hwndChild )
+ {
+ do
+ {
+ if(hwndChild != hwndChildDlg)
+ {
+ if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
+ continue;
+ GetWindowRect(hwndChild,&rectCtrl);
+ MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
+
+ rectCtrl.left += ptMoveCtl.x;
+ rectCtrl.top += ptMoveCtl.y;
+ SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
+ rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
+ SWP_NOSIZE |SWP_NOZORDER );
+ }
+ } while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
+ }
+ }
}
HRESULT WINAPI FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(GetParent(hwnd),FileOpenDlgInfosStr);
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
- fodInfos = (FileOpenDlgInfos *)lParam;
- lParam = (LPARAM) fodInfos->ofnInfos;
- ArrangeCtrlPositions(hwnd,GetParent(hwnd));
- if(fodInfos && (fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
- return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
- return 0;
- }
+
+#if 0
+ TRACE("0x%04x\n", uMsg);
+#endif
+
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ /* Hide caption since some program may leave it */
+ DWORD Style = GetWindowLongA(hwnd, GWL_STYLE);
+ if (Style & WS_CAPTION) SetWindowLongA(hwnd, GWL_STYLE, Style & (~WS_CAPTION));
+
+ fodInfos = (FileOpenDlgInfos *)lParam;
+ lParam = (LPARAM) fodInfos->ofnInfos;
+ ArrangeCtrlPositions(hwnd,GetParent(hwnd));
+
+ if(fodInfos && IsHooked(fodInfos))
+ return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
+ return 0;
+ }
}
- if(fodInfos && (fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook )
- return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
- return DefWindowProcA(hwnd,uMsg,wParam,lParam);
+
+ if(fodInfos && IsHooked(fodInfos))
+ return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
+
+ return DefWindowProcA(hwnd,uMsg,wParam,lParam);
}
-HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos,HWND hwnd)
+HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
{
LPCVOID template;
HRSRC hRes;
HANDLE hDlgTmpl = 0;
HWND hChildDlg = 0;
- if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATE || fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
- {
- if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
- {
- if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
- return (HWND)NULL;
- }
-
- }
- else
- {
- if (!(hRes = FindResourceA(MapHModuleSL(fodInfos->ofnInfos->hInstance),
- (fodInfos->ofnInfos->lpTemplateName), RT_DIALOGA)))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
- return (HWND)NULL;
- }
- if (!(hDlgTmpl = LoadResource( MapHModuleSL(fodInfos->ofnInfos->hInstance),
- hRes )) ||
- !(template = LockResource( hDlgTmpl )))
- {
- COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
- return (HWND)NULL;
+
+ TRACE("\n");
+
+ /*
+ * 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 ||
+ fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
+ {
+ HINSTANCE hinst;
+
+ if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
+ {
+ hinst = 0;
+ if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
+ return (HWND)NULL;
+ }
+ }
+ else
+ {
+ hinst = fodInfos->ofnInfos->hInstance;
+ if(fodInfos->unicode)
+ {
+ LPOPENFILENAMEW ofn = (LPOPENFILENAMEW) fodInfos->ofnInfos;
+ hRes = FindResourceW( hinst, ofn->lpTemplateName, RT_DIALOGW);
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = fodInfos->ofnInfos;
+ hRes = FindResourceA( hinst, ofn->lpTemplateName, RT_DIALOGA);
+ }
+ if (!hRes)
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
+ return (HWND)NULL;
+ }
+ if (!(hDlgTmpl = LoadResource( hinst, hRes )) ||
+ !(template = LockResource( hDlgTmpl )))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
+ return (HWND)NULL;
}
- }
-
- hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,template,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
- if(hChildDlg)
- {
- ShowWindow(hChildDlg,SW_SHOW);
- return hChildDlg;
- }
- }
- else if(fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK && fodInfos->ofnInfos->lpfnHook)
- {
- RECT rectHwnd;
- DLGTEMPLATE tmplate;
- GetClientRect(hwnd,&rectHwnd);
- tmplate.style = WS_CHILD | WS_CLIPSIBLINGS;
- tmplate.dwExtendedStyle = 0;
- tmplate.cdit = 0;
- tmplate.x = 0;
- tmplate.y = 0;
- tmplate.cx = rectHwnd.right-rectHwnd.left;
- tmplate.cy = rectHwnd.bottom-rectHwnd.top;
-
- return CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
- }
-return (HWND)NULL;
+ }
+
+ hChildDlg= CreateDialogIndirectParamA(hinst, template,
+ hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
+ if(hChildDlg)
+ {
+ ShowWindow(hChildDlg,SW_SHOW);
+ return hChildDlg;
+ }
+ }
+ else if( IsHooked(fodInfos))
+ {
+ RECT rectHwnd;
+ struct {
+ DLGTEMPLATE tmplate;
+ WORD menu,class,title;
+ } temp;
+ GetClientRect(hwnd,&rectHwnd);
+ temp.tmplate.style = WS_CHILD | WS_CLIPSIBLINGS;
+ temp.tmplate.dwExtendedStyle = 0;
+ temp.tmplate.cdit = 0;
+ temp.tmplate.x = 0;
+ temp.tmplate.y = 0;
+ temp.tmplate.cx = rectHwnd.right-rectHwnd.left;
+ temp.tmplate.cy = rectHwnd.bottom-rectHwnd.top;
+ temp.menu = temp.class = temp.title = 0;
+ hChildDlg = CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&temp,
+ hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
+ return hChildDlg;
+ }
+ return (HWND)NULL;
}
-
+
/***********************************************************************
* SendCustomDlgNotificationMessage
*
HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
- if(!fodInfos)
- return 0;
+
+ TRACE("0x%04x 0x%04x\n",hwndParentDlg, uCode);
+
+ if(!fodInfos) return 0;
+
+ if(fodInfos->unicode)
+ FIXME("sending OPENFILENAMEA structure. Hook is expecting OPENFILENAMEW!\n");
+
if(fodInfos->DlgInfos.hwndCustomDlg)
{
OFNOTIFYA ofnNotify;
+ HRESULT ret;
ofnNotify.hdr.hwndFrom=hwndParentDlg;
ofnNotify.hdr.idFrom=0;
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
- return SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+ TRACE("CALL NOTIFY for %x\n", uCode);
+ ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+ TRACE("RET NOTIFY\n");
+ return ret;
}
return TRUE;
}
{
case CDM_GETFILEPATH:
GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
- lpstrFileSpec = (LPSTR)COMDLG32_PathFindFileNameA(lpstrPath);
- if (lpstrFileSpec==lpstrPath)
+ lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath);
+ if (lpstrFileSpec==lpstrPath)
{
char lpstrCurrentDir[MAX_PATH];
/* Prepend the current path */
- COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
+ SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
if ((LPSTR)lParam!=NULL)
- wsnprintfA((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath);
+ snprintf((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath);
reqSize=strlen(lpstrCurrentDir)+1+strlen(lpstrPath)+1;
- }
- else
+ }
+ else
{
lstrcpynA((LPSTR)lParam,(LPSTR)lpstrPath,(int)wParam);
reqSize=strlen(lpstrPath);
return reqSize;
case CDM_GETFOLDERPATH:
- COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
+ SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if ((LPSTR)lParam!=NULL)
lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam);
return strlen(lpstrPath);
case CDM_GETSPEC:
reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
- lpstrFileSpec = (LPSTR)COMDLG32_PathFindFileNameA(lpstrPath);
+ lpstrFileSpec = (LPSTR)PathFindFileNameA(lpstrPath);
if ((LPSTR)lParam!=NULL)
lstrcpynA((LPSTR)lParam, lpstrFileSpec, (int)wParam);
return strlen(lpstrFileSpec);
}
return TRUE;
}
-
+
/***********************************************************************
* FileOpenDlgProc95
*
*/
HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
+#if 0
+ TRACE("0x%04x 0x%04x\n", hwnd, uMsg);
+#endif
+
switch(uMsg)
{
- case WM_INITDIALOG :
- /* Adds the FileOpenDlgInfos in the property list of the dialog
+ case WM_INITDIALOG:
+ {
+ FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
+
+ /* Adds the FileOpenDlgInfos in the property list of the dialog
so it will be easily accessible through a GetPropA(...) */
- SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) lParam);
+ SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
- FILEDLG95_OnWMInitDialog(hwnd, wParam, lParam);
- ((FileOpenDlgInfos *)lParam)->DlgInfos.hwndCustomDlg =
- CreateTemplateDialog((FileOpenDlgInfos *)lParam,hwnd);
+ fodInfos->DlgInfos.hwndCustomDlg =
+ CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
+
+ FILEDLG95_InitControls(hwnd);
SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
+ FILEDLG95_FillControls(hwnd, wParam, lParam);
+ SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
+ SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
+ SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
+ 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
return 0;
+ }
case WM_COMMAND:
return FILEDLG95_OnWMCommand(hwnd, wParam, lParam);
case WM_DRAWITEM:
}
}
return FALSE;
-
+
case WM_GETISHELLBROWSER:
return FILEDLG95_OnWMGetIShellBrowser(hwnd);
- case WM_DESTROY:
+ case WM_DESTROY:
RemovePropA(hwnd, FileOpenDlgInfosStr);
- return FALSE;
+ return FALSE;
case WM_NOTIFY:
{
/* set up the button tooltips strings */
if(TTN_GETDISPINFOA == lpnmh->code )
{
- LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
+ LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
switch(lpnmh->idFrom )
{
/* Up folder button */
default:
stringId = 0;
}
- lpdi->hinst = COMMDLG_hInstance32;
+ lpdi->hinst = COMMDLG_hInstance32;
lpdi->lpszText = (LPSTR) stringId;
}
return FALSE;
}
/***********************************************************************
- * FILEDLG95_OnWMInitDialog
+ * FILEDLG95_InitControls
+ *
+ * WM_INITDIALOG message handler (before hook notification)
+ */
+static LRESULT FILEDLG95_InitControls(HWND hwnd)
+{
+ int win2000plus = 0;
+ int win98plus = 0;
+ int handledPath = FALSE;
+ OSVERSIONINFOA osVi;
+ const WCHAR szwSlash[] = { '\\', 0 };
+ const WCHAR szwStar[] = { '*',0 };
+
+ TBBUTTON tbb[] =
+ {
+ {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
+ {VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
+ {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
+ {VIEW_NEWFOLDER+1, FCIDM_TB_DESKTOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
+ {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
+ {VIEW_NEWFOLDER, FCIDM_TB_NEWFOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
+ {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
+ {VIEW_LIST, FCIDM_TB_SMALLICON, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
+ {VIEW_DETAILS, FCIDM_TB_REPORTVIEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
+ };
+ TBADDBITMAP tba[2];
+ RECT rectTB;
+ FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
+
+ tba[0].hInst = HINST_COMMCTRL;
+ tba[0].nID = IDB_VIEW_SMALL_COLOR;
+ tba[1].hInst = COMDLG32_hInstance;
+ tba[1].nID = 800;
+
+ TRACE("%p\n", fodInfos);
+
+ /* Get windows version emulating */
+ osVi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
+ GetVersionExA(&osVi);
+ if (osVi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ win98plus = ((osVi.dwMajorVersion > 4) || ((osVi.dwMajorVersion == 4) && (osVi.dwMinorVersion > 0)));
+ } else if (osVi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ win2000plus = (osVi.dwMajorVersion > 4);
+ if (win2000plus) win98plus = TRUE;
+ }
+ TRACE("Running on 2000+ %d, 98+ %d\n", win2000plus, win98plus);
+
+ /* Get the hwnd of the controls */
+ fodInfos->DlgInfos.hwndFileName = GetDlgItem(hwnd,IDC_FILENAME);
+ fodInfos->DlgInfos.hwndFileTypeCB = GetDlgItem(hwnd,IDC_FILETYPE);
+ fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
+
+ /* construct the toolbar */
+ GetWindowRect(GetDlgItem(hwnd,IDC_TOOLBARSTATIC),&rectTB);
+ MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
+
+ fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL,
+ WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
+ 0, 0, 150, 26, hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL);
+
+ SetWindowPos(fodInfos->DlgInfos.hwndTB, 0,
+ rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,
+ SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );
+
+ SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
+
+/* FIXME: use TB_LOADIMAGES when implemented */
+/* SendMessageA(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, (WPARAM) IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
+ SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 12, (LPARAM) &tba[0]);
+ SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 1, (LPARAM) &tba[1]);
+
+ SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 9,(LPARAM) &tbb);
+ SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
+
+ /* 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)
+ {
+ SetWindowTextA(hwnd,"Save");
+ }
+
+ /* Initialise the file name edit control */
+ handledPath = FALSE;
+ TRACE("Before manipilation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
+
+ if(fodInfos->filename)
+ {
+ /* 1. If win2000 or higher and filename contains a path, use it
+ in preference over the lpstrInitialDir */
+ if (win2000plus && *fodInfos->filename && strpbrkW(fodInfos->filename, szwSlash)) {
+ WCHAR tmpBuf[MAX_PATH];
+ WCHAR *nameBit;
+ DWORD result;
+
+ result = GetFullPathNameW(fodInfos->filename, MAX_PATH, tmpBuf, &nameBit);
+ if (result) {
+
+ /* nameBit is always shorter than the original filename */
+ strcpyW(fodInfos->filename,nameBit);
+
+ *nameBit = 0x00;
+ if (fodInfos->initdir == NULL)
+ MemFree(fodInfos->initdir);
+ fodInfos->initdir = MemAlloc((strlenW(tmpBuf) + 1)*sizeof(WCHAR));
+ strcpyW(fodInfos->initdir, tmpBuf);
+ handledPath = TRUE;
+ TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
+ debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
+ }
+ SetDlgItemTextW(hwnd, IDC_FILENAME, fodInfos->filename);
+
+ } else {
+ SetDlgItemTextW(hwnd, IDC_FILENAME, fodInfos->filename);
+ }
+ }
+
+ /* 2. (All platforms) If initdir is not null, then use it */
+ if ((handledPath == FALSE) && (fodInfos->initdir!=NULL) &&
+ (*fodInfos->initdir!=0x00))
+ {
+ /* Work out the proper path as supplied one might be relative */
+ /* (Here because supplying '.' as dir browses to My Computer) */
+ if (handledPath==FALSE) {
+ WCHAR tmpBuf[MAX_PATH];
+ WCHAR tmpBuf2[MAX_PATH];
+ WCHAR *nameBit;
+ DWORD result;
+
+ strcpyW(tmpBuf, fodInfos->initdir);
+ if (tmpBuf[strlenW(tmpBuf)-1] != '\\') {
+ strcatW(tmpBuf, szwSlash);
+ }
+ strcatW(tmpBuf, szwStar);
+ result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
+ if (result) {
+ *nameBit = 0x00;
+ if (fodInfos->initdir)
+ MemFree(fodInfos->initdir);
+ fodInfos->initdir = MemAlloc((strlenW(tmpBuf2) + 1)*sizeof(WCHAR));
+ strcpyW(fodInfos->initdir, tmpBuf2);
+ handledPath = TRUE;
+ TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
+ }
+ }
+ }
+
+ if ((handledPath == FALSE) && ((fodInfos->initdir==NULL) ||
+ (*fodInfos->initdir==0x00)))
+ {
+ /* 3. All except w2k+: if filename contains a path use it */
+ if (!win2000plus && fodInfos->filename &&
+ *fodInfos->filename &&
+ strpbrkW(fodInfos->filename, szwSlash)) {
+ 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 */
+ strcpyW(fodInfos->filename, nameBit);
+ *nameBit = 0x00;
+
+ len = strlenW(tmpBuf);
+ if(fodInfos->initdir)
+ MemFree(fodInfos->initdir);
+ fodInfos->initdir = MemAlloc((len+1)*sizeof(WCHAR));
+ strcpyW(fodInfos->initdir, tmpBuf);
+
+ handledPath = TRUE;
+ TRACE("Value in Filename includes path, overriding initdir: %s, %s\n",
+ debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
+ }
+ SetDlgItemTextW(hwnd, IDC_FILENAME, fodInfos->filename);
+ }
+
+ /* 4. win98+ and win2000+ if any files of specified filter types in
+ current directory, use it */
+ if ( win98plus && handledPath == FALSE &&
+ fodInfos->filter && *fodInfos->filter) {
+
+ BOOL searchMore = TRUE;
+ LPCWSTR lpstrPos = fodInfos->filter;
+ WIN32_FIND_DATAW FindFileData;
+ HANDLE hFind;
+
+ while (searchMore)
+ {
+ /* filter is a list... title\0ext\0......\0\0 */
+
+ /* Skip the title */
+ if(! *lpstrPos) break; /* end */
+ lpstrPos += strlenW(lpstrPos) + 1;
+
+ /* 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 */
+ lpstrPos += strlenW(lpstrPos) + 1;
+
+ } else {
+ searchMore = FALSE;
+
+ if(fodInfos->initdir)
+ MemFree(fodInfos->initdir);
+ fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
+ 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));
+ break;
+ }
+ }
+ }
+
+ /* 5. Win2000+: FIXME: Next, Recently used? Not sure how windows does this */
+
+ /* 6. Win98+ and 2000+: Use personal files dir, others use current dir */
+ if (handledPath == FALSE && (win2000plus || win98plus)) {
+ fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
+
+ if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir)))
+ {
+ if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, fodInfos->initdir)))
+ {
+ /* last fallback */
+ GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
+ TRACE("No personal or desktop dir, using cwd as failsafe: %s\n", debugstr_w(fodInfos->initdir));
+ } else {
+ TRACE("No personal dir, using desktop instead: %s\n", debugstr_w(fodInfos->initdir));
+ }
+ } else {
+ TRACE("No initial dir specified, using personal files dir of %s\n", debugstr_w(fodInfos->initdir));
+ }
+ handledPath = TRUE;
+ } else if (handledPath==FALSE) {
+ fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR));
+ GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
+ handledPath = TRUE;
+ TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir));
+ }
+ }
+ TRACE("After manipilation, 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)
+ {
+ SendDlgItemMessageA(hwnd,IDC_OPENREADONLY,BM_SETCHECK,(WPARAM)TRUE,0);
+ }
+
+ /* Must the open as read only check box be hid ?*/
+ if(fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY)
+ {
+ ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE);
+ }
+
+ /* Must the help button be hid ?*/
+ if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP))
+ {
+ ShowWindow(GetDlgItem(hwnd, pshHelp), SW_HIDE);
+ }
+
+ /* Resize the height, if open as read only checkbox ad help button
+ are hidden and we are not using a custom template */
+ if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
+ (!(fodInfos->ofnInfos->Flags &
+ (OFN_SHOWHELP|OFN_ENABLETEMPLATE|OFN_ENABLETEMPLATEHANDLE))))
+ {
+ RECT rectDlg, rectHelp, rectCancel;
+ GetWindowRect(hwnd, &rectDlg);
+ GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
+ GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
+ /* subtract the height of the help button plus the space between
+ the help button and the cancel button to the height of the dialog */
+ SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
+ (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
+ SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
+ }
+
+ /* change Open to Save FIXME: use resources */
+ if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
+ {
+ SetDlgItemTextA(hwnd,IDOK,"&Save");
+ SetDlgItemTextA(hwnd,IDC_LOOKINSTATIC,"Save &in");
+ }
+ return 0;
+}
+
+/***********************************************************************
+ * FILEDLG95_FillControls
*
- * WM_INITDIALOG message handler
+ * WM_INITDIALOG message handler (after hook notification)
*/
-static LRESULT FILEDLG95_OnWMInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
+static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
- LPITEMIDLIST pidlItemId;
+ LPITEMIDLIST pidlItemId = NULL;
+
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
- TRACE("dir=%s file=%s\n",
- fodInfos->ofnInfos->lpstrInitialDir, fodInfos->ofnInfos->lpstrFile);
+ 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->ofnInfos->lpstrInitialDir)))
+ if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->initdir)))
{
- char path[MAX_PATH];
+ WCHAR path[MAX_PATH];
- GetCurrentDirectoryA(MAX_PATH,path);
+ GetCurrentDirectoryW(MAX_PATH,path);
pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder, path);
-
}
/* Initialise shell objects */
FILEDLG95_SHELL_Init(hwnd);
- /* Initialise dialog UI */
- FILEDLG95_InitUI(hwnd);
-
- /* Initialize the Look In combo box*/
+ /* Initialize the Look In combo box */
FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB);
/* Initialize the filter combo box */
{
/* OK button */
case IDOK:
- if(FILEDLG95_OnOpen(hwnd))
- SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
+ FILEDLG95_OnOpen(hwnd);
break;
/* Cancel button */
case IDCANCEL:
- FILEDLG95_Clean(hwnd);
- EndDialog(hwnd, FALSE);
+ FILEDLG95_Clean(hwnd);
+ EndDialog(hwnd, FALSE);
break;
/* Filetype combo box */
case IDC_FILETYPE:
}
/* Do not use the listview selection anymore */
fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
- return 0;
+ return 0;
}
/***********************************************************************
SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser);
- return TRUE;
+ return TRUE;
}
-/***********************************************************************
- * FILEDLG95_InitUI
- *
- */
-static LRESULT FILEDLG95_InitUI(HWND hwnd)
-{
- TBBUTTON tbb[] =
- {
- {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
- {VIEW_PARENTFOLDER, FCIDM_TB_UPFOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
- {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
- {VIEW_NEWFOLDER+1, FCIDM_TB_DESKTOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
- {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
- {VIEW_NEWFOLDER, FCIDM_TB_NEWFOLDER, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
- {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0 },
- {VIEW_LIST, FCIDM_TB_SMALLICON, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
- {VIEW_DETAILS, FCIDM_TB_REPORTVIEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0 },
- };
- TBADDBITMAP tba[] =
- {
- { HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR },
- { COMDLG32_hInstance, 800 } // desktop icon
- };
-
- RECT rectTB;
-
- FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
-
- TRACE("%p\n", fodInfos);
-
- /* Get the hwnd of the controls */
- fodInfos->DlgInfos.hwndFileName = GetDlgItem(hwnd,IDC_FILENAME);
- fodInfos->DlgInfos.hwndFileTypeCB = GetDlgItem(hwnd,IDC_FILETYPE);
- fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
-
- /* construct the toolbar */
- GetWindowRect(GetDlgItem(hwnd,IDC_TOOLBARSTATIC),&rectTB);
- MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
-
- fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, (LPSTR) NULL,
- WS_CHILD | WS_GROUP | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NORESIZE,
- 0, 0, 150, 26,
- hwnd, (HMENU) IDC_TOOLBAR, COMMDLG_hInstance32, NULL);
-
- SetWindowPos(fodInfos->DlgInfos.hwndTB, 0,
- rectTB.left,rectTB.top, rectTB.right-rectTB.left, rectTB.bottom-rectTB.top,
- SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER );
-
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
-
-/* fixme: use TB_LOADIMAGES when implemented */
-/* SendMessageA(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, (WPARAM) IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 12, (LPARAM) &tba[0]);
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, (WPARAM) 1, (LPARAM) &tba[1]);
-
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSA, (WPARAM) 9,(LPARAM) &tbb);
- SendMessageA(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
-
- /* Set the window text with the text specified in the OPENFILENAME structure */
- if(fodInfos->ofnInfos->lpstrTitle)
- {
- SetWindowTextA(hwnd,fodInfos->ofnInfos->lpstrTitle);
- }
- else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
- {
- SetWindowTextA(hwnd,"Save");
- }
-
- /* Initialise the file name edit control */
- if(fodInfos->ofnInfos->lpstrFile)
- {
- LPSTR lpstrFile = COMDLG32_PathFindFileNameA(fodInfos->ofnInfos->lpstrFile);
- SetDlgItemTextA(hwnd, IDC_FILENAME, lpstrFile);
- }
-
- /* Must the open as read only check box be checked ?*/
- if(fodInfos->ofnInfos->Flags & OFN_READONLY)
- {
- SendDlgItemMessageA(hwnd,IDC_OPENREADONLY,BM_SETCHECK,(WPARAM)TRUE,0);
- }
-
- /* Must the open as read only check box be hid ?*/
- if(fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY)
- {
- ShowWindow(GetDlgItem(hwnd,IDC_OPENREADONLY),SW_HIDE);
- }
-
- /* Must the help button be hid ?*/
- if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP))
- {
- ShowWindow(GetDlgItem(hwnd, pshHelp), SW_HIDE);
- }
-
- /* Resize the height, if open as read only checkbox ad help button
- are hidden */
- if ( (fodInfos->ofnInfos->Flags & OFN_HIDEREADONLY) &&
- (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP)) )
- {
- RECT rectDlg, rectHelp, rectCancel;
- GetWindowRect(hwnd, &rectDlg);
- GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
- GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
- /* subtract the height of the help button plus the space between
- the help button and the cancel button to the height of the dialog */
- SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
- (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
- SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
- }
-
- /* change Open to Save FIXME: use resources */
- if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
- {
- SetDlgItemTextA(hwnd,IDOK,"&Save");
- SetDlgItemTextA(hwnd,IDC_LOOKINSTATIC,"Save &in");
- }
- return 0;
-}
-
/***********************************************************************
* FILEDLG95_OnOpenMultipleFiles
- *
+ *
* Handles the opening of multiple files.
*
* FIXME
* check destination buffer size
*/
-BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
+BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
{
- CHAR lpstrPathSpec[MAX_PATH] = "";
- LPSTR lpstrFile;
+ WCHAR lpstrPathSpec[MAX_PATH] = {0};
UINT nCount, nSizePath;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("\n");
- lpstrFile = fodInfos->ofnInfos->lpstrFile;
- lpstrFile[0] = '\0';
-
- COMDLG32_SHGetPathFromIDListA( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
+ if(fodInfos->unicode)
+ {
+ LPOPENFILENAMEW ofn = (LPOPENFILENAMEW) fodInfos->ofnInfos;
+ ofn->lpstrFile[0] = '\0';
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = fodInfos->ofnInfos;
+ ofn->lpstrFile[0] = '\0';
+ }
+
+ SHGetPathFromIDListW( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
- ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
+ ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
+ ! ( fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG ) )
{
- LPSTR lpstrTemp = lpstrFileList;
+ LPWSTR lpstrTemp = lpstrFileList;
for ( nCount = 0; nCount < nFileCount; nCount++ )
{
pidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrTemp);
if (!pidl)
{
- CHAR lpstrNotFound[100];
- CHAR lpstrMsg[100];
- CHAR tmp[400];
+ WCHAR lpstrNotFound[100];
+ WCHAR lpstrMsg[100];
+ WCHAR tmp[400];
+ WCHAR nl[] = {'\n',0};
- LoadStringA(COMMDLG_hInstance32, IDS_FILENOTFOUND, lpstrNotFound, 100);
- LoadStringA(COMMDLG_hInstance32, IDS_VERIFYFILE, lpstrMsg, 100);
+ LoadStringW(COMMDLG_hInstance32, IDS_FILENOTFOUND, lpstrNotFound, 100);
+ LoadStringW(COMMDLG_hInstance32, IDS_VERIFYFILE, lpstrMsg, 100);
- strcpy(tmp, lpstrTemp);
- strcat(tmp, "\n");
- strcat(tmp, lpstrNotFound);
- strcat(tmp, "\n");
- strcat(tmp, lpstrMsg);
+ strcpyW(tmp, lpstrTemp);
+ strcatW(tmp, nl);
+ strcatW(tmp, lpstrNotFound);
+ strcatW(tmp, nl);
+ strcatW(tmp, lpstrMsg);
- MessageBoxA(hwnd, tmp, fodInfos->ofnInfos->lpstrTitle, MB_OK | MB_ICONEXCLAMATION);
+ MessageBoxW(hwnd, tmp, fodInfos->title, MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
-
- lpstrTemp += strlen(lpstrFileList) + 1;
+
+ /* move to the next file in the list of files */
+ lpstrTemp += strlenW(lpstrTemp) + 1;
COMDLG32_SHFree(pidl);
}
}
- nSizePath = lstrlenA(lpstrPathSpec);
- lstrcpyA( lpstrFile, lpstrPathSpec);
- memcpy( lpstrFile + nSizePath + 1, lpstrFileList, sizeUsed );
+ nSizePath = strlenW(lpstrPathSpec) + 1;
+ if ( !(fodInfos->ofnInfos->Flags & OFN_EXPLORER) )
+ {
+ /* For "oldstyle" dialog the components have to
+ be spearated by blanks (not '\0'!) and short
+ filenames have to be used! */
+ FIXME("Components have to be separated by blanks");
+ }
+ if(fodInfos->unicode)
+ {
+ LPOPENFILENAMEW ofn = (LPOPENFILENAMEW) fodInfos->ofnInfos;
+ strcpyW( ofn->lpstrFile, lpstrPathSpec);
+ memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) );
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = fodInfos->ofnInfos;
+
+ if (ofn->lpstrFile != NULL)
+ {
+ WideCharToMultiByte(CP_ACP, 0, lpstrPathSpec, -1,
+ ofn->lpstrFile, ofn->nMaxFile, NULL, NULL);
+ if (ofn->nMaxFile > nSizePath)
+ {
+ WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
+ ofn->lpstrFile + nSizePath,
+ ofn->nMaxFile - nSizePath, NULL, NULL);
+ }
+ }
+ }
fodInfos->ofnInfos->nFileOffset = nSizePath + 1;
fodInfos->ofnInfos->nFileExtension = 0;
* FILEDLG95_OnOpen
*
* Ok button WM_COMMAND message handler
- *
+ *
* If the function succeeds, the return value is nonzero.
*/
#define ONOPEN_BROWSE 1
BOOL FILEDLG95_OnOpen(HWND hwnd)
{
- char * lpstrFileList;
+ LPWSTR lpstrFileList;
UINT nFileCount = 0;
UINT sizeUsed = 0;
BOOL ret = TRUE;
- char lpstrPathAndFile[MAX_PATH];
- char lpstrTemp[MAX_PATH];
+ WCHAR lpstrPathAndFile[MAX_PATH];
+ WCHAR lpstrTemp[MAX_PATH];
LPSHELLFOLDER lpsf = NULL;
int nOpenAction;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
-
TRACE("hwnd=0x%04x\n", hwnd);
/* get the files from the edit control */
/* try if the user selected a folder in the shellview */
if(nFileCount == 0)
{
- if (BrowseSelectedFolder(hwnd))
+ BrowseSelectedFolder(hwnd);
return FALSE;
}
-
+
if(nFileCount > 1)
{
ret = FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed);
goto ret;
}
- TRACE("count=%u len=%u file=%s\n", nFileCount, sizeUsed, lpstrFileList);
+ 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
*/
/* Get the current directory name */
- if (!COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
+ if (!SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
{
/* we are in a special folder, default to desktop */
- if(FAILED(COMDLG32_SHGetFolderPathA(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, NULL, 0, lpstrPathAndFile)))
+ if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))
{
/* last fallback */
- GetCurrentDirectoryA(MAX_PATH, lpstrPathAndFile);
+ GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
}
}
- COMDLG32_PathAddBackslashA(lpstrPathAndFile);
+ PathAddBackslashW(lpstrPathAndFile);
- TRACE("current directory=%s\n", lpstrPathAndFile);
+ TRACE("current directory=%s\n", debugstr_w(lpstrPathAndFile));
/* if the user specifyed a fully qualified path use it */
- if(COMDLG32_PathIsRelativeA(lpstrFileList))
+ if(PathIsRelativeW(lpstrFileList))
{
- strcat(lpstrPathAndFile, lpstrFileList);
+ strcatW(lpstrPathAndFile, lpstrFileList);
}
else
{
/* does the path have a drive letter? */
- if (COMDLG32_PathGetDriveNumberA(lpstrFileList) == -1)
- strcpy(lpstrPathAndFile+2, lpstrFileList);
+ if (PathGetDriveNumberW(lpstrFileList) == -1)
+ strcpyW(lpstrPathAndFile+2, lpstrFileList);
else
- strcpy(lpstrPathAndFile, lpstrFileList);
+ strcpyW(lpstrPathAndFile, lpstrFileList);
}
/* resolve "." and ".." */
- COMDLG32_PathCanonicalizeA(lpstrTemp, lpstrPathAndFile );
- strcpy(lpstrPathAndFile, lpstrTemp);
- TRACE("canon=%s\n", lpstrPathAndFile);
+ PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
+ strcpyW(lpstrPathAndFile, lpstrTemp);
+ TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
MemFree(lpstrFileList);
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
*/
nOpenAction = ONOPEN_BROWSE;
/* dont apply any checks with OFN_NOVALIDATE */
- if(!(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
{
- LPSTR lpszTemp, lpszTemp1;
+ LPWSTR lpszTemp, lpszTemp1;
LPITEMIDLIST pidl = NULL;
+ WCHAR szwInvalid[] = { '/',':','<','>','|', 0};
/* check for invalid chars */
- if(strpbrk(lpstrPathAndFile+3, "/:<>|") != NULL)
+ if((strpbrkW(lpstrPathAndFile+3, szwInvalid) != NULL) && !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
{
FILEDLG95_OnOpenMessage(hwnd, IDS_INVALID_FILENAME_TITLE, IDS_INVALID_FILENAME);
ret = FALSE;
goto ret;
}
- if (FAILED (COMDLG32_SHGetDesktopFolder(&lpsf))) return FALSE;
-
+ if (FAILED (SHGetDesktopFolder(&lpsf))) return FALSE;
+
lpszTemp1 = lpszTemp = lpstrPathAndFile;
while (lpszTemp1)
{
LPSHELLFOLDER lpsfChild;
WCHAR lpwstrTemp[MAX_PATH];
DWORD dwEaten, dwAttributes;
+ LPWSTR p;
- lpszTemp = COMDLG32_PathFindNextComponentA(lpszTemp);
- if (*lpszTemp)
- lstrcpynAtoW(lpwstrTemp, lpszTemp1, lpszTemp - lpszTemp1);
- else
+ strcpyW(lpwstrTemp, lpszTemp);
+ p = PathFindNextComponentW(lpwstrTemp);
+
+ if (!p) break; /* end of path */
+
+ *p = 0;
+ lpszTemp = lpszTemp + strlenW(lpwstrTemp);
+
+ if(*lpszTemp==0)
{
- lstrcpyAtoW(lpwstrTemp, lpszTemp1); /* last element */
- if(strpbrk(lpszTemp1, "*?") != NULL)
+ WCHAR wszWild[] = { '*', '?', 0 };
+ /* if the last element is a wildcard do a search */
+ if(strpbrkW(lpszTemp1, wszWild) != NULL)
{
- nOpenAction = ONOPEN_SEARCH;
+ nOpenAction = ONOPEN_SEARCH;
break;
- }
+ }
}
lpszTemp1 = lpszTemp;
- TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_a(lpszTemp), lpsf);
+ TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_w(lpszTemp), lpsf);
- if(lstrlenW(lpwstrTemp)==2) COMDLG32_PathAddBackslashW(lpwstrTemp);
+ if(lstrlenW(lpwstrTemp)==2) PathAddBackslashW(lpwstrTemp);
dwAttributes = SFGAO_FOLDER;
- if(FAILED(IShellFolder_ParseDisplayName(lpsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
- {
- if(*lpszTemp) /* points to trailing null for last path element */
- {
- if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
- {
- FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING);
- break;
- }
- }
- else
- {
- if(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST)
- {
- FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING);
- break;
- }
- }
- /* change to the current folder */
- nOpenAction = ONOPEN_OPEN;
- break;
- }
- else
+ if(SUCCEEDED(IShellFolder_ParseDisplayName(lpsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
{
- /* the path component is valid */
+ /* the path component is valid, we have a pidl of the next path component */
TRACE("parse OK attr=0x%08lx pidl=%p\n", dwAttributes, pidl);
if(dwAttributes & SFGAO_FOLDER)
{
COMDLG32_SHFree(pidl);
pidl = NULL;
}
+ else if (!(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
+ {
+ if(*lpszTemp) /* points to trailing null for last path element */
+ {
+ if(fodInfos->ofnInfos->Flags & OFN_PATHMUSTEXIST)
+ {
+ FILEDLG95_OnOpenMessage(hwnd, 0, IDS_PATHNOTEXISTING);
+ break;
+ }
+ }
+ else
+ {
+ if( (fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
+ !( fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG ) )
+ {
+ FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING);
+ break;
+ }
+ }
+ /* change to the current folder */
+ nOpenAction = ONOPEN_OPEN;
+ break;
+ }
+ else
+ {
+ nOpenAction = ONOPEN_OPEN;
+ break;
+ }
}
if(pidl) COMDLG32_SHFree(pidl);
}
- /* path is valid, clean the edit box */
- SetDlgItemTextA(hwnd,IDC_FILENAME,"");
-
/*
Step 3: here we have a cleaned up and validated path
switch(nOpenAction)
{
case ONOPEN_SEARCH: /* set the current filter to the file mask and refresh */
- TRACE("ONOPEN_SEARCH %s\n", lpstrPathAndFile);
+ TRACE("ONOPEN_SEARCH %s\n", debugstr_w(lpstrPathAndFile));
{
int iPos;
- LPSTR lpszTemp = COMDLG32_PathFindFileNameA(lpstrPathAndFile);
+ LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
+ DWORD len;
/* replace the current filter */
if(fodInfos->ShellInfos.lpstrCurrentFilter)
MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
- fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpszTemp)+1)*sizeof(WCHAR));
- lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
+ len = strlenW(lpszTemp)+1;
+ fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR));
+ strcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
/* set the filter cb to the extension when possible */
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
ret = FALSE;
break;
case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
- TRACE("ONOPEN_OPEN %s\n", lpstrPathAndFile);
+ TRACE("ONOPEN_OPEN %s\n", debugstr_w(lpstrPathAndFile));
{
/* add default extension */
- if (fodInfos->ofnInfos->lpstrDefExt)
+ if (fodInfos->defext)
{
- if (! *COMDLG32_PathFindExtensionA(lpstrPathAndFile))
+ if (! *PathFindExtensionW(lpstrPathAndFile))
{
- strcat(lpstrPathAndFile, ".");
- strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt);
+ /* only add "." in case a default extension does exist */
+ if (*fodInfos->defext != '\0')
+ {
+ const WCHAR szwDot[] = {'.',0};
+ int PathLength = strlenW(lpstrPathAndFile);
+
+ strcatW(lpstrPathAndFile, szwDot);
+ strcatW(lpstrPathAndFile, fodInfos->defext);
+
+ /* if file does not exist try without extension */
+ if (!PathFileExistsW(lpstrPathAndFile))
+ lpstrPathAndFile[PathLength] = '\0';
+ }
}
}
- /* Check that size size of the file does not exceed buffer size */
- if(strlen(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile)
+ /* Check that the size of the file does not exceed buffer size.
+ (Allow for extra \0 if OFN_MULTISELECT is set.) */
+ if(strlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
+ ((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
{
- LPSTR lpszTemp;
-
+ LPWSTR lpszTemp;
+
/* fill destination buffer */
- strcpy(fodInfos->ofnInfos->lpstrFile, lpstrPathAndFile);
+ if (fodInfos->ofnInfos->lpstrFile)
+ {
+ if(fodInfos->unicode)
+ {
+ LPOPENFILENAMEW ofn = (LPOPENFILENAMEW) fodInfos->ofnInfos;
+
+ strncpyW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
+ if (ofn->Flags & OFN_ALLOWMULTISELECT)
+ ofn->lpstrFile[lstrlenW(ofn->lpstrFile) + 1] = '\0';
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = fodInfos->ofnInfos;
+
+ WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
+ ofn->lpstrFile, ofn->nMaxFile, NULL, NULL);
+ if (ofn->Flags & OFN_ALLOWMULTISELECT)
+ ofn->lpstrFile[lstrlenA(ofn->lpstrFile) + 1] = '\0';
+ }
+ }
/* set filename offset */
- lpszTemp = COMDLG32_PathFindFileNameA(lpstrPathAndFile);
- fodInfos->ofnInfos->nFileOffset = lpszTemp - lpstrPathAndFile;
-
+ lpszTemp = PathFindFileNameW(lpstrPathAndFile);
+ fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+
/* set extension offset */
- lpszTemp = COMDLG32_PathFindExtensionA(lpstrPathAndFile);
- fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? lpszTemp - lpstrPathAndFile + 1 : 0;
-
+ lpszTemp = PathFindExtensionW(lpstrPathAndFile);
+ fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+
/* set the lpstrFileTitle */
if(fodInfos->ofnInfos->lpstrFileTitle)
{
- LPSTR lpstrFileTitle = COMDLG32_PathFindFileNameA(lpstrPathAndFile);
- strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle);
+ LPWSTR lpstrFileTitle = PathFindFileNameW(lpstrPathAndFile);
+ if(fodInfos->unicode)
+ {
+ LPOPENFILENAMEW ofn = (LPOPENFILENAMEW) fodInfos->ofnInfos;
+ strncpyW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = fodInfos->ofnInfos;
+ WideCharToMultiByte(CP_ACP, 0, lpstrFileTitle, -1,
+ ofn->lpstrFileTitle, ofn->nMaxFileTitle, NULL, NULL);
+ }
}
- FILEDLG95_Clean(hwnd);
+ /* ask the hook if we can close */
+ if(IsHooked(fodInfos))
+ {
+ TRACE("---\n");
+ /* First send CDN_FILEOK as MSDN doc says */
+ SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
+
+ /* FIXME we are sending ASCII-structures. Does not work with NT */
+ CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,
+ fodInfos->DlgInfos.hwndCustomDlg,
+ fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
+ if (GetWindowLongA(fodInfos->DlgInfos.hwndCustomDlg, DWL_MSGRESULT))
+ {
+ TRACE("canceled\n");
+ ret = FALSE;
+ goto ret;
+ }
+ }
+
+ TRACE("close\n");
+ FILEDLG95_Clean(hwnd);
ret = EndDialog(hwnd, TRUE);
}
else
TRACE("\n");
/*
- * Initialisation of the FileOpenDialogInfos structure
+ * Initialisation of the FileOpenDialogInfos structure
*/
/* Shell */
/* Disable multi-select if flag not set */
if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
{
- fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
+ fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
}
fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST;
ScreenToClient(hwnd,(LPPOINT)&fodInfos->ShellInfos.rectView.right);
/* Construct the IShellBrowser interface */
- fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
-
+ fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
+
return NOERROR;
}
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
LPITEMIDLIST pidl;
HRESULT hres;
-
+
TRACE("\n");
- COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
+ SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
COMDLG32_SHFree(pidl);
return SUCCEEDED(hres);
/***********************************************************************
* FILEDLG95_FILETYPE_Init
*
- * Initialisation of the file type combo box
+ * Initialisation of the file type combo box
*/
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
{
TRACE("\n");
- if(fodInfos->ofnInfos->lpstrFilter)
+ if(fodInfos->filter)
{
int nFilters = 0; /* number of filters */
- LPSTR lpstrFilter;
- LPCSTR lpstrPos = fodInfos->ofnInfos->lpstrFilter;
+ LPWSTR lpstrFilter;
+ LPCWSTR lpstrPos = fodInfos->filter;
for(;;)
{
- /* filter is a list... title\0ext\0......\0\0
+ /* filter is a list... title\0ext\0......\0\0
* Set the combo item text to the title and the item data
* to the ext
*/
- LPCSTR lpstrDisplay;
- LPSTR lpstrExt;
+ LPCWSTR lpstrDisplay;
+ LPWSTR lpstrExt;
/* Get the title */
if(! *lpstrPos) break; /* end */
lpstrDisplay = lpstrPos;
- lpstrPos += strlen(lpstrPos) + 1;
+ lpstrPos += strlenW(lpstrPos) + 1;
/* Copy the extensions */
if (! *lpstrPos) return E_FAIL; /* malformed filter */
- if (!(lpstrExt = (LPSTR) MemAlloc(strlen(lpstrPos)+1))) return E_FAIL;
- strcpy(lpstrExt,lpstrPos);
- lpstrPos += strlen(lpstrPos) + 1;
-
+ if (!(lpstrExt = MemAlloc((strlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
+ strcpyW(lpstrExt,lpstrPos);
+ lpstrPos += strlenW(lpstrPos) + 1;
+
/* Add the item at the end of the combo */
- CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
+ CBAddStringW(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters, lpstrExt);
nFilters++;
}
* in the initialisation structure
* FIXME: lpstrCustomFilter not handled at all
*/
-
+
/* set default filter index */
- if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->ofnInfos->lpstrCustomFilter == NULL)
+ if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->customfilter == NULL)
fodInfos->ofnInfos->nFilterIndex = 1;
/* First, check to make sure our index isn't out of bounds. */
if ( fodInfos->ofnInfos->nFilterIndex > nFilters )
fodInfos->ofnInfos->nFilterIndex = nFilters;
-
+
/* Set the current index selection. */
CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->ofnInfos->nFilterIndex-1);
-
+
/* Get the corresponding text string from the combo box. */
- lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
+ lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
fodInfos->ofnInfos->nFilterIndex-1);
if ((INT)lpstrFilter == CB_ERR) /* control is empty */
- lpstrFilter = NULL;
+ lpstrFilter = NULL;
if(lpstrFilter)
{
- _strlwr(lpstrFilter); /* lowercase */
- fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFilter)+1)*2);
- lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, lpstrFilter);
+ DWORD len;
+ CharLowerW(lpstrFilter); /* lowercase */
+ len = strlenW(lpstrFilter)+1;
+ fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
+ strcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
}
}
return NOERROR;
{
case CBN_SELENDOK:
{
- LPSTR lpstrFilter;
+ LPWSTR lpstrFilter;
/* Get the current item of the filetype combo box */
int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
if(fodInfos->ShellInfos.lpstrCurrentFilter)
MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
- lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
+ lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
iItem);
if((int)lpstrFilter != CB_ERR)
{
- fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFilter)+1)*2);
- lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,_strlwr(lpstrFilter));
- SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
+ DWORD len;
+ CharLowerW(lpstrFilter); /* lowercase */
+ len = strlenW(lpstrFilter)+1;
+ fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
+ strcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
+ SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
}
/* Refresh the actual view to display the included items*/
*
* searches for a extension in the filetype box
*/
-static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCSTR lpstrExt)
+static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt)
{
int i, iCount = CBGetCount(hwnd);
- TRACE("%s\n", lpstrExt);
+ TRACE("%s\n", debugstr_w(lpstrExt));
if(iCount != CB_ERR)
{
for(i=0;i<iCount;i++)
{
- if(!strcasecmp(lpstrExt,(LPSTR)CBGetItemDataPtr(hwnd,i)))
+ if(!lstrcmpiW(lpstrExt,(LPWSTR)CBGetItemDataPtr(hwnd,i)))
return i;
}
}
MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
}
-
+
/***********************************************************************
* FILEDLG95_LOOKIN_Init
*
- * Initialisation of the look in combo box
+ * Initialisation of the look in combo box
*/
static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
{
liInfos->iMaxIndentation = 0;
SetPropA(hwndCombo, LookInInfosStr, (HANDLE) liInfos);
+
+ /* set item height for both text field and listbox */
+ CBSetItemHeight(hwndCombo,-1,GetSystemMetrics(SM_CYSMICON));
CBSetItemHeight(hwndCombo,0,GetSystemMetrics(SM_CYSMICON));
/* Initialise data of Desktop folder */
- COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
+ SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
COMDLG32_SHFree(pidlTmp);
- COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
+ SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
- COMDLG32_SHGetDesktopFolder(&psfRoot);
+ SHGetDesktopFolder(&psfRoot);
if (psfRoot)
{
SHFILEINFOA sfi;
HIMAGELIST ilItemImage;
int iIndentation;
+ TEXTMETRICA tm;
LPSFOLDER tmpFolder;
if(pDIStruct->itemID == liInfos->uSelectedItem)
{
- ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
- 0,
- &sfi,
- sizeof (SHFILEINFOA),
- SHGFI_PIDL | SHGFI_SMALLICON |
- SHGFI_OPENICON | SHGFI_SYSICONINDEX |
- SHGFI_DISPLAYNAME );
+ ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
+ 0,
+ &sfi,
+ sizeof (SHFILEINFOA),
+ SHGFI_PIDL | SHGFI_SMALLICON |
+ SHGFI_OPENICON | SHGFI_SYSICONINDEX |
+ SHGFI_DISPLAYNAME );
}
else
{
- ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
- 0,
- &sfi,
+ ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
+ 0,
+ &sfi,
sizeof (SHFILEINFOA),
- SHGFI_PIDL | SHGFI_SMALLICON |
- SHGFI_SYSICONINDEX |
+ SHGFI_PIDL | SHGFI_SMALLICON |
+ SHGFI_SYSICONINDEX |
SHGFI_DISPLAYNAME);
}
- /* Is this item selected ?*/
+ /* Is this item selected ? */
if(pDIStruct->itemState & ODS_SELECTED)
{
SetTextColor(pDIStruct->hDC,(0x00FFFFFF & ~(crText)));
SetBkColor(pDIStruct->hDC,crHighLight);
- FillRect(pDIStruct->hDC,&pDIStruct->rcItem,(HBRUSH)crHighLight);
+ FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_HIGHLIGHT));
}
else
{
SetTextColor(pDIStruct->hDC,crText);
SetBkColor(pDIStruct->hDC,crWin);
- FillRect(pDIStruct->hDC,&pDIStruct->rcItem,(HBRUSH)crWin);
+ FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_WINDOW));
}
- /* Do not indent item if drawing in the edit of the combo*/
+ /* Do not indent item if drawing in the edit of the combo */
if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
{
iIndentation = 0;
- ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
- 0,
- &sfi,
- sizeof (SHFILEINFOA),
- SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
+ ilItemImage = (HIMAGELIST) SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
+ 0,
+ &sfi,
+ sizeof (SHFILEINFOA),
+ SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
| SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME );
}
rectIcon.bottom = pDIStruct->rcItem.bottom;
/* Initialise the text display area */
+ GetTextMetricsA(pDIStruct->hDC, &tm);
rectText.left = rectIcon.right;
- rectText.top = pDIStruct->rcItem.top + YTEXTOFFSET;
+ rectText.top =
+ (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
rectText.right = pDIStruct->rcItem.right + XTEXTOFFSET;
- rectText.bottom = pDIStruct->rcItem.bottom;
+ rectText.bottom =
+ (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
-
/* Draw the icon from the image list */
- COMDLG32_ImageList_Draw(ilItemImage,
+ ImageList_Draw(ilItemImage,
sfi.iIcon,
- pDIStruct->hDC,
- rectIcon.left,
- rectIcon.top,
- ILD_TRANSPARENT );
+ pDIStruct->hDC,
+ rectIcon.left,
+ rectIcon.top,
+ ILD_TRANSPARENT );
/* Draw the associated text */
if(sfi.szDisplayName)
case CBN_SELENDOK:
{
LPSFOLDER tmpFolder;
- int iItem;
+ int iItem;
iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
}
break;
}
-
+
}
return FALSE;
}
SFOLDER *tmpFolder;
LookInInfos *liInfos;
- TRACE("\n");
+ TRACE("%08x\n", iInsertId);
if(!pidl)
return -1;
if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr)))
return -1;
-
+
tmpFolder = MemAlloc(sizeof(SFOLDER));
tmpFolder->m_iIndent = 0;
tmpFolder->m_iIndent++;
}
- tmpFolder->pidlItem = COMDLG32_PIDL_ILClone(pidl); /* FIXME: memory leak*/
+ tmpFolder->pidlItem = COMDLG32_PIDL_ILClone(pidl);
if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
liInfos->iMaxIndentation = tmpFolder->m_iIndent;
-
+
sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
- COMDLG32_SHGetFileInfoA((LPSTR)pidl,
+ SHGetFileInfoA((LPSTR)pidl,
0,
&sfi,
sizeof(sfi),
- SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
+ SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
| SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
+ TRACE("-- Add %s attr=%08lx\n", sfi.szDisplayName, sfi.dwAttributes);
if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
{
int iItemID;
-
+
+ TRACE("-- Add %s at %u\n", sfi.szDisplayName, tmpFolder->m_iIndent);
+
/* Add the item at the end of the list */
if(iInsertId < 0)
{
return iItemID;
}
+ COMDLG32_SHFree( tmpFolder->pidlItem );
MemFree( tmpFolder );
return -1;
/***********************************************************************
* FILEDLG95_LOOKIN_InsertItemAfterParent
*
- * Insert an item below its parent
+ * Insert an item below its parent
*/
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
{
-
+
LPITEMIDLIST pidlParent = GetParentPidl(pidl);
int iParentPos;
iItemPos--;
}
}
-
+
CBSetCurSel(hwnd,iItemPos);
liInfos->uSelectedItem = iItemPos;
int i = 0;
int iCount = CBGetCount(hwnd);
- TRACE("\n");
+ TRACE("0x%08x 0x%x\n",searchArg, iSearchMethod);
if (iCount != CB_ERR)
{
for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
{
pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
-
+
if (pidl)
{
/* get the total length of the selected file names*/
lpstrTemp[0] = '\0';
- GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp );
+ GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp );
if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */
{
- nLength += lstrlenA( lpstrTemp ) + 3;
+ nLength += strlen( lpstrTemp ) + 3;
nFiles++;
}
COMDLG32_SHFree( pidl );
{
/* get the file name */
lpstrTemp[0] = '\0';
- GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp );
+ GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp );
if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */
{
if ( nFiles > 1)
{
*lpstrCurrFile++ = '\"';
- lstrcpyA( lpstrCurrFile, lpstrTemp );
- lpstrCurrFile += lstrlenA( lpstrTemp );
- lstrcpyA( lpstrCurrFile, "\" " );
+ strcpy( lpstrCurrFile, lpstrTemp );
+ lpstrCurrFile += strlen( lpstrTemp );
+ strcpy( lpstrCurrFile, "\" " );
lpstrCurrFile += 2;
}
else
{
- lstrcpyA( lpstrAllFile, lpstrTemp );
+ strcpy( lpstrAllFile, lpstrTemp );
}
- }
+ }
COMDLG32_SHFree( (LPVOID) pidl );
}
}
+ SetWindowTextA( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
}
-
- SetWindowTextA( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
HeapFree(GetProcessHeap(),0, lpstrAllFile );
}
COMDLG32_SHFree(src->u.pOleStr);
break;
- case STRRET_CSTRA:
+ case STRRET_CSTR:
lstrcpynA((LPSTR)dest, src->u.cStr, len);
break;
- case STRRET_OFFSETA:
+ case STRRET_OFFSET:
lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
break;
/***********************************************************************
* FILEDLG95_FILENAME_GetFileNames
*
- * copys the filenames to a 0-delimited string
+ * copies the filenames to a 0-delimited string list (A\0B\0C\0\0)
*/
-int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPSTR * lpstrFileList, UINT * sizeUsed)
+int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
{
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
UINT nStrCharCount = 0; /* index in src buffer */
UINT nFileIndex = 0; /* index in dest buffer */
UINT nFileCount = 0; /* number of files */
UINT nStrLen = 0; /* length of string in edit control */
- LPSTR lpstrEdit; /* buffer for string from edit control */
+ LPWSTR lpstrEdit; /* buffer for string from edit control */
TRACE("\n");
/* get the filenames from the edit control */
- nStrLen = SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0);
- lpstrEdit = MemAlloc(nStrLen+1);
- GetDlgItemTextA(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1);
+ nStrLen = SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0);
+ lpstrEdit = MemAlloc( (nStrLen+1)*sizeof(WCHAR) );
+ GetDlgItemTextW(hwnd, IDC_FILENAME, lpstrEdit, nStrLen+1);
- TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit);
-
- *lpstrFileList = MemAlloc(nStrLen);
+ TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit));
+
+ /* we might get single filename without any '"',
+ * so we need nStrLen + terminating \0 + end-of-list \0 */
+ *lpstrFileList = MemAlloc( (nStrLen+2)*sizeof(WCHAR) );
*sizeUsed = 0;
- /* build 0-delimited file list from filenames*/
+ /* build 0-delimited file list from filenames */
while ( nStrCharCount <= nStrLen )
{
if ( lpstrEdit[nStrCharCount]=='"' )
(*lpstrFileList)[nFileIndex++] = '\0';
(*sizeUsed)++;
nFileCount++;
- }
+ }
nStrCharCount++;
}
/* single, unquoted string */
if ((nStrLen > 0) && (*sizeUsed == 0) )
{
- strcpy(*lpstrFileList, lpstrEdit);
- nFileIndex = strlen(lpstrEdit) + 1;
+ strcpyW(*lpstrFileList, lpstrEdit);
+ nFileIndex = strlenW(lpstrEdit) + 1;
(*sizeUsed) = nFileIndex;
nFileCount = 1;
}
MemFree(lpstrEdit);
return nFileCount;
- }
+}
#define SETDefFormatEtc(fe,cf,med) \
{ \
*/
LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex)
{
-
+
STGMEDIUM medium;
FORMATETC formatetc;
LPITEMIDLIST pidl = NULL;
-
+
TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
-
+
/* Set the FORMATETC structure*/
SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
/***********************************************************************
* GetName
*
- * Get the pidl's display name (relative to folder) and
+ * Get the pidl's display name (relative to folder) and
* put it in lpstrFileName.
- *
+ *
* Return NOERROR on success,
* E_FAIL otherwise
*/
if(!lpsf)
{
HRESULT hRes;
- COMDLG32_SHGetDesktopFolder(&lpsf);
+ SHGetDesktopFolder(&lpsf);
hRes = GetName(lpsf,pidl,dwFlags,lpstrFileName);
IShellFolder_Release(lpsf);
return hRes;
/***********************************************************************
* GetShellFolderFromPidl
*
- * pidlRel is the item pidl relative
+ * pidlRel is the item pidl relative
* Return the IShellFolder of the absolute pidl
*/
IShellFolder *GetShellFolderFromPidl(LPITEMIDLIST pidlAbs)
TRACE("%p\n", pidlAbs);
- if(SUCCEEDED(COMDLG32_SHGetDesktopFolder(&psfParent)))
+ if(SUCCEEDED(SHGetDesktopFolder(&psfParent)))
{
psf = psfParent;
if(pidlAbs && pidlAbs->mkid.cb)
pidlParent = COMDLG32_PIDL_ILClone(pidl);
COMDLG32_PIDL_ILRemoveLastID(pidlParent);
-
+
return pidlParent;
}
/***********************************************************************
* GetPidlFromName
*
- * returns the pidl of the file name relative to folder
- * NULL if an error occured
+ * returns the pidl of the file name relative to folder
+ * NULL if an error occurred
*/
-LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPCSTR lpcstrFileName)
+LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPWSTR lpcstrFileName)
{
- LPITEMIDLIST pidl;
+ LPITEMIDLIST pidl = NULL;
ULONG ulEaten;
- WCHAR lpwstrDirName[MAX_PATH];
- TRACE("sf=%p file=%s\n", lpsf, lpcstrFileName);
+ TRACE("sf=%p file=%s\n", lpsf, debugstr_w(lpcstrFileName));
if(!lpcstrFileName) return NULL;
-
- MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH);
+ if(!*lpcstrFileName) return NULL;
if(!lpsf)
{
- COMDLG32_SHGetDesktopFolder(&lpsf);
- pidl = GetPidlFromName(lpsf, lpcstrFileName);
- IShellFolder_Release(lpsf);
+ if (SUCCEEDED(SHGetDesktopFolder(&lpsf))) {
+ IShellFolder_ParseDisplayName(lpsf, 0, NULL, lpcstrFileName, &ulEaten, &pidl, NULL);
+ IShellFolder_Release(lpsf);
+ }
}
else
{
- IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL);
+ IShellFolder_ParseDisplayName(lpsf, 0, NULL, lpcstrFileName, &ulEaten, &pidl, NULL);
}
return pidl;
}
{
ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
HRESULT ret;
-
+
TRACE("%p, %p\n", psf, pidl);
-
+
ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
-
+
TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);
/* see documentation shell 4.1*/
return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
pidlSelection, SBSP_RELATIVE ) ) )
{
- MessageBoxA( hwnd, "Path does not exist", fodInfos->ofnInfos->lpstrTitle,
- MB_OK | MB_ICONEXCLAMATION );
+ WCHAR notexist[] = {'P','a','t','h',' ','d','o','e','s',
+ ' ','n','o','t',' ','e','x','i','s','t',0};
+ MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
}
bBrowseSelFolder = TRUE;
}
return bBrowseSelFolder;
-}
+}
/*
* Memory allocation methods */
HeapFree(GetProcessHeap(),0,mem);
}
}
-