Fix loads of sizeof() problems with TCHAR (possible buffer overfows by factor 2).
Fix a problem with Incremental search+UTF8 in win9x. (UTF8 is still problematic in unicode mode.) git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@314 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
c2acd30423
commit
adba68de00
@ -3070,7 +3070,7 @@ void Notepad_plus::command(int id)
|
||||
case IDM_SEARCH_VOLATILE_FINDPREV :
|
||||
{
|
||||
TCHAR text2Find[MAX_PATH];
|
||||
_pEditView->getGenericSelectedText(text2Find, sizeof(text2Find));
|
||||
_pEditView->getGenericSelectedText(text2Find, MAX_PATH);
|
||||
|
||||
FindOption op;
|
||||
op._isWholeWord = false;
|
||||
@ -3082,7 +3082,7 @@ void Notepad_plus::command(int id)
|
||||
{
|
||||
const int strSize = 64;
|
||||
TCHAR text2Find[strSize];
|
||||
_pEditView->getGenericSelectedText(text2Find, sizeof(text2Find));
|
||||
_pEditView->getGenericSelectedText(text2Find, strSize);
|
||||
|
||||
FindOption op;
|
||||
op._isWholeWord = false;
|
||||
@ -4163,7 +4163,7 @@ void Notepad_plus::command(int id)
|
||||
else if ((id > IDM_LANG_USER) && (id < IDM_LANG_USER_LIMIT))
|
||||
{
|
||||
TCHAR langName[langNameLenMax];
|
||||
::GetMenuString(_mainMenuHandle, id, langName, sizeof(langName), MF_BYCOMMAND);
|
||||
::GetMenuString(_mainMenuHandle, id, langName, langNameLenMax, MF_BYCOMMAND);
|
||||
_pEditView->getCurrentBuffer()->setLangType(L_USER, langName);
|
||||
}
|
||||
else if ((id >= IDM_LANG_EXTERNAL) && (id <= IDM_LANG_EXTERNAL_LIMIT))
|
||||
@ -4522,7 +4522,7 @@ void Notepad_plus::dropFiles(HDROP hdrop)
|
||||
for (int i = 0 ; i < filesDropped ; ++i)
|
||||
{
|
||||
TCHAR pathDropped[MAX_PATH];
|
||||
::DragQueryFile(hdrop, i, pathDropped, sizeof(pathDropped));
|
||||
::DragQueryFile(hdrop, i, pathDropped, MAX_PATH);
|
||||
BufferID test = doOpen(pathDropped);
|
||||
if (test != BUFFER_INVALID)
|
||||
lastOpened = test;
|
||||
@ -5726,7 +5726,8 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
|
||||
comment += TEXT(" ");
|
||||
generic_string long_comment = comment;
|
||||
|
||||
TCHAR linebuf[1000];
|
||||
const int linebufferSize = 1000;
|
||||
TCHAR linebuf[linebufferSize];
|
||||
size_t comment_length = comment.length();
|
||||
size_t selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART);
|
||||
size_t selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND);
|
||||
@ -5746,7 +5747,7 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
|
||||
int lineStart = _pEditView->execute(SCI_POSITIONFROMLINE, i);
|
||||
int lineIndent = lineStart;
|
||||
int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i);
|
||||
if ((lineEnd - lineIndent) >= static_cast<int>(sizeof(linebuf))) // Avoid buffer size problems
|
||||
if ((lineEnd - lineIndent) >= linebufferSize) // Avoid buffer size problems
|
||||
continue;
|
||||
/*if (props.GetInt(comment_at_line_start.c_str())) {
|
||||
GetRange(wEditor, lineIndent, lineEnd, linebuf);
|
||||
@ -6302,12 +6303,13 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
ExternalLangContainer & externalLangContainer = pNppParam->getELCFromIndex(i);
|
||||
|
||||
int numLangs = ::GetMenuItemCount(hLangMenu);
|
||||
TCHAR buffer[100];
|
||||
const int bufferSize = 100;
|
||||
TCHAR buffer[bufferSize];
|
||||
|
||||
int x;
|
||||
for(x = 0; (x == 0 || lstrcmp(externalLangContainer._name, buffer) > 0) && x < numLangs; x++)
|
||||
{
|
||||
::GetMenuString(hLangMenu, x, buffer, sizeof(buffer), MF_BYPOSITION);
|
||||
::GetMenuString(hLangMenu, x, buffer, bufferSize, MF_BYPOSITION);
|
||||
}
|
||||
|
||||
::InsertMenu(hLangMenu, x-1, MF_BYPOSITION, IDM_LANG_EXTERNAL + i, externalLangContainer._name);
|
||||
@ -6318,8 +6320,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
for (size_t i = 0 ; i < nppGUI._excludedLangList.size() ; i++)
|
||||
{
|
||||
int cmdID = pNppParam->langTypeToCommandID(nppGUI._excludedLangList[i]._langType);
|
||||
TCHAR itemName[256];
|
||||
::GetMenuString(hLangMenu, cmdID, itemName, sizeof(itemName), MF_BYCOMMAND);
|
||||
const int itemSize = 256;
|
||||
TCHAR itemName[itemSize];
|
||||
::GetMenuString(hLangMenu, cmdID, itemName, itemSize, MF_BYCOMMAND);
|
||||
nppGUI._excludedLangList[i]._cmdID = cmdID;
|
||||
nppGUI._excludedLangList[i]._langName = itemName;
|
||||
::DeleteMenu(hLangMenu, cmdID, MF_BYCOMMAND);
|
||||
|
@ -711,10 +711,11 @@ private:
|
||||
|
||||
int getLangFromMenuName(const TCHAR * langName) {
|
||||
int id = 0;
|
||||
TCHAR menuLangName[64];
|
||||
const int menuSize = 64;
|
||||
TCHAR menuLangName[menuSize];
|
||||
|
||||
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ )
|
||||
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) )
|
||||
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuSize, MF_BYCOMMAND ) )
|
||||
if ( !lstrcmp( langName, menuLangName ) )
|
||||
{
|
||||
id = i;
|
||||
@ -724,7 +725,7 @@ private:
|
||||
if ( id == 0 )
|
||||
{
|
||||
for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; i++ )
|
||||
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) )
|
||||
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuSize, MF_BYCOMMAND ) )
|
||||
if ( !lstrcmp( langName, menuLangName ) )
|
||||
{
|
||||
id = i;
|
||||
|
@ -430,7 +430,7 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
|
||||
|
||||
// Prepare for default path
|
||||
TCHAR nppPath[MAX_PATH];
|
||||
::GetModuleFileName(NULL, nppPath, sizeof(nppPath));
|
||||
::GetModuleFileName(NULL, nppPath, MAX_PATH);
|
||||
|
||||
PathRemoveFileSpec(nppPath);
|
||||
lstrcpy(_nppPath, nppPath);
|
||||
|
@ -718,7 +718,8 @@ public :
|
||||
};
|
||||
UserLangContainer(const TCHAR *name, const TCHAR *ext){
|
||||
//si le nom est trop long, on le tranche!
|
||||
int minSize = ((sizeof(_name) - 1) < lstrlen(name))?(sizeof(_name) - 1):lstrlen(name);
|
||||
//int minSize = ((sizeof(_name) - 1) < lstrlen(name))?(sizeof(_name) - 1):lstrlen(name);
|
||||
int minSize = min(langNameLenMax-1, lstrlen(_name));
|
||||
int i = 0;
|
||||
for ( ; i < minSize ; i++)
|
||||
_name[i] = name[i];
|
||||
|
@ -177,8 +177,9 @@ void AutoCompletion::update(int character)
|
||||
if (_pEditView->execute(SCI_AUTOCACTIVE) != 0)
|
||||
return;
|
||||
|
||||
TCHAR s[64];
|
||||
_pEditView->getWordToCurrentPos(s, sizeof(s));
|
||||
const int wordSize = 64;
|
||||
TCHAR s[wordSize];
|
||||
_pEditView->getWordToCurrentPos(s, wordSize);
|
||||
|
||||
if (lstrlen(s) >= int(nppGUI._autocFromLen))
|
||||
{
|
||||
|
@ -576,13 +576,14 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
{
|
||||
if (_currentStatus == FINDINFILES_DLG)
|
||||
{
|
||||
TCHAR filters[256];
|
||||
const int filterSize = 256;
|
||||
TCHAR filters[filterSize];
|
||||
TCHAR directory[MAX_PATH];
|
||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, sizeof(filters));
|
||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
|
||||
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
|
||||
_filters = filters;
|
||||
|
||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, sizeof(directory));
|
||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
||||
addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
||||
_directory = directory;
|
||||
|
||||
@ -1336,7 +1337,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable)
|
||||
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), pClosePos->left, pClosePos->top, pClosePos->right, pClosePos->bottom, TRUE);
|
||||
|
||||
TCHAR label[MAX_PATH];
|
||||
_tab.getCurrentTitle(label, sizeof(label));
|
||||
_tab.getCurrentTitle(label, MAX_PATH);
|
||||
::SetWindowText(_hSelf, label);
|
||||
}
|
||||
|
||||
@ -1378,7 +1379,7 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable)
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK), isEnable?SW_SHOW:SW_HIDE);
|
||||
|
||||
TCHAR label[MAX_PATH];
|
||||
_tab.getCurrentTitle(label, sizeof(label));
|
||||
_tab.getCurrentTitle(label, MAX_PATH);
|
||||
::SetWindowText(_hSelf, label);
|
||||
}
|
||||
|
||||
@ -1604,7 +1605,7 @@ void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt)
|
||||
return;
|
||||
|
||||
TCHAR text2Find[MAX_PATH];
|
||||
(*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false)
|
||||
(*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find, MAX_PATH, false); //do not expand selection (false)
|
||||
_pFRDlg->markAllInc(text2Find, opt);
|
||||
}
|
||||
|
||||
|
@ -406,9 +406,18 @@ public :
|
||||
::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find);
|
||||
return;
|
||||
}
|
||||
WCHAR wchars[256];
|
||||
::MultiByteToWideChar(CP_UTF8, 0, txt2find, -1, wchars, 256 / sizeof(WCHAR));
|
||||
::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars);
|
||||
const int wideBufferSize = 256;
|
||||
WCHAR wchars[wideBufferSize];
|
||||
::MultiByteToWideChar(CP_UTF8, 0, txt2find, -1, wchars, wideBufferSize);
|
||||
winVer winVersion = NppParameters::getInstance()->getWinVersion();
|
||||
if (winVersion <= WV_ME) {
|
||||
//Cannot simply take txt2find since its UTF8
|
||||
char ansiBuffer[wideBufferSize]; //Assuming no more than 2 bytes for each wchar (SBCS or DBCS, no UTF8 and sorts)
|
||||
::WideCharToMultiByte(CP_ACP, 0, wchars, -1, ansiBuffer, wideBufferSize, NULL, NULL);
|
||||
::SendDlgItemMessageA(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)ansiBuffer);
|
||||
} else {
|
||||
::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -230,27 +230,29 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
frPrint.rc.left += printMarge;
|
||||
frPrint.rc.right -= printMarge;
|
||||
|
||||
TCHAR headerL[256] = TEXT("");
|
||||
TCHAR headerM[256] = TEXT("");
|
||||
TCHAR headerR[256] = TEXT("");
|
||||
TCHAR footerL[256] = TEXT("");
|
||||
TCHAR footerM[256] = TEXT("");
|
||||
TCHAR footerR[256] = TEXT("");
|
||||
const int headerSize = 256;
|
||||
TCHAR headerL[headerSize] = TEXT("");
|
||||
TCHAR headerM[headerSize] = TEXT("");
|
||||
TCHAR headerR[headerSize] = TEXT("");
|
||||
TCHAR footerL[headerSize] = TEXT("");
|
||||
TCHAR footerM[headerSize] = TEXT("");
|
||||
TCHAR footerR[headerSize] = TEXT("");
|
||||
|
||||
|
||||
const TCHAR shortDateVar[] = TEXT("$(SHORT_DATE)");
|
||||
const TCHAR longDateVar[] = TEXT("$(LONG_DATE)");
|
||||
const TCHAR timeVar[] = TEXT("$(TIME)");
|
||||
|
||||
TCHAR shortDate[64];
|
||||
TCHAR longDate[64];
|
||||
TCHAR time[64];
|
||||
const int bufferSize = 64;
|
||||
TCHAR shortDate[bufferSize];
|
||||
TCHAR longDate[bufferSize];
|
||||
TCHAR time[bufferSize];
|
||||
|
||||
SYSTEMTIME st;
|
||||
::GetLocalTime(&st);
|
||||
::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, sizeof(shortDate));
|
||||
::GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, sizeof(longDate));
|
||||
::GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, sizeof(time));
|
||||
::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, bufferSize);
|
||||
::GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, bufferSize);
|
||||
::GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, bufferSize);
|
||||
|
||||
if (nppGUI._printSettings.isHeaderPresent())
|
||||
{
|
||||
@ -262,7 +264,7 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
replaceStr(headerLeftPart, shortDateVar, shortDate);
|
||||
replaceStr(headerLeftPart, longDateVar, longDate);
|
||||
replaceStr(headerLeftPart, timeVar, time);
|
||||
expandNppEnvironmentStrs(headerLeftPart.c_str(), headerL, sizeof(headerL), _pdlg.hwndOwner);
|
||||
expandNppEnvironmentStrs(headerLeftPart.c_str(), headerL, headerSize, _pdlg.hwndOwner);
|
||||
}
|
||||
|
||||
generic_string headerMiddlePart = nppGUI._printSettings._headerMiddle;
|
||||
@ -271,7 +273,7 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
replaceStr(headerMiddlePart, shortDateVar, shortDate);
|
||||
replaceStr(headerMiddlePart, longDateVar, longDate);
|
||||
replaceStr(headerMiddlePart, timeVar, time);
|
||||
expandNppEnvironmentStrs(headerMiddlePart.c_str(), headerM, sizeof(headerM), _pdlg.hwndOwner);
|
||||
expandNppEnvironmentStrs(headerMiddlePart.c_str(), headerM, headerSize, _pdlg.hwndOwner);
|
||||
}
|
||||
|
||||
generic_string headerRightPart = nppGUI._printSettings._headerRight;
|
||||
@ -280,7 +282,7 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
replaceStr(headerRightPart, shortDateVar, shortDate);
|
||||
replaceStr(headerRightPart, longDateVar, longDate);
|
||||
replaceStr(headerRightPart, timeVar, time);
|
||||
expandNppEnvironmentStrs(headerRightPart.c_str(), headerR, sizeof(headerR), _pdlg.hwndOwner);
|
||||
expandNppEnvironmentStrs(headerRightPart.c_str(), headerR, headerSize, _pdlg.hwndOwner);
|
||||
}
|
||||
|
||||
}
|
||||
@ -295,7 +297,7 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
replaceStr(footerLeftPart, shortDateVar, shortDate);
|
||||
replaceStr(footerLeftPart, longDateVar, longDate);
|
||||
replaceStr(footerLeftPart, timeVar, time);
|
||||
expandNppEnvironmentStrs(footerLeftPart.c_str(), footerL, sizeof(footerL), _pdlg.hwndOwner);
|
||||
expandNppEnvironmentStrs(footerLeftPart.c_str(), footerL, headerSize, _pdlg.hwndOwner);
|
||||
}
|
||||
|
||||
generic_string footerMiddlePart = nppGUI._printSettings._footerMiddle;
|
||||
@ -304,7 +306,7 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
replaceStr(footerMiddlePart, shortDateVar, shortDate);
|
||||
replaceStr(footerMiddlePart, longDateVar, longDate);
|
||||
replaceStr(footerMiddlePart, timeVar, time);
|
||||
expandNppEnvironmentStrs(footerMiddlePart.c_str(), footerM, sizeof(footerM), _pdlg.hwndOwner);
|
||||
expandNppEnvironmentStrs(footerMiddlePart.c_str(), footerM, headerSize, _pdlg.hwndOwner);
|
||||
}
|
||||
|
||||
generic_string footerRightPart = nppGUI._printSettings._footerRight;
|
||||
@ -313,7 +315,7 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
replaceStr(footerRightPart, shortDateVar, shortDate);
|
||||
replaceStr(footerRightPart, longDateVar, longDate);
|
||||
replaceStr(footerRightPart, timeVar, time);
|
||||
expandNppEnvironmentStrs(footerRightPart.c_str(), footerR, sizeof(footerR), _pdlg.hwndOwner);
|
||||
expandNppEnvironmentStrs(footerRightPart.c_str(), footerR, headerSize, _pdlg.hwndOwner);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2002,7 +2002,8 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc
|
||||
int nbInit = getNbChiffre(initial, base);
|
||||
int nb = max(nbInit, nbEnd);
|
||||
|
||||
TCHAR str[512];
|
||||
const int stringSize = 512;
|
||||
TCHAR str[stringSize];
|
||||
|
||||
int totalDiff = 0;
|
||||
for (size_t i = 0 ; i < cmi.size() ; i++)
|
||||
@ -2013,7 +2014,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc
|
||||
cmi[i].first += totalDiff;
|
||||
cmi[i].second += totalDiff;
|
||||
|
||||
int2str(str, sizeof(str), initial, base, nb, isZeroLeading);
|
||||
int2str(str, stringSize, initial, base, nb, isZeroLeading);
|
||||
|
||||
execute(SCI_SETTARGETSTART, cmi[i].first);
|
||||
execute(SCI_SETTARGETEND, cmi[i].second);
|
||||
|
@ -961,7 +961,7 @@ void SymbolsStyleDialog::listboxsInit()
|
||||
::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BO3_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT(""));
|
||||
::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BC3_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT(""));
|
||||
|
||||
for (int i = 0 ; i < int(sizeof(symbolesArray)-1) ; i++)
|
||||
for (int i = 0 ; i < int((sizeof(symbolesArray)/sizeof(TCHAR))-1) ; i++)
|
||||
{
|
||||
TCHAR s[2];
|
||||
s[0] = symbolesArray[i];
|
||||
|
@ -50,13 +50,14 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||
{
|
||||
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
|
||||
|
||||
TCHAR str[1024];
|
||||
const int stringSize = 1024;
|
||||
TCHAR str[stringSize];
|
||||
|
||||
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
|
||||
|
||||
if (isTextMode)
|
||||
{
|
||||
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, sizeof(str), (LPARAM)str);
|
||||
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, (LPARAM)str);
|
||||
|
||||
display(false);
|
||||
|
||||
@ -175,7 +176,7 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||
/*
|
||||
Calcule generic_string
|
||||
*/
|
||||
int2str(str, sizeof(str), initialNumber, base, nb, isZeroLeading);
|
||||
int2str(str, stringSize, initialNumber, base, nb, isZeroLeading);
|
||||
initialNumber += increaseNumber;
|
||||
|
||||
if (lineEndCol < cursorCol)
|
||||
|
@ -205,7 +205,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
// Draw the text!
|
||||
TCHAR szWinText[MAX_PATH];
|
||||
::GetWindowText(hwnd, szWinText, sizeof szWinText);
|
||||
::GetWindowText(hwnd, szWinText, MAX_PATH);
|
||||
::DrawText(hdc, szWinText, -1, &rect, dwDTStyle);
|
||||
|
||||
::SelectObject(hdc, hOld);
|
||||
@ -259,7 +259,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
else
|
||||
{
|
||||
TCHAR szWinText[MAX_PATH];
|
||||
::GetWindowText(hwnd, szWinText, sizeof szWinText);
|
||||
::GetWindowText(hwnd, szWinText, MAX_PATH);
|
||||
::ShellExecute(NULL, TEXT("open"), szWinText, NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ BOOL CALLBACK ColourStaticTextHooker::colourStaticProc(HWND hwnd, UINT Message,
|
||||
|
||||
// Draw the text!
|
||||
TCHAR text[MAX_PATH];
|
||||
::GetWindowText(hwnd, text, sizeof(text));
|
||||
::GetWindowText(hwnd, text, MAX_PATH);
|
||||
::DrawText(hdc, text, -1, &rect, DT_LEFT);
|
||||
|
||||
::SelectObject(hdc, hOld);
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
void create(tTbData * data, bool isRTL = false){
|
||||
StaticDialog::create(_dlgID, isRTL);
|
||||
::GetWindowText(_hSelf, _pluginName, sizeof(_pluginName));
|
||||
::GetWindowText(_hSelf, _pluginName, MAX_PATH);
|
||||
|
||||
// user information
|
||||
data->hClient = _hSelf;
|
||||
|
@ -343,8 +343,9 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
} else {
|
||||
for (size_t i = shortcutIndex ; i < nbElem ; i++) //lower the IDs of the remaining menu items so there are no gaps
|
||||
{
|
||||
TCHAR cmdName[64];
|
||||
::GetMenuString(hMenu, cmdID, cmdName, sizeof(cmdName), MF_BYCOMMAND);
|
||||
const int commandSize = 64;
|
||||
TCHAR cmdName[commandSize];
|
||||
::GetMenuString(hMenu, cmdID, cmdName, commandSize, MF_BYCOMMAND);
|
||||
::ModifyMenu(hMenu, cmdID, MF_BYCOMMAND, cmdID-1, cmdName); //update commandID
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
|
||||
_ofn.nMaxCustFilter = 0L;
|
||||
_ofn.nFilterIndex = 1L;
|
||||
_ofn.lpstrFile = _fileName;
|
||||
_ofn.nMaxFile = sizeof(_fileName);
|
||||
_ofn.nMaxFile = sizeof(_fileName)/sizeof(TCHAR);
|
||||
_ofn.lpstrFileTitle = NULL;
|
||||
_ofn.nMaxFileTitle = 0;
|
||||
_ofn.lpstrInitialDir = NULL;
|
||||
@ -238,8 +238,8 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||
case IDOK :
|
||||
{
|
||||
HWND fnControl = ::GetDlgItem(hwnd, FileDialog::_dialogFileBoxId);
|
||||
TCHAR fn[256];
|
||||
::GetWindowText(fnControl, fn, sizeof(fn));
|
||||
TCHAR fn[MAX_PATH];
|
||||
::GetWindowText(fnControl, fn, MAX_PATH);
|
||||
if (*fn == '\0')
|
||||
return oldProc(hwnd, message, wParam, lParam);
|
||||
|
||||
@ -271,8 +271,8 @@ static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the
|
||||
};
|
||||
|
||||
static generic_string addExt(HWND textCtrl, HWND typeCtrl) {
|
||||
TCHAR fn[256];
|
||||
::GetWindowText(textCtrl, fn, sizeof(fn));
|
||||
TCHAR fn[MAX_PATH];
|
||||
::GetWindowText(textCtrl, fn, MAX_PATH);
|
||||
|
||||
int i = ::SendMessage(typeCtrl, CB_GETCURSEL, 0, 0);
|
||||
TCHAR ext[256];
|
||||
|
@ -588,7 +588,7 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
case IDC_EDIT_SESSIONFILEEXT:
|
||||
{
|
||||
TCHAR sessionExt[MAX_PATH];
|
||||
::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_GETTEXT, sizeof(sessionExt), (LPARAM)sessionExt);
|
||||
::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_GETTEXT, MAX_PATH, (LPARAM)sessionExt);
|
||||
nppGUI._definedSessionExt = sessionExt;
|
||||
return TRUE;
|
||||
}
|
||||
@ -1234,9 +1234,10 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
{
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
TCHAR str[256];
|
||||
const int stringSize = 256;
|
||||
TCHAR str[stringSize];
|
||||
_focusedEditCtrl = LOWORD(wParam);
|
||||
::GetDlgItemText(_hSelf, _focusedEditCtrl, str, sizeof(str));
|
||||
::GetDlgItemText(_hSelf, _focusedEditCtrl, str, stringSize);
|
||||
::SendDlgItemMessage(_hSelf, IDC_VIEWPANEL_STATIC, WM_SETTEXT, 0, (LPARAM)str);
|
||||
|
||||
switch (LOWORD(wParam))
|
||||
@ -1277,9 +1278,10 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
}
|
||||
else if (HIWORD(wParam) == EN_SETFOCUS)
|
||||
{
|
||||
TCHAR str[256];
|
||||
const int stringSize = 256;
|
||||
TCHAR str[stringSize];
|
||||
_focusedEditCtrl = LOWORD(wParam);
|
||||
::GetDlgItemText(_hSelf, _focusedEditCtrl, str, sizeof(str));
|
||||
::GetDlgItemText(_hSelf, _focusedEditCtrl, str, stringSize);
|
||||
//_colourHooker.setColour(RGB(0, 0, 0xFF));
|
||||
::SendDlgItemMessage(_hSelf, IDC_VIEWPANEL_STATIC, WM_SETTEXT, 0, (LPARAM)str);
|
||||
|
||||
@ -1295,10 +1297,10 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
case IDC_EDIT_FRIGHT : focusedEditStatic = IDC_FR_STATIC; groupStatic = IDC_FGB_STATIC; break;
|
||||
}
|
||||
|
||||
::GetDlgItemText(_hSelf, groupStatic, str, sizeof(str));
|
||||
::GetDlgItemText(_hSelf, groupStatic, str, stringSize);
|
||||
generic_string title = str;
|
||||
title += TEXT(" ");
|
||||
::GetDlgItemText(_hSelf, focusedEditStatic, str, sizeof(str));
|
||||
::GetDlgItemText(_hSelf, focusedEditStatic, str, stringSize);
|
||||
title += str;
|
||||
title += TEXT(" : ");
|
||||
|
||||
@ -1379,8 +1381,9 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
wsprintf(toto, TEXT("_selStart = %d\r_selEnd = %d"), _selStart, _selEnd);
|
||||
::MessageBox(NULL, toto, TEXT(""), MB_OK);
|
||||
*/
|
||||
TCHAR str[256];
|
||||
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, WM_GETTEXT, sizeof(str), (LPARAM)str);
|
||||
const int stringSize = 256;
|
||||
TCHAR str[stringSize];
|
||||
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, WM_GETTEXT, stringSize, (LPARAM)str);
|
||||
//::MessageBox(NULL, str, TEXT(""), MB_OK);
|
||||
|
||||
generic_string str2Set(str);
|
||||
@ -1461,7 +1464,7 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
case IDC_BACKUPDIR_EDIT:
|
||||
{
|
||||
TCHAR inputDir[MAX_PATH];
|
||||
::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_EDIT, WM_GETTEXT, sizeof(inputDir), (LPARAM)inputDir);
|
||||
::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_EDIT, WM_GETTEXT, MAX_PATH, (LPARAM)inputDir);
|
||||
lstrcpy(nppGUI._backupDir, inputDir);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -160,10 +160,10 @@ HINSTANCE Command::run(HWND hWnd)
|
||||
TCHAR args2Exec[MAX_PATH];
|
||||
|
||||
extractArgs(cmdPure, args, _cmdLine.c_str());
|
||||
::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, sizeof(cmd2Exec));
|
||||
::ExpandEnvironmentStrings(args, argsIntermediate, sizeof(args));
|
||||
expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, sizeof(cmd2Exec), hWnd);
|
||||
expandNppEnvironmentStrs(argsIntermediate, args2Exec, sizeof(args2Exec), hWnd);
|
||||
::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, MAX_PATH);
|
||||
::ExpandEnvironmentStrings(args, argsIntermediate, MAX_PATH);
|
||||
expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, MAX_PATH, hWnd);
|
||||
expandNppEnvironmentStrs(argsIntermediate, args2Exec, MAX_PATH, hWnd);
|
||||
|
||||
return ::ShellExecute(hWnd, TEXT("open"), cmd2Exec, args2Exec, TEXT("."), SW_SHOW);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public :
|
||||
TCITEM tie;
|
||||
tie.mask = TCIF_TEXT;
|
||||
tie.pszText = (TCHAR *)newName;
|
||||
tie.cchTextMax = (sizeof(newName));
|
||||
//tie.cchTextMax = (sizeof(newName)); //this is ignored (besides, 4 bytes for a pointer? =])
|
||||
TabCtrl_SetItem(_hSelf, index, &tie);
|
||||
};
|
||||
|
||||
|
@ -738,14 +738,15 @@ void TabBarPlus::exchangeItemData(POINT point)
|
||||
//2. shift their data, and insert the source
|
||||
TCITEM itemData_nDraggedTab, itemData_shift;
|
||||
itemData_nDraggedTab.mask = itemData_shift.mask = TCIF_IMAGE | TCIF_TEXT | TCIF_PARAM;
|
||||
TCHAR str1[256];
|
||||
TCHAR str2[256];
|
||||
const int stringSize = 256;
|
||||
TCHAR str1[stringSize];
|
||||
TCHAR str2[stringSize];
|
||||
|
||||
itemData_nDraggedTab.pszText = str1;
|
||||
itemData_nDraggedTab.cchTextMax = (sizeof(str1));
|
||||
itemData_nDraggedTab.cchTextMax = (stringSize);
|
||||
|
||||
itemData_shift.pszText = str2;
|
||||
itemData_shift.cchTextMax = (sizeof(str2));
|
||||
itemData_shift.cchTextMax = (stringSize);
|
||||
|
||||
::SendMessage(_hSelf, TCM_GETITEM, _nTabDragged, reinterpret_cast<LPARAM>(&itemData_nDraggedTab));
|
||||
|
||||
|
@ -90,7 +90,7 @@ RECT TaskList::adjustSize()
|
||||
for (int i = 0 ; i < _nbItem ; i++)
|
||||
{
|
||||
TCHAR buf[MAX_PATH];
|
||||
ListView_GetItemText(_hSelf, i, 0, buf, sizeof(buf));
|
||||
ListView_GetItemText(_hSelf, i, 0, buf, MAX_PATH);
|
||||
int width = ListView_GetStringWidth(_hSelf, buf);
|
||||
|
||||
if (width > (_rc.right - _rc.left))
|
||||
|
@ -309,8 +309,9 @@ void getNameStrFromCmd(DWORD cmd, generic_string & str)
|
||||
else
|
||||
{
|
||||
HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL);
|
||||
TCHAR cmdName[64];
|
||||
int nbChar = ::GetMenuString((HMENU)::SendMessage(hNotepad_plus, NPPM_INTERNAL_GETMENU, 0, 0), cmd, cmdName, sizeof(cmdName), MF_BYCOMMAND);
|
||||
const int commandSize = 64;
|
||||
TCHAR cmdName[commandSize];
|
||||
int nbChar = ::GetMenuString((HMENU)::SendMessage(hNotepad_plus, NPPM_INTERNAL_GETMENU, 0, 0), cmd, cmdName, commandSize, MF_BYCOMMAND);
|
||||
if (!nbChar)
|
||||
return;
|
||||
bool fin = false;
|
||||
@ -635,8 +636,9 @@ void ScintillaAccelerator::updateKey(ScintillaKeyMap skmOld, ScintillaKeyMap skm
|
||||
|
||||
void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id) {
|
||||
NppParameters *pNppParam = NppParameters::getInstance();
|
||||
TCHAR cmdName[64];
|
||||
::GetMenuString(_hAccelMenu, id, cmdName, sizeof(cmdName), MF_BYCOMMAND);
|
||||
const int commandSize = 64;
|
||||
TCHAR cmdName[commandSize];
|
||||
::GetMenuString(_hAccelMenu, id, cmdName, commandSize, MF_BYCOMMAND);
|
||||
int i = 0;
|
||||
while(cmdName[i] != 0) {
|
||||
if (cmdName[i] == '\t') {
|
||||
|
@ -428,9 +428,6 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use
|
||||
<File
|
||||
RelativePath="..\src\WinControls\ColourPicker\ColourPopup.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\DockingWnd\common_func.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\WinControls\TabBar\ControlsTab.cpp">
|
||||
</File>
|
||||
|
Loading…
Reference in New Issue
Block a user