[MSPAINT_NEW]

Fix build on MSVC by rewriting the code in *STANDARD* C++ !! (and not into some strange idiom called "GCC-C++"). I suggest also to write a proper class for dynamically-allocated (resource) strings instead of either having the static arrays of hardcoded sizes, or being tempted to use non-standard constructs as the one I just saw.
(and btw, instead of defining a new "SIZEOF()" macro, there is one which already exists in the PSDK called "ARRAYSIZE()" which just does the correct job).

svn path=/trunk/; revision=68587
This commit is contained in:
Hermès Bélusca-Maïto 2015-08-01 17:30:17 +00:00
parent 2d44138c21
commit 5c15cde76e

View file

@ -196,14 +196,11 @@ LRESULT CMainWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
{
if (!imageModel.IsImageSaved())
{
TCHAR* tempptr;
TCHAR programname[LoadString(hProgInstance, IDS_PROGRAMNAME, (LPTSTR)&tempptr, 0) + 1];
CopyMemory(programname, tempptr, sizeof(programname) - sizeof(TCHAR));
programname[SIZEOF(programname) - 1] = (TCHAR)'\0';
TCHAR saveprompttext[LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, (LPTSTR)&tempptr, 0) + 1];
CopyMemory(saveprompttext, tempptr, sizeof(saveprompttext) - sizeof(TCHAR));
saveprompttext[SIZEOF(saveprompttext) - 1] = (TCHAR)'\0';
TCHAR temptext[SIZEOF(saveprompttext) + _tcslen(filename)];
TCHAR programname[20];
TCHAR saveprompttext[100];
TCHAR temptext[500];
LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
_stprintf(temptext, saveprompttext, filename);
switch (MessageBox(temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
{