[SHIMGVW] Implement ImageView_Delete (#6132)

- Call SHFileOperation to delete.
- Rebuild the file list and load the
  next file.
CORE-19358
This commit is contained in:
Katayama Hirofumi MZ 2023-12-08 15:30:55 +09:00 committed by GitHub
parent 0faa1561a6
commit e7f6b473e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -989,8 +989,35 @@ ImageView_OnSize(HWND hwnd, UINT state, INT cx, INT cy)
static LRESULT
ImageView_Delete(HWND hwnd)
{
DPRINT1("ImageView_Delete: unimplemented.\n");
return 0;
WCHAR szCurFile[MAX_PATH + 1], szNextFile[MAX_PATH];
SHFILEOPSTRUCT FileOp = { hwnd, FO_DELETE };
if (image)
{
GdipDisposeImage(image);
image = NULL;
}
/* FileOp.pFrom must be double-null-terminated */
GetFullPathNameW(currentFile->FileName, _countof(szCurFile) - 1, szCurFile, NULL);
szCurFile[_countof(szCurFile) - 2] = UNICODE_NULL; /* Avoid buffer overrun */
szCurFile[lstrlenW(szCurFile) + 1] = UNICODE_NULL;
GetFullPathNameW(currentFile->Next->FileName, _countof(szNextFile), szNextFile, NULL);
szNextFile[_countof(szNextFile) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
FileOp.pFrom = szCurFile;
FileOp.fFlags = FOF_ALLOWUNDO;
if (SHFileOperation(&FileOp) != 0)
return 0;
pFreeFileList(currentFile);
currentFile = NULL;
currentFile = pBuildFileList(szNextFile);
pLoadImageFromNode(currentFile, hwnd);
return 1;
}
static LRESULT