[MSPAINT] Fix Copy-To-File feature (#5877)

The Copy-To-File feature had some bugs that the user couldn't save.
- Modify SelectionModel::GetSelectionContents.
- Delete SelectionModel::CopyBitmap, SelectionModel::LockBitmap,
  and SelectionModel::UnlockBitmap functions.
CORE-19186
This commit is contained in:
Katayama Hirofumi MZ 2023-11-04 05:56:10 +09:00 committed by GitHub
parent e627c3b00e
commit d7ece626cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 59 deletions

View file

@ -7,6 +7,7 @@
#include "precomp.h"
#include <dlgs.h>
#include <mapi.h>
POINT g_ptStart, g_ptEnd;
@ -55,7 +56,7 @@ FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN)
CharLower(pExt);
return TRUE;
}
pch += lstrlen(pch) + 1;
pch += wcslen(pch) + 1;
}
return FALSE;
}
@ -66,6 +67,7 @@ OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hParent;
OFNOTIFY *pon;
WCHAR Path[MAX_PATH];
switch (uMsg)
{
case WM_NOTIFY:
@ -73,11 +75,10 @@ OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (pon->hdr.code == CDN_TYPECHANGE)
{
hParent = GetParent(hwnd);
TCHAR Path[MAX_PATH];
SendMessage(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
FileExtFromFilter(PathFindExtension(Path), pon->lpOFN);
SendMessage(hParent, CDM_SETCONTROLTEXT, 0x047c, (LPARAM)PathFindFileName(Path));
lstrcpyn(pon->lpOFN->lpstrFile, Path, pon->lpOFN->nMaxFile);
SendMessageW(hParent, CDM_GETFILEPATH, _countof(Path), (LPARAM)Path);
FileExtFromFilter(PathFindExtensionW(Path), pon->lpOFN);
SendMessageW(hParent, CDM_SETCONTROLTEXT, cmb13, (LPARAM)PathFindFileNameW(Path));
StringCchCopyW(pon->lpOFN->lpstrFile, pon->lpOFN->nMaxFile, Path);
}
break;
}
@ -251,7 +252,7 @@ BOOL CMainWindow::GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile)
if (*pchDotExt == UNICODE_NULL)
{
// Choose PNG
wcscat(pszFile, L".png");
StringCchCatW(pszFile, cchMaxFile, L".png");
for (INT i = 0; i < aguidFileTypesE.GetSize(); ++i)
{
if (aguidFileTypesE[i] == Gdiplus::ImageFormatPNG)