[BUG_FIXED] Adding search text on the top of combo box.

The selected text is not automatically added to the combo box, only when the search is processed.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@370 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-12-16 00:52:03 +00:00
parent bb475168ba
commit 22bf2fe477
2 changed files with 26 additions and 24 deletions

View File

@ -154,7 +154,6 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
TCHAR text[MAX_PATH];
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
bool hasFound = false;
int i = 0;
#ifdef UNICODE
@ -163,17 +162,15 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
if (!lstrcmp(txt2add, text))
{
hasFound = true;
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
break;
}
}
if (!hasFound)
{
i = ::SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)txt2add);
}
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
#else
bool bMustDie9x = _winVer <= WV_ME;
bool isWin9x = _winVer <= WV_ME;
wchar_t wchars2Add[MAX_PATH];
wchar_t textW[MAX_PATH];
@ -184,16 +181,17 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
{
if (isUTF8)
{
if ( !bMustDie9x )
if (!isWin9x)
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
else
{
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
::MultiByteToWideChar(CP_ACP, 0, text, -1, textW, MAX_PATH - 1);
}
if (!wcscmp(wchars2Add, textW))
{
hasFound = true;
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
break;
}
}
@ -202,24 +200,21 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
if (!strcmp(txt2add, text))
{
hasFound = true;
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
break;
}
}
}
if (!hasFound)
if (!isUTF8)
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
else
{
if (!isUTF8)
i = ::SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)txt2add);
if (!isWin9x)
i = ::SendMessageW(hCombo, CB_INSERTSTRING, 0, (LPARAM)wchars2Add);
else
{
if ( !bMustDie9x )
i = ::SendMessageW(hCombo, CB_ADDSTRING, 0, (LPARAM)wchars2Add);
else
{
::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, MAX_PATH - 1, NULL, NULL);
i = ::SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text);
}
::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, MAX_PATH - 1, NULL, NULL);
i = ::SendMessageA(hCombo, CB_INSERTSTRING, 0, (LPARAM)text);
}
}
#endif
@ -232,11 +227,11 @@ generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) con
#ifdef UNICODE
::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str);
#else
bool bMustDie9x = _winVer <= WV_ME;
bool isWin9x = _winVer <= WV_ME;
if (isUnicode)
{
wchar_t wchars[MAX_PATH];
if ( !bMustDie9x )
if ( !isWin9x )
{
::SendMessageW(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)wchars);
}

View File

@ -267,8 +267,15 @@ public :
void replaceAllInOpenedDocs();
void findAllIn(InWhat op);
void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) {
addText2Combo(txt2find, ::GetDlgItem(_hSelf, IDFINDWHAT), isUTF8);
void setSearchText(TCHAR * txt2find, bool isUTF8 = false) {
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
if (txt2find && txt2find[0])
{
// We got a valid search string
::SendMessage(hCombo, CB_SETCURSEL, -1, 0); // remove selection - to allow using down arrow to get to last searched word
::SetDlgItemText(_hSelf, IDFINDWHAT, txt2find);
}
::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit
}
bool isFinderEmpty() const {