mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[MSPAINT] Simplify OFNHookProc and FileExtFromFilter
... by using PathFindExtension and PathFindFileName. CORE-18867
This commit is contained in:
parent
be518f9f5a
commit
5c8d578a15
1 changed files with 4 additions and 14 deletions
|
@ -57,7 +57,7 @@ CTextEditWindow textEditWindow;
|
||||||
|
|
||||||
// get file name extension from filter string
|
// get file name extension from filter string
|
||||||
static BOOL
|
static BOOL
|
||||||
FileExtFromFilter(LPTSTR pExt, LPCTSTR pTitle, OPENFILENAME *pOFN)
|
FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN)
|
||||||
{
|
{
|
||||||
LPTSTR pchExt = pExt;
|
LPTSTR pchExt = pExt;
|
||||||
*pchExt = 0;
|
*pchExt = 0;
|
||||||
|
@ -96,19 +96,9 @@ OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
hParent = GetParent(hwnd);
|
hParent = GetParent(hwnd);
|
||||||
TCHAR Path[MAX_PATH];
|
TCHAR Path[MAX_PATH];
|
||||||
SendMessage(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
|
SendMessage(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
|
||||||
LPTSTR pchTitle = _tcsrchr(Path, _T('\\'));
|
FileExtFromFilter(PathFindExtension(Path), pon->lpOFN);
|
||||||
if (pchTitle == NULL)
|
SendMessage(hParent, CDM_SETCONTROLTEXT, 0x047c, (LPARAM)PathFindFileName(Path));
|
||||||
pchTitle = _tcsrchr(Path, _T('/'));
|
lstrcpyn(pon->lpOFN->lpstrFile, Path, pon->lpOFN->nMaxFile);
|
||||||
|
|
||||||
LPTSTR pch = _tcsrchr((pchTitle ? pchTitle : Path), _T('.'));
|
|
||||||
if (pch && pchTitle)
|
|
||||||
{
|
|
||||||
pchTitle++;
|
|
||||||
*pch = 0;
|
|
||||||
FileExtFromFilter(pch, pchTitle, pon->lpOFN);
|
|
||||||
SendMessage(hParent, CDM_SETCONTROLTEXT, 0x047c, (LPARAM)pchTitle);
|
|
||||||
lstrcpyn(pon->lpOFN->lpstrFile, Path, pon->lpOFN->nMaxFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue