Skip to content

Commit

Permalink
improve MMainWnd::DoLoadFile
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Jul 25, 2024
1 parent 3375183 commit 3362971
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/RisohEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7711,9 +7711,6 @@ BOOL MMainWnd::DoLoadFile(HWND hwnd, LPCWSTR pszFileName, DWORD nFilterIndex, BO
LFI_ALL = 5
};

if (nFilterIndex == LFI_ALL || nFilterIndex == LFI_LOADABLE)
nFilterIndex = LFI_NONE;

// if it was a shortcut file, then resolve it.
// pszFileName --> szPath
if (GetPathOfShortcutDx(hwnd, pszFileName, szResolvedPath))
Expand All @@ -7726,13 +7723,21 @@ BOOL MMainWnd::DoLoadFile(HWND hwnd, LPCWSTR pszFileName, DWORD nFilterIndex, BO
}

// find the dot extension
LPWSTR pch = wcsrchr(szPath, L'.');
if (nFilterIndex == LFI_NONE || nFilterIndex == LFI_EXECUTABLE)
LPWSTR pch = PathFindExtensionW(szPath);
if (pch && (nFilterIndex == LFI_NONE || nFilterIndex == LFI_ALL || nFilterIndex == LFI_LOADABLE))
{
if (pch && lstrcmpiW(pch, L".res") == 0)
nFilterIndex = LFI_RES;
else if (pch && lstrcmpiW(pch, L".rc") == 0)
nFilterIndex = LFI_RC;
if (lstrcmpiW(pch, L".res") == 0) nFilterIndex = LFI_RES;
else if (lstrcmpiW(pch, L".rc") == 0) nFilterIndex = LFI_RC;
else if (lstrcmpiW(pch, L".exe") == 0 || lstrcmpiW(pch, L".dll") == 0 ||
lstrcmpiW(pch, L".ocx") == 0 || lstrcmpiW(pch, L".cpl") == 0 ||
lstrcmpiW(pch, L".scr") == 0 || lstrcmpiW(pch, L".mui") == 0)
{
nFilterIndex = LFI_EXECUTABLE;
}
else
{
nFilterIndex = LFI_NONE;
}
}

if (nFilterIndex == LFI_RES) // .res files
Expand Down

0 comments on commit 3362971

Please sign in to comment.