https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5c8d578a15e7e244c63a9a...
commit 5c8d578a15e7e244c63a9aaf0272efc33578d70b Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Wed Mar 22 10:42:21 2023 +0900 Commit: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com CommitDate: Wed Mar 22 10:42:21 2023 +0900
[MSPAINT] Simplify OFNHookProc and FileExtFromFilter
... by using PathFindExtension and PathFindFileName. CORE-18867 --- base/applications/mspaint/main.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/base/applications/mspaint/main.cpp b/base/applications/mspaint/main.cpp index 1099f6af3f8..170610c7748 100644 --- a/base/applications/mspaint/main.cpp +++ b/base/applications/mspaint/main.cpp @@ -57,7 +57,7 @@ CTextEditWindow textEditWindow;
// get file name extension from filter string static BOOL -FileExtFromFilter(LPTSTR pExt, LPCTSTR pTitle, OPENFILENAME *pOFN) +FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN) { LPTSTR pchExt = pExt; *pchExt = 0; @@ -96,19 +96,9 @@ OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) hParent = GetParent(hwnd); TCHAR Path[MAX_PATH]; SendMessage(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path); - LPTSTR pchTitle = _tcsrchr(Path, _T('\')); - if (pchTitle == NULL) - pchTitle = _tcsrchr(Path, _T('/')); - - 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); - } + FileExtFromFilter(PathFindExtension(Path), pon->lpOFN); + SendMessage(hParent, CDM_SETCONTROLTEXT, 0x047c, (LPARAM)PathFindFileName(Path)); + lstrcpyn(pon->lpOFN->lpstrFile, Path, pon->lpOFN->nMaxFile); } break; }