mirror of
https://github.com/reactos/reactos.git
synced 2025-05-08 11:24:14 +00:00
[MSPAINT] Fix interpretation of command line (#707)
This commit is contained in:
parent
c79e5dc476
commit
22e86add33
1 changed files with 56 additions and 14 deletions
|
@ -261,24 +261,66 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
|
|
||||||
if (__argc >= 2)
|
if (__argc >= 2)
|
||||||
{
|
{
|
||||||
HBITMAP bmNew = NULL;
|
WIN32_FIND_DATAW find;
|
||||||
LoadDIBFromFile(&bmNew, __targv[1], &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
HANDLE hFind = FindFirstFileW(__targv[1], &find);
|
||||||
if (bmNew != NULL)
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
TCHAR *temp;
|
FindClose(hFind);
|
||||||
imageModel.Insert(bmNew);
|
|
||||||
GetFullPathName(__targv[1], SIZEOF(filepathname), filepathname, &temp);
|
// check the file size
|
||||||
CPath pathFileName(filepathname);
|
if (find.nFileSizeHigh || find.nFileSizeLow)
|
||||||
pathFileName.StripPath();
|
{
|
||||||
CString strTitle;
|
// load it now
|
||||||
strTitle.Format(IDS_WINDOWTITLE, (LPCTSTR)pathFileName);
|
HBITMAP bmNew = NULL;
|
||||||
mainWindow.SetWindowText(strTitle);
|
LoadDIBFromFile(&bmNew, __targv[1], &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
||||||
imageModel.ClearHistory();
|
if (bmNew)
|
||||||
isAFile = TRUE;
|
{
|
||||||
|
// 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
|
else
|
||||||
{
|
{
|
||||||
exit(0);
|
// does not exist
|
||||||
|
CStringW strText;
|
||||||
|
strText.Format(IDS_LOADERRORTEXT, __targv[1]);
|
||||||
|
MessageBoxW(NULL, strText, NULL, MB_ICONERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue