mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 19:43:04 +00:00
[MSPAINT] Refactor loading/saving image file (#2686)
- Add DoLoadImageFile, CreateWhiteDIB, and CMainWindow::ConfirmSave functions. - Replace LoadDIBFromFile function with DoLoadImageFile. - Fix the empty file loading. - Delete UpdateApplicationProperties function. - Rewrite SaveDIBToFile function. CORE-16982, CORE-16979
This commit is contained in:
parent
125020c23f
commit
036206a1c3
8 changed files with 186 additions and 225 deletions
|
@ -51,6 +51,7 @@ HINSTANCE hProgInstance;
|
|||
|
||||
TCHAR filepathname[1000];
|
||||
BOOL isAFile = FALSE;
|
||||
BOOL imageSaved = FALSE;
|
||||
int fileSize;
|
||||
int fileHPPM = 2834;
|
||||
int fileVPPM = 2834;
|
||||
|
@ -252,67 +253,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
|
||||
if (__argc >= 2)
|
||||
{
|
||||
WIN32_FIND_DATAW find;
|
||||
HANDLE hFind = FindFirstFileW(__targv[1], &find);
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FindClose(hFind);
|
||||
|
||||
// check the file size
|
||||
if (find.nFileSizeHigh || find.nFileSizeLow)
|
||||
{
|
||||
// load it now
|
||||
HBITMAP bmNew = NULL;
|
||||
LoadDIBFromFile(&bmNew, __targv[1], &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
||||
if (bmNew)
|
||||
{
|
||||
// valid bitmap file
|
||||
GetFullPathName(__targv[1], SIZEOF(filepathname), filepathname, NULL);
|
||||
imageModel.Insert(bmNew);
|
||||
CPath pathFileName(filepathname);
|
||||
pathFileName.StripPath();
|
||||
|
||||
CString strTitle;
|
||||
strTitle.Format(IDS_WINDOWTITLE, (LPCTSTR)pathFileName);
|
||||
mainWindow.SetWindowText(strTitle);
|
||||
|
||||
imageModel.ClearHistory();
|
||||
|
||||
isAFile = TRUE;
|
||||
registrySettings.SetMostRecentFile(filepathname);
|
||||
}
|
||||
else
|
||||
{
|
||||
// cannot open and not empty
|
||||
CStringW strText;
|
||||
strText.Format(IDS_LOADERRORTEXT, __targv[1]);
|
||||
MessageBoxW(NULL, strText, NULL, MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// open the empty file
|
||||
GetFullPathName(__targv[1], SIZEOF(filepathname), filepathname, NULL);
|
||||
CPath pathFileName(filepathname);
|
||||
pathFileName.StripPath();
|
||||
|
||||
CString strTitle;
|
||||
strTitle.Format(IDS_WINDOWTITLE, (LPCTSTR)pathFileName);
|
||||
mainWindow.SetWindowText(strTitle);
|
||||
|
||||
imageModel.ClearHistory();
|
||||
|
||||
isAFile = TRUE;
|
||||
registrySettings.SetMostRecentFile(filepathname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// does not exist
|
||||
CStringW strText;
|
||||
strText.Format(IDS_LOADERRORTEXT, __targv[1]);
|
||||
MessageBoxW(NULL, strText, NULL, MB_ICONERROR);
|
||||
}
|
||||
DoLoadImageFile(mainWindow, __targv[1], TRUE);
|
||||
}
|
||||
|
||||
/* initializing the CHOOSECOLOR structure for use with ChooseColor */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue