Add the selected extension from file type filter if file name does not

contain the file extension.
oldstable
Krishna Murthy 2004-07-14 21:47:11 +00:00 committed by Alexandre Julliard
parent 0b072cb67a
commit 38603c4c93
1 changed files with 35 additions and 22 deletions

View File

@ -1871,35 +1871,48 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
TRACE("ONOPEN_OPEN %s\n", debugstr_w(lpstrPathAndFile));
{
WCHAR *ext = NULL;
/* update READONLY check box flag */
if ((SendMessageA(GetDlgItem(hwnd,IDC_OPENREADONLY),BM_GETCHECK,0,0) & 0x03) == BST_CHECKED)
fodInfos->ofnInfos->Flags |= OFN_READONLY;
else
fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
/* add default extension */
if (fodInfos->defext)
/* Attach the file extension with file name*/
ext = PathFindExtensionW(lpstrPathAndFile);
if (! *ext)
{
/* if no extension is specified with file name, then */
/* attach the extension from file filter or default one */
WCHAR *filterExt = NULL;
LPWSTR lpstrFilter = NULL;
static const WCHAR szwDot[] = {'.',0};
int PathLength = strlenW(lpstrPathAndFile);
/* Attach the dot*/
strcatW(lpstrPathAndFile, szwDot);
/*Get the file extension from file type filter*/
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
fodInfos->ofnInfos->nFilterIndex-1);
if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
filterExt = PathFindExtensionW(lpstrFilter);
if ( *filterExt ) /* attach the file extension from file type filter*/
strcatW(lpstrPathAndFile, filterExt + 1);
else if ( fodInfos->defext ) /* attach the default file extension*/
strcatW(lpstrPathAndFile, fodInfos->defext);
/* In Open dialog: if file does not exist try without extension */
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
lpstrPathAndFile[PathLength] = '\0';
}
if (fodInfos->defext) /* add default extension */
{
WCHAR *ext = PathFindExtensionW(lpstrPathAndFile);
if (! *ext)
{
/* only add "." in case a default extension does exist */
if (*fodInfos->defext != '\0')
{
static const WCHAR szwDot[] = {'.',0};
int PathLength = strlenW(lpstrPathAndFile);
strcatW(lpstrPathAndFile, szwDot);
strcatW(lpstrPathAndFile, fodInfos->defext);
/* In Open dialog: if file does not exist try without extension */
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
&& !PathFileExistsW(lpstrPathAndFile))
lpstrPathAndFile[PathLength] = '\0';
}
}
/* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
if (*ext)
ext++;