[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:
parent
bb475168ba
commit
22bf2fe477
|
@ -154,7 +154,6 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
||||||
|
|
||||||
TCHAR text[MAX_PATH];
|
TCHAR text[MAX_PATH];
|
||||||
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||||
bool hasFound = false;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
|
@ -163,17 +162,15 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
||||||
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
||||||
if (!lstrcmp(txt2add, text))
|
if (!lstrcmp(txt2add, text))
|
||||||
{
|
{
|
||||||
hasFound = true;
|
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasFound)
|
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
||||||
{
|
|
||||||
i = ::SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)txt2add);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
bool bMustDie9x = _winVer <= WV_ME;
|
bool isWin9x = _winVer <= WV_ME;
|
||||||
wchar_t wchars2Add[MAX_PATH];
|
wchar_t wchars2Add[MAX_PATH];
|
||||||
wchar_t textW[MAX_PATH];
|
wchar_t textW[MAX_PATH];
|
||||||
|
|
||||||
|
@ -184,16 +181,17 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
||||||
{
|
{
|
||||||
if (isUTF8)
|
if (isUTF8)
|
||||||
{
|
{
|
||||||
if ( !bMustDie9x )
|
if (!isWin9x)
|
||||||
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
|
::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
||||||
::MultiByteToWideChar(CP_ACP, 0, text, -1, textW, MAX_PATH - 1);
|
::MultiByteToWideChar(CP_ACP, 0, text, -1, textW, MAX_PATH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wcscmp(wchars2Add, textW))
|
if (!wcscmp(wchars2Add, textW))
|
||||||
{
|
{
|
||||||
hasFound = true;
|
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,24 +200,21 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT
|
||||||
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text);
|
||||||
if (!strcmp(txt2add, text))
|
if (!strcmp(txt2add, text))
|
||||||
{
|
{
|
||||||
hasFound = true;
|
::SendMessage(hCombo, CB_DELETESTRING, i, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasFound)
|
|
||||||
{
|
|
||||||
if (!isUTF8)
|
if (!isUTF8)
|
||||||
i = ::SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)txt2add);
|
i = ::SendMessage(hCombo, CB_INSERTSTRING, 0, (LPARAM)txt2add);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !bMustDie9x )
|
if (!isWin9x)
|
||||||
i = ::SendMessageW(hCombo, CB_ADDSTRING, 0, (LPARAM)wchars2Add);
|
i = ::SendMessageW(hCombo, CB_INSERTSTRING, 0, (LPARAM)wchars2Add);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, MAX_PATH - 1, NULL, NULL);
|
::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, MAX_PATH - 1, NULL, NULL);
|
||||||
i = ::SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text);
|
i = ::SendMessageA(hCombo, CB_INSERTSTRING, 0, (LPARAM)text);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -232,11 +227,11 @@ generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) con
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str);
|
::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str);
|
||||||
#else
|
#else
|
||||||
bool bMustDie9x = _winVer <= WV_ME;
|
bool isWin9x = _winVer <= WV_ME;
|
||||||
if (isUnicode)
|
if (isUnicode)
|
||||||
{
|
{
|
||||||
wchar_t wchars[MAX_PATH];
|
wchar_t wchars[MAX_PATH];
|
||||||
if ( !bMustDie9x )
|
if ( !isWin9x )
|
||||||
{
|
{
|
||||||
::SendMessageW(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)wchars);
|
::SendMessageW(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)wchars);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,8 +267,15 @@ public :
|
||||||
void replaceAllInOpenedDocs();
|
void replaceAllInOpenedDocs();
|
||||||
void findAllIn(InWhat op);
|
void findAllIn(InWhat op);
|
||||||
|
|
||||||
void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) {
|
void setSearchText(TCHAR * txt2find, bool isUTF8 = false) {
|
||||||
addText2Combo(txt2find, ::GetDlgItem(_hSelf, IDFINDWHAT), isUTF8);
|
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 {
|
bool isFinderEmpty() const {
|
||||||
|
|
Loading…
Reference in New Issue