Commit 1d055249 authored by Steven Edwards's avatar Steven Edwards Committed by Alexandre Julliard

More splitting of the Win16/32 internal filedlgproc window procedures

and dialog init. Make a few internal function static and share a few others.
parent af81a021
......@@ -257,15 +257,9 @@ static void FILEDLG_StripEditControl(HWND hwnd)
*
* Call the appropriate hook
*/
BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
static BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
if (lfs->ofn16)
{
return (BOOL16) CallWindowProc16(
(WNDPROC16)lfs->ofn16->lpfnHook, HWND_16(lfs->hwnd),
(UINT16)wMsg, (WPARAM16)wParam, lParam);
}
if (lfs->ofnA)
{
return (BOOL) CallWindowProcA(
......@@ -286,7 +280,7 @@ BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
/***********************************************************************
* FILEDLG_ScanDir [internal]
*/
static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
{
WCHAR buffer[BUFFILE];
HWND hdlg, hdlgDir;
......@@ -338,7 +332,7 @@ static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
* FILEDLG_GetFileType [internal]
*/
static LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
{
int n, i;
i = 0;
......@@ -482,7 +476,7 @@ static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
* FILEDLG_WMInitDialog [internal]
*/
LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
int i, n;
WCHAR tmpstr[BUFFILE];
......
......@@ -58,10 +58,9 @@ static const int fldrWidth = 20;
* Do not Export to other applications or dlls
*/
BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam);
LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam);
LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index);
void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdis);
BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath);
LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
int savedlg, LPDRAWITEMSTRUCT lpdis);
LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,
......
......@@ -40,6 +40,139 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#include "filedlg.h"
/***********************************************************************
* FILEDLG_CallWindowProc16 [internal]
*
* Call the appropriate hook
*/
static BOOL FILEDLG_CallWindowProc16(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
if (lfs->ofn16)
{
return (BOOL16) CallWindowProc16(
(WNDPROC16)lfs->ofn16->lpfnHook, HWND_16(lfs->hwnd),
(UINT16)wMsg, (WPARAM16)wParam, lParam);
}
return FALSE;
}
/***********************************************************************
* FILEDLG_WMInitDialog16 [internal]
* The is a duplicate of the 32bit FILEDLG_WMInitDialog function
* The only differnce is that it calls FILEDLG_CallWindowProc16
* for a 16 bit Window Proc.
*/
static LONG FILEDLG_WMInitDialog16(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
int i, n;
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 (ofn->lpstrCustomFilter)
{
pstr = ofn->lpstrCustomFilter;
n = 0;
TRACE("lpstrCustomFilter = %p\n", pstr);
while(*pstr)
{
old_pstr = pstr;
i = SendDlgItemMessageW(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",
debugstr_w(old_pstr), debugstr_w(pstr));
SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
n += lstrlenW(pstr) + 1;
pstr += lstrlenW(pstr) + 1;
}
}
/* read filter information */
if (ofn->lpstrFilter) {
pstr = (LPWSTR) ofn->lpstrFilter;
n = 0;
while(*pstr) {
old_pstr = pstr;
i = SendDlgItemMessageW(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",
debugstr_w(old_pstr), debugstr_w(pstr));
SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
n += lstrlenW(pstr) + 1;
pstr += lstrlenW(pstr) + 1;
}
}
/* set default filter */
if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
ofn->nFilterIndex = 1;
SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
(LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
TRACE("nFilterIndex = %ld, SetText of edt1 to %s\n",
ofn->nFilterIndex, debugstr_w(tmpstr));
SetDlgItemTextW( hWnd, edt1, tmpstr );
/* get drive list */
*tmpstr = 0;
DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
/* read initial directory */
/* 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
*/
if (ofn->lpstrInitialDir != NULL)
{
int len;
lstrcpynW(tmpstr, ofn->lpstrInitialDir, 511);
len = lstrlenW(tmpstr);
if (len > 0 && tmpstr[len-1] != '\\' && tmpstr[len-1] != ':') {
tmpstr[len]='\\';
tmpstr[len+1]='\0';
}
}
else
*tmpstr = 0;
if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
*tmpstr = 0;
if (!FILEDLG_ScanDir(hWnd, tmpstr))
WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
}
/* select current drive in combo 2, omit missing drives */
{
char dir[MAX_PATH];
char str[4] = "a:\\";
GetCurrentDirectoryA( sizeof(dir), dir );
for(i = 0, n = -1; i < 26; i++)
{
str[0] = 'a' + i;
if (GetDriveTypeA(str) > DRIVE_NO_ROOT_DIR) n++;
if (toupper(str[0]) == toupper(dir[0])) break;
}
}
SendDlgItemMessageW(hWnd, cmb2, CB_SETCURSEL, n, 0);
if (!(ofn->Flags & OFN_SHOWHELP))
ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
if (ofn->Flags & OFN_HIDEREADONLY)
ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
if (lfs->hook)
return (BOOL) FILEDLG_CallWindowProc16(lfs, WM_INITDIALOG, wParam, lfs->lParam);
return TRUE;
}
/***********************************************************************
* FILEDLG_WMMeasureItem16 [internal]
*/
static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
......@@ -66,14 +199,14 @@ BOOL16 CALLBACK FileOpenDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam,
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);
LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc16(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_WMInitDialog16(hWnd, wParam, lParam);
case WM_MEASUREITEM:
return FILEDLG_WMMeasureItem16(hWnd16, wParam, lParam);
......@@ -116,13 +249,13 @@ BOOL16 CALLBACK FileSaveDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam,
if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
{
LRESULT lRet;
lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
lRet = (BOOL16)FILEDLG_CallWindowProc16(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_WMInitDialog16(hWnd, wParam, lParam);
case WM_MEASUREITEM:
return FILEDLG_WMMeasureItem16(hWnd16, wParam, lParam);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment