comdlg32: Move all of the win 3.1 style functionality into the same file.

This commit is contained in:
Huw Davies 2012-09-19 11:08:01 +01:00 committed by Alexandre Julliard
parent bd5162474a
commit d26335497e
4 changed files with 199 additions and 249 deletions

View File

@ -177,6 +177,9 @@ int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf,
int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed) DECLSPEC_HIDDEN;
void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) DECLSPEC_HIDDEN;
extern BOOL GetFileName31A( OPENFILENAMEA *lpofn, UINT dlgType ) DECLSPEC_HIDDEN;
extern BOOL GetFileName31W( OPENFILENAMEW *lpofn, UINT dlgType ) DECLSPEC_HIDDEN;
/* ITEMIDLIST */
extern LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST);

View File

@ -68,7 +68,6 @@
#include "commdlg.h"
#include "dlgs.h"
#include "cdlg.h"
#include "filedlg31.h"
#include "cderr.h"
#include "shellapi.h"
#include "shlobj.h"
@ -4025,188 +4024,6 @@ static void MemFree(void *mem)
HeapFree(GetProcessHeap(),0,mem);
}
/*
* Old-style (win3.1) dialogs */
/***********************************************************************
* FD32_GetTemplate [internal]
*
* Get a template (or FALSE if failure) when 16 bits dialogs are used
* by a 32 bits application
*
*/
BOOL FD32_GetTemplate(PFD31_DATA lfs)
{
LPOPENFILENAMEW ofnW = lfs->ofnW;
LPOPENFILENAMEA ofnA = lfs->ofnA;
HANDLE hDlgTmpl;
if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
{
if (!(lfs->template = LockResource( ofnW->hInstance )))
{
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
return FALSE;
}
}
else if (ofnW->Flags & OFN_ENABLETEMPLATE)
{
HRSRC hResInfo;
if (ofnA)
hResInfo = FindResourceA(ofnA->hInstance,
ofnA->lpTemplateName,
(LPSTR)RT_DIALOG);
else
hResInfo = FindResourceW(ofnW->hInstance,
ofnW->lpTemplateName,
(LPWSTR)RT_DIALOG);
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 */
HRSRC hResInfo;
if (!(hResInfo = FindResourceA(COMDLG32_hInstance,
lfs->open? "OPEN_FILE":"SAVE_FILE", (LPSTR)RT_DIALOG)))
{
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
return FALSE;
}
if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo )) ||
!(lfs->template = LockResource( hDlgTmpl )))
{
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
return FALSE;
}
}
return TRUE;
}
/***********************************************************************
* FD32_WMMeasureItem [internal]
*/
static LONG FD32_WMMeasureItem(LPARAM lParam)
{
LPMEASUREITEMSTRUCT lpmeasure;
lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
lpmeasure->itemHeight = FD31_GetFldrHeight();
return TRUE;
}
/***********************************************************************
* FileOpenDlgProc [internal]
* Used for open and save, in fact.
*/
static INT_PTR CALLBACK FD32_FileOpenDlgProc(HWND hWnd, UINT wMsg,
WPARAM wParam, LPARAM lParam)
{
PFD31_DATA lfs = (PFD31_DATA)GetPropA(hWnd,FD31_OFN_PROP);
TRACE("msg=%x wparam=%lx lParam=%lx\n", wMsg, wParam, lParam);
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
{
INT_PTR lRet;
lRet = (INT_PTR)FD31_CallWindowProc(lfs, wMsg, wParam, lParam);
if (lRet)
return lRet; /* else continue message processing */
}
switch (wMsg)
{
case WM_INITDIALOG:
return FD31_WMInitDialog(hWnd, wParam, lParam);
case WM_MEASUREITEM:
return FD32_WMMeasureItem(lParam);
case WM_DRAWITEM:
return FD31_WMDrawItem(hWnd, wParam, lParam, !lfs->open, (DRAWITEMSTRUCT *)lParam);
case WM_COMMAND:
return FD31_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;
}
break;
#endif
}
return FALSE;
}
/***********************************************************************
* GetFileName31A [internal]
*
* Creates a win31 style dialog box for the user to select a file to open/save.
*/
static BOOL GetFileName31A(LPOPENFILENAMEA lpofn, /* address of structure with data*/
UINT dlgType /* type dialogue : open/save */
)
{
BOOL bRet = FALSE;
PFD31_DATA lfs;
if (!lpofn || !FD31_Init()) return FALSE;
TRACE("ofn flags %08x\n", lpofn->Flags);
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, FALSE);
if (lfs)
{
bRet = DialogBoxIndirectParamA( COMDLG32_hInstance, lfs->template, lpofn->hwndOwner,
FD32_FileOpenDlgProc, (LPARAM)lfs);
FD31_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
*/
static BOOL GetFileName31W(LPOPENFILENAMEW lpofn, /* address of structure with data*/
UINT dlgType /* type dialogue : open/save */
)
{
BOOL bRet = FALSE;
PFD31_DATA lfs;
if (!lpofn || !FD31_Init()) return FALSE;
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, TRUE);
if (lfs)
{
bRet = DialogBoxIndirectParamW( COMDLG32_hInstance, lfs->template, lpofn->hwndOwner,
FD32_FileOpenDlgProc, (LPARAM)lfs);
FD31_DestroyPrivate(lfs);
}
TRACE("file %s, file offset %d, ext offset %d\n",
debugstr_w(lpofn->lpstrFile), lpofn->nFileOffset, lpofn->nFileExtension);
return bRet;
}
static inline BOOL is_win16_looks(DWORD flags)
{
return (flags & (OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK|OFN_ENABLETEMPLATE) &&

View File

@ -1,5 +1,5 @@
/*
* COMMDLG - File Dialogs
* Win 3.1 Style File Dialogs
*
* Copyright 1994 Martin Ayotte
* Copyright 1996 Albrecht Kleine
@ -34,11 +34,11 @@
#include "winternl.h"
#include "commdlg.h"
#include "shlwapi.h"
#include "cderr.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#include "cdlg.h"
#include "filedlg31.h"
#define BUFFILE 512
#define BUFFILEALLOC 512 * sizeof(WCHAR)
@ -56,10 +56,26 @@ static HICON hHDisk = 0;
static HICON hCDRom = 0;
static HICON hNet = 0;
#define FD31_OFN_PROP "FILEDLG_OFN"
typedef struct tagFD31_DATA
{
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 */
LPCVOID template; /* template for 32 bits resource */
BOOL open; /* TRUE if open dialog, FALSE if save dialog */
LPOPENFILENAMEW ofnW; /* pointer either to the original structure or
a W copy for A/16 API */
LPOPENFILENAMEA ofnA; /* original structure if 32bits ansi dialog */
} FD31_DATA, *PFD31_DATA;
/***********************************************************************
* FD31_Init [internal]
*/
BOOL FD31_Init(void)
static BOOL FD31_Init(void)
{
static BOOL initialized = 0;
@ -106,8 +122,7 @@ static void FD31_StripEditControl(HWND hwnd)
*
* Call the appropriate hook
*/
BOOL FD31_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam)
static BOOL FD31_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
BOOL ret;
@ -207,7 +222,7 @@ static BOOL FD31_ScanDir(const OPENFILENAMEW *ofn, HWND hWnd, LPCWSTR newPath)
/***********************************************************************
* FD31_WMDrawItem [internal]
*/
LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
int savedlg, const DRAWITEMSTRUCT *lpdis)
{
WCHAR *str;
@ -641,7 +656,7 @@ static LRESULT FD31_FileTypeChange( const FD31_DATA *lfs )
/***********************************************************************
* FD31_WMCommand [internal]
*/
LRESULT FD31_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
static LRESULT FD31_WMCommand( HWND hWnd, LPARAM lParam, UINT notification,
UINT control, const FD31_DATA *lfs )
{
switch (control)
@ -812,7 +827,7 @@ static void FD31_FreeOfnW(OPENFILENAMEW *ofnW)
* FD31_DestroyPrivate [internal]
* destroys the private object
*/
void FD31_DestroyPrivate(PFD31_DATA lfs)
static void FD31_DestroyPrivate(PFD31_DATA lfs)
{
HWND hwnd;
if (!lfs) return;
@ -829,6 +844,64 @@ void FD31_DestroyPrivate(PFD31_DATA lfs)
RemovePropA(hwnd, FD31_OFN_PROP);
}
/***********************************************************************
* FD31_GetTemplate [internal]
*
* Get a template (or FALSE if failure) when 16 bits dialogs are used
* by a 32 bits application
*
*/
static BOOL FD31_GetTemplate(PFD31_DATA lfs)
{
LPOPENFILENAMEW ofnW = lfs->ofnW;
LPOPENFILENAMEA ofnA = lfs->ofnA;
HANDLE hDlgTmpl;
if (ofnW->Flags & OFN_ENABLETEMPLATEHANDLE)
{
if (!(lfs->template = LockResource( ofnW->hInstance )))
{
COMDLG32_SetCommDlgExtendedError( CDERR_LOADRESFAILURE );
return FALSE;
}
}
else if (ofnW->Flags & OFN_ENABLETEMPLATE)
{
HRSRC hResInfo;
if (ofnA)
hResInfo = FindResourceA( ofnA->hInstance, ofnA->lpTemplateName, (LPSTR)RT_DIALOG );
else
hResInfo = FindResourceW( ofnW->hInstance, ofnW->lpTemplateName, (LPWSTR)RT_DIALOG );
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 */
{
HRSRC hResInfo;
if (!(hResInfo = FindResourceA( COMDLG32_hInstance, lfs->open ? "OPEN_FILE" : "SAVE_FILE", (LPSTR)RT_DIALOG )))
{
COMDLG32_SetCommDlgExtendedError( CDERR_FINDRESFAILURE );
return FALSE;
}
if (!(hDlgTmpl = LoadResource( COMDLG32_hInstance, hResInfo )) ||
!(lfs->template = LockResource( hDlgTmpl )))
{
COMDLG32_SetCommDlgExtendedError( CDERR_LOADRESFAILURE );
return FALSE;
}
}
return TRUE;
}
/************************************************************************
* FD31_AllocPrivate [internal]
* allocate a private object to hold 32 bits Unicode
@ -837,7 +910,7 @@ void FD31_DestroyPrivate(PFD31_DATA lfs)
* On entry : type = dialog procedure type (16,32A,32W)
* dlgType = dialog type (open or save)
*/
PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
{
PFD31_DATA lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FD31_DATA));
@ -865,7 +938,7 @@ PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
FD31_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
}
if (! FD32_GetTemplate(lfs))
if (! FD31_GetTemplate(lfs))
{
FD31_DestroyPrivate(lfs);
return NULL;
@ -879,8 +952,7 @@ PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
/***********************************************************************
* FD31_WMInitDialog [internal]
*/
LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
static LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
int i, n;
WCHAR tmpstr[BUFFILE];
@ -1001,3 +1073,113 @@ int FD31_GetFldrHeight(void)
{
return fldrHeight;
}
/***********************************************************************
* FD31_WMMeasureItem [internal]
*/
static LONG FD31_WMMeasureItem(LPARAM lParam)
{
LPMEASUREITEMSTRUCT lpmeasure;
lpmeasure = (LPMEASUREITEMSTRUCT)lParam;
lpmeasure->itemHeight = FD31_GetFldrHeight();
return TRUE;
}
/***********************************************************************
* FileOpenDlgProc [internal]
* Used for open and save, in fact.
*/
static INT_PTR CALLBACK FD31_FileOpenDlgProc(HWND hWnd, UINT wMsg,
WPARAM wParam, LPARAM lParam)
{
PFD31_DATA lfs = (PFD31_DATA)GetPropA( hWnd, FD31_OFN_PROP );
TRACE("msg=%x wparam=%lx lParam=%lx\n", wMsg, wParam, lParam);
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
{
INT_PTR lRet;
lRet = (INT_PTR)FD31_CallWindowProc( lfs, wMsg, wParam, lParam );
if (lRet) return lRet; /* else continue message processing */
}
switch (wMsg)
{
case WM_INITDIALOG:
return FD31_WMInitDialog( hWnd, wParam, lParam );
case WM_MEASUREITEM:
return FD31_WMMeasureItem( lParam );
case WM_DRAWITEM:
return FD31_WMDrawItem( hWnd, wParam, lParam, !lfs->open, (DRAWITEMSTRUCT *)lParam );
case WM_COMMAND:
return FD31_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;
}
break;
#endif
}
return FALSE;
}
/***********************************************************************
* GetFileName31A [internal]
*
* Creates a win31 style dialog box for the user to select a file to open/save.
*/
BOOL GetFileName31A( OPENFILENAMEA *lpofn, UINT dlgType )
{
BOOL bRet = FALSE;
PFD31_DATA lfs;
if (!lpofn || !FD31_Init()) return FALSE;
TRACE("ofn flags %08x\n", lpofn->Flags);
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, FALSE);
if (lfs)
{
bRet = DialogBoxIndirectParamA( COMDLG32_hInstance, lfs->template, lpofn->hwndOwner,
FD31_FileOpenDlgProc, (LPARAM)lfs);
FD31_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 GetFileName31W( OPENFILENAMEW *lpofn, UINT dlgType )
{
BOOL bRet = FALSE;
PFD31_DATA lfs;
if (!lpofn || !FD31_Init()) return FALSE;
lfs = FD31_AllocPrivate((LPARAM) lpofn, dlgType, TRUE);
if (lfs)
{
bRet = DialogBoxIndirectParamW( COMDLG32_hInstance, lfs->template, lpofn->hwndOwner,
FD31_FileOpenDlgProc, (LPARAM)lfs);
FD31_DestroyPrivate(lfs);
}
TRACE("file %s, file offset %d, ext offset %d\n",
debugstr_w(lpofn->lpstrFile), lpofn->nFileOffset, lpofn->nFileExtension);
return bRet;
}

View File

@ -1,52 +0,0 @@
/*
* Win3.1 style File Dialog interface (32 bit)
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _WINE_DLL_FILEDLG31_H
#define _WINE_DLL_FILEDLG31_H
#define FD31_OFN_PROP "FILEDLG_OFN"
typedef struct tagFD31_DATA
{
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 */
LPCVOID template; /* template for 32 bits resource */
BOOL open; /* TRUE if open dialog, FALSE if save dialog */
LPOPENFILENAMEW ofnW; /* pointer either to the original structure or
a W copy for A/16 API */
LPOPENFILENAMEA ofnA; /* original structure if 32bits ansi dialog */
} FD31_DATA, *PFD31_DATA;
extern BOOL FD32_GetTemplate(PFD31_DATA lfs) DECLSPEC_HIDDEN;
extern BOOL FD31_Init(void) DECLSPEC_HIDDEN;
extern PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode) DECLSPEC_HIDDEN;
extern void FD31_DestroyPrivate(PFD31_DATA lfs) DECLSPEC_HIDDEN;
extern BOOL FD31_CallWindowProc(const FD31_DATA *lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam) DECLSPEC_HIDDEN;
extern LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) DECLSPEC_HIDDEN;
extern LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
int savedlg, const DRAWITEMSTRUCT *lpdis) DECLSPEC_HIDDEN;
extern LRESULT FD31_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
UINT control, const FD31_DATA *lfs) DECLSPEC_HIDDEN;
extern int FD31_GetFldrHeight(void) DECLSPEC_HIDDEN;
#endif /* _WINE_DLL_FILEDLG31_H */