Author: bfreisen Date: Sun Oct 9 11:42:37 2016 New Revision: 72945
URL: http://svn.reactos.org/svn/reactos?rev=72945&view=rev Log: [MSPAINT] get rid of all _stprintf occurrences and the respective magic number sized TCHAR arrays
Modified: trunk/reactos/base/applications/mspaint/dialogs.cpp trunk/reactos/base/applications/mspaint/dib.cpp trunk/reactos/base/applications/mspaint/imgarea.cpp trunk/reactos/base/applications/mspaint/registry.cpp trunk/reactos/base/applications/mspaint/selection.cpp trunk/reactos/base/applications/mspaint/sizebox.cpp
Modified: trunk/reactos/base/applications/mspaint/dialogs.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/d... ============================================================================== --- trunk/reactos/base/applications/mspaint/dialogs.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mspaint/dialogs.cpp [iso-8859-1] Sun Oct 9 11:42:37 2016 @@ -76,9 +76,6 @@ { case WM_INITDIALOG: { - TCHAR strrc[100]; - TCHAR res[100]; - widthSetInDlg = imageModel.GetWidth(); heightSetInDlg = imageModel.GetHeight();
@@ -90,20 +87,19 @@ if (isAFile) { TCHAR date[100]; - TCHAR size[100]; TCHAR temp[100]; GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, SIZEOF(date)); GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, SIZEOF(temp)); _tcscat(date, _T(" ")); _tcscat(date, temp); - LoadString(hProgInstance, IDS_FILESIZE, strrc, SIZEOF(strrc)); - _stprintf(size, strrc, fileSize); + CString strSize; + strSize.Format(IDS_FILESIZE, fileSize); SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT6, date); - SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, size); - } - LoadString(hProgInstance, IDS_PRINTRES, strrc, SIZEOF(strrc)); - _stprintf(res, strrc, fileHPPM, fileVPPM); - SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, res); + SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, strSize); + } + CString strRes; + strRes.Format(IDS_PRINTRES, fileHPPM, fileVPPM); + SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, strRes); return TRUE; } case WM_CLOSE: @@ -128,20 +124,20 @@ break; case IDD_ATTRIBUTESRB1: { - TCHAR number[100]; - _stprintf(number, _T("%.3lf"), widthSetInDlg / (0.0254 * fileHPPM)); - SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT1, number); - _stprintf(number, _T("%.3lf"), heightSetInDlg / (0.0254 * fileVPPM)); - SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT2, number); + CString strNum; + strNum.Format(_T("%.3lf"), widthSetInDlg / (0.0254 * fileHPPM)); + SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT1, strNum); + strNum.Format(_T("%.3lf"), heightSetInDlg / (0.0254 * fileVPPM)); + SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT2, strNum); break; } case IDD_ATTRIBUTESRB2: { - TCHAR number[100]; - _stprintf(number, _T("%.3lf"), widthSetInDlg * 100.0 / fileHPPM); - SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT1, number); - _stprintf(number, _T("%.3lf"), heightSetInDlg * 100.0 / fileVPPM); - SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT2, number); + CString strNum; + strNum.Format(_T("%.3lf"), widthSetInDlg * 100.0 / fileHPPM); + SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT1, strNum); + strNum.Format(_T("%.3lf"), heightSetInDlg * 100.0 / fileVPPM); + SetDlgItemText(hwnd, IDD_ATTRIBUTESEDIT2, strNum); break; } case IDD_ATTRIBUTESRB3:
Modified: trunk/reactos/base/applications/mspaint/dib.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/d... ============================================================================== --- trunk/reactos/base/applications/mspaint/dib.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mspaint/dib.cpp [iso-8859-1] Sun Oct 9 11:42:37 2016 @@ -73,13 +73,11 @@
void ShowFileLoadError(LPCTSTR name) { - TCHAR programname[20]; - TCHAR loaderrortext[100]; - TCHAR temptext[500]; - LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname)); - LoadString(hProgInstance, IDS_LOADERRORTEXT, loaderrortext, SIZEOF(loaderrortext)); - _stprintf(temptext, loaderrortext, name); - mainWindow.MessageBox(temptext, programname, MB_OK | MB_ICONEXCLAMATION); + CString strText; + strText.Format(IDS_LOADERRORTEXT, (LPCTSTR) name); + CString strProgramName; + strProgramName.LoadString(IDS_PROGRAMNAME); + mainWindow.MessageBox(strText, strProgramName, MB_OK | MB_ICONEXCLAMATION); }
void
Modified: trunk/reactos/base/applications/mspaint/imgarea.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/i... ============================================================================== --- trunk/reactos/base/applications/mspaint/imgarea.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mspaint/imgarea.cpp [iso-8859-1] Sun Oct 9 11:42:37 2016 @@ -252,9 +252,9 @@
if (!drawing) { - TCHAR coordStr[100]; - _stprintf(coordStr, _T("%ld, %ld"), xNow, yNow); - SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr); + CString strCoord; + strCoord.Format(_T("%ld, %ld"), xNow, yNow); + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord); } } if (drawing) @@ -291,9 +291,9 @@ case TOOL_AIRBRUSH: case TOOL_SHAPE: { - TCHAR coordStr[100]; - _stprintf(coordStr, _T("%ld, %ld"), xNow, yNow); - SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr); + CString strCoord; + strCoord.Format(_T("%ld, %ld"), xNow, yNow); + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord); break; } } @@ -303,11 +303,11 @@ Invalidate(FALSE); if ((toolsModel.GetActiveTool() >= TOOL_TEXT) || (toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_FREESEL)) { - TCHAR sizeStr[100]; + CString strSize; if ((toolsModel.GetActiveTool() >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0)) yRel = xRel; - _stprintf(sizeStr, _T("%ld x %ld"), xRel, yRel); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); + strSize.Format(_T("%ld x %ld"), xRel, yRel); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize); } } if ((wParam & MK_RBUTTON) != 0) @@ -316,11 +316,11 @@ Invalidate(FALSE); if (toolsModel.GetActiveTool() >= TOOL_TEXT) { - TCHAR sizeStr[100]; + CString strSize; if ((toolsModel.GetActiveTool() >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0)) yRel = xRel; - _stprintf(sizeStr, _T("%ld x %ld"), xRel, yRel); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); + strSize.Format(_T("%ld x %ld"), xRel, yRel); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize); } } }
Modified: trunk/reactos/base/applications/mspaint/registry.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/r... ============================================================================== --- trunk/reactos/base/applications/mspaint/registry.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mspaint/registry.cpp [iso-8859-1] Sun Oct 9 11:42:37 2016 @@ -46,15 +46,15 @@ CRegKey desktop; if (desktop.Open(HKEY_CURRENT_USER, _T("Control Panel\Desktop")) == ERROR_SUCCESS) { - TCHAR szStyle[3], szTile[3]; + CString strStyle, strTile;
desktop.SetStringValue(_T("Wallpaper"), szFileName);
- _stprintf(szStyle, _T("%lu"), dwStyle); - _stprintf(szTile, _T("%lu"), dwTile); + strStyle.Format(_T("%lu"), dwStyle); + strTile.Format(_T("%lu"), dwTile);
- desktop.SetStringValue(_T("WallpaperStyle"), szStyle); - desktop.SetStringValue(_T("TileWallpaper"), szTile); + desktop.SetStringValue(_T("WallpaperStyle"), strStyle); + desktop.SetStringValue(_T("TileWallpaper"), strTile); } }
Modified: trunk/reactos/base/applications/mspaint/selection.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/s... ============================================================================== --- trunk/reactos/base/applications/mspaint/selection.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mspaint/selection.cpp [iso-8859-1] Sun Oct 9 11:42:37 2016 @@ -155,7 +155,6 @@ { if (m_bMoving) { - TCHAR sizeStr[100]; imageModel.ResetToPrevious(); m_ptFrac.x += GET_X_LPARAM(lParam) - m_ptPos.x; m_ptFrac.y += GET_Y_LPARAM(lParam) - m_ptPos.y; @@ -173,8 +172,9 @@ } selectionModel.ModifyDestRect(m_ptDelta, m_iAction);
- _stprintf(sizeStr, _T("%d x %d"), selectionModel.GetDestRectWidth(), selectionModel.GetDestRectHeight()); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); + CString strSize; + strSize.Format(_T("%d x %d"), selectionModel.GetDestRectWidth(), selectionModel.GetDestRectHeight()); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
if (toolsModel.GetActiveTool() == TOOL_TEXT) {
Modified: trunk/reactos/base/applications/mspaint/sizebox.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/s... ============================================================================== --- trunk/reactos/base/applications/mspaint/sizebox.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mspaint/sizebox.cpp [iso-8859-1] Sun Oct 9 11:42:37 2016 @@ -42,7 +42,7 @@ { if (resizing) { - TCHAR sizeStr[100]; + CString strSize; short xRel; short yRel; int imgXRes = imageModel.GetWidth(); @@ -50,22 +50,22 @@ xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom(); yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom(); if (m_hWnd == sizeboxLeftTop.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes - yRel); + strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes - yRel); if (m_hWnd == sizeboxCenterTop.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes - yRel); + strSize.Format(_T("%d x %d"), imgXRes, imgYRes - yRel); if (m_hWnd == sizeboxRightTop.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes - yRel); + strSize.Format(_T("%d x %d"), imgXRes + xRel, imgYRes - yRel); if (m_hWnd == sizeboxLeftCenter.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes); + strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes); if (m_hWnd == sizeboxRightCenter.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes); + strSize.Format(_T("%d x %d"), imgXRes + xRel, imgYRes); if (m_hWnd == sizeboxLeftBottom.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes + yRel); + strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes + yRel); if (m_hWnd == sizeboxCenterBottom.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes + yRel); + strSize.Format(_T("%d x %d"), imgXRes, imgYRes + yRel); if (m_hWnd == sizeboxRightBottom.m_hWnd) - _stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes + yRel); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); + strSize.Format(_T("%d x %d"), imgXRes + xRel, imgYRes + yRel); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize); } return 0; }