1999-07-27 18:20:36 +02:00
|
|
|
/*
|
|
|
|
* COMMDLG - File Open Dialogs Win95 look and feel
|
|
|
|
*
|
2000-11-01 02:50:21 +01:00
|
|
|
* 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)
|
|
|
|
*
|
2000-08-31 04:06:26 +02:00
|
|
|
* FIXME: lpstrCustomFilter not handled
|
2000-06-02 21:36:53 +02:00
|
|
|
*
|
2000-10-28 02:29:58 +02:00
|
|
|
* FIXME: if the size of lpstrFile (nMaxFile) is too small the first
|
2000-06-02 21:36:53 +02:00
|
|
|
* two bytes of lpstrFile should contain the needed size
|
|
|
|
*
|
2000-08-31 04:06:26 +02:00
|
|
|
* FIXME: algorithm for selecting the initial directory is too simple
|
2000-06-02 21:36:53 +02:00
|
|
|
*
|
|
|
|
* FIXME: add to recent docs
|
|
|
|
*
|
|
|
|
* FIXME: flags not implemented: OFN_CREATEPROMPT, OFN_DONTADDTORECENT,
|
|
|
|
* OFN_ENABLEINCLUDENOTIFY, OFN_ENABLESIZING, OFN_EXTENSIONDIFFERENT,
|
2000-12-18 04:12:06 +01:00
|
|
|
* OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
|
2000-06-02 21:36:53 +02:00
|
|
|
* OFN_NOTESTFILECREATE, OFN_OVERWRITEPROMPT, OFN_USEMONIKERS
|
|
|
|
*
|
|
|
|
* FIXME: lCustData for lpfnHook (WM_INITDIALOG)
|
|
|
|
*
|
|
|
|
*
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <stdio.h>
|
1999-07-27 18:20:36 +02:00
|
|
|
#include <string.h>
|
2000-06-07 04:16:47 +02:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
#include "winbase.h"
|
2000-08-14 19:39:15 +02:00
|
|
|
#include "ntddk.h"
|
2000-11-28 23:40:56 +01:00
|
|
|
#include "winnls.h"
|
1999-07-27 18:20:36 +02:00
|
|
|
#include "heap.h"
|
|
|
|
#include "commdlg.h"
|
|
|
|
#include "dlgs.h"
|
1999-08-21 16:47:28 +02:00
|
|
|
#include "cdlg.h"
|
1999-07-27 18:20:36 +02:00
|
|
|
#include "debugtools.h"
|
|
|
|
#include "cderr.h"
|
|
|
|
#include "shellapi.h"
|
2000-08-03 06:19:24 +02:00
|
|
|
#include "shlguid.h"
|
1999-07-27 18:20:36 +02:00
|
|
|
#include "filedlgbrowser.h"
|
2000-06-02 21:36:53 +02:00
|
|
|
#include "shlwapi.h"
|
1999-07-27 18:20:36 +02:00
|
|
|
#include "wine/obj_contextmenu.h"
|
|
|
|
|
2000-02-10 23:15:21 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
#define UNIMPLEMENTED_FLAGS \
|
|
|
|
(OFN_CREATEPROMPT | OFN_DONTADDTORECENT |\
|
|
|
|
OFN_ENABLEINCLUDENOTIFY | OFN_ENABLESIZING | OFN_EXTENSIONDIFFERENT |\
|
2000-12-18 04:12:06 +01:00
|
|
|
OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
|
2000-11-01 02:50:21 +01:00
|
|
|
OFN_NOTESTFILECREATE | OFN_OVERWRITEPROMPT /*| OFN_USEMONIKERS*/)
|
|
|
|
|
|
|
|
#define IsHooked(fodInfos) \
|
|
|
|
((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook)
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Data structure and global variables
|
|
|
|
*/
|
|
|
|
typedef struct SFolder
|
|
|
|
{
|
|
|
|
int m_iImageIndex; /* Index of picture in image list */
|
|
|
|
HIMAGELIST hImgList;
|
|
|
|
int m_iIndent; /* Indentation index */
|
|
|
|
LPITEMIDLIST pidlItem; /* absolute pidl of the item */
|
|
|
|
|
|
|
|
} SFOLDER,*LPSFOLDER;
|
|
|
|
|
|
|
|
typedef struct tagLookInInfo
|
|
|
|
{
|
|
|
|
int iMaxIndentation;
|
|
|
|
UINT uSelectedItem;
|
|
|
|
} LookInInfos;
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Defines and global variables
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Draw item constant */
|
|
|
|
#define ICONWIDTH 18
|
|
|
|
#define XTEXTOFFSET 3
|
|
|
|
|
|
|
|
/* AddItem flags*/
|
|
|
|
#define LISTEND -1
|
|
|
|
|
|
|
|
/* SearchItem methods */
|
|
|
|
#define SEARCH_PIDL 1
|
|
|
|
#define SEARCH_EXP 2
|
|
|
|
#define ITEM_NOTFOUND -1
|
|
|
|
|
|
|
|
/* Undefined windows message sent by CreateViewObject*/
|
|
|
|
#define WM_GETISHELLBROWSER WM_USER+7
|
|
|
|
|
|
|
|
/* NOTE
|
|
|
|
* Those macros exist in windowsx.h. However, you can't really use them since
|
2000-10-28 02:29:58 +02:00
|
|
|
* they rely on the UNICODE defines and can't be used inside Wine itself.
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Combo box macros */
|
|
|
|
#define CBAddString(hwnd,str) \
|
|
|
|
SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)str);
|
|
|
|
|
|
|
|
#define CBInsertString(hwnd,str,pos) \
|
|
|
|
SendMessageA(hwnd,CB_INSERTSTRING,(WPARAM)pos,(LPARAM)str);
|
|
|
|
|
|
|
|
#define CBDeleteString(hwnd,pos) \
|
|
|
|
SendMessageA(hwnd,CB_DELETESTRING,(WPARAM)pos,0);
|
|
|
|
|
|
|
|
#define CBSetItemDataPtr(hwnd,iItemId,dataPtr) \
|
|
|
|
SendMessageA(hwnd,CB_SETITEMDATA,(WPARAM)iItemId,(LPARAM)dataPtr);
|
|
|
|
|
|
|
|
#define CBGetItemDataPtr(hwnd,iItemId) \
|
|
|
|
SendMessageA(hwnd,CB_GETITEMDATA,(WPARAM)iItemId,0)
|
|
|
|
|
|
|
|
#define CBGetLBText(hwnd,iItemId,str) \
|
|
|
|
SendMessageA(hwnd,CB_GETLBTEXT,(WPARAM)iItemId,(LPARAM)str);
|
|
|
|
|
|
|
|
#define CBGetCurSel(hwnd) \
|
|
|
|
SendMessageA(hwnd,CB_GETCURSEL,0,0);
|
|
|
|
|
|
|
|
#define CBSetCurSel(hwnd,pos) \
|
|
|
|
SendMessageA(hwnd,CB_SETCURSEL,(WPARAM)pos,0);
|
|
|
|
|
|
|
|
#define CBGetCount(hwnd) \
|
|
|
|
SendMessageA(hwnd,CB_GETCOUNT,0,0);
|
|
|
|
#define CBShowDropDown(hwnd,show) \
|
|
|
|
SendMessageA(hwnd,CB_SHOWDROPDOWN,(WPARAM)show,0);
|
1999-09-04 16:28:49 +02:00
|
|
|
#define CBSetItemHeight(hwnd,index,height) \
|
|
|
|
SendMessageA(hwnd,CB_SETITEMHEIGHT,(WPARAM)index,(LPARAM)height);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
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 */
|
2000-11-01 02:50:21 +01:00
|
|
|
static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam);
|
1999-07-27 18:20:36 +02:00
|
|
|
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
|
|
|
|
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd);
|
|
|
|
BOOL FILEDLG95_OnOpen(HWND hwnd);
|
2000-11-01 02:50:21 +01:00
|
|
|
static LRESULT FILEDLG95_InitControls(HWND hwnd);
|
1999-07-27 18:20:36 +02:00
|
|
|
static void FILEDLG95_Clean(HWND hwnd);
|
|
|
|
|
2000-06-24 15:39:53 +02:00
|
|
|
/* Functions used by the shell navigation */
|
1999-07-27 18:20:36 +02:00
|
|
|
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd);
|
|
|
|
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd);
|
|
|
|
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb);
|
|
|
|
static void FILEDLG95_SHELL_Clean(HWND hwnd);
|
2000-06-24 15:39:53 +02:00
|
|
|
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd);
|
1999-08-21 16:47:28 +02:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* Functions used by the filetype combo box */
|
|
|
|
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);
|
|
|
|
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode);
|
2000-06-02 21:36:53 +02:00
|
|
|
static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCSTR lpstrExt);
|
1999-07-27 18:20:36 +02:00
|
|
|
static void FILEDLG95_FILETYPE_Clean(HWND hwnd);
|
|
|
|
|
|
|
|
/* Functions used by the Look In combo box */
|
|
|
|
static HRESULT 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);
|
|
|
|
static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod);
|
|
|
|
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl);
|
|
|
|
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd);
|
|
|
|
int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
|
|
|
|
static void FILEDLG95_LOOKIN_Clean(HWND hwnd);
|
|
|
|
|
|
|
|
/* Miscellaneous tool functions */
|
|
|
|
HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
|
|
|
|
HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
|
|
|
|
IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
|
|
|
|
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
|
|
|
|
LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
|
|
|
|
|
|
|
|
/* Shell memory allocation */
|
2000-04-23 22:40:23 +02:00
|
|
|
static void *MemAlloc(UINT size);
|
|
|
|
static void MemFree(void *mem);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
1999-11-07 23:41:05 +01:00
|
|
|
BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos);
|
1999-07-27 18:20:36 +02:00
|
|
|
HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
1999-11-07 06:39:24 +01:00
|
|
|
HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
|
|
|
|
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
2000-02-20 19:54:04 +01:00
|
|
|
BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
|
2000-06-02 21:36:53 +02:00
|
|
|
static BOOL BrowseSelectedFolder(HWND hwnd);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
1999-11-07 23:41:05 +01:00
|
|
|
* GetFileName95
|
1999-07-27 18:20:36 +02:00
|
|
|
*
|
|
|
|
* Creates an Open common dialog box that lets the user select
|
|
|
|
* the drive, directory, and the name of a file or set of files to open.
|
|
|
|
*
|
|
|
|
* IN : The FileOpenDlgInfos structure associated with the dialog
|
|
|
|
* OUT : TRUE on success
|
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*/
|
1999-11-07 23:41:05 +01:00
|
|
|
BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
LRESULT lRes;
|
|
|
|
LPCVOID template;
|
|
|
|
HRSRC hRes;
|
|
|
|
HANDLE hDlgTmpl = 0;
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/* test for missing functionality */
|
|
|
|
if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
|
|
|
|
{
|
|
|
|
FIXME("Flags 0x%08lx not yet implemented\n",
|
|
|
|
fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS);
|
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* Create the dialog from a template */
|
|
|
|
|
1999-11-07 23:41:05 +01:00
|
|
|
if(!(hRes = FindResourceA(COMMDLG_hInstance32,MAKEINTRESOURCEA(NEWFILEOPENORD),RT_DIALOGA)))
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hRes )) ||
|
|
|
|
!(template = LockResource( hDlgTmpl )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
/* old style hook messages */
|
|
|
|
if (IsHooked(fodInfos))
|
|
|
|
{
|
|
|
|
fodInfos->HookMsg.fileokstring = RegisterWindowMessageA(FILEOKSTRING);
|
|
|
|
fodInfos->HookMsg.lbselchstring = RegisterWindowMessageA(LBSELCHSTRING);
|
|
|
|
fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageA(HELPMSGSTRING);
|
|
|
|
fodInfos->HookMsg.sharevistring = RegisterWindowMessageA(SHAREVISTRING);
|
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
lRes = DialogBoxIndirectParamA(COMMDLG_hInstance32,
|
|
|
|
(LPDLGTEMPLATEA) template,
|
2000-02-20 19:54:04 +01:00
|
|
|
fodInfos->ofnInfos->hwndOwner,
|
1999-07-27 18:20:36 +02:00
|
|
|
(DLGPROC) FileOpenDlgProc95,
|
|
|
|
(LPARAM) fodInfos);
|
|
|
|
|
2000-10-28 02:29:58 +02:00
|
|
|
/* Unable to create the dialog */
|
1999-07-27 18:20:36 +02:00
|
|
|
if( lRes == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetFileDialog95A
|
|
|
|
*
|
1999-11-07 23:41:05 +01:00
|
|
|
* Call GetFileName95 with this structure and clean the memory.
|
1999-07-27 18:20:36 +02:00
|
|
|
*
|
|
|
|
* IN : The OPENFILENAMEA initialisation structure passed to
|
|
|
|
* GetOpenFileNameA win api function (see filedlg.c)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
|
|
|
|
{
|
|
|
|
|
|
|
|
BOOL ret;
|
|
|
|
FileOpenDlgInfos *fodInfos;
|
2000-02-20 19:54:04 +01:00
|
|
|
HINSTANCE hInstance;
|
2000-08-11 02:40:00 +02:00
|
|
|
LPCSTR lpstrInitialDir = (LPCSTR)-1;
|
2000-12-18 04:12:06 +01:00
|
|
|
LPSTR lpstrSavDir = NULL;
|
2000-02-20 19:54:04 +01:00
|
|
|
DWORD dwFlags = 0;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Initialise FileOpenDlgInfos structure*/
|
|
|
|
fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
|
2000-06-02 21:36:53 +02:00
|
|
|
ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
/* Pass in the original ofn */
|
|
|
|
fodInfos->ofnInfos = ofn;
|
|
|
|
|
|
|
|
/* Save original hInstance value */
|
|
|
|
hInstance = ofn->hInstance;
|
|
|
|
fodInfos->ofnInfos->hInstance = MapHModuleLS(ofn->hInstance);
|
|
|
|
|
2000-12-18 04:12:06 +01:00
|
|
|
/* save current directory */
|
|
|
|
if (ofn->Flags & OFN_NOCHANGEDIR)
|
|
|
|
{
|
|
|
|
lpstrSavDir = MemAlloc(MAX_PATH);
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
|
|
|
|
}
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
dwFlags = ofn->Flags;
|
2000-06-02 21:36:53 +02:00
|
|
|
ofn->Flags = ofn->Flags|OFN_WINE;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
1999-09-03 18:46:41 +02:00
|
|
|
/* Initialise the dialog property */
|
|
|
|
fodInfos->DlgInfos.dwDlgProp = 0;
|
1999-11-07 06:39:24 +01:00
|
|
|
fodInfos->DlgInfos.hwndCustomDlg = (HWND)NULL;
|
1999-09-03 18:46:41 +02:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
switch(iDlgType)
|
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
case OPEN_DIALOG :
|
1999-11-07 23:41:05 +01:00
|
|
|
ret = GetFileName95(fodInfos);
|
1999-07-27 18:20:36 +02:00
|
|
|
break;
|
2000-06-02 21:36:53 +02:00
|
|
|
case SAVE_DIALOG :
|
1999-09-03 18:46:41 +02:00
|
|
|
fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
|
1999-11-07 23:41:05 +01:00
|
|
|
ret = GetFileName95(fodInfos);
|
1999-07-27 18:20:36 +02:00
|
|
|
break;
|
2000-06-02 21:36:53 +02:00
|
|
|
default :
|
1999-07-27 18:20:36 +02:00
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
2000-12-18 04:12:06 +01:00
|
|
|
if (lpstrSavDir)
|
|
|
|
{
|
|
|
|
SetCurrentDirectoryA(lpstrSavDir);
|
|
|
|
MemFree(lpstrSavDir);
|
|
|
|
}
|
|
|
|
|
2000-08-11 02:40:00 +02:00
|
|
|
if (lpstrInitialDir != (LPCSTR)-1)
|
1999-12-04 05:03:01 +01:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
MemFree((LPVOID)(ofn->lpstrInitialDir));
|
|
|
|
ofn->lpstrInitialDir = lpstrInitialDir;
|
1999-12-04 05:03:01 +01:00
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
ofn->Flags = dwFlags;
|
|
|
|
ofn->hInstance = hInstance;
|
1999-07-27 18:20:36 +02:00
|
|
|
MemFree((LPVOID)(fodInfos));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetFileDialog95W
|
|
|
|
*
|
|
|
|
* Copy the OPENFILENAMEW structure in a FileOpenDlgInfos structure.
|
1999-11-07 23:41:05 +01:00
|
|
|
* Call GetFileName95 with this structure and clean the memory.
|
1999-07-27 18:20:36 +02:00
|
|
|
*
|
2000-11-01 02:50:21 +01:00
|
|
|
* FIXME: lpstrCustomFilter has to converted back
|
2000-02-20 19:54:04 +01:00
|
|
|
*
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
/* converting IN arguments */
|
|
|
|
#define AllocInArgWtoA(arg, save) \
|
|
|
|
if(arg) \
|
|
|
|
{ \
|
2000-11-28 23:40:56 +01:00
|
|
|
DWORD _len = WideCharToMultiByte( CP_ACP, 0, arg, -1, NULL, 0, NULL, NULL ); \
|
2000-11-01 02:50:21 +01:00
|
|
|
save = arg; \
|
2000-11-28 23:40:56 +01:00
|
|
|
arg = MemAlloc(_len); \
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, save, -1, (LPSTR)arg, _len, NULL, NULL ); \
|
2000-11-01 02:50:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define FreeInArg(arg, save) \
|
|
|
|
if(arg) \
|
|
|
|
{ \
|
|
|
|
MemFree((LPSTR)arg); \
|
|
|
|
arg = save; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* converting OUT arguments */
|
|
|
|
#define AllocOutArgWtoA(arg, save, len) \
|
|
|
|
if(arg) \
|
|
|
|
{ \
|
|
|
|
save = arg; \
|
|
|
|
arg = MemAlloc(len); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FreeOutArg(arg, save, len) \
|
|
|
|
if(arg) \
|
|
|
|
{ \
|
2000-11-28 23:40:56 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)(arg), -1, (save), (len) ); \
|
2000-11-01 02:50:21 +01:00
|
|
|
MemFree(arg); \
|
|
|
|
arg = save; \
|
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
FileOpenDlgInfos *fodInfos;
|
2000-02-20 19:54:04 +01:00
|
|
|
HINSTANCE hInstance;
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
/* out arguments */
|
2000-02-25 21:51:33 +01:00
|
|
|
LPWSTR lpstrFile = NULL;
|
2000-11-01 02:50:21 +01:00
|
|
|
LPWSTR lpstrFileTitle = NULL;
|
|
|
|
|
|
|
|
/* in/out arguments */
|
|
|
|
LPWSTR lpstrCustomFilter = NULL;
|
|
|
|
|
|
|
|
/* input arguments */
|
|
|
|
LPCWSTR lpstrFilter = NULL;
|
|
|
|
LPCWSTR lpstrInitialDir = NULL;
|
|
|
|
LPCWSTR lpstrTitle = NULL;
|
|
|
|
LPCWSTR lpstrDefExt = NULL;
|
|
|
|
LPCWSTR lpTemplateName = NULL;
|
2000-02-20 19:54:04 +01:00
|
|
|
DWORD dwFlags;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Initialise FileOpenDlgInfos structure*/
|
|
|
|
fodInfos = (FileOpenDlgInfos*)MemAlloc(sizeof(FileOpenDlgInfos));
|
2000-06-02 21:36:53 +02:00
|
|
|
ZeroMemory(fodInfos, sizeof(FileOpenDlgInfos));
|
2000-02-20 19:54:04 +01:00
|
|
|
|
|
|
|
/* Pass in the original ofn */
|
|
|
|
fodInfos->ofnInfos = (LPOPENFILENAMEA) ofn;
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/* convert lpstrFilter */
|
1999-07-27 18:20:36 +02:00
|
|
|
if (ofn->lpstrFilter)
|
|
|
|
{
|
2000-11-01 02:50:21 +01:00
|
|
|
LPCWSTR s;
|
2000-11-28 23:40:56 +01:00
|
|
|
LPSTR y;
|
|
|
|
int n, len;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
lpstrFilter = ofn->lpstrFilter;
|
2000-02-20 19:54:04 +01:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* filter is a list... title\0ext\0......\0\0 */
|
2000-11-01 02:50:21 +01:00
|
|
|
s = ofn->lpstrFilter;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-11-28 23:40:56 +01:00
|
|
|
while (*s) s = s+strlenW(s)+1;
|
1999-07-27 18:20:36 +02:00
|
|
|
s++;
|
|
|
|
n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
|
2000-11-28 23:40:56 +01:00
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0, NULL, NULL );
|
|
|
|
y = (LPSTR)MemAlloc(len);
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, y, len, NULL, NULL );
|
2000-11-01 02:50:21 +01:00
|
|
|
(LPSTR)ofn->lpstrFilter = y;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
/* convert lpstrCustomFilter */
|
2000-02-20 19:54:04 +01:00
|
|
|
if (ofn->lpstrCustomFilter)
|
|
|
|
{
|
1999-07-27 18:20:36 +02:00
|
|
|
LPWSTR s;
|
2000-11-28 23:40:56 +01:00
|
|
|
LPSTR y;
|
|
|
|
int n, len;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
lpstrCustomFilter = ofn->lpstrCustomFilter;
|
1999-07-27 18:20:36 +02:00
|
|
|
/* filter is a list... title\0ext\0......\0\0 */
|
2000-11-01 02:50:21 +01:00
|
|
|
s = ofn->lpstrCustomFilter;
|
2000-11-28 23:40:56 +01:00
|
|
|
while (*s) s = s+strlenW(s)+1;
|
1999-07-27 18:20:36 +02:00
|
|
|
s++;
|
|
|
|
n = s - ofn->lpstrCustomFilter;
|
2000-11-28 23:40:56 +01:00
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0, NULL, NULL );
|
|
|
|
y = (LPSTR)MemAlloc(len);
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, y, len, NULL, NULL );
|
2000-11-01 02:50:21 +01:00
|
|
|
(LPSTR)ofn->lpstrCustomFilter = y;
|
1999-09-03 18:46:41 +02:00
|
|
|
}
|
1999-11-21 03:20:45 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/* convert string arguments, save others */
|
|
|
|
AllocOutArgWtoA(ofn->lpstrFile, lpstrFile, ofn->nMaxFile);
|
|
|
|
AllocOutArgWtoA(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
|
|
|
|
AllocInArgWtoA(ofn->lpstrInitialDir, lpstrInitialDir);
|
|
|
|
AllocInArgWtoA(ofn->lpstrTitle, lpstrTitle);
|
|
|
|
AllocInArgWtoA(ofn->lpstrDefExt, lpstrDefExt);
|
|
|
|
AllocInArgWtoA(ofn->lpTemplateName, lpTemplateName);
|
|
|
|
dwFlags = ofn->Flags;
|
|
|
|
hInstance = ofn->hInstance;
|
|
|
|
|
|
|
|
ofn->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
|
|
|
|
ofn->hInstance = MapHModuleLS(ofn->hInstance);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
switch(iDlgType)
|
|
|
|
{
|
|
|
|
case OPEN_DIALOG :
|
1999-11-07 23:41:05 +01:00
|
|
|
ret = GetFileName95(fodInfos);
|
1999-07-27 18:20:36 +02:00
|
|
|
break;
|
|
|
|
case SAVE_DIALOG :
|
1999-09-03 18:46:41 +02:00
|
|
|
fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
|
1999-11-07 23:41:05 +01:00
|
|
|
ret = GetFileName95(fodInfos);
|
1999-07-27 18:20:36 +02:00
|
|
|
break;
|
|
|
|
default :
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/* restore saved IN arguments and convert OUT arguments back */
|
|
|
|
ofn->Flags = dwFlags;
|
|
|
|
ofn->hInstance = hInstance;
|
|
|
|
FreeInArg(ofn->lpstrFilter, lpstrFilter);
|
|
|
|
FreeInArg(ofn->lpstrCustomFilter, lpstrCustomFilter);
|
|
|
|
FreeOutArg(ofn->lpstrFile, lpstrFile, ofn->nMaxFile);
|
|
|
|
FreeOutArg(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
|
|
|
|
FreeInArg(ofn->lpstrInitialDir, lpstrInitialDir);
|
|
|
|
FreeInArg(ofn->lpstrTitle, lpstrTitle);
|
|
|
|
FreeInArg(ofn->lpstrDefExt, lpstrDefExt);
|
|
|
|
FreeInArg(ofn->lpTemplateName, lpTemplateName);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
MemFree((LPVOID)(fodInfos));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-10-31 18:37:39 +01:00
|
|
|
void ArrangeCtrlPositions( HWND hwndChildDlg, HWND hwndParentDlg)
|
|
|
|
{
|
2000-11-01 02:50:21 +01:00
|
|
|
HWND hwndChild,hwndStc32;
|
|
|
|
RECT rectParent, rectChild, rectCtrl, rectStc32, rectTemp;
|
|
|
|
POINT ptMoveCtl;
|
|
|
|
POINT ptParentClient;
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
TRACE("\n");
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
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);
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
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);
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
hwndChild = GetWindow(hwndChildDlg,GW_CHILD);
|
|
|
|
if(hwndStc32)
|
|
|
|
{
|
|
|
|
GetWindowRect(hwndStc32,&rectStc32);
|
|
|
|
MapWindowPoints( 0, hwndChildDlg,(LPPOINT)&rectStc32,2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetRect(&rectStc32,0,0,0,0);
|
1999-11-13 21:48:47 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
if (hwndChild )
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(hwndChild != hwndStc32)
|
|
|
|
{
|
|
|
|
if (GetWindowLongA( hwndChild, GWL_STYLE ) & WS_MAXIMIZE)
|
1999-10-31 18:37:39 +01:00
|
|
|
continue;
|
2000-11-01 02:50:21 +01:00
|
|
|
GetWindowRect(hwndChild,&rectCtrl);
|
|
|
|
MapWindowPoints( 0, hwndParentDlg,(LPPOINT)&rectCtrl,2);
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/*
|
|
|
|
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;
|
|
|
|
}
|
1999-11-13 21:48:47 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
SetWindowPos( hwndChild, 0, rectCtrl.left, rectCtrl.top,
|
1999-10-31 18:37:39 +01:00
|
|
|
rectCtrl.right-rectCtrl.left,rectCtrl.bottom-rectCtrl.top,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER );
|
2000-11-01 02:50:21 +01:00
|
|
|
}
|
|
|
|
} while ((hwndChild=GetWindow( hwndChild, GW_HWNDNEXT )) != (HWND)NULL);
|
|
|
|
}
|
|
|
|
hwndChild = GetWindow(hwndParentDlg,GW_CHILD);
|
1999-11-13 21:48:47 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
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;
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
1999-10-31 18:37:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
1999-12-04 05:03:01 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(GetParent(hwnd),FileOpenDlgInfosStr);
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
TRACE("0x%04x\n", uMsg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
1999-12-04 05:03:01 +01:00
|
|
|
}
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
if(fodInfos && IsHooked(fodInfos))
|
|
|
|
return CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,hwnd,uMsg,wParam,lParam);
|
|
|
|
|
|
|
|
return DefWindowProcA(hwnd,uMsg,wParam,lParam);
|
1999-10-31 18:37:39 +01:00
|
|
|
}
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
|
1999-10-31 18:37:39 +01:00
|
|
|
{
|
|
|
|
LPCVOID template;
|
|
|
|
HRSRC hRes;
|
|
|
|
HANDLE hDlgTmpl = 0;
|
|
|
|
HWND hChildDlg = 0;
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
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;
|
1999-10-31 18:37:39 +01:00
|
|
|
}
|
2000-11-01 02:50:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hChildDlg= CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,template,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
|
|
|
|
if(hChildDlg)
|
|
|
|
{
|
|
|
|
ShowWindow(hChildDlg,SW_SHOW);
|
|
|
|
return hChildDlg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( IsHooked(fodInfos))
|
|
|
|
{
|
|
|
|
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;
|
1999-10-31 18:37:39 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
return CreateDialogIndirectParamA(fodInfos->ofnInfos->hInstance,&tmplate,hwnd,(DLGPROC)FileOpenDlgProcUserTemplate,(LPARAM)fodInfos);
|
|
|
|
}
|
|
|
|
return (HWND)NULL;
|
1999-10-31 18:37:39 +01:00
|
|
|
}
|
1999-12-04 05:03:01 +01:00
|
|
|
|
1999-11-07 06:39:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SendCustomDlgNotificationMessage
|
|
|
|
*
|
|
|
|
* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
|
|
|
|
*/
|
|
|
|
|
|
|
|
HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
TRACE("0x%04x 0x%04x\n",hwndParentDlg, uCode);
|
|
|
|
|
|
|
|
if(!fodInfos) return 0;
|
|
|
|
|
|
|
|
if(fodInfos->ofnInfos->Flags & OFN_UNICODE)
|
|
|
|
FIXME("sending OPENFILENAMEA structure. Hook is expecting OPENFILENAMEW!");
|
|
|
|
|
1999-11-07 06:39:24 +01:00
|
|
|
if(fodInfos->DlgInfos.hwndCustomDlg)
|
|
|
|
{
|
|
|
|
OFNOTIFYA ofnNotify;
|
2000-11-01 02:50:21 +01:00
|
|
|
HRESULT ret;
|
1999-11-07 06:39:24 +01:00
|
|
|
ofnNotify.hdr.hwndFrom=hwndParentDlg;
|
|
|
|
ofnNotify.hdr.idFrom=0;
|
|
|
|
ofnNotify.hdr.code = uCode;
|
2000-02-20 19:54:04 +01:00
|
|
|
ofnNotify.lpOFN = fodInfos->ofnInfos;
|
2000-11-01 02:50:21 +01:00
|
|
|
TRACE("CALL NOTIFY for %x\n", uCode);
|
|
|
|
ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
|
|
|
|
TRACE("RET NOTIFY\n");
|
|
|
|
return ret;
|
1999-11-07 06:39:24 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_HandleCustomDialogMessages
|
|
|
|
*
|
|
|
|
* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
|
|
|
|
*/
|
|
|
|
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
LPSTR lpstrFileSpec;
|
1999-12-26 01:34:23 +01:00
|
|
|
int reqSize;
|
|
|
|
char lpstrPath[MAX_PATH];
|
1999-11-07 06:39:24 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
2000-02-20 19:54:04 +01:00
|
|
|
if(!fodInfos) return -1;
|
|
|
|
|
1999-11-07 06:39:24 +01:00
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case CDM_GETFILEPATH:
|
1999-12-26 01:34:23 +01:00
|
|
|
GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
|
2000-06-02 21:36:53 +02:00
|
|
|
lpstrFileSpec = (LPSTR)COMDLG32_PathFindFileNameA(lpstrPath);
|
2000-02-20 19:54:04 +01:00
|
|
|
if (lpstrFileSpec==lpstrPath)
|
|
|
|
{
|
1999-12-26 01:34:23 +01:00
|
|
|
char lpstrCurrentDir[MAX_PATH];
|
|
|
|
/* Prepend the current path */
|
|
|
|
COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);
|
|
|
|
if ((LPSTR)lParam!=NULL)
|
2000-11-26 23:39:50 +01:00
|
|
|
snprintf((LPSTR)lParam,(int)wParam,"%s\\%s",lpstrCurrentDir,lpstrPath);
|
1999-12-26 01:34:23 +01:00
|
|
|
reqSize=strlen(lpstrCurrentDir)+1+strlen(lpstrPath)+1;
|
2000-02-20 19:54:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-12-26 01:34:23 +01:00
|
|
|
lstrcpynA((LPSTR)lParam,(LPSTR)lpstrPath,(int)wParam);
|
|
|
|
reqSize=strlen(lpstrPath);
|
1999-11-07 06:39:24 +01:00
|
|
|
}
|
1999-12-26 01:34:23 +01:00
|
|
|
/* return the required buffer size */
|
|
|
|
return reqSize;
|
2000-02-20 19:54:04 +01:00
|
|
|
|
1999-12-26 01:34:23 +01:00
|
|
|
case CDM_GETFOLDERPATH:
|
2000-02-20 19:54:04 +01:00
|
|
|
COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
|
1999-12-26 01:34:23 +01:00
|
|
|
if ((LPSTR)lParam!=NULL)
|
|
|
|
lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam);
|
|
|
|
return strlen(lpstrPath);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
|
|
|
case CDM_GETSPEC:
|
|
|
|
reqSize=GetDlgItemTextA(hwnd,IDC_FILENAME,lpstrPath, sizeof(lpstrPath));
|
2000-06-02 21:36:53 +02:00
|
|
|
lpstrFileSpec = (LPSTR)COMDLG32_PathFindFileNameA(lpstrPath);
|
1999-12-26 01:34:23 +01:00
|
|
|
if ((LPSTR)lParam!=NULL)
|
|
|
|
lstrcpynA((LPSTR)lParam, lpstrFileSpec, (int)wParam);
|
|
|
|
return strlen(lpstrFileSpec);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
1999-11-07 06:39:24 +01:00
|
|
|
case CDM_SETCONTROLTEXT:
|
2000-02-20 19:54:04 +01:00
|
|
|
if ( 0 != lParam )
|
|
|
|
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case CDM_HIDECONTROL:
|
1999-11-07 06:39:24 +01:00
|
|
|
case CDM_SETDEFEXT:
|
2000-02-20 19:54:04 +01:00
|
|
|
FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n");
|
|
|
|
return -1;
|
1999-11-07 06:39:24 +01:00
|
|
|
}
|
2000-02-20 19:54:04 +01:00
|
|
|
return TRUE;
|
1999-11-07 06:39:24 +01:00
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FileOpenDlgProc95
|
|
|
|
*
|
|
|
|
* File open dialog procedure
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2000-11-01 02:50:21 +01:00
|
|
|
#if 0
|
|
|
|
TRACE("0x%04x 0x%04x\n", hwnd, uMsg);
|
|
|
|
#endif
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
switch(uMsg)
|
|
|
|
{
|
2000-08-31 04:06:26 +02:00
|
|
|
case WM_INITDIALOG:
|
2000-11-01 02:50:21 +01:00
|
|
|
{
|
|
|
|
FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
|
|
|
|
|
|
|
|
/* Adds the FileOpenDlgInfos in the property list of the dialog
|
1999-11-21 03:20:45 +01:00
|
|
|
so it will be easily accessible through a GetPropA(...) */
|
2000-11-01 02:50:21 +01:00
|
|
|
SetPropA(hwnd, FileOpenDlgInfosStr, (HANDLE) fodInfos);
|
|
|
|
|
|
|
|
fodInfos->DlgInfos.hwndCustomDlg =
|
|
|
|
CreateTemplateDialog((FileOpenDlgInfos *)lParam, hwnd);
|
1999-11-21 03:20:45 +01:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
FILEDLG95_InitControls(hwnd);
|
1999-11-07 06:39:24 +01:00
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
|
2000-11-01 02:50:21 +01:00
|
|
|
FILEDLG95_FillControls(hwnd, wParam, lParam);
|
2000-12-03 00:43:10 +01:00
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
|
1999-11-07 06:39:24 +01:00
|
|
|
return 0;
|
2000-11-01 02:50:21 +01:00
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
return FILEDLG95_OnWMCommand(hwnd, wParam, lParam);
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
{
|
|
|
|
switch(((LPDRAWITEMSTRUCT)lParam)->CtlID)
|
|
|
|
{
|
|
|
|
case IDC_LOOKIN:
|
|
|
|
FILEDLG95_LOOKIN_DrawItem((LPDRAWITEMSTRUCT) lParam);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case WM_GETISHELLBROWSER:
|
|
|
|
return FILEDLG95_OnWMGetIShellBrowser(hwnd);
|
|
|
|
|
2000-08-31 04:06:26 +02:00
|
|
|
case WM_DESTROY:
|
1999-07-27 18:20:36 +02:00
|
|
|
RemovePropA(hwnd, FileOpenDlgInfosStr);
|
2000-08-31 04:06:26 +02:00
|
|
|
return FALSE;
|
2000-02-20 19:54:04 +01:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR lpnmh = (LPNMHDR)lParam;
|
|
|
|
UINT stringId = -1;
|
1999-09-03 18:46:41 +02:00
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
/* set up the button tooltips strings */
|
|
|
|
if(TTN_GETDISPINFOA == lpnmh->code )
|
|
|
|
{
|
|
|
|
LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
|
|
|
|
switch(lpnmh->idFrom )
|
|
|
|
{
|
|
|
|
/* Up folder button */
|
|
|
|
case FCIDM_TB_UPFOLDER:
|
|
|
|
stringId = IDS_UPFOLDER;
|
|
|
|
break;
|
|
|
|
/* New folder button */
|
|
|
|
case FCIDM_TB_NEWFOLDER:
|
|
|
|
stringId = IDS_NEWFOLDER;
|
|
|
|
break;
|
|
|
|
/* List option button */
|
|
|
|
case FCIDM_TB_SMALLICON:
|
|
|
|
stringId = IDS_LISTVIEW;
|
|
|
|
break;
|
|
|
|
/* Details option button */
|
|
|
|
case FCIDM_TB_REPORTVIEW:
|
|
|
|
stringId = IDS_REPORTVIEW;
|
|
|
|
break;
|
2000-06-24 15:39:53 +02:00
|
|
|
/* Desktop button */
|
|
|
|
case FCIDM_TB_DESKTOP:
|
|
|
|
stringId = IDS_TODESKTOP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stringId = 0;
|
2000-02-20 19:54:04 +01:00
|
|
|
}
|
|
|
|
lpdi->hinst = COMMDLG_hInstance32;
|
|
|
|
lpdi->lpszText = (LPSTR) stringId;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
default :
|
1999-11-07 06:39:24 +01:00
|
|
|
if(uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
|
|
|
|
return FILEDLG95_HandleCustomDialogMessages(hwnd, uMsg, wParam, lParam);
|
1999-07-27 18:20:36 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-11-01 02:50:21 +01:00
|
|
|
* FILEDLG95_InitControls
|
1999-07-27 18:20:36 +02:00
|
|
|
*
|
2000-11-01 02:50:21 +01:00
|
|
|
* WM_INITDIALOG message handler (before hook notification)
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
2000-11-01 02:50:21 +01:00
|
|
|
static LRESULT FILEDLG95_InitControls(HWND hwnd)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-11-01 02:50:21 +01:00
|
|
|
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 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 (after hook notification)
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlItemId = NULL;
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) lParam;
|
|
|
|
|
2000-06-24 15:39:53 +02:00
|
|
|
TRACE("dir=%s file=%s\n",
|
|
|
|
fodInfos->ofnInfos->lpstrInitialDir, fodInfos->ofnInfos->lpstrFile);
|
|
|
|
|
|
|
|
/* Get the initial directory pidl */
|
|
|
|
|
|
|
|
if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->ofnInfos->lpstrInitialDir)))
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
GetCurrentDirectoryA(MAX_PATH,path);
|
|
|
|
pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder, path);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Initialise shell objects */
|
|
|
|
FILEDLG95_SHELL_Init(hwnd);
|
|
|
|
|
2000-10-28 02:29:58 +02:00
|
|
|
/* Initialize the Look In combo box */
|
1999-07-27 18:20:36 +02:00
|
|
|
FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB);
|
|
|
|
|
|
|
|
/* Initialize the filter combo box */
|
|
|
|
FILEDLG95_FILETYPE_Init(hwnd);
|
|
|
|
|
|
|
|
/* Browse to the initial directory */
|
2000-06-02 21:36:53 +02:00
|
|
|
IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId, SBSP_ABSOLUTE);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Free pidlItem memory */
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHFree(pidlItemId);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_Clean
|
|
|
|
*
|
|
|
|
* Regroups all the cleaning functions of the filedlg
|
|
|
|
*/
|
|
|
|
void FILEDLG95_Clean(HWND hwnd)
|
|
|
|
{
|
|
|
|
FILEDLG95_FILETYPE_Clean(hwnd);
|
|
|
|
FILEDLG95_LOOKIN_Clean(hwnd);
|
|
|
|
FILEDLG95_SHELL_Clean(hwnd);
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnWMCommand
|
|
|
|
*
|
|
|
|
* WM_COMMAND message handler
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
1999-07-31 19:34:43 +02:00
|
|
|
WORD wNotifyCode = HIWORD(wParam); /* notification code */
|
|
|
|
WORD wID = LOWORD(wParam); /* item, control, or accelerator identifier */
|
1999-09-03 18:46:41 +02:00
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
switch(wID)
|
|
|
|
{
|
|
|
|
/* OK button */
|
|
|
|
case IDOK:
|
1999-11-07 06:39:24 +01:00
|
|
|
if(FILEDLG95_OnOpen(hwnd))
|
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
|
1999-07-27 18:20:36 +02:00
|
|
|
break;
|
|
|
|
/* Cancel button */
|
|
|
|
case IDCANCEL:
|
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
EndDialog(hwnd, FALSE);
|
|
|
|
break;
|
|
|
|
/* Filetype combo box */
|
|
|
|
case IDC_FILETYPE:
|
|
|
|
FILEDLG95_FILETYPE_OnCommand(hwnd,wNotifyCode);
|
|
|
|
break;
|
|
|
|
/* LookIn combo box */
|
|
|
|
case IDC_LOOKIN:
|
|
|
|
FILEDLG95_LOOKIN_OnCommand(hwnd,wNotifyCode);
|
|
|
|
break;
|
1999-11-12 02:02:27 +01:00
|
|
|
|
|
|
|
/* --- toolbar --- */
|
1999-07-27 18:20:36 +02:00
|
|
|
/* Up folder button */
|
1999-11-12 02:02:27 +01:00
|
|
|
case FCIDM_TB_UPFOLDER:
|
1999-07-27 18:20:36 +02:00
|
|
|
FILEDLG95_SHELL_UpFolder(hwnd);
|
|
|
|
break;
|
1999-11-12 02:02:27 +01:00
|
|
|
/* New folder button */
|
|
|
|
case FCIDM_TB_NEWFOLDER:
|
2000-02-20 19:54:04 +01:00
|
|
|
FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_NEWFOLDER);
|
1999-11-12 02:02:27 +01:00
|
|
|
break;
|
1999-07-27 18:20:36 +02:00
|
|
|
/* List option button */
|
1999-11-12 02:02:27 +01:00
|
|
|
case FCIDM_TB_SMALLICON:
|
1999-07-27 18:20:36 +02:00
|
|
|
FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWLIST);
|
|
|
|
break;
|
|
|
|
/* Details option button */
|
1999-11-12 02:02:27 +01:00
|
|
|
case FCIDM_TB_REPORTVIEW:
|
1999-07-27 18:20:36 +02:00
|
|
|
FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILS);
|
|
|
|
break;
|
2000-06-24 15:39:53 +02:00
|
|
|
/* Details option button */
|
|
|
|
case FCIDM_TB_DESKTOP:
|
|
|
|
FILEDLG95_SHELL_BrowseToDesktop(hwnd);
|
|
|
|
break;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
case IDC_FILENAME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
1999-09-03 18:46:41 +02:00
|
|
|
/* Do not use the listview selection anymore */
|
|
|
|
fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
|
1999-07-27 18:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnWMGetIShellBrowser
|
|
|
|
*
|
|
|
|
* WM_GETISHELLBROWSER message handler
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
|
|
|
|
{
|
|
|
|
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
SetWindowLongA(hwnd,DWL_MSGRESULT,(LONG)fodInfos->Shell.FOIShellBrowser);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnOpenMultipleFiles
|
|
|
|
*
|
|
|
|
* Handles the opening of multiple files.
|
2000-06-02 21:36:53 +02:00
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* check destination buffer size
|
|
|
|
*/
|
2000-02-20 19:54:04 +01:00
|
|
|
BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
|
|
|
|
{
|
|
|
|
CHAR lpstrPathSpec[MAX_PATH] = "";
|
|
|
|
LPSTR lpstrFile;
|
2000-06-02 21:36:53 +02:00
|
|
|
UINT nCount, nSizePath;
|
2000-02-20 19:54:04 +01:00
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
lpstrFile = fodInfos->ofnInfos->lpstrFile;
|
2000-06-02 21:36:53 +02:00
|
|
|
lpstrFile[0] = '\0';
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
COMDLG32_SHGetPathFromIDListA( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
|
|
|
|
( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
|
|
|
|
{
|
|
|
|
LPSTR lpstrTemp = lpstrFileList;
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
for ( nCount = 0; nCount < nFileCount; nCount++ )
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
pidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrTemp);
|
|
|
|
if (!pidl)
|
2000-02-20 19:54:04 +01:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
CHAR lpstrNotFound[100];
|
|
|
|
CHAR lpstrMsg[100];
|
|
|
|
CHAR tmp[400];
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
LoadStringA(COMMDLG_hInstance32, IDS_FILENOTFOUND, lpstrNotFound, 100);
|
|
|
|
LoadStringA(COMMDLG_hInstance32, IDS_VERIFYFILE, lpstrMsg, 100);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
strcpy(tmp, lpstrTemp);
|
|
|
|
strcat(tmp, "\n");
|
|
|
|
strcat(tmp, lpstrNotFound);
|
|
|
|
strcat(tmp, "\n");
|
|
|
|
strcat(tmp, lpstrMsg);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
MessageBoxA(hwnd, tmp, fodInfos->ofnInfos->lpstrTitle, MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
return FALSE;
|
2000-02-20 19:54:04 +01:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/* move to the next file in the list of files */
|
|
|
|
lpstrTemp += strlen(lpstrTemp) + 1;
|
2000-06-02 21:36:53 +02:00
|
|
|
COMDLG32_SHFree(pidl);
|
|
|
|
}
|
2000-02-20 19:54:04 +01:00
|
|
|
}
|
|
|
|
|
2000-08-14 16:41:19 +02:00
|
|
|
nSizePath = strlen(lpstrPathSpec);
|
|
|
|
strcpy( lpstrFile, lpstrPathSpec);
|
2000-06-02 21:36:53 +02:00
|
|
|
memcpy( lpstrFile + nSizePath + 1, lpstrFileList, sizeUsed );
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
fodInfos->ofnInfos->nFileOffset = nSizePath + 1;
|
|
|
|
fodInfos->ofnInfos->nFileExtension = 0;
|
2000-02-20 19:54:04 +01:00
|
|
|
|
|
|
|
/* clean and exit */
|
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
return EndDialog(hwnd,TRUE);
|
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_OnOpen
|
|
|
|
*
|
|
|
|
* Ok button WM_COMMAND message handler
|
|
|
|
*
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
2000-06-02 21:36:53 +02:00
|
|
|
#define ONOPEN_BROWSE 1
|
|
|
|
#define ONOPEN_OPEN 2
|
|
|
|
#define ONOPEN_SEARCH 3
|
|
|
|
static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
|
|
|
|
{
|
|
|
|
char strMsgTitle[MAX_PATH];
|
|
|
|
char strMsgText [MAX_PATH];
|
|
|
|
if (idCaption)
|
|
|
|
LoadStringA(COMDLG32_hInstance, idCaption, strMsgTitle, sizeof(strMsgTitle));
|
|
|
|
else
|
|
|
|
strMsgTitle[0] = '\0';
|
|
|
|
LoadStringA(COMDLG32_hInstance, idText, strMsgText, sizeof(strMsgText));
|
|
|
|
MessageBoxA(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
|
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
BOOL FILEDLG95_OnOpen(HWND hwnd)
|
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
char * lpstrFileList;
|
2000-02-20 19:54:04 +01:00
|
|
|
UINT nFileCount = 0;
|
|
|
|
UINT sizeUsed = 0;
|
2000-06-02 21:36:53 +02:00
|
|
|
BOOL ret = TRUE;
|
|
|
|
char lpstrPathAndFile[MAX_PATH];
|
|
|
|
char lpstrTemp[MAX_PATH];
|
|
|
|
LPSHELLFOLDER lpsf = NULL;
|
|
|
|
int nOpenAction;
|
1999-07-27 18:20:36 +02:00
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("hwnd=0x%04x\n", hwnd);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* get the files from the edit control */
|
|
|
|
nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* try if the user selected a folder in the shellview */
|
|
|
|
if(nFileCount == 0)
|
1999-09-03 18:46:41 +02:00
|
|
|
{
|
2000-07-08 13:45:58 +02:00
|
|
|
BrowseSelectedFolder(hwnd);
|
2000-06-02 21:36:53 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nFileCount > 1)
|
|
|
|
{
|
|
|
|
ret = FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed);
|
|
|
|
goto ret;
|
1999-09-03 18:46:41 +02:00
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("count=%u len=%u file=%s\n", nFileCount, sizeUsed, lpstrFileList);
|
2000-02-20 19:54:04 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/*
|
|
|
|
Step 1: Build a complete path name from the current folder and
|
|
|
|
the filename or path in the edit box.
|
|
|
|
Special cases:
|
|
|
|
- the path in the edit box is a root path
|
|
|
|
(with or without drive letter)
|
|
|
|
- the edit box contains ".." (or a path with ".." in it)
|
|
|
|
*/
|
1999-11-13 21:48:47 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* Get the current directory name */
|
|
|
|
if (!COMDLG32_SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))
|
|
|
|
{
|
|
|
|
/* we are in a special folder, default to desktop */
|
2000-11-27 23:03:23 +01:00
|
|
|
if(FAILED(COMDLG32_SHGetFolderPathA(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))
|
2000-06-16 23:51:33 +02:00
|
|
|
{
|
|
|
|
/* last fallback */
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, lpstrPathAndFile);
|
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
}
|
|
|
|
COMDLG32_PathAddBackslashA(lpstrPathAndFile);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("current directory=%s\n", lpstrPathAndFile);
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* if the user specifyed a fully qualified path use it */
|
|
|
|
if(COMDLG32_PathIsRelativeA(lpstrFileList))
|
|
|
|
{
|
|
|
|
strcat(lpstrPathAndFile, lpstrFileList);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* does the path have a drive letter? */
|
|
|
|
if (COMDLG32_PathGetDriveNumberA(lpstrFileList) == -1)
|
|
|
|
strcpy(lpstrPathAndFile+2, lpstrFileList);
|
|
|
|
else
|
|
|
|
strcpy(lpstrPathAndFile, lpstrFileList);
|
|
|
|
}
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* resolve "." and ".." */
|
|
|
|
COMDLG32_PathCanonicalizeA(lpstrTemp, lpstrPathAndFile );
|
|
|
|
strcpy(lpstrPathAndFile, lpstrTemp);
|
|
|
|
TRACE("canon=%s\n", lpstrPathAndFile);
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
MemFree(lpstrFileList);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/*
|
|
|
|
Step 2: here we have a cleaned up path
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
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
|
|
|
|
*/
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
nOpenAction = ONOPEN_BROWSE;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* dont apply any checks with OFN_NOVALIDATE */
|
|
|
|
if(!(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE))
|
|
|
|
{
|
|
|
|
LPSTR lpszTemp, lpszTemp1;
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* check for invalid chars */
|
|
|
|
if(strpbrk(lpstrPathAndFile+3, "/:<>|") != NULL)
|
|
|
|
{
|
|
|
|
FILEDLG95_OnOpenMessage(hwnd, IDS_INVALID_FILENAME_TITLE, IDS_INVALID_FILENAME);
|
|
|
|
ret = FALSE;
|
|
|
|
goto ret;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if (FAILED (COMDLG32_SHGetDesktopFolder(&lpsf))) return FALSE;
|
|
|
|
|
|
|
|
lpszTemp1 = lpszTemp = lpstrPathAndFile;
|
|
|
|
while (lpszTemp1)
|
|
|
|
{
|
|
|
|
LPSHELLFOLDER lpsfChild;
|
|
|
|
WCHAR lpwstrTemp[MAX_PATH];
|
|
|
|
DWORD dwEaten, dwAttributes;
|
|
|
|
|
2000-06-07 05:14:40 +02:00
|
|
|
lpszTemp = COMDLG32_PathFindNextComponentA(lpszTemp);
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
if (!lpszTemp) break; /* end of path */
|
|
|
|
|
|
|
|
if(*lpszTemp)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar( CP_ACP, 0, lpszTemp1, lpszTemp - lpszTemp1,
|
|
|
|
lpwstrTemp, MAX_PATH );
|
|
|
|
lpwstrTemp[len] = 0;
|
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
else
|
1999-12-04 05:03:01 +01:00
|
|
|
{
|
2000-11-28 23:40:56 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpszTemp1, -1,
|
|
|
|
lpwstrTemp, sizeof(lpwstrTemp)/sizeof(WCHAR) );
|
2000-11-01 02:50:21 +01:00
|
|
|
|
|
|
|
/* if the last element is a wildcard do a search */
|
2000-06-02 21:36:53 +02:00
|
|
|
if(strpbrk(lpszTemp1, "*?") != NULL)
|
|
|
|
{
|
2000-11-01 02:50:21 +01:00
|
|
|
nOpenAction = ONOPEN_SEARCH;
|
2000-06-02 21:36:53 +02:00
|
|
|
break;
|
2000-11-01 02:50:21 +01:00
|
|
|
}
|
1999-12-04 05:03:01 +01:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
lpszTemp1 = lpszTemp;
|
1999-12-04 05:03:01 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_a(lpszTemp), lpsf);
|
1999-11-13 21:48:47 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if(lstrlenW(lpwstrTemp)==2) COMDLG32_PathAddBackslashW(lpwstrTemp);
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
dwAttributes = SFGAO_FOLDER;
|
2000-11-01 02:50:21 +01:00
|
|
|
if(SUCCEEDED(IShellFolder_ParseDisplayName(lpsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-11-01 02:50:21 +01:00
|
|
|
/* the path component is valid, we have a pidl of the next path component */
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("parse OK attr=0x%08lx pidl=%p\n", dwAttributes, pidl);
|
|
|
|
if(dwAttributes & SFGAO_FOLDER)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
if(FAILED(IShellFolder_BindToObject(lpsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild)))
|
|
|
|
{
|
|
|
|
ERR("bind to failed\n"); /* should not fail */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
IShellFolder_Release(lpsf);
|
|
|
|
lpsf = lpsfChild;
|
|
|
|
lpsfChild = NULL;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("value\n");
|
|
|
|
|
|
|
|
/* end dialog, return value */
|
|
|
|
nOpenAction = ONOPEN_OPEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
COMDLG32_SHFree(pidl);
|
|
|
|
pidl = NULL;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-11-01 02:50:21 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
if(pidl) COMDLG32_SHFree(pidl);
|
|
|
|
}
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/*
|
|
|
|
Step 3: here we have a cleaned up and validated path
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
valid variables:
|
|
|
|
lpsf: ShellFolder bound to the rightmost valid path component
|
|
|
|
lpstrPathAndFile: cleaned up path
|
|
|
|
nOpenAction: action to do
|
|
|
|
*/
|
|
|
|
TRACE("end validate sf=%p\n", lpsf);
|
|
|
|
|
|
|
|
switch(nOpenAction)
|
|
|
|
{
|
|
|
|
case ONOPEN_SEARCH: /* set the current filter to the file mask and refresh */
|
|
|
|
TRACE("ONOPEN_SEARCH %s\n", lpstrPathAndFile);
|
1999-08-21 16:47:28 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
int iPos;
|
|
|
|
LPSTR lpszTemp = COMDLG32_PathFindFileNameA(lpstrPathAndFile);
|
2000-11-28 23:40:56 +01:00
|
|
|
DWORD len;
|
2000-06-02 21:36:53 +02:00
|
|
|
|
|
|
|
/* replace the current filter */
|
|
|
|
if(fodInfos->ShellInfos.lpstrCurrentFilter)
|
|
|
|
MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
|
2000-11-28 23:40:56 +01:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1, NULL, 0 );
|
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1,
|
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter, len );
|
2000-06-02 21:36:53 +02:00
|
|
|
|
|
|
|
/* set the filter cb to the extension when possible */
|
|
|
|
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
|
|
|
|
CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos);
|
1999-08-21 16:47:28 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
/* fall through */
|
|
|
|
case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
|
|
|
|
TRACE("ONOPEN_BROWSE\n");
|
1999-08-21 16:47:28 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
IPersistFolder2 * ppf2;
|
|
|
|
if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlCurrent;
|
|
|
|
IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
|
|
|
|
IPersistFolder2_Release(ppf2);
|
|
|
|
if( ! COMDLG32_PIDL_ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
|
|
|
|
{
|
|
|
|
IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);
|
|
|
|
}
|
|
|
|
else if( nOpenAction == ONOPEN_SEARCH )
|
|
|
|
{
|
|
|
|
IShellView_Refresh(fodInfos->Shell.FOIShellView);
|
|
|
|
}
|
|
|
|
COMDLG32_SHFree(pidlCurrent);
|
|
|
|
}
|
1999-08-21 16:47:28 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
|
|
|
|
TRACE("ONOPEN_OPEN %s\n", lpstrPathAndFile);
|
|
|
|
{
|
|
|
|
/* add default extension */
|
|
|
|
if (fodInfos->ofnInfos->lpstrDefExt)
|
2000-06-24 15:39:53 +02:00
|
|
|
{
|
|
|
|
if (! *COMDLG32_PathFindExtensionA(lpstrPathAndFile))
|
|
|
|
{
|
|
|
|
strcat(lpstrPathAndFile, ".");
|
|
|
|
strcat(lpstrPathAndFile, fodInfos->ofnInfos->lpstrDefExt);
|
|
|
|
}
|
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
|
2000-12-13 02:46:26 +01:00
|
|
|
/* Check that the size of the file does not exceed buffer size.
|
|
|
|
(Allow for extra \0 if OFN_MULTISELECT is set.) */
|
|
|
|
if(strlen(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
|
|
|
|
((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
|
2000-06-02 21:36:53 +02:00
|
|
|
{
|
|
|
|
LPSTR lpszTemp;
|
|
|
|
|
|
|
|
/* fill destination buffer */
|
|
|
|
strcpy(fodInfos->ofnInfos->lpstrFile, lpstrPathAndFile);
|
2000-12-13 02:46:26 +01:00
|
|
|
if (fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)
|
|
|
|
fodInfos->ofnInfos->lpstrFile[strlen(fodInfos->ofnInfos->lpstrFile)
|
|
|
|
+ 1] = '\0';
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* set filename offset */
|
|
|
|
lpszTemp = COMDLG32_PathFindFileNameA(lpstrPathAndFile);
|
|
|
|
fodInfos->ofnInfos->nFileOffset = lpszTemp - lpstrPathAndFile;
|
|
|
|
|
|
|
|
/* set extension offset */
|
|
|
|
lpszTemp = COMDLG32_PathFindExtensionA(lpstrPathAndFile);
|
2000-06-24 15:39:53 +02:00
|
|
|
fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? lpszTemp - lpstrPathAndFile + 1 : 0;
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* set the lpstrFileTitle */
|
|
|
|
if(fodInfos->ofnInfos->lpstrFileTitle)
|
|
|
|
{
|
|
|
|
LPSTR lpstrFileTitle = COMDLG32_PathFindFileNameA(lpstrPathAndFile);
|
|
|
|
strncpy(fodInfos->ofnInfos->lpstrFileTitle, lpstrFileTitle, fodInfos->ofnInfos->nMaxFileTitle);
|
|
|
|
}
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
/* ask the hook if we can close */
|
|
|
|
if(IsHooked(fodInfos))
|
|
|
|
{
|
|
|
|
/* FIXME we are sending ASCII-structures. Does not work with NT */
|
|
|
|
/* first old style */
|
|
|
|
TRACE("---\n");
|
2000-12-08 00:54:19 +01:00
|
|
|
CallWindowProcA((WNDPROC)fodInfos->ofnInfos->lpfnHook,
|
|
|
|
fodInfos->DlgInfos.hwndCustomDlg,
|
|
|
|
fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
|
2000-11-01 02:50:21 +01:00
|
|
|
if (GetWindowLongA(hwnd, DWL_MSGRESULT))
|
|
|
|
{
|
|
|
|
TRACE("cancled\n");
|
|
|
|
ret = FALSE;
|
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("close\n");
|
|
|
|
FILEDLG95_Clean(hwnd);
|
2000-06-02 21:36:53 +02:00
|
|
|
ret = EndDialog(hwnd, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME set error FNERR_BUFFERTOSMALL */
|
|
|
|
FILEDLG95_Clean(hwnd);
|
|
|
|
ret = EndDialog(hwnd, FALSE);
|
|
|
|
}
|
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
break;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
ret:
|
|
|
|
if(lpsf) IShellFolder_Release(lpsf);
|
|
|
|
return ret;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_SHELL_Init
|
|
|
|
*
|
|
|
|
* Initialisation of the shell objects
|
|
|
|
*/
|
|
|
|
static HRESULT FILEDLG95_SHELL_Init(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialisation of the FileOpenDialogInfos structure
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Shell */
|
|
|
|
|
|
|
|
/*ShellInfos */
|
|
|
|
fodInfos->ShellInfos.hwndOwner = hwnd;
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
/* Disable multi-select if flag not set */
|
|
|
|
if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
|
|
|
|
{
|
|
|
|
fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
|
|
|
|
}
|
|
|
|
fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
|
1999-07-27 18:20:36 +02:00
|
|
|
fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST;
|
|
|
|
|
|
|
|
GetWindowRect(GetDlgItem(hwnd,IDC_SHELLSTATIC),&fodInfos->ShellInfos.rectView);
|
|
|
|
ScreenToClient(hwnd,(LPPOINT)&fodInfos->ShellInfos.rectView.left);
|
|
|
|
ScreenToClient(hwnd,(LPPOINT)&fodInfos->ShellInfos.rectView.right);
|
|
|
|
|
|
|
|
/* Construct the IShellBrowser interface */
|
|
|
|
fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_SHELL_ExecuteCommand
|
|
|
|
*
|
|
|
|
* Change the folder option and refresh the view
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
|
|
|
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
IContextMenu * pcm;
|
2000-02-20 19:54:04 +01:00
|
|
|
TRACE("(0x%08x,%p)\n", hwnd, lpVerb);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
|
|
|
|
SVGIO_BACKGROUND,
|
|
|
|
&IID_IContextMenu,
|
|
|
|
(LPVOID*)&pcm)))
|
|
|
|
{
|
2000-02-20 19:54:04 +01:00
|
|
|
CMINVOKECOMMANDINFO ci;
|
|
|
|
ZeroMemory(&ci, sizeof(CMINVOKECOMMANDINFO));
|
1999-07-27 18:20:36 +02:00
|
|
|
ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
|
|
|
|
ci.lpVerb = lpVerb;
|
|
|
|
ci.hwnd = hwnd;
|
|
|
|
|
|
|
|
IContextMenu_InvokeCommand(pcm, &ci);
|
|
|
|
IContextMenu_Release(pcm);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_SHELL_UpFolder
|
|
|
|
*
|
|
|
|
* Browse to the specified object
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
|
|
|
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
|
|
|
|
NULL,
|
|
|
|
SBSP_PARENT)))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-06-24 15:39:53 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_SHELL_BrowseToDesktop
|
|
|
|
*
|
|
|
|
* Browse to the Desktop
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
|
|
|
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
|
|
|
|
hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
|
|
|
|
COMDLG32_SHFree(pidl);
|
|
|
|
return SUCCEEDED(hres);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_SHELL_Clean
|
|
|
|
*
|
|
|
|
* Cleans the memory used by shell objects
|
|
|
|
*/
|
|
|
|
static void FILEDLG95_SHELL_Clean(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
COMDLG32_SHFree(fodInfos->ShellInfos.pidlAbsCurrent);
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* clean Shell interfaces */
|
|
|
|
IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
|
|
|
|
IShellView_Release(fodInfos->Shell.FOIShellView);
|
|
|
|
IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
|
|
|
|
IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
|
2000-06-02 21:36:53 +02:00
|
|
|
if (fodInfos->Shell.FOIDataObject)
|
|
|
|
IDataObject_Release(fodInfos->Shell.FOIDataObject);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILETYPE_Init
|
|
|
|
*
|
|
|
|
* Initialisation of the file type combo box
|
|
|
|
*/
|
|
|
|
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
if(fodInfos->ofnInfos->lpstrFilter)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
int nFilters = 0; /* number of filters */
|
1999-07-27 18:20:36 +02:00
|
|
|
LPSTR lpstrFilter;
|
2000-06-02 21:36:53 +02:00
|
|
|
LPCSTR lpstrPos = fodInfos->ofnInfos->lpstrFilter;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
1999-12-04 05:03:01 +01:00
|
|
|
/* filter is a list... title\0ext\0......\0\0
|
|
|
|
* Set the combo item text to the title and the item data
|
|
|
|
* to the ext
|
|
|
|
*/
|
2000-06-02 21:36:53 +02:00
|
|
|
LPCSTR lpstrDisplay;
|
|
|
|
LPSTR lpstrExt;
|
1999-12-04 05:03:01 +01:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* Get the title */
|
2000-06-02 21:36:53 +02:00
|
|
|
if(! *lpstrPos) break; /* end */
|
|
|
|
lpstrDisplay = lpstrPos;
|
|
|
|
lpstrPos += strlen(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;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Add the item at the end of the combo */
|
2000-06-02 21:36:53 +02:00
|
|
|
CBAddString(fodInfos->DlgInfos.hwndFileTypeCB, lpstrDisplay);
|
|
|
|
CBSetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, nFilters, lpstrExt);
|
|
|
|
nFilters++;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
/*
|
|
|
|
* Set the current filter to the one specified
|
|
|
|
* in the initialisation structure
|
|
|
|
* FIXME: lpstrCustomFilter not handled at all
|
|
|
|
*/
|
1999-12-04 05:03:01 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* set default filter index */
|
|
|
|
if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->ofnInfos->lpstrCustomFilter == 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;
|
1999-12-04 05:03:01 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* Set the current index selection. */
|
|
|
|
CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, fodInfos->ofnInfos->nFilterIndex-1);
|
1999-12-04 05:03:01 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* Get the corresponding text string from the combo box. */
|
|
|
|
lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
|
2000-02-20 19:54:04 +01:00
|
|
|
fodInfos->ofnInfos->nFilterIndex-1);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if ((INT)lpstrFilter == CB_ERR) /* control is empty */
|
|
|
|
lpstrFilter = NULL;
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
if(lpstrFilter)
|
|
|
|
{
|
2000-11-28 23:40:56 +01:00
|
|
|
DWORD len;
|
2000-06-23 18:16:30 +02:00
|
|
|
_strlwr(lpstrFilter); /* lowercase */
|
2000-11-28 23:40:56 +01:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 );
|
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1,
|
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter, len );
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILETYPE_OnCommand
|
|
|
|
*
|
|
|
|
* WM_COMMAND of the file type combo box
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
|
|
|
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
switch(wNotifyCode)
|
|
|
|
{
|
2000-02-20 19:54:04 +01:00
|
|
|
case CBN_SELENDOK:
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
LPSTR lpstrFilter;
|
|
|
|
|
|
|
|
/* Get the current item of the filetype combo box */
|
|
|
|
int iItem = CBGetCurSel(fodInfos->DlgInfos.hwndFileTypeCB);
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
/* set the current filter index - indexed from 1 */
|
|
|
|
fodInfos->ofnInfos->nFilterIndex = iItem + 1;
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* Set the current filter with the current selection */
|
|
|
|
if(fodInfos->ShellInfos.lpstrCurrentFilter)
|
|
|
|
MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter);
|
|
|
|
|
|
|
|
lpstrFilter = (LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
|
|
|
|
iItem);
|
1999-12-04 05:03:01 +01:00
|
|
|
if((int)lpstrFilter != CB_ERR)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-11-28 23:40:56 +01:00
|
|
|
DWORD len;
|
|
|
|
_strlwr(lpstrFilter); /* lowercase */
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 );
|
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1,
|
|
|
|
fodInfos->ShellInfos.lpstrCurrentFilter, len );
|
|
|
|
SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Refresh the actual view to display the included items*/
|
|
|
|
IShellView_Refresh(fodInfos->Shell.FOIShellView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILETYPE_SearchExt
|
|
|
|
*
|
2000-06-02 21:36:53 +02:00
|
|
|
* searches for a extension in the filetype box
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
2000-06-02 21:36:53 +02:00
|
|
|
static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCSTR lpstrExt)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
int i, iCount = CBGetCount(hwnd);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("%s\n", lpstrExt);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if(iCount != CB_ERR)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
for(i=0;i<iCount;i++)
|
|
|
|
{
|
|
|
|
if(!strcasecmp(lpstrExt,(LPSTR)CBGetItemDataPtr(hwnd,i)))
|
1999-12-12 00:00:17 +01:00
|
|
|
return i;
|
2000-06-02 21:36:53 +02:00
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILETYPE_Clean
|
|
|
|
*
|
|
|
|
* Clean the memory used by the filetype combo box
|
|
|
|
*/
|
|
|
|
static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
int iPos;
|
|
|
|
int iCount = CBGetCount(fodInfos->DlgInfos.hwndFileTypeCB);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/* Delete each string of the combo and their associated data */
|
2000-06-02 21:36:53 +02:00
|
|
|
if(iCount != CB_ERR)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
for(iPos = iCount-1;iPos>=0;iPos--)
|
|
|
|
{
|
|
|
|
MemFree((LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
|
|
|
|
CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
/* Current filter */
|
|
|
|
if(fodInfos->ShellInfos.lpstrCurrentFilter)
|
2000-06-02 21:36:53 +02:00
|
|
|
MemFree(fodInfos->ShellInfos.lpstrCurrentFilter);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_Init
|
|
|
|
*
|
|
|
|
* Initialisation of the look in combo box
|
|
|
|
*/
|
|
|
|
static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)
|
|
|
|
{
|
|
|
|
IShellFolder *psfRoot, *psfDrives;
|
|
|
|
IEnumIDList *lpeRoot, *lpeDrives;
|
|
|
|
LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
|
|
|
|
|
|
|
|
LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos));
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
liInfos->iMaxIndentation = 0;
|
|
|
|
|
|
|
|
SetPropA(hwndCombo, LookInInfosStr, (HANDLE) liInfos);
|
2000-10-28 02:29:58 +02:00
|
|
|
|
|
|
|
/* set item height for both text field and listbox */
|
|
|
|
CBSetItemHeight(hwndCombo,-1,GetSystemMetrics(SM_CYSMICON));
|
1999-09-04 16:28:49 +02:00
|
|
|
CBSetItemHeight(hwndCombo,0,GetSystemMetrics(SM_CYSMICON));
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Initialise data of Desktop folder */
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidlTmp);
|
1999-07-27 18:20:36 +02:00
|
|
|
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHFree(pidlTmp);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHGetSpecialFolderLocation(0,CSIDL_DRIVES,&pidlDrives);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHGetDesktopFolder(&psfRoot);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
if (psfRoot)
|
|
|
|
{
|
|
|
|
/* enumerate the contents of the desktop */
|
|
|
|
if(SUCCEEDED(IShellFolder_EnumObjects(psfRoot, hwndCombo, SHCONTF_FOLDERS, &lpeRoot)))
|
|
|
|
{
|
|
|
|
while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
|
|
|
|
{
|
|
|
|
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
|
|
|
|
|
|
|
|
/* special handling for CSIDL_DRIVES */
|
1999-08-21 16:47:28 +02:00
|
|
|
if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives))
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
|
|
|
|
{
|
|
|
|
/* enumerate the drives */
|
|
|
|
if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
|
|
|
|
{
|
|
|
|
while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
|
|
|
|
{
|
1999-08-21 16:47:28 +02:00
|
|
|
pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1);
|
1999-07-27 18:20:36 +02:00
|
|
|
FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHFree(pidlAbsTmp);
|
|
|
|
COMDLG32_SHFree(pidlTmp1);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
IEnumIDList_Release(lpeDrives);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(psfDrives);
|
|
|
|
}
|
|
|
|
}
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHFree(pidlTmp);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
IEnumIDList_Release(lpeRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfRoot);
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHFree(pidlDrives);
|
1999-07-27 18:20:36 +02:00
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_DrawItem
|
|
|
|
*
|
|
|
|
* WM_DRAWITEM message handler
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct)
|
|
|
|
{
|
|
|
|
COLORREF crWin = GetSysColor(COLOR_WINDOW);
|
|
|
|
COLORREF crHighLight = GetSysColor(COLOR_HIGHLIGHT);
|
|
|
|
COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
RECT rectText;
|
|
|
|
RECT rectIcon;
|
|
|
|
SHFILEINFOA sfi;
|
|
|
|
HIMAGELIST ilItemImage;
|
|
|
|
int iIndentation;
|
2000-10-28 02:29:58 +02:00
|
|
|
TEXTMETRICA tm;
|
1999-07-27 18:20:36 +02:00
|
|
|
LPSFOLDER tmpFolder;
|
|
|
|
|
|
|
|
|
|
|
|
LookInInfos *liInfos = (LookInInfos *)GetPropA(pDIStruct->hwndItem,LookInInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(pDIStruct->itemID == -1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem,
|
|
|
|
pDIStruct->itemID)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
if(pDIStruct->itemID == liInfos->uSelectedItem)
|
|
|
|
{
|
1999-08-21 16:47:28 +02:00
|
|
|
ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
|
1999-07-27 18:20:36 +02:00
|
|
|
0,
|
|
|
|
&sfi,
|
|
|
|
sizeof (SHFILEINFOA),
|
|
|
|
SHGFI_PIDL | SHGFI_SMALLICON |
|
|
|
|
SHGFI_OPENICON | SHGFI_SYSICONINDEX |
|
|
|
|
SHGFI_DISPLAYNAME );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-08-21 16:47:28 +02:00
|
|
|
ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
|
1999-07-27 18:20:36 +02:00
|
|
|
0,
|
|
|
|
&sfi,
|
|
|
|
sizeof (SHFILEINFOA),
|
|
|
|
SHGFI_PIDL | SHGFI_SMALLICON |
|
|
|
|
SHGFI_SYSICONINDEX |
|
|
|
|
SHGFI_DISPLAYNAME);
|
|
|
|
}
|
|
|
|
|
2000-10-28 02:29:58 +02:00
|
|
|
/* Is this item selected ? */
|
1999-07-27 18:20:36 +02:00
|
|
|
if(pDIStruct->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
SetTextColor(pDIStruct->hDC,(0x00FFFFFF & ~(crText)));
|
|
|
|
SetBkColor(pDIStruct->hDC,crHighLight);
|
|
|
|
FillRect(pDIStruct->hDC,&pDIStruct->rcItem,(HBRUSH)crHighLight);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetTextColor(pDIStruct->hDC,crText);
|
|
|
|
SetBkColor(pDIStruct->hDC,crWin);
|
|
|
|
FillRect(pDIStruct->hDC,&pDIStruct->rcItem,(HBRUSH)crWin);
|
|
|
|
}
|
|
|
|
|
2000-10-28 02:29:58 +02:00
|
|
|
/* Do not indent item if drawing in the edit of the combo */
|
1999-07-27 18:20:36 +02:00
|
|
|
if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
|
|
|
|
{
|
|
|
|
iIndentation = 0;
|
1999-08-21 16:47:28 +02:00
|
|
|
ilItemImage = (HIMAGELIST) COMDLG32_SHGetFileInfoA ((LPCSTR) tmpFolder->pidlItem,
|
1999-07-27 18:20:36 +02:00
|
|
|
0,
|
|
|
|
&sfi,
|
|
|
|
sizeof (SHFILEINFOA),
|
|
|
|
SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_OPENICON
|
|
|
|
| SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME );
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iIndentation = tmpFolder->m_iIndent;
|
|
|
|
}
|
|
|
|
/* Draw text and icon */
|
|
|
|
|
|
|
|
/* Initialise the icon display area */
|
|
|
|
rectIcon.left = pDIStruct->rcItem.left + ICONWIDTH/2 * iIndentation;
|
|
|
|
rectIcon.top = pDIStruct->rcItem.top;
|
|
|
|
rectIcon.right = rectIcon.left + ICONWIDTH;
|
|
|
|
rectIcon.bottom = pDIStruct->rcItem.bottom;
|
|
|
|
|
|
|
|
/* Initialise the text display area */
|
2000-10-28 02:29:58 +02:00
|
|
|
GetTextMetricsA(pDIStruct->hDC, &tm);
|
1999-07-27 18:20:36 +02:00
|
|
|
rectText.left = rectIcon.right;
|
2000-10-28 02:29:58 +02:00
|
|
|
rectText.top =
|
|
|
|
(pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
|
1999-07-27 18:20:36 +02:00
|
|
|
rectText.right = pDIStruct->rcItem.right + XTEXTOFFSET;
|
2000-10-28 02:29:58 +02:00
|
|
|
rectText.bottom =
|
|
|
|
(pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/* Draw the icon from the image list */
|
|
|
|
COMDLG32_ImageList_Draw(ilItemImage,
|
|
|
|
sfi.iIcon,
|
|
|
|
pDIStruct->hDC,
|
|
|
|
rectIcon.left,
|
|
|
|
rectIcon.top,
|
|
|
|
ILD_TRANSPARENT );
|
|
|
|
|
|
|
|
/* Draw the associated text */
|
|
|
|
if(sfi.szDisplayName)
|
|
|
|
TextOutA(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,strlen(sfi.szDisplayName));
|
|
|
|
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_OnCommand
|
|
|
|
*
|
|
|
|
* LookIn combo box WM_COMMAND message handler
|
|
|
|
* If the function succeeds, the return value is nonzero.
|
|
|
|
*/
|
|
|
|
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
TRACE("%p\n", fodInfos);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
switch(wNotifyCode)
|
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
case CBN_SELENDOK:
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
LPSFOLDER tmpFolder;
|
|
|
|
int iItem;
|
|
|
|
|
|
|
|
iItem = CBGetCurSel(fodInfos->DlgInfos.hwndLookInCB);
|
|
|
|
|
1999-09-19 20:27:05 +02:00
|
|
|
if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
|
|
|
|
iItem)))
|
|
|
|
return FALSE;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
|
|
|
|
tmpFolder->pidlItem,
|
|
|
|
SBSP_ABSOLUTE)))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_AddItem
|
|
|
|
*
|
|
|
|
* Adds an absolute pidl item to the lookin combo box
|
|
|
|
* returns the index of the inserted item
|
|
|
|
*/
|
|
|
|
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlNext;
|
|
|
|
SHFILEINFOA sfi;
|
2000-02-20 19:54:04 +01:00
|
|
|
SFOLDER *tmpFolder;
|
1999-07-27 18:20:36 +02:00
|
|
|
LookInInfos *liInfos;
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
TRACE("%08x\n", iInsertId);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
if(!pidl)
|
|
|
|
return -1;
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
if(!(liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr)))
|
|
|
|
return -1;
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
tmpFolder = MemAlloc(sizeof(SFOLDER));
|
1999-07-27 18:20:36 +02:00
|
|
|
tmpFolder->m_iIndent = 0;
|
|
|
|
|
|
|
|
/* Calculate the indentation of the item in the lookin*/
|
|
|
|
pidlNext = pidl;
|
1999-08-21 16:47:28 +02:00
|
|
|
while( (pidlNext=COMDLG32_PIDL_ILGetNext(pidlNext)) )
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
tmpFolder->m_iIndent++;
|
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
tmpFolder->pidlItem = COMDLG32_PIDL_ILClone(pidl); /* FIXME: memory leak*/
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
|
|
|
|
liInfos->iMaxIndentation = tmpFolder->m_iIndent;
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHGetFileInfoA((LPSTR)pidl,
|
1999-07-27 18:20:36 +02:00
|
|
|
0,
|
|
|
|
&sfi,
|
|
|
|
sizeof(sfi),
|
|
|
|
SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
|
2000-06-02 21:36:53 +02:00
|
|
|
| SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
TRACE("-- Add %s attr=%08lx\n", sfi.szDisplayName, sfi.dwAttributes);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
|
2000-06-02 21:36:53 +02:00
|
|
|
{
|
|
|
|
int iItemID;
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
TRACE("-- Add %s at %u\n", sfi.szDisplayName, tmpFolder->m_iIndent);
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* Add the item at the end of the list */
|
|
|
|
if(iInsertId < 0)
|
|
|
|
{
|
|
|
|
iItemID = CBAddString(hwnd,sfi.szDisplayName);
|
|
|
|
}
|
|
|
|
/* Insert the item at the iInsertId position*/
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iItemID = CBInsertString(hwnd,sfi.szDisplayName,iInsertId);
|
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
CBSetItemDataPtr(hwnd,iItemID,tmpFolder);
|
|
|
|
return iItemID;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
2000-02-20 19:54:04 +01:00
|
|
|
MemFree( tmpFolder );
|
1999-07-27 18:20:36 +02:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_InsertItemAfterParent
|
|
|
|
*
|
|
|
|
* Insert an item below its parent
|
|
|
|
*/
|
|
|
|
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd,LPITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
|
|
|
|
LPITEMIDLIST pidlParent = GetParentPidl(pidl);
|
|
|
|
int iParentPos;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
iParentPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidlParent,SEARCH_PIDL);
|
|
|
|
|
|
|
|
if(iParentPos < 0)
|
|
|
|
{
|
|
|
|
iParentPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidlParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free pidlParent memory */
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHFree((LPVOID)pidlParent);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_SelectItem
|
|
|
|
*
|
|
|
|
* Adds an absolute pidl item to the lookin combo box
|
|
|
|
* returns the index of the inserted item
|
|
|
|
*/
|
|
|
|
int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
int iItemPos;
|
|
|
|
LookInInfos *liInfos;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidl,SEARCH_PIDL);
|
|
|
|
|
|
|
|
liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr);
|
|
|
|
|
|
|
|
if(iItemPos < 0)
|
|
|
|
{
|
|
|
|
while(FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd) > -1);
|
|
|
|
iItemPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
|
|
|
|
while(liInfos->iMaxIndentation > tmpFolder->m_iIndent)
|
|
|
|
{
|
|
|
|
int iRemovedItem;
|
|
|
|
|
|
|
|
if(-1 == (iRemovedItem = FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd)))
|
|
|
|
break;
|
|
|
|
if(iRemovedItem < iItemPos)
|
|
|
|
iItemPos--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CBSetCurSel(hwnd,iItemPos);
|
|
|
|
liInfos->uSelectedItem = iItemPos;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_RemoveMostExpandedItem
|
|
|
|
*
|
|
|
|
* Remove the item with an expansion level over iExpansionLevel
|
|
|
|
*/
|
|
|
|
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
|
|
|
|
{
|
|
|
|
int iItemPos;
|
|
|
|
|
|
|
|
LookInInfos *liInfos = (LookInInfos *)GetPropA(hwnd,LookInInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(liInfos->iMaxIndentation <= 2)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if((iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)liInfos->iMaxIndentation,SEARCH_EXP)) >=0)
|
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
|
|
|
|
COMDLG32_SHFree(tmpFolder->pidlItem);
|
|
|
|
MemFree(tmpFolder);
|
1999-07-27 18:20:36 +02:00
|
|
|
CBDeleteString(hwnd,iItemPos);
|
|
|
|
liInfos->iMaxIndentation--;
|
|
|
|
|
|
|
|
return iItemPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_SearchItem
|
|
|
|
*
|
|
|
|
* Search for pidl in the lookin combo box
|
|
|
|
* returns the index of the found item
|
|
|
|
*/
|
|
|
|
static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int iCount = CBGetCount(hwnd);
|
|
|
|
|
2000-11-01 02:50:21 +01:00
|
|
|
TRACE("0x%08x 0x%x\n",searchArg, iSearchMethod);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if (iCount != CB_ERR)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
for(;i<iCount;i++)
|
|
|
|
{
|
|
|
|
LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if(iSearchMethod == SEARCH_PIDL && COMDLG32_PIDL_ILIsEqual((LPITEMIDLIST)searchArg,tmpFolder->pidlItem))
|
|
|
|
return i;
|
|
|
|
if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
|
|
|
|
return i;
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_LOOKIN_Clean
|
|
|
|
*
|
|
|
|
* Clean the memory used by the lookin combo box
|
|
|
|
*/
|
|
|
|
static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
int iPos;
|
|
|
|
int iCount = CBGetCount(fodInfos->DlgInfos.hwndLookInCB);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/* Delete each string of the combo and their associated data */
|
2000-06-02 21:36:53 +02:00
|
|
|
if (iCount != CB_ERR)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
for(iPos = iCount-1;iPos>=0;iPos--)
|
|
|
|
{
|
|
|
|
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
|
|
|
|
COMDLG32_SHFree(tmpFolder->pidlItem);
|
|
|
|
MemFree(tmpFolder);
|
1999-07-27 18:20:36 +02:00
|
|
|
CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos);
|
2000-06-02 21:36:53 +02:00
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/* LookInInfos structure */
|
|
|
|
RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
|
|
|
|
|
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILENAME_FillFromSelection
|
|
|
|
*
|
|
|
|
* fills the edit box from the cached DataObject
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
2000-06-02 21:36:53 +02:00
|
|
|
void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
|
|
|
|
{
|
|
|
|
FileOpenDlgInfos *fodInfos;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
UINT nFiles = 0, nFileToOpen, nFileSelected, nLength = 0;
|
|
|
|
char lpstrTemp[MAX_PATH];
|
|
|
|
LPSTR lpstrAllFile = NULL, lpstrCurrFile = NULL;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
/* Count how many files we have */
|
|
|
|
nFileSelected = GetNumSelected( fodInfos->Shell.FOIDataObject );
|
|
|
|
|
|
|
|
/* calculate the string length, count files */
|
|
|
|
if (nFileSelected >= 1)
|
|
|
|
{
|
|
|
|
nLength += 3; /* first and last quotes, trailing \0 */
|
|
|
|
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 );
|
|
|
|
|
|
|
|
if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */
|
|
|
|
{
|
2000-08-14 16:41:19 +02:00
|
|
|
nLength += strlen( lpstrTemp ) + 3;
|
2000-06-02 21:36:53 +02:00
|
|
|
nFiles++;
|
|
|
|
}
|
|
|
|
COMDLG32_SHFree( pidl );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate the buffer */
|
|
|
|
if (nFiles <= 1) nLength = MAX_PATH;
|
|
|
|
lpstrAllFile = (LPSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength);
|
|
|
|
lpstrAllFile[0] = '\0';
|
|
|
|
|
|
|
|
/* Generate the string for the edit control */
|
|
|
|
if(nFiles >= 1)
|
|
|
|
{
|
|
|
|
lpstrCurrFile = lpstrAllFile;
|
|
|
|
for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
|
|
|
|
{
|
|
|
|
pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 );
|
|
|
|
|
|
|
|
if (pidl)
|
|
|
|
{
|
|
|
|
/* get the file name */
|
|
|
|
lpstrTemp[0] = '\0';
|
|
|
|
GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER, lpstrTemp );
|
|
|
|
|
|
|
|
if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */
|
|
|
|
{
|
|
|
|
if ( nFiles > 1)
|
|
|
|
{
|
|
|
|
*lpstrCurrFile++ = '\"';
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpy( lpstrCurrFile, lpstrTemp );
|
|
|
|
lpstrCurrFile += strlen( lpstrTemp );
|
|
|
|
strcpy( lpstrCurrFile, "\" " );
|
2000-06-02 21:36:53 +02:00
|
|
|
lpstrCurrFile += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpy( lpstrAllFile, lpstrTemp );
|
2000-06-02 21:36:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
COMDLG32_SHFree( (LPVOID) pidl );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowTextA( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
|
|
|
|
HeapFree(GetProcessHeap(),0, lpstrAllFile );
|
|
|
|
}
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-04-23 22:40:23 +02:00
|
|
|
/* copied from shell32 to avoid linking to it */
|
|
|
|
static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
|
|
|
COMDLG32_SHFree(src->u.pOleStr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTRA:
|
|
|
|
lstrcpynA((LPSTR)dest, src->u.cStr, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSETA:
|
|
|
|
lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
*(LPSTR)dest = '\0';
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG95_FILENAME_GetFileNames
|
|
|
|
*
|
2000-08-31 04:06:26 +02:00
|
|
|
* copies the filenames to a 0-delimited string list (A\0B\0C\0\0)
|
2000-06-02 21:36:53 +02:00
|
|
|
*/
|
|
|
|
int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPSTR * 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 */
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
TRACE("nStrLen=%u str=%s\n", nStrLen, lpstrEdit);
|
|
|
|
|
2000-08-31 04:06:26 +02:00
|
|
|
/* we might get single filename without any '"',
|
|
|
|
* so we need nStrLen + terminating \0 + end-of-list \0 */
|
|
|
|
*lpstrFileList = MemAlloc(nStrLen+2);
|
2000-06-02 21:36:53 +02:00
|
|
|
*sizeUsed = 0;
|
|
|
|
|
2000-08-31 04:06:26 +02:00
|
|
|
/* build 0-delimited file list from filenames */
|
2000-06-02 21:36:53 +02:00
|
|
|
while ( nStrCharCount <= nStrLen )
|
|
|
|
{
|
|
|
|
if ( lpstrEdit[nStrCharCount]=='"' )
|
|
|
|
{
|
|
|
|
nStrCharCount++;
|
|
|
|
while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen))
|
|
|
|
{
|
|
|
|
(*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
|
|
|
|
(*sizeUsed)++;
|
|
|
|
nStrCharCount++;
|
|
|
|
}
|
|
|
|
(*lpstrFileList)[nFileIndex++] = '\0';
|
|
|
|
(*sizeUsed)++;
|
|
|
|
nFileCount++;
|
|
|
|
}
|
|
|
|
nStrCharCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* single, unquoted string */
|
|
|
|
if ((nStrLen > 0) && (*sizeUsed == 0) )
|
|
|
|
{
|
|
|
|
strcpy(*lpstrFileList, lpstrEdit);
|
|
|
|
nFileIndex = strlen(lpstrEdit) + 1;
|
|
|
|
(*sizeUsed) = nFileIndex;
|
|
|
|
nFileCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* trailing \0 */
|
|
|
|
(*lpstrFileList)[nFileIndex] = '\0';
|
|
|
|
(*sizeUsed)++;
|
|
|
|
|
|
|
|
MemFree(lpstrEdit);
|
|
|
|
return nFileCount;
|
2000-08-31 04:06:26 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
|
|
|
|
#define SETDefFormatEtc(fe,cf,med) \
|
|
|
|
{ \
|
|
|
|
(fe).cfFormat = cf;\
|
|
|
|
(fe).dwAspect = DVASPECT_CONTENT; \
|
|
|
|
(fe).ptd =NULL;\
|
|
|
|
(fe).tymed = med;\
|
|
|
|
(fe).lindex = -1;\
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DATAOBJECT Helper functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* COMCTL32_ReleaseStgMedium
|
|
|
|
*
|
|
|
|
* like ReleaseStgMedium from ole32
|
|
|
|
*/
|
|
|
|
static void COMCTL32_ReleaseStgMedium (STGMEDIUM medium)
|
|
|
|
{
|
|
|
|
if(medium.pUnkForRelease)
|
|
|
|
{
|
|
|
|
IUnknown_Release(medium.pUnkForRelease);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GlobalUnlock(medium.u.hGlobal);
|
|
|
|
GlobalFree(medium.u.hGlobal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetPidlFromDataObject
|
|
|
|
*
|
|
|
|
* Return pidl(s) by number from the cached DataObject
|
|
|
|
*
|
|
|
|
* nPidlIndex=0 gets the fully qualified root path
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* Get the pidls from IDataObject */
|
|
|
|
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
|
|
|
|
{
|
|
|
|
LPIDA cida = GlobalLock(medium.u.hGlobal);
|
|
|
|
if(nPidlIndex <= cida->cidl)
|
|
|
|
{
|
|
|
|
pidl = COMDLG32_PIDL_ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex]]));
|
|
|
|
}
|
|
|
|
COMCTL32_ReleaseStgMedium(medium);
|
|
|
|
}
|
|
|
|
return pidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNumSelected
|
|
|
|
*
|
|
|
|
* Return the number of selected items in the DataObject.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
UINT GetNumSelected( IDataObject *doSelected )
|
|
|
|
{
|
|
|
|
UINT retVal = 0;
|
|
|
|
STGMEDIUM medium;
|
|
|
|
FORMATETC formatetc;
|
|
|
|
|
|
|
|
TRACE("sv=%p\n", doSelected);
|
|
|
|
|
|
|
|
if (!doSelected) return 0;
|
|
|
|
|
|
|
|
/* Set the FORMATETC structure*/
|
|
|
|
SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
|
|
|
|
|
|
|
|
/* Get the pidls from IDataObject */
|
|
|
|
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
|
|
|
|
{
|
|
|
|
LPIDA cida = GlobalLock(medium.u.hGlobal);
|
|
|
|
retVal = cida->cidl;
|
|
|
|
COMCTL32_ReleaseStgMedium(medium);
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TOOLS
|
|
|
|
*/
|
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetName
|
|
|
|
*
|
|
|
|
* Get the pidl's display name (relative to folder) and
|
|
|
|
* put it in lpstrFileName.
|
|
|
|
*
|
|
|
|
* Return NOERROR on success,
|
|
|
|
* E_FAIL otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)
|
|
|
|
{
|
|
|
|
STRRET str;
|
|
|
|
HRESULT hRes;
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("sf=%p pidl=%p\n", lpsf, pidl);
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
if(!lpsf)
|
|
|
|
{
|
|
|
|
HRESULT hRes;
|
1999-08-21 16:47:28 +02:00
|
|
|
COMDLG32_SHGetDesktopFolder(&lpsf);
|
1999-07-27 18:20:36 +02:00
|
|
|
hRes = GetName(lpsf,pidl,dwFlags,lpstrFileName);
|
|
|
|
IShellFolder_Release(lpsf);
|
|
|
|
return hRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the display name of the pidl relative to the folder */
|
2000-06-02 21:36:53 +02:00
|
|
|
if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, pidl, dwFlags, &str)))
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-04-23 22:40:23 +02:00
|
|
|
return COMDLG32_StrRetToStrNA(lpstrFileName, MAX_PATH, &str, pidl);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetShellFolderFromPidl
|
|
|
|
*
|
|
|
|
* pidlRel is the item pidl relative
|
|
|
|
* Return the IShellFolder of the absolute pidl
|
|
|
|
*/
|
|
|
|
IShellFolder *GetShellFolderFromPidl(LPITEMIDLIST pidlAbs)
|
|
|
|
{
|
|
|
|
IShellFolder *psf = NULL,*psfParent;
|
|
|
|
|
|
|
|
TRACE("%p\n", pidlAbs);
|
|
|
|
|
1999-08-21 16:47:28 +02:00
|
|
|
if(SUCCEEDED(COMDLG32_SHGetDesktopFolder(&psfParent)))
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
psf = psfParent;
|
|
|
|
if(pidlAbs && pidlAbs->mkid.cb)
|
|
|
|
{
|
1999-09-19 20:27:05 +02:00
|
|
|
if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
1999-09-19 20:27:05 +02:00
|
|
|
IShellFolder_Release(psfParent);
|
|
|
|
return psf;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
1999-09-19 20:27:05 +02:00
|
|
|
/* return the desktop */
|
|
|
|
return psfParent;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
1999-09-19 20:27:05 +02:00
|
|
|
return NULL;
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetParentPidl
|
|
|
|
*
|
|
|
|
* Return the LPITEMIDLIST to the parent of the pidl in the list
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlParent;
|
|
|
|
|
|
|
|
TRACE("%p\n", pidl);
|
2000-11-01 02:50:21 +01:00
|
|
|
|
1999-08-21 16:47:28 +02:00
|
|
|
pidlParent = COMDLG32_PIDL_ILClone(pidl);
|
|
|
|
COMDLG32_PIDL_ILRemoveLastID(pidlParent);
|
1999-09-19 20:27:05 +02:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
return pidlParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetPidlFromName
|
|
|
|
*
|
|
|
|
* returns the pidl of the file name relative to folder
|
|
|
|
* NULL if an error occured
|
|
|
|
*/
|
2000-06-02 21:36:53 +02:00
|
|
|
LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPCSTR lpcstrFileName)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
ULONG ulEaten;
|
2000-06-02 21:36:53 +02:00
|
|
|
WCHAR lpwstrDirName[MAX_PATH];
|
1999-07-28 18:38:45 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
TRACE("sf=%p file=%s\n", lpsf, lpcstrFileName);
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if(!lpcstrFileName) return NULL;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpcstrFileName,-1,(LPWSTR)lpwstrDirName,MAX_PATH);
|
1999-08-21 16:47:28 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if(!lpsf)
|
|
|
|
{
|
|
|
|
COMDLG32_SHGetDesktopFolder(&lpsf);
|
|
|
|
pidl = GetPidlFromName(lpsf, lpcstrFileName);
|
|
|
|
IShellFolder_Release(lpsf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IShellFolder_ParseDisplayName(lpsf, 0, NULL, (LPWSTR)lpwstrDirName, &ulEaten, &pidl, NULL);
|
|
|
|
}
|
|
|
|
return pidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
BOOL IsPidlFolder (LPSHELLFOLDER psf, LPITEMIDLIST 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);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-06-02 21:36:53 +02:00
|
|
|
* BrowseSelectedFolder
|
1999-07-27 18:20:36 +02:00
|
|
|
*/
|
2000-06-02 21:36:53 +02:00
|
|
|
static BOOL BrowseSelectedFolder(HWND hwnd)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
BOOL bBrowseSelFolder = FALSE;
|
|
|
|
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
|
|
|
|
|
|
|
|
TRACE("\n");
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
if (GetNumSelected(fodInfos->Shell.FOIDataObject) == 1)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
2000-06-02 21:36:53 +02:00
|
|
|
LPITEMIDLIST pidlSelection;
|
1999-07-27 18:20:36 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/* get the file selected */
|
|
|
|
pidlSelection = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 1);
|
|
|
|
if (IsPidlFolder (fodInfos->Shell.FOIShellFolder, pidlSelection))
|
|
|
|
{
|
|
|
|
if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
|
|
|
|
pidlSelection, SBSP_RELATIVE ) ) )
|
|
|
|
{
|
|
|
|
MessageBoxA( hwnd, "Path does not exist", fodInfos->ofnInfos->lpstrTitle,
|
|
|
|
MB_OK | MB_ICONEXCLAMATION );
|
|
|
|
}
|
|
|
|
|
|
|
|
bBrowseSelFolder = TRUE;
|
|
|
|
}
|
|
|
|
COMDLG32_SHFree( pidlSelection );
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
|
|
|
|
return bBrowseSelFolder;
|
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory allocation methods */
|
2000-04-23 22:40:23 +02:00
|
|
|
static void *MemAlloc(UINT size)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
|
|
|
|
}
|
|
|
|
|
2000-04-23 22:40:23 +02:00
|
|
|
static void MemFree(void *mem)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
if(mem)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(),0,mem);
|
|
|
|
}
|
|
|
|
}
|
2000-06-02 21:36:53 +02:00
|
|
|
|