Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d8cb43c7
Commit
d8cb43c7
authored
Aug 01, 2000
by
Gerard Patel
Committed by
Alexandre Julliard
Aug 01, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the win31 style file dialog to 32 bits structures and
messages.
parent
15d9a602
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
979 additions
and
924 deletions
+979
-924
filedlg.c
dlls/commdlg/filedlg.c
+972
-924
unicode.h
include/wine/unicode.h
+7
-0
No files found.
dlls/commdlg/filedlg.c
View file @
d8cb43c7
...
...
@@ -13,6 +13,7 @@
#include "wingdi.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/unicode.h"
#include "ldt.h"
#include "heap.h"
#include "commdlg.h"
...
...
@@ -29,6 +30,37 @@ DEFAULT_DEBUG_CHANNEL(commdlg);
#include "cdlg.h"
#define BUFFILE 512
#define BUFFILEALLOC 512 * sizeof(WCHAR)
struct
FSPRIVATE
{
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
static
const
WCHAR
FILE_star
[]
=
{
'*'
,
'.'
,
'*'
,
0
};
static
const
WCHAR
FILE_bslash
[]
=
{
'\\'
,
0
};
static
const
WCHAR
FILE_specc
[]
=
{
'%'
,
'c'
,
':'
,
0
};
static
HICON16
hFolder
=
0
;
static
HICON16
hFolder2
=
0
;
static
HICON16
hFloppy
=
0
;
...
...
@@ -38,12 +70,15 @@ static HICON16 hNet = 0;
static
int
fldrHeight
=
0
;
static
int
fldrWidth
=
0
;
#define OFN_PROP "FILEDLG_OFN"
static
const
char
defaultfilter
[]
=
"
\0\0
"
;
#define OFN_PROP "FILEDLG_OFN_LPARAM"
static
char
defaultopen
[]
=
"Open File"
;
static
char
defaultsave
[]
=
"Save as"
;
/***********************************************************************
*
* Windows 3.1 OpenFileName/SaveFileName dialog
* Windows 3.1
style
OpenFileName/SaveFileName dialog
*
*/
...
...
@@ -52,6 +87,9 @@ LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
LRESULT
WINAPI
FileSaveDlgProc16
(
HWND16
hWnd
,
UINT16
wMsg
,
WPARAM16
wParam
,
LPARAM
lParam
);
static
LRESULT
WINAPI
FileOpenDlgProc
(
HWND
hDlg
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
);
/***********************************************************************
* FileDlg_Init [internal]
*/
...
...
@@ -87,477 +125,273 @@ static BOOL FileDlg_Init(void)
return
TRUE
;
}
/***********************************************************************
* FileOpenDlgProc [internal]
*
* FIXME: Convert to real 32-bit message processing
*/
static
LRESULT
WINAPI
FileOpenDlgProc
(
HWND
hDlg
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
UINT16
msg16
;
MSGPARAM16
mp16
;
mp16
.
lParam
=
lParam
;
if
(
WINPROC_MapMsg32ATo16
(
hDlg
,
msg
,
wParam
,
&
msg16
,
&
mp16
.
wParam
,
&
mp16
.
lParam
)
==
-
1
)
return
0
;
mp16
.
lResult
=
FileOpenDlgProc16
(
(
HWND16
)
hDlg
,
msg16
,
mp16
.
wParam
,
mp16
.
lParam
);
WINPROC_UnmapMsg32ATo16
(
hDlg
,
msg
,
wParam
,
lParam
,
&
mp16
);
return
mp16
.
lResult
;
}
/***********************************************************************
* FileSaveDlgProc [internal]
*
* FIXME: Convert to real 32-bit message processing
*/
static
LRESULT
WINAPI
FileSaveDlgProc
(
HWND
hDlg
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
UINT16
msg16
;
MSGPARAM16
mp16
;
mp16
.
lParam
=
lParam
;
if
(
WINPROC_MapMsg32ATo16
(
hDlg
,
msg
,
wParam
,
&
msg16
,
&
mp16
.
wParam
,
&
mp16
.
lParam
)
==
-
1
)
return
0
;
mp16
.
lResult
=
FileSaveDlgProc16
(
(
HWND16
)
hDlg
,
msg16
,
mp16
.
wParam
,
mp16
.
lParam
);
WINPROC_UnmapMsg32ATo16
(
hDlg
,
msg
,
wParam
,
lParam
,
&
mp16
);
return
mp16
.
lResult
;
}
/***********************************************************************
* GetOpenFileName16 (COMMDLG.1)
*
* Creates a dialog box for the user to select a file to open.
* Get32BitsTemplate [internal]
*
* RETURNS
* TRUE on success: user selected a valid file
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
* Get a template (or FALSE if failure) when 16 bits dialogs are used
* by a 32 bits application
*
* BUGS
* unknown, there are some FIXME's left.
*/
BOOL16
WINAPI
GetOpenFileName16
(
SEGPTR
ofn
/* addess of structure with data*/
)
BOOL
Get32BitsTemplate
(
LFSPRIVATE
lfs
)
{
HINSTANCE
hInst
;
HANDLE
hDlgTmpl
=
0
,
hResInfo
;
BOOL
bRet
=
FALSE
,
win32Format
=
FALSE
;
HWND
hwndDialog
;
LPOPENFILENAME16
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
ofn
);
LPCVOID
template
;
char
defaultopen
[]
=
"Open File"
;
char
*
str
=
0
,
*
str1
=
0
;
if
(
!
lpofn
||
!
FileDlg_Init
())
return
FALSE
;
LPOPENFILENAMEW
ofnW
=
lfs
->
ofnW
;
HANDLE
hDlgTmpl
;
if
(
lpofn
->
Flags
&
OFN_WINE
)
{
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATEHANDLE
)
{
if
(
!
(
template
=
LockResource
(
MapHModuleSL
(
lpofn
->
hInstance
))))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATE
)
{
if
(
!
(
hResInfo
=
FindResourceA
(
MapHModuleSL
(
lpofn
->
hInstance
),
PTR_SEG_TO_LIN
(
lpofn
->
lpTemplateName
),
RT_DIALOGA
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource
(
MapHModuleSL
(
lpofn
->
hInstance
),
hResInfo
))
||
!
(
template
=
LockResource
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
{
if
(
!
(
hResInfo
=
FindResourceA
(
COMMDLG_hInstance32
,
"OPEN_FILE"
,
RT_DIALOGA
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource
(
COMMDLG_hInstance32
,
hResInfo
))
||
!
(
template
=
LockResource
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
win32Format
=
TRUE
;
}
else
{
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATEHANDLE
)
{
if
(
!
(
template
=
LockResource16
(
lpofn
->
hInstance
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATE
)
{
if
(
!
(
hResInfo
=
FindResource16
(
lpofn
->
hInstance
,
lpofn
->
lpTemplateName
,
RT_DIALOG16
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource16
(
lpofn
->
hInstance
,
hResInfo
))
||
!
(
template
=
LockResource16
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
{
if
(
!
(
hResInfo
=
FindResourceA
(
COMMDLG_hInstance32
,
"OPEN_FILE"
,
RT_DIALOGA
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource
(
COMMDLG_hInstance32
,
hResInfo
))
||
!
(
template
=
LockResource
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
win32Format
=
TRUE
;
}
if
(
ofnW
->
Flags
&
OFN_ENABLETEMPLATEHANDLE
)
{
if
(
!
(
lfs
->
template
=
LockResource
(
ofnW
->
hInstance
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
hInst
=
GetWindowLongA
(
lpofn
->
hwndOwner
,
GWL_HINSTANCE
);
if
(
!
(
lpofn
->
lpstrFilter
))
{
str
=
SEGPTR_ALLOC
(
sizeof
(
defaultfilter
));
TRACE
(
"Alloc %p default for Filetype in GetOpenFileName
\n
"
,
str
);
memcpy
(
str
,
defaultfilter
,
sizeof
(
defaultfilter
));
lpofn
->
lpstrFilter
=
SEGPTR_GET
(
str
);
}
if
(
!
(
lpofn
->
lpstrTitle
))
{
str1
=
SEGPTR_ALLOC
(
strlen
(
defaultopen
)
+
1
);
TRACE
(
"Alloc %p default for Title in GetOpenFileName
\n
"
,
str1
);
strcpy
(
str1
,
defaultopen
);
lpofn
->
lpstrTitle
=
SEGPTR_GET
(
str1
);
}
/* FIXME: doesn't handle win32 format correctly yet */
hwndDialog
=
DIALOG_CreateIndirect
(
hInst
,
template
,
win32Format
,
lpofn
->
hwndOwner
,
(
DLGPROC16
)
FileOpenDlgProc
,
ofn
,
WIN_PROC_32A
);
if
(
hwndDialog
)
bRet
=
DIALOG_DoDialogBox
(
hwndDialog
,
lpofn
->
hwndOwner
);
if
(
str1
)
{
TRACE
(
"Freeing %p default for Title in GetOpenFileName
\n
"
,
str1
);
SEGPTR_FREE
(
str1
);
lpofn
->
lpstrTitle
=
0
;
}
if
(
str
)
{
TRACE
(
"Freeing %p default for Filetype in GetOpenFileName
\n
"
,
str
);
SEGPTR_FREE
(
str
);
lpofn
->
lpstrFilter
=
0
;
}
if
(
hDlgTmpl
)
{
if
(
lpofn
->
Flags
&
OFN_WINE
)
FreeResource
(
hDlgTmpl
);
else
FreeResource16
(
hDlgTmpl
);
else
if
(
ofnW
->
Flags
&
OFN_ENABLETEMPLATE
)
{
HANDLE
hResInfo
;
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 */
HANDLE
hResInfo
;
if
(
!
(
hResInfo
=
FindResourceA
(
COMMDLG_hInstance32
,
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
;
}
}
TRACE
(
"return lpstrFile='%s' !
\n
"
,
(
LPSTR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFile
));
return
bRet
;
return
TRUE
;
}
/***********************************************************************
* Get
SaveFileName (COMMDLG.2)
* Get
16BitsTemplate [internal]
*
* Creates a dialog box for the user to select a file to save.
* Get a template (FALSE if failure) when 16 bits dialogs are used
* by a 16 bits application
*
* RETURNS
* TRUE on succes: 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.
*/
BOOL16
WINAPI
GetSaveFileName16
(
SEGPTR
ofn
/* addess of structure with data*/
)
BOOL
Get16BitsTemplate
(
LFSPRIVATE
lfs
)
{
HINSTANCE
hInst
;
HANDLE
hDlgTmpl
=
0
;
BOOL
bRet
=
FALSE
,
win32Format
=
FALSE
;
LPOPENFILENAME16
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
ofn
);
LPOPENFILENAME16
ofn16
=
lfs
->
ofn16
;
LPCVOID
template
;
HWND
hwndDialog
;
char
defaultsave
[]
=
"Save as"
;
char
*
str
=
0
,
*
str1
=
0
;
HGLOBAL16
hGlobal16
=
0
;
if
(
!
lpofn
||
!
FileDlg_Init
())
return
FALSE
;
if
(
lpofn
->
Flags
&
OFN_WINE
)
{
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATEHANDLE
)
{
if
(
!
(
template
=
LockResource
(
MapHModuleSL
(
lpofn
->
hInstance
))))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATE
)
{
HANDLE
hResInfo
;
if
(
!
(
hResInfo
=
FindResourceA
(
MapHModuleSL
(
lpofn
->
hInstance
),
PTR_SEG_TO_LIN
(
lpofn
->
lpTemplateName
),
RT_DIALOGA
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource
(
MapHModuleSL
(
lpofn
->
hInstance
),
hResInfo
))
||
!
(
template
=
LockResource
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
win32Format
=
TRUE
;
}
else
{
HANDLE
hResInfo
;
if
(
!
(
hResInfo
=
FindResourceA
(
COMMDLG_hInstance32
,
"SAVE_FILE"
,
RT_DIALOGA
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource
(
COMMDLG_hInstance32
,
hResInfo
))
||
!
(
template
=
LockResource
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
win32Format
=
TRUE
;
}
}
else
{
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATEHANDLE
)
{
if
(
!
(
template
=
LockResource16
(
lpofn
->
hInstance
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
if
(
lpofn
->
Flags
&
OFN_ENABLETEMPLATE
)
{
HANDLE16
hResInfo
;
if
(
!
(
hResInfo
=
FindResource16
(
lpofn
->
hInstance
,
lpofn
->
lpTemplateName
,
RT_DIALOG16
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource16
(
lpofn
->
hInstance
,
hResInfo
))
||
!
(
template
=
LockResource16
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
}
else
{
HANDLE
hResInfo
;
if
(
!
(
hResInfo
=
FindResourceA
(
COMMDLG_hInstance32
,
"SAVE_FILE"
,
RT_DIALOGA
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
hDlgTmpl
=
LoadResource
(
COMMDLG_hInstance32
,
hResInfo
))
||
!
(
template
=
LockResource
(
hDlgTmpl
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
win32Format
=
TRUE
;
if
(
ofn16
->
Flags
&
OFN_ENABLETEMPLATEHANDLE
)
lfs
->
hDlgTmpl16
=
ofn16
->
hInstance
;
else
if
(
ofn16
->
Flags
&
OFN_ENABLETEMPLATE
)
{
HANDLE16
hResInfo
;
if
(
!
(
hResInfo
=
FindResource16
(
ofn16
->
hInstance
,
ofn16
->
lpTemplateName
,
RT_DIALOG16
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_FINDRESFAILURE
);
return
FALSE
;
}
if
(
!
(
lfs
->
hDlgTmpl16
=
LoadResource16
(
ofn16
->
hInstance
,
hResInfo
)))
{
COMDLG32_SetCommDlgExtendedError
(
CDERR_LOADRESFAILURE
);
return
FALSE
;
}
lfs
->
hResource16
=
lfs
->
hDlgTmpl16
;
}
else
{
/* get resource from (32 bits) own Wine resource; convert it to 16 */
HANDLE
hResInfo
,
hDlgTmpl32
;
LPCVOID
template32
;
DWORD
size
;
hInst
=
GetWindowLongA
(
lpofn
->
hwndOwner
,
GWL_HINSTANCE
);
if
(
!
(
lpofn
->
lpstrFilter
))
{
str
=
SEGPTR_ALLOC
(
sizeof
(
defaultfilter
));
TRACE
(
"Alloc default for Filetype in GetSaveFileName
\n
"
);
memcpy
(
str
,
defaultfilter
,
sizeof
(
defaultfilter
));
lpofn
->
lpstrFilter
=
SEGPTR_GET
(
str
);
}
if
(
!
(
lpofn
->
lpstrTitle
))
{
str1
=
SEGPTR_ALLOC
(
sizeof
(
defaultsave
)
+
1
);
TRACE
(
"Alloc default for Title in GetSaveFileName
\n
"
);
strcpy
(
str1
,
defaultsave
);
lpofn
->
lpstrTitle
=
SEGPTR_GET
(
str1
);
}
hwndDialog
=
DIALOG_CreateIndirect
(
hInst
,
template
,
win32Format
,
lpofn
->
hwndOwner
,
(
DLGPROC16
)
FileSaveDlgProc
,
ofn
,
WIN_PROC_32A
);
if
(
hwndDialog
)
bRet
=
DIALOG_DoDialogBox
(
hwndDialog
,
lpofn
->
hwndOwner
);
if
(
str1
)
{
TRACE
(
"Freeing %p default for Title in GetSaveFileName
\n
"
,
str1
);
SEGPTR_FREE
(
str1
);
lpofn
->
lpstrTitle
=
0
;
}
if
(
str
)
{
TRACE
(
"Freeing %p default for Filetype in GetSaveFileName
\n
"
,
str
);
SEGPTR_FREE
(
str
);
lpofn
->
lpstrFilter
=
0
;
}
if
(
hDlgTmpl
)
{
if
(
lpofn
->
Flags
&
OFN_WINE
)
FreeResource
(
hDlgTmpl
);
else
FreeResource16
(
hDlgTmpl
);
if
(
!
(
hResInfo
=
FindResourceA
(
COMMDLG_hInstance32
,
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
;
}
TRACE
(
"return lpstrFile='%s' !
\n
"
,
(
LPSTR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFile
));
return
bRet
;
return
TRUE
;
}
/***********************************************************************
* FILEDLG_StripEditControl [internal]
* Strip pathnames off the contents of the edit control.
*/
static
void
FILEDLG_StripEditControl
(
HWND
16
hwnd
)
static
void
FILEDLG_StripEditControl
(
HWND
hwnd
)
{
char
temp
[
512
],
*
cp
;
WCHAR
temp
[
BUFFILE
],
*
cp
;
GetDlgItemText
A
(
hwnd
,
edt1
,
temp
,
sizeof
(
temp
)
);
cp
=
strrchr
(
temp
,
'\\'
);
GetDlgItemText
W
(
hwnd
,
edt1
,
temp
,
sizeof
(
temp
)
);
cp
=
strrchr
W
(
temp
,
'\\'
);
if
(
cp
!=
NULL
)
{
strcpy
(
temp
,
cp
+
1
);
lstrcpyW
(
temp
,
cp
+
1
);
}
cp
=
strrchr
(
temp
,
':'
);
cp
=
strrchr
W
(
temp
,
':'
);
if
(
cp
!=
NULL
)
{
strcpy
(
temp
,
cp
+
1
);
lstrcpyW
(
temp
,
cp
+
1
);
}
/* FIXME: shouldn't we do something with the result here? ;-) */
}
/***********************************************************************
* FILEDLG_ScanDir [internal]
* FILEDLG_CallWindowProc [internal]
*
* Call the appropriate hook
*/
static
BOOL
FILEDLG_ScanDir
(
HWND16
hWnd
,
LPSTR
newPath
)
static
BOOL
FILEDLG_CallWindowProc
(
LFSPRIVATE
lfs
,
UINT
wMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
char
buffer
[
512
];
char
*
str
=
buffer
;
int
drive
;
HWND
hlb
;
lstrcpynA
(
buffer
,
newPath
,
sizeof
(
buffer
));
if
(
str
[
0
]
&&
(
str
[
1
]
==
':'
))
{
drive
=
toupper
(
str
[
0
])
-
'A'
;
str
+=
2
;
if
(
!
DRIVE_SetCurrentDrive
(
drive
))
return
FALSE
;
}
else
{
drive
=
DRIVE_GetCurrentDrive
();
}
if
(
lfs
->
ofn16
)
{
return
(
BOOL
)
CallWindowProc16
(
(
WNDPROC16
)
lfs
->
ofn16
->
lpfnHook
,
lfs
->
hwnd
,
(
UINT16
)
wMsg
,
(
WPARAM16
)
wParam
,
lParam
);
}
if
(
lfs
->
ofnA
)
{
return
(
BOOL
)
CallWindowProcA
(
(
WNDPROC
)
lfs
->
ofnA
->
lpfnHook
,
lfs
->
hwnd
,
wMsg
,
wParam
,
lParam
);
}
if
(
str
[
0
]
&&
!
DRIVE_Chdir
(
drive
,
str
))
{
return
FALSE
;
if
(
lfs
->
ofnW
)
{
return
(
BOOL
)
CallWindowProcW
(
(
WNDPROC
)
lfs
->
ofnW
->
lpfnHook
,
lfs
->
hwnd
,
wMsg
,
wParam
,
lParam
);
}
return
FALSE
;
}
GetDlgItemTextA
(
hWnd
,
edt1
,
buffer
,
sizeof
(
buffer
));
if
((
hlb
=
GetDlgItem
(
hWnd
,
lst1
))
!=
0
)
{
char
*
scptr
;
/* ptr on semi-colon */
char
*
filter
=
buffer
;
TRACE
(
"Using filter %s
\n
"
,
filter
);
SendMessageA
(
hlb
,
LB_RESETCONTENT
,
0
,
0
);
while
(
filter
)
{
scptr
=
strchr
(
filter
,
';'
);
if
(
scptr
)
*
scptr
=
0
;
TRACE
(
"Using file spec %s
\n
"
,
filter
);
if
(
SendMessageA
(
hlb
,
LB_DIR
,
0
,
(
LPARAM
)
filter
)
==
LB_ERR
)
return
FALSE
;
if
(
scptr
)
*
scptr
=
';'
;
filter
=
(
scptr
)
?
(
scptr
+
1
)
:
0
;
}
}
strcpy
(
buffer
,
"*.*"
);
return
DlgDirListA
(
hWnd
,
buffer
,
lst2
,
stc1
,
DDL_EXCLUSIVE
|
DDL_DIRECTORY
);
/***********************************************************************
* FILEDLG_ScanDir [internal]
*/
static
BOOL
FILEDLG_ScanDir
(
HWND
hWnd
,
LPWSTR
newPath
)
{
WCHAR
buffer
[
BUFFILE
];
HWND
hdlg
;
lstrcpynW
(
buffer
,
newPath
,
sizeof
(
buffer
));
if
(
!
SetCurrentDirectoryW
(
newPath
))
return
FALSE
;
/* get the list of spec files */
GetDlgItemTextW
(
hWnd
,
edt1
,
buffer
,
sizeof
(
buffer
));
/* 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
;
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
;
}
}
/* list of directories */
lstrcpyW
(
buffer
,
FILE_star
);
return
DlgDirListW
(
hWnd
,
buffer
,
lst2
,
stc1
,
DDL_EXCLUSIVE
|
DDL_DIRECTORY
);
}
/***********************************************************************
* FILEDLG_GetFileType [internal]
*/
static
LP
STR
FILEDLG_GetFileType
(
LPSTR
cfptr
,
LP
STR
fptr
,
WORD
index
)
static
LP
WSTR
FILEDLG_GetFileType
(
LPWSTR
cfptr
,
LPW
STR
fptr
,
WORD
index
)
{
int
n
,
i
;
i
=
0
;
if
(
cfptr
)
for
(
;(
n
=
strlen
(
cfptr
))
!=
0
;
i
++
)
for
(
;(
n
=
lstrlenW
(
cfptr
))
!=
0
;
i
++
)
{
cfptr
+=
n
+
1
;
if
(
i
==
index
)
return
cfptr
;
cfptr
+=
strlen
(
cfptr
)
+
1
;
cfptr
+=
lstrlenW
(
cfptr
)
+
1
;
}
if
(
fptr
)
for
(
;(
n
=
strlen
(
fptr
))
!=
0
;
i
++
)
for
(
;(
n
=
lstrlenW
(
fptr
))
!=
0
;
i
++
)
{
fptr
+=
n
+
1
;
if
(
i
==
index
)
return
fptr
;
fptr
+=
strlen
(
fptr
)
+
1
;
fptr
+=
lstrlenW
(
fptr
)
+
1
;
}
return
"*.*"
;
/* FIXME */
return
(
LPWSTR
)
FILE_star
;
/* FIXME */
}
/***********************************************************************
* FILEDLG_WMDrawItem [internal]
*/
static
LONG
FILEDLG_WMDrawItem
(
HWND16
hWnd
,
WPARAM16
wParam
,
LPARAM
lParam
,
int
savedlg
)
static
LONG
FILEDLG_WMDrawItem
(
HWND
hWnd
,
WPARAM
wParam
,
LPARAM
lParam
,
int
savedlg
,
LPDRAWITEMSTRUCT
lpdis
)
{
LPDRAWITEMSTRUCT16
lpdis
=
(
LPDRAWITEMSTRUCT16
)
PTR_SEG_TO_LIN
(
lParam
);
char
*
str
;
HICON16
hIcon
;
WCHAR
*
str
;
HICON
hIcon
;
COLORREF
oldText
=
0
,
oldBk
=
0
;
if
(
lpdis
->
CtlType
==
ODT_LISTBOX
&&
lpdis
->
CtlID
==
lst1
)
{
if
(
!
(
str
=
SEGPTR_ALLOC
(
512
)))
return
FALSE
;
SendMessage
16
(
lpdis
->
hwndItem
,
LB_GETTEXT16
,
lpdis
->
itemID
,
(
LPARAM
)
SEGPTR_GET
(
str
)
);
if
(
!
(
str
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BUFFILEALLOC
)))
return
FALSE
;
SendMessage
W
(
lpdis
->
hwndItem
,
LB_GETTEXT
,
lpdis
->
itemID
,
(
LPARAM
)
str
);
if
((
lpdis
->
itemState
&
ODS_SELECTED
)
&&
!
savedlg
)
{
...
...
@@ -567,39 +401,40 @@ static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int s
if
(
savedlg
)
SetTextColor
(
lpdis
->
hDC
,
GetSysColor
(
COLOR_GRAYTEXT
)
);
ExtTextOut
16
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
+
1
,
ExtTextOut
W
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
+
1
,
lpdis
->
rcItem
.
top
+
1
,
ETO_OPAQUE
|
ETO_CLIPPED
,
&
(
lpdis
->
rcItem
),
str
,
strlen
(
str
),
NULL
);
&
(
lpdis
->
rcItem
),
str
,
lstrlenW
(
str
),
NULL
);
if
(
lpdis
->
itemState
&
ODS_SELECTED
)
DrawFocusRect
16
(
lpdis
->
hDC
,
&
(
lpdis
->
rcItem
)
);
DrawFocusRect
(
lpdis
->
hDC
,
&
(
lpdis
->
rcItem
)
);
if
((
lpdis
->
itemState
&
ODS_SELECTED
)
&&
!
savedlg
)
{
SetBkColor
(
lpdis
->
hDC
,
oldBk
);
SetTextColor
(
lpdis
->
hDC
,
oldText
);
}
SEGPTR_FREE
(
str
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
return
TRUE
;
}
if
(
lpdis
->
CtlType
==
ODT_LISTBOX
&&
lpdis
->
CtlID
==
lst2
)
{
if
(
!
(
str
=
SEGPTR_ALLOC
(
512
)))
return
FALSE
;
SendMessage16
(
lpdis
->
hwndItem
,
LB_GETTEXT16
,
lpdis
->
itemID
,
(
LPARAM
)
SEGPTR_GET
(
str
));
if
(
!
(
str
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BUFFILEALLOC
)))
return
FALSE
;
SendMessageW
(
lpdis
->
hwndItem
,
LB_GETTEXT
,
lpdis
->
itemID
,
(
LPARAM
)
str
);
if
(
lpdis
->
itemState
&
ODS_SELECTED
)
{
oldBk
=
SetBkColor
(
lpdis
->
hDC
,
GetSysColor
(
COLOR_HIGHLIGHT
)
);
oldText
=
SetTextColor
(
lpdis
->
hDC
,
GetSysColor
(
COLOR_HIGHLIGHTTEXT
));
}
ExtTextOut
16
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
+
fldrWidth
,
ExtTextOut
W
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
+
fldrWidth
,
lpdis
->
rcItem
.
top
+
1
,
ETO_OPAQUE
|
ETO_CLIPPED
,
&
(
lpdis
->
rcItem
),
str
,
strlen
(
str
),
NULL
);
&
(
lpdis
->
rcItem
),
str
,
lstrlenW
(
str
),
NULL
);
if
(
lpdis
->
itemState
&
ODS_SELECTED
)
DrawFocusRect
16
(
lpdis
->
hDC
,
&
(
lpdis
->
rcItem
)
);
DrawFocusRect
(
lpdis
->
hDC
,
&
(
lpdis
->
rcItem
)
);
if
(
lpdis
->
itemState
&
ODS_SELECTED
)
{
...
...
@@ -607,14 +442,15 @@ static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int s
SetTextColor
(
lpdis
->
hDC
,
oldText
);
}
DrawIcon
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
,
lpdis
->
rcItem
.
top
,
hFolder
);
SEGPTR_FREE
(
str
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
return
TRUE
;
}
if
(
lpdis
->
CtlType
==
ODT_COMBOBOX
&&
lpdis
->
CtlID
==
cmb2
)
{
if
(
!
(
str
=
SEGPTR_ALLOC
(
512
)))
return
FALSE
;
SendMessage16
(
lpdis
->
hwndItem
,
CB_GETLBTEXT16
,
lpdis
->
itemID
,
(
LPARAM
)
SEGPTR_GET
(
str
));
if
(
!
(
str
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BUFFILEALLOC
)))
return
FALSE
;
SendMessageW
(
lpdis
->
hwndItem
,
CB_GETLBTEXT
,
lpdis
->
itemID
,
(
LPARAM
)
str
);
switch
(
DRIVE_GetType
(
str
[
2
]
-
'a'
))
{
case
TYPE_FLOPPY
:
hIcon
=
hFloppy
;
break
;
...
...
@@ -628,9 +464,9 @@ static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int s
oldBk
=
SetBkColor
(
lpdis
->
hDC
,
GetSysColor
(
COLOR_HIGHLIGHT
)
);
oldText
=
SetTextColor
(
lpdis
->
hDC
,
GetSysColor
(
COLOR_HIGHLIGHTTEXT
));
}
ExtTextOut
16
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
+
fldrWidth
,
ExtTextOut
W
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
+
fldrWidth
,
lpdis
->
rcItem
.
top
+
1
,
ETO_OPAQUE
|
ETO_CLIPPED
,
&
(
lpdis
->
rcItem
),
str
,
strlen
(
str
),
NULL
);
&
(
lpdis
->
rcItem
),
str
,
lstrlenW
(
str
),
NULL
);
if
(
lpdis
->
itemState
&
ODS_SELECTED
)
{
...
...
@@ -638,7 +474,7 @@ static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int s
SetTextColor
(
lpdis
->
hDC
,
oldText
);
}
DrawIcon
(
lpdis
->
hDC
,
lpdis
->
rcItem
.
left
,
lpdis
->
rcItem
.
top
,
hIcon
);
SEGPTR_FREE
(
str
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
return
TRUE
;
}
return
FALSE
;
...
...
@@ -647,167 +483,102 @@ static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int s
/***********************************************************************
* FILEDLG_WMMeasureItem [internal]
*/
static
LONG
FILEDLG_WMMeasureItem
(
HWND
16
hWnd
,
WPARAM16
wParam
,
LPARAM
lParam
)
static
LONG
FILEDLG_WMMeasureItem
(
HWND
hWnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
LPMEASUREITEMSTRUCT
16
lpmeasure
;
LPMEASUREITEMSTRUCT
lpmeasure
;
lpmeasure
=
(
LPMEASUREITEMSTRUCT
16
)
PTR_SEG_TO_LIN
(
lParam
)
;
lpmeasure
=
(
LPMEASUREITEMSTRUCT
)
lParam
;
lpmeasure
->
itemHeight
=
fldrHeight
;
return
TRUE
;
}
/***********************************************************************
* FILEDLG_
HookCallChk
[internal]
* FILEDLG_
WMMeasureItem16
[internal]
*/
static
int
FILEDLG_HookCallChk
(
LPOPENFILENAME16
lpofn
)
static
LONG
FILEDLG_WMMeasureItem16
(
HWND16
hWnd
,
WPARAM16
wParam
,
LPARAM
lParam
)
{
if
(
lpofn
)
if
(
lpofn
->
Flags
&
OFN_ENABLEHOOK
)
if
(
lpofn
->
lpfnHook
)
return
1
;
return
0
;
}
/***********************************************************************
* FILEDLG_CallWindowProc [internal]
*
* Adapt the structures back for win32 calls so the callee can read lpCustData
*/
static
BOOL
FILEDLG_CallWindowProc
(
LPOPENFILENAME16
lpofn
,
HWND
hwnd
,
UINT
wMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
BOOL
needstruct
;
BOOL
result
=
FALSE
;
WINDOWPROCTYPE
ProcType
;
/* Type of Hook Function to be called. */
/* TRUE if lParam points to the OPENFILENAME16 Structure */
needstruct
=
(
PTR_SEG_TO_LIN
(
lParam
)
==
lpofn
);
ProcType
=
(
lpofn
->
Flags
&
OFN_WINE
)
?
(
lpofn
->
Flags
&
OFN_UNICODE
)
/* 32-Bit call to GetOpenFileName */
?
WIN_PROC_32W
:
WIN_PROC_32A
:
WIN_PROC_16
;
/* 16-Bit call to GetOpenFileName */
if
(
!
(
lpofn
->
Flags
&
OFN_WINE
))
/* Call to 16-Bit Hooking function... No Problem at all. */
return
(
BOOL
)
CallWindowProc16
(
(
WNDPROC16
)
lpofn
->
lpfnHook
,
hwnd
,(
UINT16
)
wMsg
,(
WPARAM16
)
wParam
,
lParam
);
/* |OFN_WINE32 */
if
(
needstruct
)
{
/* Parameter lParam points to lpofn... Convert Structure Data... */
if
(
lpofn
->
Flags
&
OFN_UNICODE
)
{
OPENFILENAMEW
ofnw
;
/* FIXME: probably needs more converted */
ofnw
.
lCustData
=
lpofn
->
lCustData
;
return
(
BOOL
)
CallWindowProcW
(
(
WNDPROC
)
lpofn
->
lpfnHook
,
hwnd
,
wMsg
,
wParam
,(
LPARAM
)
&
ofnw
);
}
else
/* ! |OFN_UNICODE */
{
OPENFILENAMEA
ofna
;
/* FIXME: probably needs more converted */
ofna
.
lCustData
=
lpofn
->
lCustData
;
return
(
BOOL
)
CallWindowProcA
(
(
WNDPROC
)
lpofn
->
lpfnHook
,
hwnd
,
wMsg
,
wParam
,(
LPARAM
)
&
ofna
);
}
}
else
/* ! needstruct */
{
HWINDOWPROC
hWindowProc
=
NULL
;
if
(
WINPROC_SetProc
(
&
hWindowProc
,
(
WNDPROC16
)
lpofn
->
lpfnHook
,
ProcType
,
WIN_PROC_WINDOW
))
{
/* Call Window Procedure converting 16-Bit Type Parameters to 32-Bit Type Parameters */
result
=
CallWindowProc16
(
(
WNDPROC16
)
hWindowProc
,
hwnd
,
wMsg
,
wParam
,
lParam
);
result
=
LOWORD
(
result
);
WINPROC_FreeProc
(
hWindowProc
,
WIN_PROC_WINDOW
);
}
return
result
;
}
LPMEASUREITEMSTRUCT16
lpmeasure
;
lpmeasure
=
(
LPMEASUREITEMSTRUCT16
)
PTR_SEG_TO_LIN
(
lParam
);
lpmeasure
->
itemHeight
=
fldrHeight
;
return
TRUE
;
}
/***********************************************************************
* FILEDLG_WMInitDialog [internal]
*/
static
LONG
FILEDLG_WMInitDialog
(
HWND
16
hWnd
,
WPARAM16
wParam
,
LPARAM
lParam
)
static
LONG
FILEDLG_WMInitDialog
(
HWND
hWnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
int
i
,
n
;
LPOPENFILENAME16
lpofn
;
char
tmpstr
[
512
];
LPSTR
pstr
,
old_pstr
;
SetPropA
(
hWnd
,
OFN_PROP
,
lParam
);
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
lParam
);
if
(
lpofn
->
lpstrTitle
)
SetWindowText16
(
hWnd
,
lpofn
->
lpstrTitle
);
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
);
/* read custom filter information */
if
(
lp
ofn
->
lpstrCustomFilter
)
if
(
ofn
->
lpstrCustomFilter
)
{
pstr
=
(
LPSTR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrCustomFilter
)
;
pstr
=
ofn
->
lpstrCustomFilter
;
n
=
0
;
TRACE
(
"lpstrCustomFilter = %p
\n
"
,
pstr
);
while
(
*
pstr
)
{
old_pstr
=
pstr
;
i
=
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_ADDSTRING16
,
0
,
(
LPARAM
)
lpofn
->
lpstrCustomFilter
+
n
);
n
+=
strlen
(
pstr
)
+
1
;
pstr
+=
strlen
(
pstr
)
+
1
;
i
=
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_ADDSTRING
,
0
,
(
LPARAM
)
(
ofn
->
lpstrCustomFilter
)
+
n
);
n
+=
lstrlenW
(
pstr
)
+
1
;
pstr
+=
lstrlenW
(
pstr
)
+
1
;
TRACE
(
"add str='%s' "
"associated to '%s'
\n
"
,
old_pstr
,
pstr
);
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_SETITEMDATA16
,
i
,
(
LPARAM
)
pstr
);
n
+=
strlen
(
pstr
)
+
1
;
pstr
+=
strlen
(
pstr
)
+
1
;
"associated to '%s'
\n
"
,
debugstr_w
(
old_pstr
),
debugstr_w
(
pstr
)
);
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_SETITEMDATA
,
i
,
(
LPARAM
)
pstr
);
n
+=
lstrlenW
(
pstr
)
+
1
;
pstr
+=
lstrlenW
(
pstr
)
+
1
;
}
}
/* read filter information */
if
(
lp
ofn
->
lpstrFilter
)
{
pstr
=
(
LP
STR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFilter
)
;
if
(
ofn
->
lpstrFilter
)
{
pstr
=
(
LP
WSTR
)
ofn
->
lpstrFilter
;
n
=
0
;
while
(
*
pstr
)
{
old_pstr
=
pstr
;
i
=
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_ADDSTRING16
,
0
,
(
LPARAM
)
lpofn
->
lpstrFilter
+
n
);
n
+=
strlen
(
pstr
)
+
1
;
pstr
+=
strlen
(
pstr
)
+
1
;
i
=
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_ADDSTRING
,
0
,
(
LPARAM
)
(
ofn
->
lpstrFilter
+
n
)
);
n
+=
lstrlenW
(
pstr
)
+
1
;
pstr
+=
lstrlenW
(
pstr
)
+
1
;
TRACE
(
"add str='%s' "
"associated to '%s'
\n
"
,
old_pstr
,
pstr
);
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_SETITEMDATA16
,
i
,
(
LPARAM
)
pstr
);
n
+=
strlen
(
pstr
)
+
1
;
pstr
+=
strlen
(
pstr
)
+
1
;
"associated to '%s'
\n
"
,
debugstr_w
(
old_pstr
),
debugstr_w
(
pstr
)
);
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_SETITEMDATA
,
i
,
(
LPARAM
)
pstr
);
n
+=
lstrlenW
(
pstr
)
+
1
;
pstr
+=
lstrlenW
(
pstr
)
+
1
;
}
}
/* set default filter */
if
(
lpofn
->
nFilterIndex
==
0
&&
lpofn
->
lpstrCustomFilter
==
(
SEGPTR
)
NULL
)
lp
ofn
->
nFilterIndex
=
1
;
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_SETCURSEL16
,
lp
ofn
->
nFilterIndex
-
1
,
0
);
lstrcpyn
A
(
tmpstr
,
FILEDLG_GetFileType
(
PTR_SEG_TO_LIN
(
lpofn
->
lpstrCustomFilter
)
,
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFilter
),
lpofn
->
nFilterIndex
-
1
),
512
);
if
(
ofn
->
nFilterIndex
==
0
&&
ofn
->
lpstrCustomFilter
==
NULL
)
ofn
->
nFilterIndex
=
1
;
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_SETCURSEL
,
ofn
->
nFilterIndex
-
1
,
0
);
lstrcpyn
W
(
tmpstr
,
FILEDLG_GetFileType
(
ofn
->
lpstrCustomFilter
,
(
LPWSTR
)
ofn
->
lpstrFilter
,
ofn
->
nFilterIndex
-
1
),
BUFFILE
);
TRACE
(
"nFilterIndex = %ld, SetText of edt1 to '%s'
\n
"
,
lpofn
->
nFilterIndex
,
tmpstr
);
SetDlgItemText
A
(
hWnd
,
edt1
,
tmpstr
);
ofn
->
nFilterIndex
,
debugstr_w
(
tmpstr
)
);
SetDlgItemText
W
(
hWnd
,
edt1
,
tmpstr
);
/* get drive list */
*
tmpstr
=
0
;
DlgDirListComboBox
A
(
hWnd
,
tmpstr
,
cmb2
,
0
,
DDL_DRIVES
|
DDL_EXCLUSIVE
);
DlgDirListComboBox
W
(
hWnd
,
tmpstr
,
cmb2
,
0
,
DDL_DRIVES
|
DDL_EXCLUSIVE
);
/* read initial directory */
if
(
PTR_SEG_TO_LIN
(
lpofn
->
lpstrInitialDir
)
!=
NULL
)
if
(
ofn
->
lpstrInitialDir
!=
NULL
)
{
int
len
;
lstrcpyn
A
(
tmpstr
,
PTR_SEG_TO_LIN
(
lpofn
->
lpstrInitialDir
)
,
511
);
len
=
strlen
(
tmpstr
);
lstrcpyn
W
(
tmpstr
,
ofn
->
lpstrInitialDir
,
511
);
len
=
lstrlenW
(
tmpstr
);
if
(
len
>
0
&&
tmpstr
[
len
-
1
]
!=
'\\'
&&
tmpstr
[
len
-
1
]
!=
':'
)
{
tmpstr
[
len
]
=
'\\'
;
tmpstr
[
len
+
1
]
=
'\0'
;
...
...
@@ -818,20 +589,81 @@ static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
if
(
!
FILEDLG_ScanDir
(
hWnd
,
tmpstr
))
{
*
tmpstr
=
0
;
if
(
!
FILEDLG_ScanDir
(
hWnd
,
tmpstr
))
WARN
(
"Couldn't read initial directory %s!
\n
"
,
tmpstr
);
WARN
(
"Couldn't read initial directory %s!
\n
"
,
debugstr_w
(
tmpstr
)
);
}
/* select current drive in combo 2, omit missing drives */
for
(
i
=
0
,
n
=-
1
;
i
<=
DRIVE_GetCurrentDrive
();
i
++
)
for
(
i
=
0
,
n
=
-
1
;
i
<=
DRIVE_GetCurrentDrive
();
i
++
)
if
(
DRIVE_IsValid
(
i
))
n
++
;
SendDlgItemMessage
16
(
hWnd
,
cmb2
,
CB_SETCURSEL16
,
n
,
0
);
if
(
!
(
lp
ofn
->
Flags
&
OFN_SHOWHELP
))
SendDlgItemMessage
W
(
hWnd
,
cmb2
,
CB_SETCURSEL
,
n
,
0
);
if
(
!
(
ofn
->
Flags
&
OFN_SHOWHELP
))
ShowWindow
(
GetDlgItem
(
hWnd
,
pshHelp
),
SW_HIDE
);
if
(
lpofn
->
Flags
&
OFN_HIDEREADONLY
)
ShowWindow
(
GetDlgItem
(
hWnd
,
chx1
),
SW_HIDE
);
if
(
FILEDLG_HookCallChk
(
lpofn
))
return
(
BOOL16
)
FILEDLG_CallWindowProc
(
lpofn
,
hWnd
,
WM_INITDIALOG
,
wParam
,
lParam
);
else
return
TRUE
;
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]
* update the displayed file name (with path)
*/
void
FILEDLG_UpdateResult
(
LFSPRIVATE
lfs
,
WCHAR
*
tmpstr
,
WCHAR
*
tmpstr2
)
{
int
lenstr2
;
LPOPENFILENAMEW
ofnW
=
lfs
->
ofnW
;
GetCurrentDirectoryW
(
BUFFILE
,
tmpstr2
);
lenstr2
=
lstrlenW
(
tmpstr2
);
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
)
{
lstrcpynWtoA
(
PTR_SEG_TO_LIN
(
lfs
->
ofn16
->
lpstrFile
),
ofnW
->
lpstrFile
,
ofnW
->
nMaxFile
);
lfs
->
ofn16
->
nFileOffset
=
ofnW
->
nFileOffset
;
lfs
->
ofn16
->
nFileExtension
=
ofnW
->
nFileExtension
;
}
if
(
lfs
->
ofnA
)
{
lstrcpynWtoA
(
lfs
->
ofnA
->
lpstrFile
,
ofnW
->
lpstrFile
,
ofnW
->
nMaxFile
);
lfs
->
ofnA
->
nFileOffset
=
ofnW
->
nFileOffset
;
lfs
->
ofnA
->
nFileExtension
=
ofnW
->
nFileExtension
;
}
}
/***********************************************************************
* FILEDLG_UpdateFileTitle [internal]
* update the displayed file name (without path)
*/
void
FILEDLG_UpdateFileTitle
(
LFSPRIVATE
lfs
)
{
LONG
lRet
;
LPOPENFILENAMEW
ofnW
=
lfs
->
ofnW
;
if
(
ofnW
->
lpstrFileTitle
!=
NULL
)
{
lRet
=
SendDlgItemMessageW
(
lfs
->
hwnd
,
lst1
,
LB_GETCURSEL
,
0
,
0
);
SendDlgItemMessageW
(
lfs
->
hwnd
,
lst1
,
LB_GETTEXT
,
lRet
,
(
LPARAM
)
ofnW
->
lpstrFileTitle
);
if
(
lfs
->
ofn16
)
lstrcpynWtoA
(
PTR_SEG_TO_LIN
(
lfs
->
ofn16
->
lpstrFileTitle
),
ofnW
->
lpstrFileTitle
,
ofnW
->
nMaxFileTitle
);
if
(
lfs
->
ofnA
)
lstrcpynWtoA
(
lfs
->
ofnA
->
lpstrFileTitle
,
ofnW
->
lpstrFileTitle
,
ofnW
->
nMaxFileTitle
);
}
}
/***********************************************************************
...
...
@@ -839,61 +671,69 @@ static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
*/
BOOL
in_update
=
FALSE
;
static
LRESULT
FILEDLG_WMCommand
(
HWND16
hWnd
,
WPARAM16
wParam
,
LPARAM
lParam
)
static
LRESULT
FILEDLG_WMCommand
(
HWND
hWnd
,
LPARAM
lParam
,
UINT
notification
,
UINT
control
,
LFSPRIVATE
lfs
)
{
LONG
lRet
;
LPOPENFILENAME16
lpofn
;
OPENFILENAME16
ofn2
;
char
tmpstr
[
512
],
tmpstr2
[
512
];
LPSTR
pstr
,
pstr2
;
UINT16
control
,
notification
;
/* Notifications are packaged differently in Win32 */
control
=
wParam
;
notification
=
HIWORD
(
lParam
);
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
GetPropA
(
hWnd
,
OFN_PROP
));
OPENFILENAMEW
ofn2
;
LPOPENFILENAMEW
ofnW
=
lfs
->
ofnW
;
WCHAR
tmpstr
[
BUFFILE
],
tmpstr2
[
BUFFILE
];
LPWSTR
pstr
,
pstr2
;
switch
(
control
)
{
case
lst1
:
/* file list */
FILEDLG_StripEditControl
(
hWnd
);
if
(
notification
==
LBN_DBLCLK
)
goto
almost_ok
;
lRet
=
SendDlgItemMessage16
(
hWnd
,
lst1
,
LB_GETCURSEL16
,
0
,
0
);
/* notify the app */
lRet
=
SendDlgItemMessageW
(
hWnd
,
lst1
,
LB_GETCURSEL16
,
0
,
0
);
if
(
lRet
==
LB_ERR
)
return
TRUE
;
if
((
pstr
=
SEGPTR_ALLOC
(
512
)))
if
((
pstr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BUFFILEALLOC
)))
{
SendDlgItemMessage
16
(
hWnd
,
lst1
,
LB_GETTEXT16
,
lRet
,
(
LPARAM
)
SEGPTR_GET
(
pstr
)
);
SetDlgItemText
A
(
hWnd
,
edt1
,
pstr
);
SEGPTR_FREE
(
pstr
);
SendDlgItemMessage
W
(
hWnd
,
lst1
,
LB_GETTEXT
,
lRet
,
(
LPARAM
)
pstr
);
SetDlgItemText
W
(
hWnd
,
edt1
,
pstr
);
HeapFree
(
GetProcessHeap
(),
0
,
pstr
);
}
if
(
FILEDLG_HookCallChk
(
lpofn
))
FILEDLG_CallWindowProc
(
lpofn
,
hWnd
,
RegisterWindowMessageA
(
LBSELCHSTRING
),
control
,
MAKELONG
(
lRet
,
CD_LBSELCHANGE
));
/* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
if
(
lfs
->
hook
)
FILEDLG_CallWindowProc
(
lfs
,
lfs
->
lbselchstring
,
control
,
MAKELONG
(
lRet
,
CD_LBSELCHANGE
));
/* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
return
TRUE
;
case
lst2
:
/* directory list */
FILEDLG_StripEditControl
(
hWnd
);
if
(
notification
==
LBN_DBLCLK
)
{
lRet
=
SendDlgItemMessage16
(
hWnd
,
lst2
,
LB_GETCURSEL16
,
0
,
0
);
/* get the raw string (with brackets) */
lRet
=
SendDlgItemMessageW
(
hWnd
,
lst2
,
LB_GETCURSEL
,
0
,
0
);
if
(
lRet
==
LB_ERR
)
return
TRUE
;
pstr
=
SEGPTR_ALLOC
(
512
);
SendDlgItemMessage16
(
hWnd
,
lst2
,
LB_GETTEXT16
,
lRet
,
(
LPARAM
)
SEGPTR_GET
(
pstr
));
strcpy
(
tmpstr
,
pstr
);
SEGPTR_FREE
(
pstr
);
pstr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BUFFILEALLOC
);
SendDlgItemMessageW
(
hWnd
,
lst2
,
LB_GETTEXT
,
lRet
,
(
LPARAM
)
pstr
);
lstrcpyW
(
tmpstr
,
pstr
);
HeapFree
(
GetProcessHeap
(),
0
,
pstr
);
/* get the selected directory in tmpstr */
if
(
tmpstr
[
0
]
==
'['
)
{
tmpstr
[
strlen
(
tmpstr
)
-
1
]
=
0
;
strcpy
(
tmpstr
,
tmpstr
+
1
);
tmpstr
[
lstrlenW
(
tmpstr
)
-
1
]
=
0
;
lstrcpyW
(
tmpstr
,
tmpstr
+
1
);
}
strcat
(
tmpstr
,
"
\\
"
);
lstrcatW
(
tmpstr
,
FILE_bslash
);
/* directory *has* to be changed before notifying the hook */
SetCurrentDirectoryW
(
tmpstr
);
/* notify the app */
if
(
lfs
->
hook
)
{
if
(
FILEDLG_CallWindowProc
(
lfs
,
lfs
->
lbselchstring
,
control
,
MAKELONG
(
lRet
,
CD_LBSELCHANGE
)))
return
TRUE
;
}
goto
reset_scan
;
}
return
TRUE
;
case
cmb1
:
/* file type drop list */
if
(
notification
==
CBN_SELCHANGE
)
{
...
...
@@ -901,144 +741,123 @@ static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
goto
reset_scan
;
}
return
TRUE
;
case
chx1
:
return
TRUE
;
case
pshHelp
:
return
TRUE
;
case
cmb2
:
/* disk drop list */
FILEDLG_StripEditControl
(
hWnd
);
lRet
=
SendDlgItemMessage
16
(
hWnd
,
cmb2
,
CB_GETCURSEL16
,
0
,
0L
);
lRet
=
SendDlgItemMessage
W
(
hWnd
,
cmb2
,
CB_GETCURSEL
,
0
,
0L
);
if
(
lRet
==
LB_ERR
)
return
0
;
pstr
=
SEGPTR_ALLOC
(
512
);
SendDlgItemMessage
16
(
hWnd
,
cmb2
,
CB_GETLBTEXT16
,
lRet
,
(
LPARAM
)
SEGPTR_GET
(
pstr
)
);
sprintf
(
tmpstr
,
"%c:"
,
pstr
[
2
]);
SEGPTR_FREE
(
pstr
);
pstr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
BUFFILEALLOC
);
SendDlgItemMessage
W
(
hWnd
,
cmb2
,
CB_GETLBTEXT
,
lRet
,
(
LPARAM
)
pstr
);
wsprintfW
(
tmpstr
,
FILE_specc
,
pstr
[
2
]);
HeapFree
(
GetProcessHeap
(),
0
,
pstr
);
if
(
notification
!=
CBN_SELCHANGE
)
return
TRUE
;
/* on entry tmpstr points to the new path to scan */
reset_scan:
lRet
=
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_GETCURSEL16
,
0
,
0
);
lRet
=
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_GETCURSEL
,
0
,
0
);
if
(
lRet
==
LB_ERR
)
return
TRUE
;
pstr
=
(
LP
STR
)
SendDlgItemMessage16
(
hWnd
,
cmb1
,
CB_GETITEMDATA16
,
lRet
,
0
);
TRACE
(
"Selected filter : %s
\n
"
,
pstr
);
SetDlgItemText
A
(
hWnd
,
edt1
,
pstr
);
pstr
=
(
LP
WSTR
)
SendDlgItemMessageW
(
hWnd
,
cmb1
,
CB_GETITEMDATA
,
lRet
,
0
);
TRACE
(
"Selected filter : %s
\n
"
,
debugstr_w
(
pstr
)
);
SetDlgItemText
W
(
hWnd
,
edt1
,
pstr
);
FILEDLG_ScanDir
(
hWnd
,
tmpstr
);
in_update
=
TRUE
;
case
IDOK
:
almost_ok:
ofn2
=*
lpofn
;
/* for later restoring */
GetDlgItemTextA
(
hWnd
,
edt1
,
tmpstr
,
sizeof
(
tmpstr
)
);
pstr
=
strrchr
(
tmpstr
,
'\\'
);
ofn2
=
*
ofnW
;
/* for later restoring */
/* get current file name */
GetDlgItemTextW
(
hWnd
,
edt1
,
tmpstr
,
sizeof
(
tmpstr
)
);
pstr
=
strrchrW
(
tmpstr
,
'\\'
);
if
(
pstr
==
NULL
)
pstr
=
strrchr
(
tmpstr
,
':'
);
if
(
strchr
(
tmpstr
,
'*'
)
!=
NULL
||
strchr
(
tmpstr
,
'?'
)
!=
NULL
)
pstr
=
strrchrW
(
tmpstr
,
':'
);
if
(
strchrW
(
tmpstr
,
'*'
)
!=
NULL
||
strchrW
(
tmpstr
,
'?'
)
!=
NULL
)
{
/* edit control contains wildcards */
if
(
pstr
!=
NULL
)
{
lstrcpyn
A
(
tmpstr2
,
pstr
+
1
,
512
);
lstrcpyn
W
(
tmpstr2
,
pstr
+
1
,
BUFFILE
);
*
(
pstr
+
1
)
=
0
;
}
else
{
strcpy
(
tmpstr2
,
tmpstr
);
lstrcpyW
(
tmpstr2
,
tmpstr
);
*
tmpstr
=
0
;
}
TRACE
(
"tmpstr=%s, tmpstr2=%s
\n
"
,
tmpstr
,
tmpstr2
);
SetDlgItemTextA
(
hWnd
,
edt1
,
tmpstr2
);
TRACE
(
"tmpstr=%s, tmpstr2=%s
\n
"
,
debugstr_w
(
tmpstr
),
debugstr_w
(
tmpstr2
));
SetDlgItemTextW
(
hWnd
,
edt1
,
tmpstr2
);
FILEDLG_ScanDir
(
hWnd
,
tmpstr
);
return
TRUE
;
}
/* no wildcards, we might have a directory or a filename */
/* try appending a wildcard and reading the directory */
pstr2
=
tmpstr
+
strlen
(
tmpstr
);
pstr2
=
tmpstr
+
lstrlenW
(
tmpstr
);
if
(
pstr
==
NULL
||
*
(
pstr
+
1
)
!=
0
)
strcat
(
tmpstr
,
"
\\
"
);
lRet
=
SendDlgItemMessage
16
(
hWnd
,
cmb1
,
CB_GETCURSEL16
,
0
,
0
);
lstrcatW
(
tmpstr
,
FILE_bslash
);
lRet
=
SendDlgItemMessage
W
(
hWnd
,
cmb1
,
CB_GETCURSEL
,
0
,
0
);
if
(
lRet
==
LB_ERR
)
return
TRUE
;
lpofn
->
nFilterIndex
=
lRet
+
1
;
TRACE
(
"
lpofn->nFilterIndex=%ld
\n
"
,
lpofn
->
nFilterIndex
);
lstrcpyn
A
(
tmpstr2
,
FILEDLG_GetFileType
(
PTR_SEG_TO_LIN
(
lpofn
->
lpstrCustomFilter
)
,
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFilter
)
,
ofnW
->
nFilterIndex
=
lRet
+
1
;
TRACE
(
"
ofn->nFilterIndex=%ld
\n
"
,
ofnW
->
nFilterIndex
);
lstrcpyn
W
(
tmpstr2
,
FILEDLG_GetFileType
(
ofnW
->
lpstrCustomFilter
,
(
LPWSTR
)
ofnW
->
lpstrFilter
,
lRet
),
sizeof
(
tmpstr2
));
SetDlgItemTextA
(
hWnd
,
edt1
,
tmpstr2
);
SetDlgItemTextW
(
hWnd
,
edt1
,
tmpstr2
);
if
(
!
in_update
)
/* if ScanDir succeeds, we have changed the directory */
if
(
FILEDLG_ScanDir
(
hWnd
,
tmpstr
))
return
TRUE
;
{
/* if ScanDir succeeds, we have changed the directory */
if
(
FILEDLG_ScanDir
(
hWnd
,
tmpstr
))
return
TRUE
;
}
/* if not, this must be a filename */
*
pstr2
=
0
;
*
pstr2
=
0
;
/* remove the wildcard added before */
if
(
pstr
!=
NULL
)
{
/* strip off the pathname */
*
pstr
=
0
;
SetDlgItemText
A
(
hWnd
,
edt1
,
pstr
+
1
);
lstrcpyn
A
(
tmpstr2
,
pstr
+
1
,
sizeof
(
tmpstr2
)
);
SetDlgItemText
W
(
hWnd
,
edt1
,
pstr
+
1
);
lstrcpyn
W
(
tmpstr2
,
pstr
+
1
,
sizeof
(
tmpstr2
)
);
/* Should we MessageBox() if this fails? */
if
(
!
FILEDLG_ScanDir
(
hWnd
,
tmpstr
))
return
TRUE
;
strcpy
(
tmpstr
,
tmpstr2
);
lstrcpyW
(
tmpstr
,
tmpstr2
);
}
else
SetDlgItemTextA
(
hWnd
,
edt1
,
tmpstr
);
#if 0
ShowWindow16(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
#endif
{
int
lenstr2
;
int
drive
=
DRIVE_GetCurrentDrive
();
tmpstr2
[
0
]
=
'A'
+
drive
;
tmpstr2
[
1
]
=
':'
;
tmpstr2
[
2
]
=
'\\'
;
lstrcpynA
(
tmpstr2
+
3
,
DRIVE_GetDosCwd
(
drive
),
507
);
lenstr2
=
strlen
(
tmpstr2
);
if
(
lenstr2
>
3
)
tmpstr2
[
lenstr2
++
]
=
'\\'
;
lstrcpynA
(
tmpstr2
+
lenstr2
,
tmpstr
,
512
-
lenstr2
);
if
(
lpofn
->
lpstrFile
)
lstrcpynA
(
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFile
),
tmpstr2
,
lpofn
->
nMaxFile
);
}
lpofn
->
nFileOffset
=
strrchr
(
tmpstr2
,
'\\'
)
-
tmpstr2
+
1
;
lpofn
->
nFileExtension
=
0
;
while
(
tmpstr2
[
lpofn
->
nFileExtension
]
!=
'.'
&&
tmpstr2
[
lpofn
->
nFileExtension
]
!=
'\0'
)
lpofn
->
nFileExtension
++
;
if
(
tmpstr2
[
lpofn
->
nFileExtension
]
==
'\0'
)
lpofn
->
nFileExtension
=
0
;
else
lpofn
->
nFileExtension
++
;
else
SetDlgItemTextW
(
hWnd
,
edt1
,
tmpstr
);
FILEDLG_UpdateResult
(
lfs
,
tmpstr
,
tmpstr2
);
if
(
in_update
)
{
if
(
FILEDLG_HookCallChk
(
lpofn
))
FILEDLG_CallWindowProc
(
lpofn
,
hWnd
,
RegisterWindowMessageA
(
LBSELCHSTRING
),
control
,
MAKELONG
(
lRet
,
CD_LBSELCHANGE
));
if
(
lfs
->
hook
)
FILEDLG_CallWindowProc
(
lfs
,
lfs
->
lbselchstring
,
control
,
MAKELONG
(
lRet
,
CD_LBSELCHANGE
));
in_update
=
FALSE
;
return
TRUE
;
}
if
(
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFileTitle
)
!=
NULL
)
{
lRet
=
SendDlgItemMessage16
(
hWnd
,
lst1
,
LB_GETCURSEL16
,
0
,
0
);
SendDlgItemMessage16
(
hWnd
,
lst1
,
LB_GETTEXT16
,
lRet
,
lpofn
->
lpstrFileTitle
);
}
if
(
FILEDLG_HookCallChk
(
lpofn
))
FILEDLG_UpdateFileTitle
(
lfs
);
if
(
lfs
->
hook
)
{
lRet
=
(
BOOL16
)
FILEDLG_CallWindowProc
(
lpofn
,
hWnd
,
RegisterWindowMessageA
(
FILEOKSTRING
),
0
,
lParam
);
if
(
lRet
)
{
*
lpofn
=
ofn2
;
/* restore old state */
#if 0
ShowWindow16(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
#endif
break
;
}
lRet
=
(
BOOL
)
FILEDLG_CallWindowProc
(
lfs
,
lfs
->
fileokstring
,
0
,
lfs
->
lParam
);
if
(
lRet
)
{
*
ofnW
=
ofn2
;
/* restore old state */
break
;
}
}
if
((
lpofn
->
Flags
&
OFN_ALLOWMULTISELECT
)
&&
(
lpofn
->
Flags
&
OFN_EXPLORER
))
{
if
(
lpofn
->
lpstrFile
)
{
LP
STR
str
=
(
LPSTR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFile
)
;
LP
STR
ptr
=
strrchr
(
str
,
'\\'
);
str
[
strlen
(
str
)
+
1
]
=
'\0'
;
if
((
ofnW
->
Flags
&
OFN_ALLOWMULTISELECT
)
&&
(
ofnW
->
Flags
&
OFN_EXPLORER
))
{
if
(
ofnW
->
lpstrFile
)
{
LP
WSTR
str
=
(
LPWSTR
)
ofnW
->
lpstrFile
;
LP
WSTR
ptr
=
strrchrW
(
str
,
'\\'
);
str
[
lstrlenW
(
str
)
+
1
]
=
'\0'
;
*
ptr
=
0
;
}
}
...
...
@@ -1047,51 +866,378 @@ static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
case
IDCANCEL
:
EndDialog
(
hWnd
,
FALSE
);
return
TRUE
;
case
IDABORT
:
/* can be sent by the hook procedure */
EndDialog
(
hWnd
,
TRUE
);
return
TRUE
;
}
return
FALSE
;
}
/***********************************************************************
* 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
;
lpdis
->
hwndItem
=
lpdis16
->
hwndItem
;
lpdis
->
hDC
=
lpdis16
->
hDC
;
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
*/
LPWSTR
FILEDLG_MapStringPairsToW
(
LPCSTR
strA
,
UINT
size
)
{
LPCSTR
s
;
LPWSTR
x
,
y
;
int
n
;
s
=
strA
;
while
(
*
s
)
s
=
s
+
strlen
(
s
)
+
1
;
s
++
;
n
=
s
-
strA
;
if
(
n
<
size
)
n
=
size
;
x
=
y
=
HeapAlloc
(
GetProcessHeap
(),
0
,
n
*
sizeof
(
WCHAR
));
s
=
strA
;
while
(
*
s
)
{
lstrcpyAtoW
(
x
,
s
);
x
+=
lstrlenW
(
x
)
+
1
;
s
+=
strlen
(
s
)
+
1
;
}
*
x
=
0
;
return
y
;
}
/************************************************************************
* FILEDLG_DupToW [internal]
* duplicates an Ansi string to unicode, with a buffer size
*/
LPWSTR
FILEDLG_DupToW
(
LPCSTR
str
,
UINT
size
)
{
LPWSTR
strW
;
if
(
str
&&
(
size
>
0
))
{
strW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
));
lstrcpynAtoW
(
strW
,
str
,
size
);
return
strW
;
}
else
return
NULL
;
}
/************************************************************************
* FILEDLG_MapOfnStructA [internal]
* map a 32 bits Ansi structure to an Unicode one
*/
void
FILEDLG_MapOfnStructA
(
LPOPENFILENAMEA
ofnA
,
LPOPENFILENAMEW
ofnW
,
BOOL
open
)
{
LPCSTR
str
;
ofnW
->
lStructSize
=
sizeof
(
OPENFILENAMEW
);
ofnW
->
hwndOwner
=
ofnA
->
hwndOwner
;
ofnW
->
hInstance
=
ofnA
->
hInstance
;
if
(
ofnA
->
lpstrFilter
)
ofnW
->
lpstrFilter
=
FILEDLG_MapStringPairsToW
(
ofnA
->
lpstrFilter
,
0
);
else
ofnW
->
lpstrFilter
=
FILEDLG_MapStringPairsToW
(
defaultfilter
,
0
);
if
((
ofnA
->
lpstrCustomFilter
)
&&
(
*
(
ofnA
->
lpstrCustomFilter
)))
ofnW
->
lpstrCustomFilter
=
FILEDLG_MapStringPairsToW
(
ofnA
->
lpstrCustomFilter
,
ofnA
->
nMaxCustFilter
);
ofnW
->
nMaxCustFilter
=
ofnA
->
nMaxCustFilter
;
ofnW
->
nFilterIndex
=
ofnA
->
nFilterIndex
;
ofnW
->
lpstrFile
=
FILEDLG_DupToW
(
ofnA
->
lpstrFile
,
ofnA
->
nMaxFile
);
ofnW
->
nMaxFile
=
ofnA
->
nMaxFile
;
ofnW
->
lpstrFileTitle
=
FILEDLG_DupToW
(
ofnA
->
lpstrFileTitle
,
ofnA
->
nMaxFileTitle
);
ofnW
->
nMaxFileTitle
=
ofnA
->
nMaxFileTitle
;
if
(
ofnA
->
lpstrInitialDir
)
ofnW
->
lpstrInitialDir
=
HEAP_strdupAtoW
(
GetProcessHeap
(),
0
,
ofnA
->
lpstrInitialDir
);
if
(
ofnA
->
lpstrTitle
)
str
=
ofnA
->
lpstrTitle
;
else
/* Allocates default title (FIXME : get it from resource) */
str
=
open
?
defaultopen
:
defaultsave
;
ofnW
->
lpstrTitle
=
HEAP_strdupAtoW
(
GetProcessHeap
(),
0
,
str
);
ofnW
->
Flags
=
ofnA
->
Flags
;
ofnW
->
nFileOffset
=
ofnA
->
nFileOffset
;
ofnW
->
nFileExtension
=
ofnA
->
nFileExtension
;
ofnW
->
lpstrDefExt
=
FILEDLG_DupToW
(
ofnA
->
lpstrDefExt
,
3
);
if
((
ofnA
->
Flags
&
OFN_ENABLETEMPLATE
)
&&
(
ofnA
->
lpTemplateName
))
{
if
(
HIWORD
(
ofnA
->
lpTemplateName
))
ofnW
->
lpTemplateName
=
HEAP_strdupAtoW
(
GetProcessHeap
(),
0
,
ofnA
->
lpTemplateName
);
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
);
ofnA
.
hwndOwner
=
ofn16
->
hwndOwner
;
ofnA
.
hInstance
=
ofn16
->
hInstance
;
if
(
ofn16
->
lpstrFilter
)
ofnA
.
lpstrFilter
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFilter
);
if
(
ofn16
->
lpstrCustomFilter
)
ofnA
.
lpstrCustomFilter
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrCustomFilter
);
ofnA
.
nMaxCustFilter
=
ofn16
->
nMaxCustFilter
;
ofnA
.
nFilterIndex
=
ofn16
->
nFilterIndex
;
ofnA
.
lpstrFile
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFile
);
ofnA
.
nMaxFile
=
ofn16
->
nMaxFile
;
ofnA
.
lpstrFileTitle
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFileTitle
);
ofnA
.
nMaxFileTitle
=
ofn16
->
nMaxFileTitle
;
ofnA
.
lpstrInitialDir
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrInitialDir
);
ofnA
.
lpstrTitle
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrTitle
);
ofnA
.
Flags
=
ofn16
->
Flags
;
ofnA
.
nFileOffset
=
ofn16
->
nFileOffset
;
ofnA
.
nFileExtension
=
ofn16
->
nFileExtension
;
ofnA
.
lpstrDefExt
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrDefExt
);
if
(
HIWORD
(
ofn16
->
lpTemplateName
))
ofnA
.
lpTemplateName
=
PTR_SEG_TO_LIN
(
ofn16
->
lpTemplateName
);
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]
* destroys the private object
*/
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]
* allocate a private object to hold 32 bits Unicode
* 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
;
lfs
->
lbselchstring
=
RegisterWindowMessageA
(
LBSELCHSTRING
);
lfs
->
fileokstring
=
RegisterWindowMessageA
(
FILEOKSTRING
);
switch
(
type
)
{
case
LFS16
:
lfs
->
ofn16
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
lParam
);
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
);
}
else
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.
*/
BOOL
WINAPI
GetFileName31A
(
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
)
{
hInst
=
GetWindowLongA
(
lpofn
->
hwndOwner
,
GWL_HINSTANCE
);
bRet
=
DialogBoxIndirectParamA
(
hInst
,
lfs
->
template
,
lpofn
->
hwndOwner
,
(
DLGPROC
)
FileOpenDlgProc
,
(
DWORD
)
lfs
);
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
*/
BOOL
WINAPI
GetFileName31W
(
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
)
{
hInst
=
GetWindowLongA
(
lpofn
->
hwndOwner
,
GWL_HINSTANCE
);
bRet
=
DialogBoxIndirectParamW
(
hInst
,
lfs
->
template
,
lpofn
->
hwndOwner
,
(
DLGPROC
)
FileOpenDlgProc
,
(
DWORD
)
lfs
);
FILEDLG_DestroyPrivate
(
lfs
);
}
TRACE
(
"return lpstrFile='%s' !
\n
"
,
debugstr_w
(
lpofn
->
lpstrFile
));
return
bRet
;
}
/* ------------------ Dialog procedures ---------------------- */
/***********************************************************************
* FileOpenDlgProc16 (COMMDLG.6)
*/
LRESULT
WINAPI
FileOpenDlgProc16
(
HWND16
hWnd
,
UINT16
wMsg
,
WPARAM16
wParam
,
LPARAM
lParam
)
{
LPOPENFILENAME16
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
GetPropA
(
hWnd
,
OFN_PROP
));
LFSPRIVATE
lfs
=
(
LFSPRIVATE
)
GetPropA
(
hWnd
,
OFN_PROP
);
DRAWITEMSTRUCT
dis
;
if
(
wMsg
!=
WM_INITDIALOG
)
if
(
FILEDLG_HookCallChk
(
lpofn
)
)
{
LRESULT
lRet
=
(
BOOL16
)
FILEDLG_CallWindowProc
(
lpofn
,
hWnd
,
wMsg
,
wParam
,
lParam
);
if
(
lRet
)
return
lRet
;
/* else continue message processing */
}
switch
(
wMsg
)
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
);
if
(
lRet
)
return
lRet
;
/* else continue message processing */
}
switch
(
wMsg
)
{
case
WM_INITDIALOG
:
return
FILEDLG_WMInitDialog
(
hWnd
,
wParam
,
lParam
);
return
FILEDLG_WMInitDialog
(
hWnd
,
wParam
,
lParam
);
case
WM_MEASUREITEM
:
return
FILEDLG_WMMeasureItem
(
hWnd
,
wParam
,
lParam
);
return
FILEDLG_WMMeasureItem16
(
hWnd
,
wParam
,
lParam
);
case
WM_DRAWITEM
:
return
FILEDLG_WMDrawItem
(
hWnd
,
wParam
,
lParam
,
FALSE
);
FILEDLG_MapDrawItemStruct
((
LPDRAWITEMSTRUCT16
)
PTR_SEG_TO_LIN
(
lParam
),
&
dis
);
return
FILEDLG_WMDrawItem
(
hWnd
,
wParam
,
lParam
,
FALSE
,
&
dis
);
case
WM_COMMAND
:
return
FILEDLG_WMCommand
(
hWnd
,
wParam
,
lParam
);
return
FILEDLG_WMCommand
(
hWnd
,
lParam
,
HIWORD
(
lParam
),
wParam
,
lfs
);
#if 0
case WM_CTLCOLOR:
SetBkColor((HDC16)wParam, 0x00C0C0C0);
switch (HIWORD(lParam))
{
case CTLCOLOR_BTN:
SetTextColor((HDC16)wParam, 0x00000000);
return hGRAYBrush;
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;
SetTextColor((HDC16)wParam, 0x00000000);
return hGRAYBrush;
}
break;
#endif
}
return
FALSE
;
return
FALSE
;
}
/***********************************************************************
...
...
@@ -1100,12 +1246,14 @@ LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
LRESULT
WINAPI
FileSaveDlgProc16
(
HWND16
hWnd
,
UINT16
wMsg
,
WPARAM16
wParam
,
LPARAM
lParam
)
{
LPOPENFILENAME16
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
GetPropA
(
hWnd
,
OFN_PROP
));
if
(
wMsg
!=
WM_INITDIALOG
)
if
(
FILEDLG_HookCallChk
(
lpofn
))
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
)
{
LRESULT
lRet
=
(
BOOL16
)
FILEDLG_CallWindowProc
(
lpofn
,
hWnd
,
wMsg
,
wParam
,
lParam
);
LRESULT
lRet
;
lRet
=
(
BOOL16
)
FILEDLG_CallWindowProc
(
lfs
,
wMsg
,
wParam
,
lParam
);
if
(
lRet
)
return
lRet
;
/* else continue message processing */
}
...
...
@@ -1114,13 +1262,14 @@ LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
return
FILEDLG_WMInitDialog
(
hWnd
,
wParam
,
lParam
);
case
WM_MEASUREITEM
:
return
FILEDLG_WMMeasureItem
(
hWnd
,
wParam
,
lParam
);
return
FILEDLG_WMMeasureItem
16
(
hWnd
,
wParam
,
lParam
);
case
WM_DRAWITEM
:
return
FILEDLG_WMDrawItem
(
hWnd
,
wParam
,
lParam
,
TRUE
);
FILEDLG_MapDrawItemStruct
((
LPDRAWITEMSTRUCT16
)
PTR_SEG_TO_LIN
(
lParam
),
&
dis
);
return
FILEDLG_WMDrawItem
(
hWnd
,
wParam
,
lParam
,
TRUE
,
&
dis
);
case
WM_COMMAND
:
return
FILEDLG_WMCommand
(
hWnd
,
wParam
,
lParam
);
return
FILEDLG_WMCommand
(
hWnd
,
lParam
,
HIWORD
(
lParam
),
wParam
,
lfs
);
}
/*
...
...
@@ -1141,238 +1290,141 @@ LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
return
FALSE
;
}
static
BOOL
Commdlg_GetFileNameA
(
BOOL16
(
CALLBACK
*
dofunction
)(
SEGPTR
x
),
LPOPENFILENAMEA
ofn
)
/***********************************************************************
* FileOpenDlgProc [internal]
* Used for open and save, in fact.
*/
static
LRESULT
WINAPI
FileOpenDlgProc
(
HWND
hWnd
,
UINT
wMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
BOOL16
ret
;
LPOPENFILENAME16
ofn16
=
SEGPTR_ALLOC
(
sizeof
(
OPENFILENAME16
));
memset
(
ofn16
,
'\0'
,
sizeof
(
*
ofn16
));
ofn16
->
lStructSize
=
sizeof
(
*
ofn16
);
ofn16
->
hwndOwner
=
ofn
->
hwndOwner
;
ofn16
->
hInstance
=
MapHModuleLS
(
ofn
->
hInstance
);
if
(
ofn
->
lpstrFilter
)
{
LPSTR
s
,
x
;
/* filter is a list... title\0ext\0......\0\0 */
s
=
(
LPSTR
)
ofn
->
lpstrFilter
;
while
(
*
s
)
s
=
s
+
strlen
(
s
)
+
1
;
s
++
;
x
=
(
LPSTR
)
SEGPTR_ALLOC
(
s
-
ofn
->
lpstrFilter
);
memcpy
(
x
,
ofn
->
lpstrFilter
,
s
-
ofn
->
lpstrFilter
);
ofn16
->
lpstrFilter
=
SEGPTR_GET
(
x
);
}
if
(
ofn
->
lpstrCustomFilter
)
{
LPSTR
s
,
x
;
/* filter is a list... title\0ext\0......\0\0 */
s
=
(
LPSTR
)
ofn
->
lpstrCustomFilter
;
while
(
*
s
)
s
=
s
+
strlen
(
s
)
+
1
;
s
++
;
x
=
SEGPTR_ALLOC
(
s
-
ofn
->
lpstrCustomFilter
);
memcpy
(
x
,
ofn
->
lpstrCustomFilter
,
s
-
ofn
->
lpstrCustomFilter
);
ofn16
->
lpstrCustomFilter
=
SEGPTR_GET
(
x
);
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
)
{
LRESULT
lRet
;
lRet
=
(
BOOL
)
FILEDLG_CallWindowProc
(
lfs
,
wMsg
,
wParam
,
lParam
);
if
(
lRet
)
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;
}
ofn16
->
nMaxCustFilter
=
ofn
->
nMaxCustFilter
;
ofn16
->
nFilterIndex
=
ofn
->
nFilterIndex
;
if
(
ofn
->
nMaxFile
)
ofn16
->
lpstrFile
=
SEGPTR_GET
(
SEGPTR_ALLOC
(
ofn
->
nMaxFile
));
ofn16
->
nMaxFile
=
ofn
->
nMaxFile
;
ofn16
->
nMaxFileTitle
=
ofn
->
nMaxFileTitle
;
if
(
ofn16
->
nMaxFileTitle
)
ofn16
->
lpstrFileTitle
=
SEGPTR_GET
(
SEGPTR_ALLOC
(
ofn
->
nMaxFileTitle
));
if
(
ofn
->
lpstrInitialDir
)
ofn16
->
lpstrInitialDir
=
SEGPTR_GET
(
SEGPTR_STRDUP
(
ofn
->
lpstrInitialDir
));
if
(
ofn
->
lpstrTitle
)
ofn16
->
lpstrTitle
=
SEGPTR_GET
(
SEGPTR_STRDUP
(
ofn
->
lpstrTitle
));
ofn16
->
Flags
=
ofn
->
Flags
|
OFN_WINE
;
ofn16
->
nFileOffset
=
ofn
->
nFileOffset
;
ofn16
->
nFileExtension
=
ofn
->
nFileExtension
;
if
(
ofn
->
lpstrDefExt
)
ofn16
->
lpstrDefExt
=
SEGPTR_GET
(
SEGPTR_STRDUP
(
ofn
->
lpstrDefExt
));
ofn16
->
lCustData
=
ofn
->
lCustData
;
ofn16
->
lpfnHook
=
(
LPOFNHOOKPROC16
)
ofn
->
lpfnHook
;
if
(
ofn
->
lpTemplateName
)
ofn16
->
lpTemplateName
=
SEGPTR_GET
(
SEGPTR_STRDUP
(
ofn
->
lpTemplateName
));
ret
=
dofunction
(
SEGPTR_GET
(
ofn16
));
ofn
->
nFileOffset
=
ofn16
->
nFileOffset
;
ofn
->
nFileExtension
=
ofn16
->
nFileExtension
;
if
(
ofn16
->
lpstrFilter
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFilter
));
if
(
ofn16
->
lpTemplateName
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpTemplateName
));
if
(
ofn16
->
lpstrDefExt
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrDefExt
));
if
(
ofn16
->
lpstrTitle
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrTitle
));
if
(
ofn16
->
lpstrInitialDir
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrInitialDir
));
if
(
ofn16
->
lpstrCustomFilter
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrCustomFilter
));
if
(
ofn16
->
lpstrFile
)
{
LPCSTR
src
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFile
);
LPSTR
dst
=
ofn
->
lpstrFile
;
if
((
ofn
->
Flags
&
OFN_ALLOWMULTISELECT
)
&&
(
ofn
->
Flags
&
OFN_EXPLORER
))
{
/* FIXME(EPP): I tried to use:
* memcpy(ofn->lpstrFile, PTR_SEG_TO_LIN(ofn16->lpstrFile, ofn->nMaxFile)
* but it did crash with winamp 2.21, so copy string by string
*/
int
len
;
do
{
strcpy
(
dst
,
src
);
len
=
strlen
(
dst
)
+
1
;
/* strlen(dst) == strlen(src) */
dst
+=
len
;
src
+=
len
;
}
while
(
len
>
1
);
}
else
{
strcpy
(
dst
,
src
);
}
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFile
));
}
if
(
ofn16
->
lpstrFileTitle
)
{
if
(
ofn
->
lpstrFileTitle
)
strcpy
(
ofn
->
lpstrFileTitle
,
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFileTitle
));
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFileTitle
));
}
SEGPTR_FREE
(
ofn16
);
return
ret
;
break;
#endif
}
return
FALSE
;
}
static
BOOL
Commdlg_GetFileNameW
(
BOOL16
(
CALLBACK
*
dofunction
)(
SEGPTR
x
),
LPOPENFILENAMEW
ofn
)
/* ------------------ APIs ---------------------- */
/***********************************************************************
* GetOpenFileName16 (COMMDLG.1)
*
* 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.
*/
BOOL16
WINAPI
GetOpenFileName16
(
SEGPTR
ofn
/* addess of structure with data*/
)
{
BOOL16
ret
;
LPOPENFILENAME16
ofn16
=
SEGPTR_ALLOC
(
sizeof
(
OPENFILENAME16
));
memset
(
ofn16
,
'\0'
,
sizeof
(
*
ofn16
));
ofn16
->
lStructSize
=
sizeof
(
*
ofn16
);
ofn16
->
hwndOwner
=
ofn
->
hwndOwner
;
ofn16
->
hInstance
=
MapHModuleLS
(
ofn
->
hInstance
);
if
(
ofn
->
lpstrFilter
)
{
LPWSTR
s
;
LPSTR
x
,
y
;
int
n
;
/* filter is a list... title\0ext\0......\0\0 */
s
=
(
LPWSTR
)
ofn
->
lpstrFilter
;
while
(
*
s
)
s
=
s
+
lstrlenW
(
s
)
+
1
;
s
++
;
n
=
s
-
ofn
->
lpstrFilter
;
/* already divides by 2. ptr magic */
x
=
y
=
(
LPSTR
)
SEGPTR_ALLOC
(
n
);
s
=
(
LPWSTR
)
ofn
->
lpstrFilter
;
while
(
*
s
)
{
lstrcpyWtoA
(
x
,
s
);
x
+=
lstrlenA
(
x
)
+
1
;
s
+=
lstrlenW
(
s
)
+
1
;
}
*
x
=
0
;
ofn16
->
lpstrFilter
=
SEGPTR_GET
(
y
);
HINSTANCE
hInst
;
BOOL
bRet
=
FALSE
;
LPOPENFILENAME16
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
ofn
);
LFSPRIVATE
lfs
;
FARPROC16
ptr
;
if
(
!
lpofn
||
!
FileDlg_Init
())
return
FALSE
;
lfs
=
FILEDLG_AllocPrivate
((
LPARAM
)
ofn
,
LFS16
,
OPEN_DIALOG
);
if
(
lfs
)
{
hInst
=
GetWindowLongA
(
lpofn
->
hwndOwner
,
GWL_HINSTANCE
);
ptr
=
GetProcAddress16
(
GetModuleHandle16
(
"COMMDLG"
),
(
SEGPTR
)
6
);
bRet
=
DialogBoxIndirectParam16
(
hInst
,
lfs
->
hDlgTmpl16
,
lpofn
->
hwndOwner
,
(
DLGPROC16
)
ptr
,
(
DWORD
)
lfs
);
FILEDLG_DestroyPrivate
(
lfs
);
}
TRACE
(
"return lpstrFile='%s' !
\n
"
,
(
LPSTR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFile
));
return
bRet
;
}
if
(
ofn
->
lpstrCustomFilter
)
{
LPWSTR
s
;
LPSTR
x
,
y
;
int
n
;
/* filter is a list... title\0ext\0......\0\0 */
s
=
(
LPWSTR
)
ofn
->
lpstrCustomFilter
;
while
(
*
s
)
s
=
s
+
lstrlenW
(
s
)
+
1
;
s
++
;
n
=
s
-
ofn
->
lpstrCustomFilter
;
x
=
y
=
(
LPSTR
)
SEGPTR_ALLOC
(
n
);
s
=
(
LPWSTR
)
ofn
->
lpstrCustomFilter
;
while
(
*
s
)
{
lstrcpyWtoA
(
x
,
s
);
x
+=
lstrlenA
(
x
)
+
1
;
s
+=
lstrlenW
(
s
)
+
1
;
}
*
x
=
0
;
ofn16
->
lpstrCustomFilter
=
SEGPTR_GET
(
y
);
}
ofn16
->
nMaxCustFilter
=
ofn
->
nMaxCustFilter
;
ofn16
->
nFilterIndex
=
ofn
->
nFilterIndex
;
if
(
ofn
->
nMaxFile
)
ofn16
->
lpstrFile
=
SEGPTR_GET
(
SEGPTR_ALLOC
(
ofn
->
nMaxFile
));
ofn16
->
nMaxFile
=
ofn
->
nMaxFile
;
ofn16
->
nMaxFileTitle
=
ofn
->
nMaxFileTitle
;
if
(
ofn
->
nMaxFileTitle
)
ofn16
->
lpstrFileTitle
=
SEGPTR_GET
(
SEGPTR_ALLOC
(
ofn
->
nMaxFileTitle
));
if
(
ofn
->
lpstrInitialDir
)
ofn16
->
lpstrInitialDir
=
SEGPTR_GET
(
SEGPTR_STRDUP_WtoA
(
ofn
->
lpstrInitialDir
));
if
(
ofn
->
lpstrTitle
)
ofn16
->
lpstrTitle
=
SEGPTR_GET
(
SEGPTR_STRDUP_WtoA
(
ofn
->
lpstrTitle
));
ofn16
->
Flags
=
ofn
->
Flags
|
OFN_WINE
|
OFN_UNICODE
;
ofn16
->
nFileOffset
=
ofn
->
nFileOffset
;
ofn16
->
nFileExtension
=
ofn
->
nFileExtension
;
if
(
ofn
->
lpstrDefExt
)
ofn16
->
lpstrDefExt
=
SEGPTR_GET
(
SEGPTR_STRDUP_WtoA
(
ofn
->
lpstrDefExt
));
ofn16
->
lCustData
=
ofn
->
lCustData
;
ofn16
->
lpfnHook
=
(
LPOFNHOOKPROC16
)
ofn
->
lpfnHook
;
if
(
ofn
->
lpTemplateName
)
ofn16
->
lpTemplateName
=
SEGPTR_GET
(
SEGPTR_STRDUP_WtoA
(
ofn
->
lpTemplateName
));
ret
=
dofunction
(
SEGPTR_GET
(
ofn16
));
ofn
->
nFileOffset
=
ofn16
->
nFileOffset
;
ofn
->
nFileExtension
=
ofn16
->
nFileExtension
;
if
(
ofn16
->
lpstrFilter
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFilter
));
if
(
ofn16
->
lpTemplateName
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpTemplateName
));
if
(
ofn16
->
lpstrDefExt
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrDefExt
));
if
(
ofn16
->
lpstrTitle
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrTitle
));
if
(
ofn16
->
lpstrInitialDir
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrInitialDir
));
if
(
ofn16
->
lpstrCustomFilter
)
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrCustomFilter
));
if
(
ofn16
->
lpstrFile
)
{
LPCSTR
src
=
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFile
);
LPWSTR
dst
=
ofn
->
lpstrFile
;
if
((
ofn
->
Flags
&
OFN_ALLOWMULTISELECT
)
&&
(
ofn
->
Flags
&
OFN_EXPLORER
))
{
int
len
;
do
{
lstrcpyAtoW
(
dst
,
src
);
dst
+=
lstrlenW
(
dst
)
+
1
;
src
+=
(
len
=
strlen
(
src
)
+
1
);
}
while
(
len
>
1
);
}
else
{
lstrcpyAtoW
(
ofn
->
lpstrFile
,
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFile
));
}
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFile
));
}
if
(
ofn16
->
lpstrFileTitle
)
{
if
(
ofn
->
lpstrFileTitle
)
lstrcpyAtoW
(
ofn
->
lpstrFileTitle
,
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFileTitle
));
SEGPTR_FREE
(
PTR_SEG_TO_LIN
(
ofn16
->
lpstrFileTitle
));
}
SEGPTR_FREE
(
ofn16
);
return
ret
;
/***********************************************************************
* GetSaveFileName16 (COMMDLG.2)
*
* 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.
*/
BOOL16
WINAPI
GetSaveFileName16
(
SEGPTR
ofn
/* addess of structure with data*/
)
{
HINSTANCE
hInst
;
BOOL
bRet
=
FALSE
;
LPOPENFILENAME16
lpofn
=
(
LPOPENFILENAME16
)
PTR_SEG_TO_LIN
(
ofn
);
LFSPRIVATE
lfs
;
FARPROC16
ptr
;
if
(
!
lpofn
||
!
FileDlg_Init
())
return
FALSE
;
lfs
=
FILEDLG_AllocPrivate
((
LPARAM
)
ofn
,
LFS16
,
SAVE_DIALOG
);
if
(
lfs
)
{
hInst
=
GetWindowLongA
(
lpofn
->
hwndOwner
,
GWL_HINSTANCE
);
ptr
=
GetProcAddress16
(
GetModuleHandle16
(
"COMMDLG"
),
(
SEGPTR
)
7
);
bRet
=
DialogBoxIndirectParam16
(
hInst
,
lfs
->
hDlgTmpl16
,
lpofn
->
hwndOwner
,
(
DLGPROC16
)
ptr
,
(
DWORD
)
lfs
);
FILEDLG_DestroyPrivate
(
lfs
);
}
TRACE
(
"return lpstrFile='%s' !
\n
"
,
(
LPSTR
)
PTR_SEG_TO_LIN
(
lpofn
->
lpstrFile
));
return
bRet
;
}
/***********************************************************************
* GetOpenFileNameA (COMDLG32.10)
*
* Creates a dialog box for the user to select a file to open.
*
* RETURNS
* TRUE on succes: user enters a valid file
* TRUE on succes
s
: user enters a valid file
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
...
...
@@ -1398,8 +1450,7 @@ BOOL WINAPI GetOpenFileNameA(
}
else
{
BOOL16
(
CALLBACK
*
dofunction
)(
SEGPTR
ofn16
)
=
GetOpenFileName16
;
return
Commdlg_GetFileNameA
(
dofunction
,
ofn
);
return
GetFileName31A
(
ofn
,
OPEN_DIALOG
);
}
}
...
...
@@ -1409,7 +1460,7 @@ BOOL WINAPI GetOpenFileNameA(
* Creates a dialog box for the user to select a file to open.
*
* RETURNS
* TRUE on succes: user enters a valid file
* TRUE on succes
s
: user enters a valid file
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
...
...
@@ -1435,8 +1486,7 @@ BOOL WINAPI GetOpenFileNameW(
}
else
{
BOOL16
(
CALLBACK
*
dofunction
)(
SEGPTR
ofn16
)
=
GetOpenFileName16
;
return
Commdlg_GetFileNameW
(
dofunction
,
ofn
);
return
GetFileName31W
(
ofn
,
OPEN_DIALOG
);
}
}
...
...
@@ -1446,7 +1496,7 @@ BOOL WINAPI GetOpenFileNameW(
* Creates a dialog box for the user to select a file to save.
*
* RETURNS
* TRUE on succes: user enters a valid file
* TRUE on succes
s
: user enters a valid file
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
...
...
@@ -1472,8 +1522,7 @@ BOOL WINAPI GetSaveFileNameA(
}
else
{
BOOL16
(
CALLBACK
*
dofunction
)(
SEGPTR
ofn16
)
=
GetSaveFileName16
;
return
Commdlg_GetFileNameA
(
dofunction
,
ofn
);
return
GetFileName31A
(
ofn
,
SAVE_DIALOG
);
}
}
...
...
@@ -1483,7 +1532,7 @@ BOOL WINAPI GetSaveFileNameA(
* Creates a dialog box for the user to select a file to save.
*
* RETURNS
* TRUE on succes: user enters a valid file
* TRUE on succes
s
: user enters a valid file
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
...
...
@@ -1509,7 +1558,6 @@ BOOL WINAPI GetSaveFileNameW(
}
else
{
BOOL16
(
CALLBACK
*
dofunction
)(
SEGPTR
ofn16
)
=
GetSaveFileName16
;
return
Commdlg_GetFileNameW
(
dofunction
,
ofn
);
return
GetFileName31W
(
ofn
,
SAVE_DIALOG
);
}
}
include/wine/unicode.h
View file @
d8cb43c7
...
...
@@ -134,6 +134,13 @@ static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch )
for
(
;
*
str
;
str
++
)
if
(
*
str
==
ch
)
return
(
WCHAR
*
)
str
;
return
NULL
;
}
static
inline
WCHAR
*
strrchrW
(
const
WCHAR
*
str
,
WCHAR
ch
)
{
WCHAR
*
ret
=
NULL
;
for
(
;
*
str
;
str
++
)
if
(
*
str
==
ch
)
ret
=
(
WCHAR
*
)
str
;
return
ret
;
}
static
inline
WCHAR
*
strlwrW
(
WCHAR
*
str
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment