mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-21 08:58:06 +02:00
Adjust "Find what" tooltip position for not hidding search settings
Fix #16979, close #16988
This commit is contained in:
parent
962a17e9f6
commit
7a1cde702a
@ -2136,7 +2136,7 @@ bool isCoreWindows()
|
||||
return isCoreWindows;
|
||||
}
|
||||
|
||||
bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond /* = 0 */)
|
||||
bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond /* = 0 */, int maxWidth /* = 200 */)
|
||||
{
|
||||
_hWndInfoTip = CreateWindowEx(isRTL ? WS_EX_LAYOUTRTL : 0, TOOLTIPS_CLASS, NULL,
|
||||
WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
|
||||
@ -2161,7 +2161,7 @@ bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attache
|
||||
return false;
|
||||
}
|
||||
|
||||
SendMessage(_hWndInfoTip, TTM_SETMAXTIPWIDTH, 0, 200);
|
||||
SendMessage(_hWndInfoTip, TTM_SETMAXTIPWIDTH, 0, maxWidth);
|
||||
SendMessage(_hWndInfoTip, TTM_ACTIVATE, TRUE, 0);
|
||||
|
||||
if (remainTimeMillisecond)
|
||||
@ -2170,14 +2170,22 @@ bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attache
|
||||
return true;
|
||||
}
|
||||
|
||||
void ControlInfoTip::show() const
|
||||
void ControlInfoTip::show(showPosition pos) const
|
||||
{
|
||||
if (!isValid()) return;
|
||||
|
||||
RECT rcComboBox;
|
||||
GetWindowRect(reinterpret_cast<HWND>(_toolInfo.uId), &rcComboBox);
|
||||
|
||||
int xPos = rcComboBox.left + (rcComboBox.right - rcComboBox.left) / 2;
|
||||
int xPos = 0;
|
||||
|
||||
if (pos == beginning)
|
||||
xPos = rcComboBox.left + 15;
|
||||
else if (pos == middle)
|
||||
xPos = rcComboBox.left + (rcComboBox.right - rcComboBox.left) / 2;
|
||||
else // (pos == end)
|
||||
xPos = rcComboBox.left + (rcComboBox.right - rcComboBox.left) - 15;
|
||||
|
||||
int yPos = rcComboBox.top + 25;
|
||||
|
||||
SendMessage(_hWndInfoTip, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
|
||||
|
@ -311,7 +311,7 @@ public:
|
||||
hide();
|
||||
}
|
||||
};
|
||||
bool init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const std::wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond = 0); // remainTimeMillisecond = 0: no timeout
|
||||
bool init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const std::wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond = 0, int maxWidth = 200); // remainTimeMillisecond = 0: no timeout
|
||||
|
||||
bool isValid() const {
|
||||
return _hWndInfoTip != nullptr;
|
||||
@ -321,7 +321,8 @@ public:
|
||||
return _hWndInfoTip;
|
||||
};
|
||||
|
||||
void show() const;
|
||||
enum showPosition {beginning, middle, end};
|
||||
void show(showPosition pos = middle) const;
|
||||
|
||||
void hide();
|
||||
|
||||
|
@ -1985,7 +1985,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
|
||||
static wstring maxLenOnSearchTip = tip;
|
||||
|
||||
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSearchTip.c_str(), _isRTL);
|
||||
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSearchTip.c_str(), _isRTL, 0, 170);
|
||||
|
||||
if (!isSuccessful)
|
||||
{
|
||||
@ -1994,7 +1994,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
|
||||
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
|
||||
}
|
||||
_maxLenOnSearchTip.show();
|
||||
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
|
||||
}
|
||||
else if (length >= FINDREPLACE_MAXLENGTH2SAVE - 1) // FINDREPLACE_MAXLENGTH2SAVE < length < FINDREPLACE_MAXLENGTH
|
||||
{
|
||||
@ -2006,7 +2006,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
|
||||
static wstring maxLenOnSaveTip = tip;
|
||||
|
||||
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSaveTip.c_str(), _isRTL);
|
||||
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSaveTip.c_str(), _isRTL, 0, 170);
|
||||
|
||||
if (!isSuccessful)
|
||||
{
|
||||
@ -2015,7 +2015,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
|
||||
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
|
||||
}
|
||||
_maxLenOnSearchTip.show();
|
||||
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user