1999-02-28 21:05:11 +01:00
|
|
|
/*
|
|
|
|
* COMMDLG - File Dialogs
|
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <string.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2000-11-28 23:40:56 +01:00
|
|
|
#include "winnls.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "wine/winuser16.h"
|
2000-08-02 01:33:37 +02:00
|
|
|
#include "wine/unicode.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "commdlg.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-13 18:07:56 +01:00
|
|
|
#include "cderr.h"
|
2003-01-24 00:07:38 +01:00
|
|
|
#include "winternl.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "cdlg.h"
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
#define BUFFILE 512
|
2002-06-01 01:06:46 +02:00
|
|
|
#define BUFFILEALLOC 512 * sizeof(WCHAR)
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
struct FSPRIVATE
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
HWND hwnd; /* file dialog window handle */
|
|
|
|
BOOL hook; /* TRUE if the dialog is hooked */
|
|
|
|
UINT lbselchstring; /* registered message id */
|
|
|
|
UINT fileokstring; /* registered message id */
|
|
|
|
LPARAM lParam; /* save original lparam */
|
|
|
|
HANDLE16 hDlgTmpl16; /* handle for resource 16 */
|
|
|
|
HANDLE16 hResource16; /* handle for allocated resource 16 */
|
|
|
|
HANDLE16 hGlobal16; /* 16 bits mem block (resources) */
|
|
|
|
LPCVOID template; /* template for 32 bits resource */
|
|
|
|
BOOL open; /* TRUE if open dialog, FALSE if save dialog */
|
|
|
|
OPENFILENAMEW *ofnW; /* original structure or work struct */
|
|
|
|
OPENFILENAMEA *ofnA; /* original structure if 32bits ansi dialog */
|
|
|
|
OPENFILENAME16 *ofn16; /* original structure if 16 bits dialog */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define LFSPRIVATE struct FSPRIVATE *
|
|
|
|
|
|
|
|
#define LFS16 1
|
|
|
|
#define LFS32A 2
|
|
|
|
#define LFS32W 3
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
static const WCHAR FILE_star[] = {'*','.','*', 0};
|
|
|
|
static const WCHAR FILE_bslash[] = {'\\', 0};
|
|
|
|
static const WCHAR FILE_specc[] = {'%','c',':', 0};
|
|
|
|
|
2002-10-10 23:22:09 +02:00
|
|
|
static HICON hFolder = 0;
|
|
|
|
static HICON hFolder2 = 0;
|
|
|
|
static HICON hFloppy = 0;
|
|
|
|
static HICON hHDisk = 0;
|
|
|
|
static HICON hCDRom = 0;
|
|
|
|
static HICON hNet = 0;
|
2001-01-21 22:11:28 +01:00
|
|
|
static const int fldrHeight = 16;
|
|
|
|
static const int fldrWidth = 20;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
#define OFN_PROP "FILEDLG_OFN"
|
|
|
|
|
|
|
|
static char defaultopen[]="Open File";
|
|
|
|
static char defaultsave[]="Save as";
|
1999-02-28 21:05:11 +01:00
|
|
|
|
1999-07-27 18:20:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
2000-08-02 01:33:37 +02:00
|
|
|
* Windows 3.1 style OpenFileName/SaveFileName dialog
|
1999-07-27 18:20:36 +02:00
|
|
|
*
|
|
|
|
*/
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
LPARAM lParam);
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
LPARAM lParam);
|
|
|
|
|
2002-10-31 02:04:39 +01:00
|
|
|
static INT_PTR CALLBACK FileOpenDlgProc(HWND hDlg, UINT msg,
|
2000-08-02 01:33:37 +02:00
|
|
|
WPARAM wParam, LPARAM lParam);
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* FileDlg_Init [internal]
|
|
|
|
*/
|
|
|
|
static BOOL FileDlg_Init(void)
|
|
|
|
{
|
|
|
|
static BOOL initialized = 0;
|
2001-01-21 22:11:28 +01:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (!initialized) {
|
2001-01-20 03:48:30 +01:00
|
|
|
HINSTANCE inst = GetModuleHandleA( "comdlg32.dll" );
|
|
|
|
if (!inst)
|
|
|
|
{
|
|
|
|
ERR( "cannot get comdlg32.dll instance\n" );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-01-21 22:11:28 +01:00
|
|
|
hFolder = LoadImageA( inst, "FOLDER", IMAGE_ICON, 16, 16, LR_SHARED );
|
|
|
|
hFolder2 = LoadImageA( inst, "FOLDER2", IMAGE_ICON, 16, 16, LR_SHARED );
|
|
|
|
hFloppy = LoadImageA( inst, "FLOPPY", IMAGE_ICON, 16, 16, LR_SHARED );
|
|
|
|
hHDisk = LoadImageA( inst, "HDISK", IMAGE_ICON, 16, 16, LR_SHARED );
|
|
|
|
hCDRom = LoadImageA( inst, "CDROM", IMAGE_ICON, 16, 16, LR_SHARED );
|
|
|
|
hNet = LoadImageA( inst, "NETWORK", IMAGE_ICON, 16, 16, LR_SHARED );
|
2002-06-01 01:06:46 +02:00
|
|
|
if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
|
1999-03-13 19:10:43 +01:00
|
|
|
hHDisk == 0 || hCDRom == 0 || hNet == 0)
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("Error loading icons !\n");
|
1999-03-13 19:10:43 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:27:58 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-08-02 01:33:37 +02:00
|
|
|
* Get32BitsTemplate [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
2000-08-02 01:33:37 +02:00
|
|
|
* Get a template (or FALSE if failure) when 16 bits dialogs are used
|
|
|
|
* by a 32 bits application
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
*/
|
2000-08-02 01:33:37 +02:00
|
|
|
BOOL Get32BitsTemplate(LFSPRIVATE lfs)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
LPOPENFILENAMEW ofnW = lfs->ofnW;
|
|
|
|
HANDLE hDlgTmpl;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
|
|
|
|
{
|
|
|
|
if (!(lfs->template = LockResource( ofnW->hInstance )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
else if (ofnW->Flags & OFN_ENABLETEMPLATE)
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
2000-08-02 01:33:37 +02:00
|
|
|
if (lfs->ofnA)
|
|
|
|
hResInfo = FindResourceA(lfs->ofnA->hInstance,
|
|
|
|
lfs->ofnA->lpTemplateName,
|
|
|
|
RT_DIALOGA);
|
|
|
|
else
|
|
|
|
hResInfo = FindResourceW(ofnW->hInstance,
|
|
|
|
ofnW->lpTemplateName,
|
|
|
|
RT_DIALOGW);
|
|
|
|
if (!hResInfo)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(ofnW->hInstance,
|
|
|
|
hResInfo)) ||
|
|
|
|
!(lfs->template = LockResource(hDlgTmpl)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else { /* get it from internal Wine resource */
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
|
2000-08-02 01:33:37 +02:00
|
|
|
lfs->open? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
|
|
|
!(lfs->template = LockResource( hDlgTmpl )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-02 01:33:37 +02:00
|
|
|
* Get16BitsTemplate [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
2000-08-02 01:33:37 +02:00
|
|
|
* Get a template (FALSE if failure) when 16 bits dialogs are used
|
|
|
|
* by a 16 bits application
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
*/
|
2000-08-02 01:33:37 +02:00
|
|
|
BOOL Get16BitsTemplate(LFSPRIVATE lfs)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
LPOPENFILENAME16 ofn16 = lfs->ofn16;
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCVOID template;
|
2000-08-02 01:33:37 +02:00
|
|
|
HGLOBAL16 hGlobal16 = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn16->Flags & OFN_ENABLETEMPLATEHANDLE)
|
|
|
|
lfs->hDlgTmpl16 = ofn16->hInstance;
|
|
|
|
else if (ofn16->Flags & OFN_ENABLETEMPLATE)
|
|
|
|
{
|
|
|
|
HANDLE16 hResInfo;
|
|
|
|
if (!(hResInfo = FindResource16(ofn16->hInstance,
|
2000-12-13 21:20:09 +01:00
|
|
|
MapSL(ofn16->lpTemplateName),
|
2000-11-27 22:54:01 +01:00
|
|
|
RT_DIALOGA)))
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
if (!(lfs->hDlgTmpl16 = LoadResource16( ofn16->hInstance, hResInfo )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lfs->hResource16 = lfs->hDlgTmpl16;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
else
|
|
|
|
{ /* get resource from (32 bits) own Wine resource; convert it to 16 */
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl32;
|
2000-08-02 01:33:37 +02:00
|
|
|
LPCVOID template32;
|
|
|
|
DWORD size;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
|
2000-08-02 01:33:37 +02:00
|
|
|
lfs->open ? "OPEN_FILE":"SAVE_FILE", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
|
|
|
!(template32 = LockResource( hDlgTmpl32 )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
|
|
|
|
hGlobal16 = GlobalAlloc16(0, size);
|
|
|
|
if (!hGlobal16)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
|
|
|
|
ERR("alloc failure for %ld bytes\n", size);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
template = GlobalLock16(hGlobal16);
|
|
|
|
if (!template)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
|
|
|
ERR("global lock failure for %x handle\n", hGlobal16);
|
|
|
|
GlobalFree16(hGlobal16);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
|
|
|
|
lfs->hDlgTmpl16 = hGlobal16;
|
|
|
|
lfs->hGlobal16 = hGlobal16;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_StripEditControl [internal]
|
|
|
|
* Strip pathnames off the contents of the edit control.
|
|
|
|
*/
|
2000-08-02 01:33:37 +02:00
|
|
|
static void FILEDLG_StripEditControl(HWND hwnd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
WCHAR temp[BUFFILE], *cp;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2001-01-02 21:50:34 +01:00
|
|
|
GetDlgItemTextW( hwnd, edt1, temp, sizeof(temp)/sizeof(WCHAR));
|
2000-08-02 01:33:37 +02:00
|
|
|
cp = strrchrW(temp, '\\');
|
1999-02-28 21:05:11 +01:00
|
|
|
if (cp != NULL) {
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpyW(temp, cp+1);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
cp = strrchrW(temp, ':');
|
1999-02-28 21:05:11 +01:00
|
|
|
if (cp != NULL) {
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpyW(temp, cp+1);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
/* FIXME: shouldn't we do something with the result here? ;-) */
|
|
|
|
}
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-08-02 01:33:37 +02:00
|
|
|
* FILEDLG_CallWindowProc [internal]
|
|
|
|
*
|
|
|
|
* Call the appropriate hook
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-08-02 01:33:37 +02:00
|
|
|
static BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
if (lfs->ofn16)
|
|
|
|
{
|
2000-08-14 22:53:21 +02:00
|
|
|
return (BOOL16) CallWindowProc16(
|
2002-09-06 22:40:42 +02:00
|
|
|
(WNDPROC16)lfs->ofn16->lpfnHook, HWND_16(lfs->hwnd),
|
2000-08-02 01:33:37 +02:00
|
|
|
(UINT16)wMsg, (WPARAM16)wParam, lParam);
|
|
|
|
}
|
|
|
|
if (lfs->ofnA)
|
|
|
|
{
|
|
|
|
return (BOOL) CallWindowProcA(
|
|
|
|
(WNDPROC)lfs->ofnA->lpfnHook, lfs->hwnd,
|
|
|
|
wMsg, wParam, lParam);
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
if (lfs->ofnW)
|
|
|
|
{
|
|
|
|
return (BOOL) CallWindowProcW(
|
|
|
|
(WNDPROC)lfs->ofnW->lpfnHook, lfs->hwnd,
|
|
|
|
wMsg, wParam, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/***********************************************************************
|
2000-08-19 01:03:44 +02:00
|
|
|
* FILEDLG_ScanDir [internal]
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2000-10-23 01:46:21 +02:00
|
|
|
static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
WCHAR buffer[BUFFILE];
|
2000-10-23 01:46:21 +02:00
|
|
|
HWND hdlg, hdlgDir;
|
|
|
|
LRESULT lRet = TRUE;
|
|
|
|
HCURSOR hCursorWait, oldCursor;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
if ( !SetCurrentDirectoryW( newPath ))
|
|
|
|
return FALSE;
|
2001-01-02 21:50:34 +01:00
|
|
|
lstrcpynW(buffer, newPath, sizeof(buffer)/sizeof(WCHAR));
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/* get the list of spec files */
|
2001-01-02 21:50:34 +01:00
|
|
|
GetDlgItemTextW(hWnd, edt1, buffer, sizeof(buffer)/sizeof(WCHAR));
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2000-11-27 22:54:01 +01:00
|
|
|
hCursorWait = LoadCursorA(0, IDC_WAITA);
|
2000-10-23 01:46:21 +02:00
|
|
|
oldCursor = SetCursor(hCursorWait);
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/* list of files */
|
|
|
|
if ((hdlg = GetDlgItem(hWnd, lst1)) != 0) {
|
|
|
|
WCHAR* scptr; /* ptr on semi-colon */
|
|
|
|
WCHAR* filter = buffer;
|
|
|
|
|
|
|
|
TRACE("Using filter %s\n", debugstr_w(filter));
|
|
|
|
SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
|
|
|
|
while (filter) {
|
|
|
|
scptr = strchrW(filter, ';');
|
|
|
|
if (scptr) *scptr = 0;
|
2000-10-23 01:46:21 +02:00
|
|
|
while (*filter == ' ') filter++;
|
2000-08-02 01:33:37 +02:00
|
|
|
TRACE("Using file spec %s\n", debugstr_w(filter));
|
|
|
|
if (SendMessageW(hdlg, LB_DIR, 0, (LPARAM)filter) == LB_ERR)
|
|
|
|
return FALSE;
|
|
|
|
if (scptr) *scptr = ';';
|
|
|
|
filter = (scptr) ? (scptr + 1) : 0;
|
|
|
|
}
|
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/* list of directories */
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpyW(buffer, FILE_star);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
|
|
|
if ((hdlgDir = GetDlgItem(hWnd, lst2)) != 0) {
|
|
|
|
lRet = DlgDirListW(hWnd, buffer, lst2, stc1, DDL_EXCLUSIVE | DDL_DIRECTORY);
|
|
|
|
}
|
|
|
|
SetCursor(oldCursor);
|
|
|
|
return lRet;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-08-19 01:03:44 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_GetFileType [internal]
|
|
|
|
*/
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
static LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
int n, i;
|
|
|
|
i = 0;
|
|
|
|
if (cfptr)
|
2002-06-01 01:06:46 +02:00
|
|
|
for ( ;(n = lstrlenW(cfptr)) != 0; i++)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
cfptr += n + 1;
|
|
|
|
if (i == index)
|
|
|
|
return cfptr;
|
2000-08-02 01:33:37 +02:00
|
|
|
cfptr += lstrlenW(cfptr) + 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (fptr)
|
2002-06-01 01:06:46 +02:00
|
|
|
for ( ;(n = lstrlenW(fptr)) != 0; i++)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
fptr += n + 1;
|
|
|
|
if (i == index)
|
|
|
|
return fptr;
|
2000-08-02 01:33:37 +02:00
|
|
|
fptr += lstrlenW(fptr) + 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
return (LPWSTR) FILE_star; /* FIXME */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_WMDrawItem [internal]
|
|
|
|
*/
|
2000-08-02 01:33:37 +02:00
|
|
|
static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
|
|
|
|
int savedlg, LPDRAWITEMSTRUCT lpdis)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
WCHAR *str;
|
|
|
|
HICON hIcon;
|
1999-03-13 19:10:43 +01:00
|
|
|
COLORREF oldText = 0, oldBk = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
|
2000-08-02 01:33:37 +02:00
|
|
|
(LPARAM)str);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
1999-03-13 19:10:43 +01:00
|
|
|
if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
|
|
|
|
{
|
|
|
|
oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
|
|
|
|
oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
|
|
|
}
|
|
|
|
if (savedlg)
|
1999-02-28 21:05:11 +01:00
|
|
|
SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + 1,
|
1999-03-13 19:10:43 +01:00
|
|
|
lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
|
2000-08-02 01:33:37 +02:00
|
|
|
&(lpdis->rcItem), str, lstrlenW(str), NULL);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
2000-08-02 01:33:37 +02:00
|
|
|
DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
|
1999-03-13 19:10:43 +01:00
|
|
|
|
|
|
|
if ((lpdis->itemState & ODS_SELECTED) && !savedlg)
|
|
|
|
{
|
|
|
|
SetBkColor( lpdis->hDC, oldBk );
|
|
|
|
SetTextColor( lpdis->hDC, oldText );
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-03-13 19:10:43 +01:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
|
2000-08-02 01:33:37 +02:00
|
|
|
(LPARAM)str);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
1999-03-13 19:10:43 +01:00
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
|
|
|
|
oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
|
1999-03-13 19:10:43 +01:00
|
|
|
lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
|
2000-08-02 01:33:37 +02:00
|
|
|
&(lpdis->rcItem), str, lstrlenW(str), NULL);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
2000-08-02 01:33:37 +02:00
|
|
|
DrawFocusRect( lpdis->hDC, &(lpdis->rcItem) );
|
1999-03-13 19:10:43 +01:00
|
|
|
|
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
SetBkColor( lpdis->hDC, oldBk );
|
|
|
|
SetTextColor( lpdis->hDC, oldText );
|
|
|
|
}
|
|
|
|
DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder);
|
2000-08-02 01:33:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
|
|
|
|
{
|
2000-11-27 22:54:01 +01:00
|
|
|
char root[] = "a:";
|
2000-08-02 01:33:37 +02:00
|
|
|
if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
|
2000-08-02 01:33:37 +02:00
|
|
|
(LPARAM)str);
|
2000-11-27 22:54:01 +01:00
|
|
|
root[0] += str[2] - 'a';
|
|
|
|
switch(GetDriveTypeA(root))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-11-27 22:54:01 +01:00
|
|
|
case DRIVE_REMOVABLE: hIcon = hFloppy; break;
|
|
|
|
case DRIVE_CDROM: hIcon = hCDRom; break;
|
|
|
|
case DRIVE_REMOTE: hIcon = hNet; break;
|
|
|
|
case DRIVE_FIXED:
|
1999-03-13 19:10:43 +01:00
|
|
|
default: hIcon = hHDisk; break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
1999-03-13 19:10:43 +01:00
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
oldBk = SetBkColor( lpdis->hDC, GetSysColor( COLOR_HIGHLIGHT ) );
|
|
|
|
oldText = SetTextColor( lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
ExtTextOutW(lpdis->hDC, lpdis->rcItem.left + fldrWidth,
|
1999-03-13 19:10:43 +01:00
|
|
|
lpdis->rcItem.top + 1, ETO_OPAQUE | ETO_CLIPPED,
|
2000-08-02 01:33:37 +02:00
|
|
|
&(lpdis->rcItem), str, lstrlenW(str), NULL);
|
1999-03-13 19:10:43 +01:00
|
|
|
|
|
|
|
if (lpdis->itemState & ODS_SELECTED)
|
|
|
|
{
|
|
|
|
SetBkColor( lpdis->hDC, oldBk );
|
|
|
|
SetTextColor( lpdis->hDC, oldText );
|
|
|
|
}
|
|
|
|
DrawIcon(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon);
|
2000-08-02 01:33:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_WMMeasureItem [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
LPMEASUREITEMSTRUCT lpmeasure;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
|
1999-03-13 19:10:43 +01:00
|
|
|
lpmeasure->itemHeight = fldrHeight;
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-02 01:33:37 +02:00
|
|
|
* FILEDLG_WMMeasureItem16 [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
LPMEASUREITEMSTRUCT16 lpmeasure;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-13 21:20:09 +01:00
|
|
|
lpmeasure = MapSL(lParam);
|
2000-08-02 01:33:37 +02:00
|
|
|
lpmeasure->itemHeight = fldrHeight;
|
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_WMInitDialog [internal]
|
|
|
|
*/
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
int i, n;
|
2000-08-02 01:33:37 +02:00
|
|
|
WCHAR tmpstr[BUFFILE];
|
|
|
|
LPWSTR pstr, old_pstr;
|
|
|
|
LPOPENFILENAMEW ofn;
|
|
|
|
LFSPRIVATE lfs = (LFSPRIVATE) lParam;
|
|
|
|
|
|
|
|
if (!lfs) return FALSE;
|
|
|
|
SetPropA(hWnd, OFN_PROP, (HANDLE)lfs);
|
|
|
|
lfs->hwnd = hWnd;
|
|
|
|
ofn = lfs->ofnW;
|
|
|
|
|
|
|
|
TRACE("flags=%lx initialdir=%s\n", ofn->Flags, debugstr_w(ofn->lpstrInitialDir));
|
|
|
|
|
|
|
|
SetWindowTextW( hWnd, ofn->lpstrTitle );
|
1999-02-28 21:05:11 +01:00
|
|
|
/* read custom filter information */
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn->lpstrCustomFilter)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
pstr = ofn->lpstrCustomFilter;
|
1999-02-28 21:05:11 +01:00
|
|
|
n = 0;
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("lpstrCustomFilter = %p\n", pstr);
|
1999-02-28 21:05:11 +01:00
|
|
|
while(*pstr)
|
|
|
|
{
|
|
|
|
old_pstr = pstr;
|
2000-08-02 01:33:37 +02:00
|
|
|
i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
|
|
|
|
(LPARAM)(ofn->lpstrCustomFilter) + n );
|
|
|
|
n += lstrlenW(pstr) + 1;
|
|
|
|
pstr += lstrlenW(pstr) + 1;
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("add str=%s associated to %s\n",
|
|
|
|
debugstr_w(old_pstr), debugstr_w(pstr));
|
2000-08-02 01:33:37 +02:00
|
|
|
SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
|
|
|
|
n += lstrlenW(pstr) + 1;
|
|
|
|
pstr += lstrlenW(pstr) + 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* read filter information */
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn->lpstrFilter) {
|
|
|
|
pstr = (LPWSTR) ofn->lpstrFilter;
|
1999-02-28 21:05:11 +01:00
|
|
|
n = 0;
|
|
|
|
while(*pstr) {
|
|
|
|
old_pstr = pstr;
|
2000-08-02 01:33:37 +02:00
|
|
|
i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
|
|
|
|
(LPARAM)(ofn->lpstrFilter + n) );
|
|
|
|
n += lstrlenW(pstr) + 1;
|
|
|
|
pstr += lstrlenW(pstr) + 1;
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("add str=%s associated to %s\n",
|
|
|
|
debugstr_w(old_pstr), debugstr_w(pstr));
|
2000-08-02 01:33:37 +02:00
|
|
|
SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
|
|
|
|
n += lstrlenW(pstr) + 1;
|
|
|
|
pstr += lstrlenW(pstr) + 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* set default filter */
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
|
|
|
|
ofn->nFilterIndex = 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
|
2000-08-02 01:33:37 +02:00
|
|
|
lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
|
|
|
|
(LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("nFilterIndex = %ld, SetText of edt1 to %s\n",
|
2000-08-02 01:33:37 +02:00
|
|
|
ofn->nFilterIndex, debugstr_w(tmpstr));
|
|
|
|
SetDlgItemTextW( hWnd, edt1, tmpstr );
|
1999-02-28 21:05:11 +01:00
|
|
|
/* get drive list */
|
|
|
|
*tmpstr = 0;
|
2000-08-02 01:33:37 +02:00
|
|
|
DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
|
1999-02-28 21:05:11 +01:00
|
|
|
/* read initial directory */
|
2002-05-09 01:15:38 +02:00
|
|
|
/* FIXME: Note that this is now very version-specific (See MSDN description of
|
|
|
|
* the OPENFILENAME structure). For example under 2000/XP any path in the
|
|
|
|
* lpstrFile overrides the lpstrInitialDir, but not under 95/98/ME
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
if (ofn->lpstrInitialDir != NULL)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
1999-12-27 06:24:06 +01:00
|
|
|
int len;
|
2000-08-02 01:33:37 +02:00
|
|
|
lstrcpynW(tmpstr, ofn->lpstrInitialDir, 511);
|
|
|
|
len = lstrlenW(tmpstr);
|
1999-12-27 06:24:06 +01:00
|
|
|
if (len > 0 && tmpstr[len-1] != '\\' && tmpstr[len-1] != ':') {
|
|
|
|
tmpstr[len]='\\';
|
|
|
|
tmpstr[len+1]='\0';
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
*tmpstr = 0;
|
2000-10-23 01:46:21 +02:00
|
|
|
if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
|
1999-02-28 21:05:11 +01:00
|
|
|
*tmpstr = 0;
|
2000-10-23 01:46:21 +02:00
|
|
|
if (!FILEDLG_ScanDir(hWnd, tmpstr))
|
2000-08-02 01:33:37 +02:00
|
|
|
WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
/* select current drive in combo 2, omit missing drives */
|
2000-11-29 19:38:24 +01:00
|
|
|
{
|
|
|
|
char dir[MAX_PATH];
|
|
|
|
char str[4] = "a:\\";
|
|
|
|
GetCurrentDirectoryA( sizeof(dir), dir );
|
|
|
|
for(i = 0, n = -1; i < 26; i++)
|
|
|
|
{
|
|
|
|
str[0] = 'a' + i;
|
2002-05-09 01:15:38 +02:00
|
|
|
if (GetDriveTypeA(str) > DRIVE_NO_ROOT_DIR) n++;
|
2000-11-29 19:38:24 +01:00
|
|
|
if (toupper(str[0]) == toupper(dir[0])) break;
|
|
|
|
}
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
SendDlgItemMessageW(hWnd, cmb2, CB_SETCURSEL, n, 0);
|
|
|
|
if (!(ofn->Flags & OFN_SHOWHELP))
|
1999-02-28 21:05:11 +01:00
|
|
|
ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn->Flags & OFN_HIDEREADONLY)
|
|
|
|
ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
|
|
|
|
if (lfs->hook)
|
|
|
|
return (BOOL) FILEDLG_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_UpdateResult [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* update the displayed file name (with path)
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2000-10-23 01:46:21 +02:00
|
|
|
void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
int lenstr2;
|
|
|
|
LPOPENFILENAMEW ofnW = lfs->ofnW;
|
2000-10-23 01:46:21 +02:00
|
|
|
WCHAR tmpstr2[BUFFILE];
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
GetCurrentDirectoryW(BUFFILE, tmpstr2);
|
2000-11-28 23:40:56 +01:00
|
|
|
lenstr2 = strlenW(tmpstr2);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (lenstr2 > 3)
|
|
|
|
tmpstr2[lenstr2++]='\\';
|
|
|
|
lstrcpynW(tmpstr2+lenstr2, tmpstr, BUFFILE-lenstr2);
|
|
|
|
if (ofnW->lpstrFile)
|
|
|
|
lstrcpynW(ofnW->lpstrFile, tmpstr2, ofnW->nMaxFile);
|
|
|
|
ofnW->nFileOffset = strrchrW(tmpstr2,'\\') - tmpstr2 +1;
|
|
|
|
ofnW->nFileExtension = 0;
|
|
|
|
while(tmpstr2[ofnW->nFileExtension] != '.' && tmpstr2[ofnW->nFileExtension] != '\0')
|
|
|
|
ofnW->nFileExtension++;
|
|
|
|
if (tmpstr2[ofnW->nFileExtension] == '\0')
|
|
|
|
ofnW->nFileExtension = 0;
|
|
|
|
else
|
|
|
|
ofnW->nFileExtension++;
|
|
|
|
/* update the real client structures if any */
|
|
|
|
if (lfs->ofn16)
|
2001-01-02 21:50:34 +01:00
|
|
|
{ /* we have to convert to short (8.3) path */
|
|
|
|
char tmp[1024]; /* MAX_PATHNAME_LEN */
|
|
|
|
LPOPENFILENAME16 ofn16 = lfs->ofn16;
|
|
|
|
char *dest = MapSL(ofn16->lpstrFile);
|
2000-11-28 23:40:56 +01:00
|
|
|
if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
|
2002-10-13 19:52:32 +02:00
|
|
|
tmp, sizeof(tmp), NULL, NULL ))
|
|
|
|
tmp[sizeof(tmp)-1] = 0;
|
2001-01-02 21:50:34 +01:00
|
|
|
GetShortPathNameA(tmp, dest, ofn16->nMaxFile);
|
|
|
|
|
|
|
|
/* the same procedure as every year... */
|
|
|
|
ofn16->nFileOffset = strrchr(dest,'\\') - dest +1;
|
|
|
|
ofn16->nFileExtension = 0;
|
|
|
|
while(dest[ofn16->nFileExtension] != '.' && dest[ofn16->nFileExtension] != '\0')
|
|
|
|
ofn16->nFileExtension++;
|
|
|
|
if (dest[ofn16->nFileExtension] == '\0')
|
|
|
|
ofn16->nFileExtension = 0;
|
|
|
|
else
|
|
|
|
ofn16->nFileExtension++;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
if (lfs->ofnA)
|
|
|
|
{
|
2002-10-13 19:52:32 +02:00
|
|
|
if (ofnW->nMaxFile &&
|
|
|
|
!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
|
2000-11-28 23:40:56 +01:00
|
|
|
lfs->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
|
|
|
|
lfs->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
|
2000-08-02 01:33:37 +02:00
|
|
|
lfs->ofnA->nFileOffset = ofnW->nFileOffset;
|
|
|
|
lfs->ofnA->nFileExtension = ofnW->nFileExtension;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_UpdateFileTitle [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* update the displayed file name (without path)
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
|
|
|
void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs)
|
|
|
|
{
|
|
|
|
LONG lRet;
|
|
|
|
LPOPENFILENAMEW ofnW = lfs->ofnW;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (ofnW->lpstrFileTitle != NULL)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
lRet = SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETCURSEL, 0, 0);
|
|
|
|
SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETTEXT, lRet,
|
|
|
|
(LPARAM)ofnW->lpstrFileTitle );
|
|
|
|
if (lfs->ofn16)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
2000-12-13 21:20:09 +01:00
|
|
|
char *dest = MapSL(lfs->ofn16->lpstrFileTitle);
|
2000-11-28 23:40:56 +01:00
|
|
|
if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
|
|
|
|
dest, ofnW->nMaxFileTitle, NULL, NULL ))
|
|
|
|
dest[ofnW->nMaxFileTitle-1] = 0;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
if (lfs->ofnA)
|
2000-11-28 23:40:56 +01:00
|
|
|
{
|
|
|
|
if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1,
|
|
|
|
lfs->ofnA->lpstrFileTitle, ofnW->nMaxFileTitle, NULL, NULL ))
|
|
|
|
lfs->ofnA->lpstrFileTitle[ofnW->nMaxFileTitle-1] = 0;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-08-19 01:03:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_DirListDblClick [internal]
|
|
|
|
*/
|
2000-10-23 01:46:21 +02:00
|
|
|
static LRESULT FILEDLG_DirListDblClick( LFSPRIVATE lfs )
|
2000-08-19 01:03:44 +02:00
|
|
|
{
|
|
|
|
LONG lRet;
|
2000-10-23 01:46:21 +02:00
|
|
|
HWND hWnd = lfs->hwnd;
|
2000-08-19 01:03:44 +02:00
|
|
|
LPWSTR pstr;
|
|
|
|
WCHAR tmpstr[BUFFILE];
|
|
|
|
|
|
|
|
/* get the raw string (with brackets) */
|
|
|
|
lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0);
|
|
|
|
if (lRet == LB_ERR) return TRUE;
|
|
|
|
pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
|
|
|
|
SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
|
|
|
|
(LPARAM)pstr);
|
|
|
|
strcpyW( tmpstr, pstr );
|
|
|
|
HeapFree(GetProcessHeap(), 0, pstr);
|
|
|
|
/* get the selected directory in tmpstr */
|
|
|
|
if (tmpstr[0] == '[')
|
|
|
|
{
|
|
|
|
tmpstr[lstrlenW(tmpstr) - 1] = 0;
|
|
|
|
strcpyW(tmpstr,tmpstr+1);
|
|
|
|
}
|
|
|
|
strcatW(tmpstr, FILE_bslash);
|
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
FILEDLG_ScanDir(hWnd, tmpstr);
|
2000-08-19 01:03:44 +02:00
|
|
|
/* notify the app */
|
|
|
|
if (lfs->hook)
|
|
|
|
{
|
|
|
|
if (FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, lst2,
|
|
|
|
MAKELONG(lRet,CD_LBSELCHANGE)))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-10-23 01:46:21 +02:00
|
|
|
* FILEDLG_FileListSelect [internal]
|
|
|
|
* called when a new item is picked in the file list
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-10-23 01:46:21 +02:00
|
|
|
static LRESULT FILEDLG_FileListSelect( LFSPRIVATE lfs )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-10-23 01:46:21 +02:00
|
|
|
LONG lRet;
|
|
|
|
HWND hWnd = lfs->hwnd;
|
|
|
|
LPWSTR pstr;
|
|
|
|
|
|
|
|
lRet = SendDlgItemMessageW(hWnd, lst1, LB_GETCURSEL16, 0, 0);
|
|
|
|
if (lRet == LB_ERR)
|
|
|
|
return TRUE;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
/* set the edit control to the choosen file */
|
|
|
|
if ((pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC)))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-10-23 01:46:21 +02:00
|
|
|
SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet,
|
|
|
|
(LPARAM)pstr);
|
|
|
|
SetDlgItemTextW( hWnd, edt1, pstr );
|
|
|
|
HeapFree(GetProcessHeap(), 0, pstr);
|
|
|
|
}
|
|
|
|
if (lfs->hook)
|
|
|
|
{
|
|
|
|
FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, lst1,
|
|
|
|
MAKELONG(lRet,CD_LBSELCHANGE));
|
|
|
|
}
|
|
|
|
/* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD,
|
|
|
|
CD_LBSELNOITEMS */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_TestPath [internal]
|
|
|
|
* before accepting the file name, test if it includes wild cards
|
|
|
|
* tries to scan the directory and returns TRUE if no error.
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG_TestPath( LFSPRIVATE lfs, LPWSTR path )
|
|
|
|
{
|
|
|
|
HWND hWnd = lfs->hwnd;
|
|
|
|
LPWSTR pBeginFileName, pstr2;
|
|
|
|
WCHAR tmpstr2[BUFFILE];
|
|
|
|
|
|
|
|
pBeginFileName = strrchrW(path, '\\');
|
|
|
|
if (pBeginFileName == NULL)
|
|
|
|
pBeginFileName = strrchrW(path, ':');
|
|
|
|
|
|
|
|
if (strchrW(path,'*') != NULL || strchrW(path,'?') != NULL)
|
|
|
|
{
|
|
|
|
/* edit control contains wildcards */
|
|
|
|
if (pBeginFileName != NULL)
|
|
|
|
{
|
|
|
|
lstrcpynW(tmpstr2, pBeginFileName + 1, BUFFILE);
|
|
|
|
*(pBeginFileName + 1) = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
else
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-10-23 01:46:21 +02:00
|
|
|
strcpyW(tmpstr2, path);
|
|
|
|
*path = 0;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
TRACE("path=%s, tmpstr2=%s\n", debugstr_w(path), debugstr_w(tmpstr2));
|
|
|
|
SetDlgItemTextW( hWnd, edt1, tmpstr2 );
|
|
|
|
FILEDLG_ScanDir(hWnd, path);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no wildcards, we might have a directory or a filename */
|
|
|
|
/* try appending a wildcard and reading the directory */
|
|
|
|
|
|
|
|
pstr2 = path + lstrlenW(path);
|
|
|
|
if (pBeginFileName == NULL || *(pBeginFileName + 1) != 0)
|
|
|
|
strcatW(path, FILE_bslash);
|
|
|
|
|
|
|
|
/* if ScanDir succeeds, we have changed the directory */
|
|
|
|
if (FILEDLG_ScanDir(hWnd, path))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* if not, this must be a filename */
|
|
|
|
|
|
|
|
*pstr2 = 0; /* remove the wildcard added before */
|
|
|
|
|
|
|
|
if (pBeginFileName != NULL)
|
|
|
|
{
|
|
|
|
/* strip off the pathname */
|
|
|
|
*pBeginFileName = 0;
|
|
|
|
SetDlgItemTextW( hWnd, edt1, pBeginFileName + 1 );
|
|
|
|
|
2001-01-02 21:50:34 +01:00
|
|
|
lstrcpynW(tmpstr2, pBeginFileName + 1, sizeof(tmpstr2)/sizeof(WCHAR) );
|
2000-10-23 01:46:21 +02:00
|
|
|
/* Should we MessageBox() if this fails? */
|
|
|
|
if (!FILEDLG_ScanDir(hWnd, path))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
strcpyW(path, tmpstr2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetDlgItemTextW( hWnd, edt1, path );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_Validate [internal]
|
|
|
|
* called on: click Ok button, Enter in edit, DoubleClick in file list
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG_Validate( LFSPRIVATE lfs, LPWSTR path, UINT control, INT itemIndex,
|
|
|
|
BOOL internalUse )
|
|
|
|
{
|
|
|
|
LONG lRet;
|
|
|
|
HWND hWnd = lfs->hwnd;
|
|
|
|
OPENFILENAMEW ofnsav;
|
|
|
|
LPOPENFILENAMEW ofnW = lfs->ofnW;
|
|
|
|
WCHAR filename[BUFFILE];
|
|
|
|
|
|
|
|
ofnsav = *ofnW; /* for later restoring */
|
|
|
|
|
|
|
|
/* get current file name */
|
|
|
|
if (path)
|
2001-01-02 21:50:34 +01:00
|
|
|
lstrcpynW(filename, path, sizeof(filename)/sizeof(WCHAR));
|
2000-10-23 01:46:21 +02:00
|
|
|
else
|
2001-01-02 21:50:34 +01:00
|
|
|
GetDlgItemTextW( hWnd, edt1, filename, sizeof(filename)/sizeof(WCHAR));
|
2000-10-23 01:46:21 +02:00
|
|
|
|
|
|
|
/* if we did not click in file list to get there */
|
|
|
|
if (control != lst1)
|
|
|
|
{
|
|
|
|
if (!FILEDLG_TestPath( lfs, filename) )
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
FILEDLG_UpdateResult(lfs, filename);
|
|
|
|
|
|
|
|
if (internalUse)
|
|
|
|
{ /* called internally after a change in a combo */
|
|
|
|
if (lfs->hook)
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
FILEDLG_CallWindowProc(lfs, lfs->lbselchstring, control,
|
2000-10-23 01:46:21 +02:00
|
|
|
MAKELONG(itemIndex,CD_LBSELCHANGE));
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILEDLG_UpdateFileTitle(lfs);
|
|
|
|
if (lfs->hook)
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
lRet = (BOOL)FILEDLG_CallWindowProc(lfs, lfs->fileokstring,
|
|
|
|
0, lfs->lParam );
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lRet)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2000-10-23 01:46:21 +02:00
|
|
|
*ofnW = ofnsav; /* restore old state */
|
|
|
|
return FALSE;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
|
|
|
if ((ofnW->Flags & OFN_ALLOWMULTISELECT) && (ofnW->Flags & OFN_EXPLORER))
|
|
|
|
{
|
|
|
|
if (ofnW->lpstrFile)
|
|
|
|
{
|
|
|
|
LPWSTR str = (LPWSTR)ofnW->lpstrFile;
|
|
|
|
LPWSTR ptr = strrchrW(str, '\\');
|
2000-08-02 01:33:37 +02:00
|
|
|
str[lstrlenW(str) + 1] = '\0';
|
1999-06-22 21:02:52 +02:00
|
|
|
*ptr = 0;
|
2000-10-23 01:46:21 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-10-23 01:46:21 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-10-23 01:46:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_DiskChange [internal]
|
|
|
|
* called when a new item is picked in the disk selection combo
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG_DiskChange( LFSPRIVATE lfs )
|
|
|
|
{
|
|
|
|
LONG lRet;
|
|
|
|
HWND hWnd = lfs->hwnd;
|
|
|
|
LPWSTR pstr;
|
|
|
|
WCHAR diskname[BUFFILE];
|
|
|
|
|
|
|
|
FILEDLG_StripEditControl(hWnd);
|
|
|
|
lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
|
|
|
|
if (lRet == LB_ERR)
|
|
|
|
return 0;
|
|
|
|
pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC);
|
|
|
|
SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet,
|
|
|
|
(LPARAM)pstr);
|
|
|
|
wsprintfW(diskname, FILE_specc, pstr[2]);
|
2002-06-01 01:06:46 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pstr);
|
2000-10-23 01:46:21 +02:00
|
|
|
|
|
|
|
return FILEDLG_Validate( lfs, diskname, cmb2, lRet, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_FileTypeChange [internal]
|
|
|
|
* called when a new item is picked in the file type combo
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG_FileTypeChange( LFSPRIVATE lfs )
|
|
|
|
{
|
|
|
|
LONG lRet;
|
|
|
|
WCHAR diskname[BUFFILE];
|
|
|
|
LPWSTR pstr;
|
|
|
|
|
|
|
|
diskname[0] = 0;
|
|
|
|
|
|
|
|
lRet = SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETCURSEL, 0, 0);
|
|
|
|
if (lRet == LB_ERR)
|
|
|
|
return TRUE;
|
|
|
|
pstr = (LPWSTR)SendDlgItemMessageW(lfs->hwnd, cmb1, CB_GETITEMDATA, lRet, 0);
|
|
|
|
TRACE("Selected filter : %s\n", debugstr_w(pstr));
|
|
|
|
SetDlgItemTextW( lfs->hwnd, edt1, pstr );
|
|
|
|
|
|
|
|
return FILEDLG_Validate( lfs, NULL, cmb1, lRet, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_WMCommand [internal]
|
|
|
|
*/
|
|
|
|
static LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
|
2002-06-01 01:06:46 +02:00
|
|
|
UINT control, LFSPRIVATE lfs )
|
2000-10-23 01:46:21 +02:00
|
|
|
{
|
|
|
|
switch (control)
|
|
|
|
{
|
|
|
|
case lst1: /* file list */
|
|
|
|
FILEDLG_StripEditControl(hWnd);
|
|
|
|
if (notification == LBN_DBLCLK)
|
|
|
|
{
|
|
|
|
if (FILEDLG_Validate( lfs, NULL, control, 0, FALSE ))
|
|
|
|
EndDialog(hWnd, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (notification == LBN_SELCHANGE)
|
|
|
|
return FILEDLG_FileListSelect( lfs );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case lst2: /* directory list */
|
|
|
|
FILEDLG_StripEditControl(hWnd);
|
|
|
|
if (notification == LBN_DBLCLK)
|
|
|
|
return FILEDLG_DirListDblClick( lfs );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cmb1: /* file type drop list */
|
2002-06-01 01:06:46 +02:00
|
|
|
if (notification == CBN_SELCHANGE)
|
2000-10-23 01:46:21 +02:00
|
|
|
return FILEDLG_FileTypeChange( lfs );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case chx1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case pshHelp:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cmb2: /* disk dropdown combo */
|
|
|
|
if (notification == CBN_SELCHANGE)
|
|
|
|
return FILEDLG_DiskChange( lfs );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDOK:
|
|
|
|
if (FILEDLG_Validate( lfs, NULL, control, 0, FALSE ))
|
|
|
|
EndDialog(hWnd, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hWnd, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDABORT: /* can be sent by the hook procedure */
|
|
|
|
EndDialog(hWnd, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FILEDLG_MapDrawItemStruct [internal]
|
|
|
|
* map a 16 bits drawitem struct to 32
|
|
|
|
*/
|
|
|
|
void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdis)
|
|
|
|
{
|
|
|
|
lpdis->CtlType = lpdis16->CtlType;
|
|
|
|
lpdis->CtlID = lpdis16->CtlID;
|
|
|
|
lpdis->itemID = lpdis16->itemID;
|
|
|
|
lpdis->itemAction = lpdis16->itemAction;
|
|
|
|
lpdis->itemState = lpdis16->itemState;
|
2002-09-06 22:40:42 +02:00
|
|
|
lpdis->hwndItem = HWND_32(lpdis16->hwndItem);
|
2002-11-01 02:50:06 +01:00
|
|
|
lpdis->hDC = HDC_32(lpdis16->hDC);
|
2000-08-02 01:33:37 +02:00
|
|
|
lpdis->rcItem.right = lpdis16->rcItem.right;
|
|
|
|
lpdis->rcItem.left = lpdis16->rcItem.left;
|
|
|
|
lpdis->rcItem.top = lpdis16->rcItem.top;
|
|
|
|
lpdis->rcItem.bottom = lpdis16->rcItem.bottom;
|
|
|
|
lpdis->itemData = lpdis16->itemData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* FILEDLG_MapStringPairsToW [internal]
|
|
|
|
* map string pairs to Unicode
|
|
|
|
*/
|
2002-05-09 01:15:38 +02:00
|
|
|
static LPWSTR FILEDLG_MapStringPairsToW(LPCSTR strA, UINT size)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
|
|
|
LPCSTR s;
|
2000-11-28 23:40:56 +01:00
|
|
|
LPWSTR x;
|
|
|
|
int n, len;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
s = strA;
|
|
|
|
while (*s)
|
|
|
|
s = s+strlen(s)+1;
|
|
|
|
s++;
|
2002-05-09 01:15:38 +02:00
|
|
|
n = s + 1 - strA; /* Don't forget the other \0 */
|
2000-08-02 01:33:37 +02:00
|
|
|
if (n < size) n = size;
|
|
|
|
|
2000-11-28 23:40:56 +01:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 );
|
|
|
|
x = HeapAlloc(GetProcessHeap(),0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, strA, n, x, len );
|
|
|
|
return x;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* FILEDLG_DupToW [internal]
|
|
|
|
* duplicates an Ansi string to unicode, with a buffer size
|
|
|
|
*/
|
2000-11-29 20:01:07 +01:00
|
|
|
LPWSTR FILEDLG_DupToW(LPCSTR str, DWORD size)
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2000-11-28 23:40:56 +01:00
|
|
|
LPWSTR strW = NULL;
|
2000-11-29 20:01:07 +01:00
|
|
|
if (str && (size > 0))
|
2000-08-02 01:33:37 +02:00
|
|
|
{
|
2000-11-29 20:01:07 +01:00
|
|
|
strW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
|
|
|
if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size );
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2000-11-28 23:40:56 +01:00
|
|
|
return strW;
|
2000-08-02 01:33:37 +02:00
|
|
|
}
|
2000-11-28 23:40:56 +01:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* FILEDLG_MapOfnStructA [internal]
|
|
|
|
* map a 32 bits Ansi structure to an Unicode one
|
|
|
|
*/
|
|
|
|
void FILEDLG_MapOfnStructA(LPOPENFILENAMEA ofnA, LPOPENFILENAMEW ofnW, BOOL open)
|
|
|
|
{
|
|
|
|
LPCSTR str;
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING usBuffer;
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
ofnW->lStructSize = sizeof(OPENFILENAMEW);
|
|
|
|
ofnW->hwndOwner = ofnA->hwndOwner;
|
|
|
|
ofnW->hInstance = ofnA->hInstance;
|
|
|
|
if (ofnA->lpstrFilter)
|
|
|
|
ofnW->lpstrFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrFilter, 0);
|
|
|
|
|
|
|
|
if ((ofnA->lpstrCustomFilter) && (*(ofnA->lpstrCustomFilter)))
|
|
|
|
ofnW->lpstrCustomFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrCustomFilter, ofnA->nMaxCustFilter);
|
|
|
|
ofnW->nMaxCustFilter = ofnA->nMaxCustFilter;
|
|
|
|
ofnW->nFilterIndex = ofnA->nFilterIndex;
|
2000-11-29 20:01:07 +01:00
|
|
|
ofnW->nMaxFile = ofnA->nMaxFile;
|
|
|
|
ofnW->lpstrFile = FILEDLG_DupToW(ofnA->lpstrFile, ofnW->nMaxFile);
|
|
|
|
ofnW->nMaxFileTitle = ofnA->nMaxFileTitle;
|
|
|
|
ofnW->lpstrFileTitle = FILEDLG_DupToW(ofnA->lpstrFileTitle, ofnW->nMaxFileTitle);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofnA->lpstrInitialDir)
|
2003-01-24 00:07:38 +01:00
|
|
|
{
|
|
|
|
RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrInitialDir);
|
|
|
|
ofnW->lpstrInitialDir = usBuffer.Buffer;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofnA->lpstrTitle)
|
|
|
|
str = ofnA->lpstrTitle;
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-08-02 01:33:37 +02:00
|
|
|
/* Allocates default title (FIXME : get it from resource) */
|
|
|
|
str = open ? defaultopen:defaultsave;
|
2003-01-24 00:07:38 +01:00
|
|
|
RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpstrTitle);
|
|
|
|
ofnW->lpstrTitle = usBuffer.Buffer;
|
2000-08-02 01:33:37 +02:00
|
|
|
ofnW->Flags = ofnA->Flags;
|
|
|
|
ofnW->nFileOffset = ofnA->nFileOffset;
|
|
|
|
ofnW->nFileExtension = ofnA->nFileExtension;
|
2000-11-29 20:01:07 +01:00
|
|
|
ofnW->lpstrDefExt = FILEDLG_DupToW(ofnA->lpstrDefExt, 3);
|
2000-08-02 01:33:37 +02:00
|
|
|
if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName))
|
|
|
|
{
|
|
|
|
if (HIWORD(ofnA->lpTemplateName))
|
2003-01-24 00:07:38 +01:00
|
|
|
{
|
|
|
|
RtlCreateUnicodeStringFromAsciiz (&usBuffer,ofnA->lpTemplateName);
|
|
|
|
ofnW->lpTemplateName = usBuffer.Buffer;
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
else /* numbered resource */
|
|
|
|
ofnW->lpTemplateName = (LPWSTR) ofnA->lpTemplateName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* FILEDLG_MapOfnStruct16 [internal]
|
|
|
|
* map a 16 bits structure to an Unicode one
|
|
|
|
*/
|
|
|
|
void FILEDLG_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofnA;
|
|
|
|
/* first convert to linear pointers */
|
|
|
|
memset(&ofnA, 0, sizeof(OPENFILENAMEA));
|
|
|
|
ofnA.lStructSize = sizeof(OPENFILENAMEA);
|
2002-09-06 22:40:42 +02:00
|
|
|
ofnA.hwndOwner = HWND_32(ofn16->hwndOwner);
|
2002-11-22 00:55:10 +01:00
|
|
|
ofnA.hInstance = HINSTANCE_32(ofn16->hInstance);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn16->lpstrFilter)
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpstrFilter = MapSL(ofn16->lpstrFilter);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (ofn16->lpstrCustomFilter)
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpstrCustomFilter = MapSL(ofn16->lpstrCustomFilter);
|
2000-08-02 01:33:37 +02:00
|
|
|
ofnA.nMaxCustFilter = ofn16->nMaxCustFilter;
|
|
|
|
ofnA.nFilterIndex = ofn16->nFilterIndex;
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpstrFile = MapSL(ofn16->lpstrFile);
|
2000-08-02 01:33:37 +02:00
|
|
|
ofnA.nMaxFile = ofn16->nMaxFile;
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpstrFileTitle = MapSL(ofn16->lpstrFileTitle);
|
2000-08-02 01:33:37 +02:00
|
|
|
ofnA.nMaxFileTitle = ofn16->nMaxFileTitle;
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpstrInitialDir = MapSL(ofn16->lpstrInitialDir);
|
|
|
|
ofnA.lpstrTitle = MapSL(ofn16->lpstrTitle);
|
2000-08-02 01:33:37 +02:00
|
|
|
ofnA.Flags = ofn16->Flags;
|
|
|
|
ofnA.nFileOffset = ofn16->nFileOffset;
|
|
|
|
ofnA.nFileExtension = ofn16->nFileExtension;
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpstrDefExt = MapSL(ofn16->lpstrDefExt);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (HIWORD(ofn16->lpTemplateName))
|
2000-12-13 21:20:09 +01:00
|
|
|
ofnA.lpTemplateName = MapSL(ofn16->lpTemplateName);
|
2000-08-02 01:33:37 +02:00
|
|
|
else
|
|
|
|
ofnA.lpTemplateName = (LPSTR) ofn16->lpTemplateName; /* ressource number */
|
|
|
|
/* now calls the 32 bits Ansi to Unicode version to complete the job */
|
|
|
|
FILEDLG_MapOfnStructA(&ofnA, ofnW, open);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* FILEDLG_DestroyPrivate [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* destroys the private object
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
|
|
|
void FILEDLG_DestroyPrivate(LFSPRIVATE lfs)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
if (!lfs) return;
|
|
|
|
hwnd = lfs->hwnd;
|
|
|
|
/* free resources for a 16 bits dialog */
|
|
|
|
if (lfs->hResource16) FreeResource16(lfs->hResource16);
|
|
|
|
if (lfs->hGlobal16)
|
|
|
|
{
|
|
|
|
GlobalUnlock16(lfs->hGlobal16);
|
|
|
|
GlobalFree16(lfs->hGlobal16);
|
|
|
|
}
|
|
|
|
/* if ofnW has been allocated, have to free everything in it */
|
|
|
|
if (lfs->ofn16 || lfs->ofnA)
|
|
|
|
{
|
|
|
|
LPOPENFILENAMEW ofnW = lfs->ofnW;
|
|
|
|
if (ofnW->lpstrFilter) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter);
|
|
|
|
if (ofnW->lpstrCustomFilter) HeapFree(GetProcessHeap(), 0, ofnW->lpstrCustomFilter);
|
|
|
|
if (ofnW->lpstrFile) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFile);
|
|
|
|
if (ofnW->lpstrFileTitle) HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
|
|
|
|
if (ofnW->lpstrInitialDir) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
|
|
|
|
if (ofnW->lpstrTitle) HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
|
|
|
|
if ((ofnW->lpTemplateName) && (HIWORD(ofnW->lpTemplateName)))
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ofnW);
|
|
|
|
}
|
|
|
|
TRACE("destroying private allocation %p\n", lfs);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lfs);
|
|
|
|
RemovePropA(hwnd, OFN_PROP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* FILEDLG_AllocPrivate [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* allocate a private object to hold 32 bits Unicode
|
2000-08-02 01:33:37 +02:00
|
|
|
* structure that will be used throughtout the calls, while
|
|
|
|
* keeping available the original structures and a few variables
|
|
|
|
* On entry : type = dialog procedure type (16,32A,32W)
|
|
|
|
* dlgType = dialog type (open or save)
|
|
|
|
*/
|
|
|
|
LFSPRIVATE FILEDLG_AllocPrivate(LPARAM lParam, int type, UINT dlgType)
|
|
|
|
{
|
|
|
|
LFSPRIVATE lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct FSPRIVATE));
|
|
|
|
LFSPRIVATE ret;
|
|
|
|
TRACE("alloc private buf %p\n", lfs);
|
|
|
|
if (!lfs) return NULL;
|
|
|
|
lfs->hook = FALSE;
|
|
|
|
lfs->lParam = lParam;
|
|
|
|
if (dlgType == OPEN_DIALOG)
|
|
|
|
lfs->open = TRUE;
|
|
|
|
else
|
|
|
|
lfs->open = FALSE;
|
2001-01-22 03:13:58 +01:00
|
|
|
lfs->lbselchstring = RegisterWindowMessageA(LBSELCHSTRINGA);
|
|
|
|
lfs->fileokstring = RegisterWindowMessageA(FILEOKSTRINGA);
|
2000-08-02 01:33:37 +02:00
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case LFS16:
|
2000-12-13 21:20:09 +01:00
|
|
|
lfs->ofn16 = MapSL(lParam);
|
2000-08-02 01:33:37 +02:00
|
|
|
if (lfs->ofn16->Flags & OFN_ENABLEHOOK)
|
|
|
|
if (lfs->ofn16->lpfnHook)
|
|
|
|
lfs->hook = TRUE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFS32A:
|
|
|
|
lfs->ofnA = (LPOPENFILENAMEA) lParam;
|
|
|
|
if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
|
|
|
|
if (lfs->ofnA->lpfnHook)
|
|
|
|
lfs->hook = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFS32W:
|
|
|
|
lfs->ofnW = (LPOPENFILENAMEW) lParam;
|
|
|
|
if (lfs->ofnW->Flags & OFN_ENABLEHOOK)
|
|
|
|
if (lfs->ofnW->lpfnHook)
|
|
|
|
lfs->hook = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ret = lfs;
|
|
|
|
if (!lfs->ofnW)
|
|
|
|
{ /* this structure is needed internally, so create it */
|
|
|
|
lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPENFILENAMEW));
|
|
|
|
if (lfs->ofnW)
|
|
|
|
{
|
|
|
|
if (lfs->ofn16)
|
|
|
|
FILEDLG_MapOfnStruct16(lfs->ofn16, lfs->ofnW, lfs->open);
|
|
|
|
if (lfs->ofnA)
|
|
|
|
FILEDLG_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
2000-08-02 01:33:37 +02:00
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
if (lfs->ofn16)
|
|
|
|
{
|
|
|
|
if (!Get16BitsTemplate(lfs)) ret = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (!Get32BitsTemplate(lfs)) ret = NULL;
|
|
|
|
if (!ret) FILEDLG_DestroyPrivate(lfs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetFileName31A [internal]
|
|
|
|
*
|
|
|
|
* Creates a win31 style dialog box for the user to select a file to open/save.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI GetFileName31A(
|
2000-08-02 01:33:37 +02:00
|
|
|
LPOPENFILENAMEA lpofn, /* addess of structure with data*/
|
|
|
|
UINT dlgType /* type dialogue : open/save */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HINSTANCE hInst;
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
LFSPRIVATE lfs;
|
|
|
|
|
|
|
|
if (!lpofn || !FileDlg_Init()) return FALSE;
|
|
|
|
|
|
|
|
lfs = FILEDLG_AllocPrivate((LPARAM) lpofn, LFS32A, dlgType);
|
|
|
|
if (lfs)
|
|
|
|
{
|
2002-11-22 00:55:10 +01:00
|
|
|
hInst = (HINSTANCE)GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
|
2002-06-01 01:06:46 +02:00
|
|
|
bRet = DialogBoxIndirectParamA( hInst, lfs->template, lpofn->hwndOwner,
|
2002-10-31 02:04:39 +01:00
|
|
|
FileOpenDlgProc, (LPARAM)lfs);
|
2000-08-02 01:33:37 +02:00
|
|
|
FILEDLG_DestroyPrivate(lfs);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("return lpstrFile='%s' !\n", lpofn->lpstrFile);
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetFileName31W [internal]
|
|
|
|
*
|
|
|
|
* Creates a win31 style dialog box for the user to select a file to open/save
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI GetFileName31W(
|
2000-08-02 01:33:37 +02:00
|
|
|
LPOPENFILENAMEW lpofn, /* addess of structure with data*/
|
|
|
|
UINT dlgType /* type dialogue : open/save */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HINSTANCE hInst;
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
LFSPRIVATE lfs;
|
|
|
|
|
|
|
|
if (!lpofn || !FileDlg_Init()) return FALSE;
|
|
|
|
|
|
|
|
lfs = FILEDLG_AllocPrivate((LPARAM) lpofn, LFS32W, dlgType);
|
|
|
|
if (lfs)
|
|
|
|
{
|
2002-11-22 00:55:10 +01:00
|
|
|
hInst = (HINSTANCE)GetWindowLongA( lpofn->hwndOwner, GWL_HINSTANCE );
|
2002-06-01 01:06:46 +02:00
|
|
|
bRet = DialogBoxIndirectParamW( hInst, lfs->template, lpofn->hwndOwner,
|
2002-10-31 02:04:39 +01:00
|
|
|
FileOpenDlgProc, (LPARAM)lfs);
|
2000-08-02 01:33:37 +02:00
|
|
|
FILEDLG_DestroyPrivate(lfs);
|
|
|
|
}
|
|
|
|
|
2001-05-11 22:03:40 +02:00
|
|
|
TRACE("return lpstrFile=%s !\n", debugstr_w(lpofn->lpstrFile));
|
2000-08-02 01:33:37 +02:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------ Dialog procedures ---------------------- */
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FileOpenDlgProc (COMMDLG.6)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FileOpenDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPARAM lParam)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hWnd = HWND_32(hWnd16);
|
2000-08-02 01:33:37 +02:00
|
|
|
LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
|
|
|
|
DRAWITEMSTRUCT dis;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
|
|
|
|
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
|
|
|
|
{
|
|
|
|
LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lRet)
|
2000-08-02 01:33:37 +02:00
|
|
|
return lRet; /* else continue message processing */
|
|
|
|
}
|
|
|
|
switch (wMsg)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2000-08-02 01:33:37 +02:00
|
|
|
return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_MEASUREITEM:
|
2002-09-06 22:40:42 +02:00
|
|
|
return FILEDLG_WMMeasureItem16(hWnd16, wParam, lParam);
|
2000-08-02 01:33:37 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_DRAWITEM:
|
2000-12-13 21:20:09 +01:00
|
|
|
FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis);
|
2000-08-02 01:33:37 +02:00
|
|
|
return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE, &dis);
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_COMMAND:
|
2000-08-02 01:33:37 +02:00
|
|
|
return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam),wParam, lfs);
|
1999-02-28 21:05:11 +01:00
|
|
|
#if 0
|
|
|
|
case WM_CTLCOLOR:
|
2000-08-02 01:33:37 +02:00
|
|
|
SetBkColor((HDC16)wParam, 0x00C0C0C0);
|
|
|
|
switch (HIWORD(lParam))
|
|
|
|
{
|
|
|
|
case CTLCOLOR_BTN:
|
|
|
|
SetTextColor((HDC16)wParam, 0x00000000);
|
|
|
|
return hGRAYBrush;
|
1999-02-28 21:05:11 +01:00
|
|
|
case CTLCOLOR_STATIC:
|
2000-08-02 01:33:37 +02:00
|
|
|
SetTextColor((HDC16)wParam, 0x00000000);
|
|
|
|
return hGRAYBrush;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FileSaveDlgProc (COMMDLG.7)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FileSaveDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hWnd = HWND_32(hWnd16);
|
2000-08-02 01:33:37 +02:00
|
|
|
LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
|
|
|
|
DRAWITEMSTRUCT dis;
|
|
|
|
|
|
|
|
TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
|
|
|
|
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
LRESULT lRet;
|
|
|
|
lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lRet)
|
1999-02-28 21:05:11 +01:00
|
|
|
return lRet; /* else continue message processing */
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
switch (wMsg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_MEASUREITEM:
|
2002-09-06 22:40:42 +02:00
|
|
|
return FILEDLG_WMMeasureItem16(hWnd16, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_DRAWITEM:
|
2000-12-13 21:20:09 +01:00
|
|
|
FILEDLG_MapDrawItemStruct(MapSL(lParam), &dis);
|
2000-08-02 01:33:37 +02:00
|
|
|
return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE, &dis);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
2000-08-02 01:33:37 +02:00
|
|
|
return FILEDLG_WMCommand(hWnd, lParam, HIWORD(lParam), wParam, lfs);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/*
|
|
|
|
case WM_CTLCOLOR:
|
|
|
|
SetBkColor((HDC16)wParam, 0x00C0C0C0);
|
|
|
|
switch (HIWORD(lParam))
|
|
|
|
{
|
|
|
|
case CTLCOLOR_BTN:
|
|
|
|
SetTextColor((HDC16)wParam, 0x00000000);
|
|
|
|
return hGRAYBrush;
|
|
|
|
case CTLCOLOR_STATIC:
|
|
|
|
SetTextColor((HDC16)wParam, 0x00000000);
|
|
|
|
return hGRAYBrush;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-08-02 01:33:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FileOpenDlgProc [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* Used for open and save, in fact.
|
2000-08-02 01:33:37 +02:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
static INT_PTR CALLBACK FileOpenDlgProc(HWND hWnd, UINT wMsg,
|
2000-08-02 01:33:37 +02:00
|
|
|
WPARAM wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
LFSPRIVATE lfs = (LFSPRIVATE)GetPropA(hWnd,OFN_PROP);
|
|
|
|
|
|
|
|
TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
|
|
|
|
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
|
|
|
|
{
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR lRet;
|
|
|
|
lRet = (INT_PTR)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lRet)
|
2000-08-02 01:33:37 +02:00
|
|
|
return lRet; /* else continue message processing */
|
|
|
|
}
|
|
|
|
switch (wMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_MEASUREITEM:
|
|
|
|
return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
return FILEDLG_WMDrawItem(hWnd, wParam, lParam, !lfs->open, (DRAWITEMSTRUCT *)lParam);
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
return FILEDLG_WMCommand(hWnd, lParam, HIWORD(wParam), LOWORD(wParam), lfs);
|
|
|
|
#if 0
|
|
|
|
case WM_CTLCOLOR:
|
|
|
|
SetBkColor((HDC16)wParam, 0x00C0C0C0);
|
|
|
|
switch (HIWORD(lParam))
|
|
|
|
{
|
|
|
|
case CTLCOLOR_BTN:
|
|
|
|
SetTextColor((HDC16)wParam, 0x00000000);
|
|
|
|
return hGRAYBrush;
|
|
|
|
case CTLCOLOR_STATIC:
|
|
|
|
SetTextColor((HDC16)wParam, 0x00000000);
|
|
|
|
return hGRAYBrush;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* ------------------ APIs ---------------------- */
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* GetOpenFileName (COMMDLG.1)
|
2000-08-02 01:33:37 +02:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to open.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success: user selected a valid file
|
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* unknown, there are some FIXME's left.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL16 WINAPI GetOpenFileName16(
|
2000-12-02 00:58:28 +01:00
|
|
|
SEGPTR ofn /* [in/out] address of structure with data*/
|
2000-08-02 01:33:37 +02:00
|
|
|
)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2002-11-22 00:55:10 +01:00
|
|
|
HINSTANCE16 hInst;
|
2000-08-02 01:33:37 +02:00
|
|
|
BOOL bRet = FALSE;
|
2000-12-13 21:20:09 +01:00
|
|
|
LPOPENFILENAME16 lpofn = MapSL(ofn);
|
2000-08-02 01:33:37 +02:00
|
|
|
LFSPRIVATE lfs;
|
|
|
|
FARPROC16 ptr;
|
|
|
|
|
|
|
|
if (!lpofn || !FileDlg_Init()) return FALSE;
|
|
|
|
|
|
|
|
lfs = FILEDLG_AllocPrivate((LPARAM) ofn, LFS16, OPEN_DIALOG);
|
|
|
|
if (lfs)
|
|
|
|
{
|
2002-11-22 00:55:10 +01:00
|
|
|
hInst = GetWindowWord( HWND_32(lpofn->hwndOwner), GWL_HINSTANCE );
|
2000-11-27 22:54:01 +01:00
|
|
|
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 6);
|
2002-06-01 01:06:46 +02:00
|
|
|
bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
|
2002-10-31 02:04:39 +01:00
|
|
|
(DLGPROC16) ptr, (LPARAM) lfs);
|
2000-08-02 01:33:37 +02:00
|
|
|
FILEDLG_DestroyPrivate(lfs);
|
|
|
|
}
|
|
|
|
|
2000-12-13 21:20:09 +01:00
|
|
|
TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
|
2000-08-02 01:33:37 +02:00
|
|
|
return bRet;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* GetSaveFileName (COMMDLG.2)
|
2000-08-02 01:33:37 +02:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to save.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success: user enters a valid file
|
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* unknown. There are some FIXME's left.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL16 WINAPI GetSaveFileName16(
|
2000-12-02 00:58:28 +01:00
|
|
|
SEGPTR ofn /* [in/out] addess of structure with data*/
|
2000-08-02 01:33:37 +02:00
|
|
|
)
|
|
|
|
{
|
2002-11-22 00:55:10 +01:00
|
|
|
HINSTANCE16 hInst;
|
2000-08-02 01:33:37 +02:00
|
|
|
BOOL bRet = FALSE;
|
2000-12-13 21:20:09 +01:00
|
|
|
LPOPENFILENAME16 lpofn = MapSL(ofn);
|
2000-08-02 01:33:37 +02:00
|
|
|
LFSPRIVATE lfs;
|
|
|
|
FARPROC16 ptr;
|
|
|
|
|
|
|
|
if (!lpofn || !FileDlg_Init()) return FALSE;
|
|
|
|
|
|
|
|
lfs = FILEDLG_AllocPrivate((LPARAM) ofn, LFS16, SAVE_DIALOG);
|
|
|
|
if (lfs)
|
|
|
|
{
|
2002-11-22 00:55:10 +01:00
|
|
|
hInst = GetWindowWord( HWND_32(lpofn->hwndOwner), GWL_HINSTANCE );
|
2000-11-27 22:54:01 +01:00
|
|
|
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 7);
|
2002-06-01 01:06:46 +02:00
|
|
|
bRet = DialogBoxIndirectParam16( hInst, lfs->hDlgTmpl16, lpofn->hwndOwner,
|
2002-10-31 02:04:39 +01:00
|
|
|
(DLGPROC16) ptr, (LPARAM) lfs);
|
2000-08-02 01:33:37 +02:00
|
|
|
FILEDLG_DestroyPrivate(lfs);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
2000-12-13 21:20:09 +01:00
|
|
|
TRACE("return lpstrFile='%s' !\n", (char *)MapSL(lpofn->lpstrFile));
|
2000-08-02 01:33:37 +02:00
|
|
|
return bRet;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-08-02 01:33:37 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetOpenFileNameA (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to open.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetOpenFileNameA(
|
2000-12-02 00:58:28 +01:00
|
|
|
LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-11-30 20:07:09 +01:00
|
|
|
BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
|
2001-03-03 01:18:14 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(0);
|
2000-02-25 21:36:42 +01:00
|
|
|
/* some flags don't allow to match the TWEAK_WineLook */
|
|
|
|
if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
|
|
|
|
{
|
|
|
|
newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newlook)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
return GetFileDialog95A(ofn, OPEN_DIALOG);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
return GetFileName31A(ofn, OPEN_DIALOG);
|
2000-02-20 19:50:18 +01:00
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetOpenFileNameW (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to open.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetOpenFileNameW(
|
2000-12-02 00:58:28 +01:00
|
|
|
LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-11-30 20:07:09 +01:00
|
|
|
BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
|
2001-03-03 01:18:14 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(0);
|
2000-02-25 21:36:42 +01:00
|
|
|
/* some flags don't allow to match the TWEAK_WineLook */
|
|
|
|
if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
|
|
|
|
{
|
|
|
|
newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newlook)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
return GetFileDialog95W(ofn, OPEN_DIALOG);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
return GetFileName31W(ofn, OPEN_DIALOG);
|
2000-02-20 19:50:18 +01:00
|
|
|
}
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetSaveFileNameA (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to save.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetSaveFileNameA(
|
2000-12-02 00:58:28 +01:00
|
|
|
LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-11-30 20:07:09 +01:00
|
|
|
BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
|
2001-03-03 01:18:14 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(0);
|
2000-02-25 21:36:42 +01:00
|
|
|
/* some flags don't allow to match the TWEAK_WineLook */
|
|
|
|
if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
|
|
|
|
{
|
|
|
|
newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newlook)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
return GetFileDialog95A(ofn, SAVE_DIALOG);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-02-20 19:50:18 +01:00
|
|
|
else
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
return GetFileName31A(ofn, SAVE_DIALOG);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* GetSaveFileNameW (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Creates a dialog box for the user to select a file to save.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2000-08-02 01:33:37 +02:00
|
|
|
* TRUE on success: user enters a valid file
|
1999-02-28 21:05:11 +01:00
|
|
|
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetSaveFileNameW(
|
2000-12-02 00:58:28 +01:00
|
|
|
LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-11-30 20:07:09 +01:00
|
|
|
BOOL newlook = TRUE; /* FIXME: TWEAK_WineLook */
|
2001-03-03 01:18:14 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(0);
|
2000-02-25 21:36:42 +01:00
|
|
|
/* some flags don't allow to match the TWEAK_WineLook */
|
|
|
|
if (ofn->Flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE))
|
|
|
|
{
|
|
|
|
newlook = (ofn->Flags & OFN_EXPLORER) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newlook)
|
1999-07-27 18:20:36 +02:00
|
|
|
{
|
|
|
|
return GetFileDialog95W(ofn, SAVE_DIALOG);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-02-20 19:50:18 +01:00
|
|
|
else
|
|
|
|
{
|
2000-08-02 01:33:37 +02:00
|
|
|
return GetFileName31W(ofn, SAVE_DIALOG);
|
1999-07-27 18:20:36 +02:00
|
|
|
}
|
|
|
|
}
|