From 1d055249196519124f264757b4e01bbb6ff30171 Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Tue, 24 Jun 2003 19:24:29 +0000 Subject: [PATCH] More splitting of the Win16/32 internal filedlgproc window procedures and dialog init. Make a few internal function static and share a few others. --- dlls/commdlg/filedlg.c | 14 ++--- dlls/commdlg/filedlg.h | 5 +- dlls/commdlg/filedlg16.c | 141 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 143 insertions(+), 17 deletions(-) diff --git a/dlls/commdlg/filedlg.c b/dlls/commdlg/filedlg.c index 447ce827942..05a04bb27a3 100644 --- a/dlls/commdlg/filedlg.c +++ b/dlls/commdlg/filedlg.c @@ -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]; diff --git a/dlls/commdlg/filedlg.h b/dlls/commdlg/filedlg.h index 7310d74b911..28bbb57af2a 100644 --- a/dlls/commdlg/filedlg.h +++ b/dlls/commdlg/filedlg.h @@ -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, diff --git a/dlls/commdlg/filedlg16.c b/dlls/commdlg/filedlg16.c index 172eb717db2..7d4550f8905 100644 --- a/dlls/commdlg/filedlg16.c +++ b/dlls/commdlg/filedlg16.c @@ -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); -- 2.11.4.GIT