From a757184e5db3112d3de0b69eec7d39b937e396bc Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Jul 2013 15:32:06 +0000 Subject: replace sprintf to mir_snprintf (part 5) git-svn-id: http://svn.miranda-ng.org/main/trunk@5481 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/opt_adv.cpp | 4 ++-- plugins/Popup/src/opt_class.cpp | 4 ++-- plugins/Popup/src/opt_skins.cpp | 8 ++++---- plugins/Popup/src/popup_thread.cpp | 2 +- plugins/Popup/src/popup_wnd2.cpp | 16 +++++++++------- 5 files changed, 18 insertions(+), 16 deletions(-) (limited to 'plugins/Popup/src') diff --git a/plugins/Popup/src/opt_adv.cpp b/plugins/Popup/src/opt_adv.cpp index 33e323618a..6df45bf210 100644 --- a/plugins/Popup/src/opt_adv.cpp +++ b/plugins/Popup/src/opt_adv.cpp @@ -163,7 +163,7 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwnd, IDC_TRANS_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(1,255)); SendDlgItemMessage(hwnd, IDC_TRANS_SLIDER, TBM_SETPOS, TRUE, PopupOptions.Alpha); mir_subclassWindow(GetDlgItem(hwnd, IDC_TRANS_SLIDER), AlphaTrackBarWndProc); - wsprintf(tstr, _T("%d%%"), Byte2Percentile(PopupOptions.Alpha)); + mir_sntprintf(tstr, SIZEOF(tstr), _T("%d%%"), Byte2Percentile(PopupOptions.Alpha)); SetDlgItemText(hwnd, IDC_TRANS_PERCENT, tstr); CheckDlgButton(hwnd, IDC_TRANS_OPAQUEONHOVER, PopupOptions.OpaqueOnHover); { @@ -239,7 +239,7 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_TRANS_SLIDER: PopupOptions.Alpha = (BYTE)SendDlgItemMessage(hwnd,IDC_TRANS_SLIDER, TBM_GETPOS, 0,0); - wsprintf(tstr, TranslateT("%d%%"), Byte2Percentile(PopupOptions.Alpha)); + mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("%d%%"), Byte2Percentile(PopupOptions.Alpha)); SetDlgItemText(hwnd, IDC_TRANS_PERCENT, tstr); SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); break; diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index 5e87499881..53e9c0028e 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -196,11 +196,11 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case 1: //Treeview part for typ 1 (notification) mir_snprintf(iconName, sizeof(iconName), "%s_%S_%S", MODULNAME, gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); iconIndex = ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(iconName)); - wsprintf(itemName, _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); + mir_sntprintf(itemName, SIZEOF(itemName), _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription); break; case 2: //Treeview part typ 2 (popup class api) iconIndex = ImageList_ReplaceIcon(hImgLst, -1, gTreeData[i]->pupClass.hIcon); - wsprintf(itemName, _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription); + mir_sntprintf(itemName, SIZEOF(itemName), _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription); break; } OptTree_AddItem(hwndTree, itemName, (LPARAM)gTreeData[i], iconIndex); diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp index 7d973d90e6..5b3c656684 100644 --- a/plugins/Popup/src/opt_skins.cpp +++ b/plugins/Popup/src/opt_skins.cpp @@ -48,7 +48,7 @@ void RegisterOptPrevBox() err = GetLastError(); if (!g_wndClass.cPopupPreviewBoxWndclass) { TCHAR msg[1024]; - wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName); MSGERROR(msg); } @@ -62,7 +62,7 @@ void RegisterOptPrevBox() err = GetLastError(); if (!g_wndClass.cPopupPlusDlgBox) { TCHAR msg[1024]; - wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName); MSGERROR(msg); } } @@ -189,7 +189,7 @@ int SkinOptionList_AddSkin(OPTTREE_OPTION* &options, int *OptionsCount, int pos options[pos].pszOptionName = (LPTSTR)mir_alloc(sizeof(TCHAR)*( lstrlen(options[pos].pszSettingName)+ lstrlenA(skin->getFlagName(i)) +10 )); - wsprintf(options[pos].pszOptionName,_T("%s/%hs"), options[pos].pszSettingName, skin->getFlagName(i)); + wsprintf(options[pos].pszOptionName, _T("%s/%hs"), options[pos].pszSettingName, skin->getFlagName(i)); //!!!!!!!!!!!!! options[pos].bState = skin->getFlag(i) ? TRUE : FALSE; options[pos].Data = i; //skin flag index *dwGlobalOptions |= skin->getFlag(i) ? (1 << (i-1)) : 0; @@ -252,7 +252,7 @@ int SkinOptionList_AddMain(OPTTREE_OPTION* &options, int *OptionsCount, int pos, options[pos].pszOptionName = (LPTSTR)mir_alloc(sizeof(TCHAR)*( lstrlen(options[pos].pszSettingName)+ lstrlen(mainOption[i]) + 10)); - wsprintf(options[pos].pszOptionName,_T("%s/%s"), options[pos].pszSettingName, mainOption[i]); + wsprintf(options[pos].pszOptionName, _T("%s/%s"), options[pos].pszSettingName, mainOption[i]); //!!!!!!!!!!!!! options[pos].bState = bCheck; pos++; } diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index 6bb9084155..cede4d0a00 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -231,7 +231,7 @@ static void __cdecl PopupThread(void *arg) err = GetLastError(); if (!g_wndClass.cPopupThreadManagerWnd) { TCHAR msg[1024]; - wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName); MSGERROR(msg); } diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 158736b427..15dadb8db6 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -71,7 +71,7 @@ bool LoadPopupWnd2() if (!g_wndClass.cPopupWnd2) { res = false; TCHAR msg[1024]; - wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName); MessageBox(NULL, msg, _T(MODULNAME_LONG), MB_ICONSTOP|MB_OK); } @@ -93,7 +93,7 @@ bool LoadPopupWnd2() err = GetLastError(); if (!g_wndClass.cPopupEditBox) { TCHAR msg[2048]; - wsprintf(msg, LPGENT("Failed to register custom edit box window class.\r\n\r\ncbSize: %i\r\nstyle: %p\r\nlpfnWndProc: %i\r\ncbClsExtra: %i\r\ncbWndExtra: %i\r\nhInstance: %i\r\nhIcon: %i\r\nhCursor: %i\r\nhbrBackground: %i\r\nlpszMenuName: %s\r\nlpszClassName: %s\r\nhIconSm: %i\r\n"), + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register custom edit box window class.\r\n\r\ncbSize: %i\r\nstyle: %p\r\nlpfnWndProc: %i\r\ncbClsExtra: %i\r\ncbWndExtra: %i\r\nhInstance: %i\r\nhIcon: %i\r\nhCursor: %i\r\nhbrBackground: %i\r\nlpszMenuName: %s\r\nlpszClassName: %s\r\nhIconSm: %i\r\n"), wclw.cbSize, //UINT cbSize; wclw.style, //UINT style; wclw.lpfnWndProc, //WNDPROC lpfnWndProc; @@ -130,7 +130,7 @@ bool LoadPopupWnd2() if (!g_wndClass.cPopupMenuHostWnd) { res = false; TCHAR msg[1024]; - wsprintf(msg, TranslateT("Failed to register %s class."),wcl.lpszClassName); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Failed to register %s class."), wcl.lpszClassName); MSGERROR(msg); } @@ -1182,13 +1182,15 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara char* sztext; if ((this->m_lpwzText) || (this->m_lpwzTitle)) { - text = (TCHAR*)mir_alloc((_tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3)*sizeof(TCHAR)); - mir_sntprintf(text, _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText); + int size = _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle) + 3; + text = (TCHAR*)mir_alloc(size * sizeof(TCHAR)); + mir_sntprintf(text, size, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText); } else if ((this->m_lpzText) || (this->m_lpzTitle)) { - sztext = (char*)mir_alloc((lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3)*sizeof(char)); - mir_snprintf(sztext, lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3, "%s\n\n%s", this->m_lpzTitle, this->m_lpzText); + int size = lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle) + 3; + sztext = (char*)mir_alloc(size * sizeof(char)); + mir_snprintf(sztext, size, "%s\n\n%s", this->m_lpzTitle, this->m_lpzText); text = mir_a2t(sztext); } OpenClipboard(m_hwnd); -- cgit v1.2.3