Commit 38603c4c authored by Krishna Murthy's avatar Krishna Murthy Committed by Alexandre Julliard

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

contain the file extension.
parent 0b072cb6
......@@ -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)
{
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';
}
}
/* 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 */
{
/* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
if (*ext)
ext++;
......
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