mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-21 17:08:12 +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;
|
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,
|
_hWndInfoTip = CreateWindowEx(isRTL ? WS_EX_LAYOUTRTL : 0, TOOLTIPS_CLASS, NULL,
|
||||||
WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
|
WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
|
||||||
@ -2161,7 +2161,7 @@ bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attache
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessage(_hWndInfoTip, TTM_SETMAXTIPWIDTH, 0, 200);
|
SendMessage(_hWndInfoTip, TTM_SETMAXTIPWIDTH, 0, maxWidth);
|
||||||
SendMessage(_hWndInfoTip, TTM_ACTIVATE, TRUE, 0);
|
SendMessage(_hWndInfoTip, TTM_ACTIVATE, TRUE, 0);
|
||||||
|
|
||||||
if (remainTimeMillisecond)
|
if (remainTimeMillisecond)
|
||||||
@ -2170,14 +2170,22 @@ bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attache
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlInfoTip::show() const
|
void ControlInfoTip::show(showPosition pos) const
|
||||||
{
|
{
|
||||||
if (!isValid()) return;
|
if (!isValid()) return;
|
||||||
|
|
||||||
RECT rcComboBox;
|
RECT rcComboBox;
|
||||||
GetWindowRect(reinterpret_cast<HWND>(_toolInfo.uId), &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;
|
int yPos = rcComboBox.top + 25;
|
||||||
|
|
||||||
SendMessage(_hWndInfoTip, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
|
SendMessage(_hWndInfoTip, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
|
||||||
|
@ -311,7 +311,7 @@ public:
|
|||||||
hide();
|
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 {
|
bool isValid() const {
|
||||||
return _hWndInfoTip != nullptr;
|
return _hWndInfoTip != nullptr;
|
||||||
@ -321,7 +321,8 @@ public:
|
|||||||
return _hWndInfoTip;
|
return _hWndInfoTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
void show() const;
|
enum showPosition {beginning, middle, end};
|
||||||
|
void show(showPosition pos = middle) const;
|
||||||
|
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
|
@ -1985,7 +1985,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
static wstring maxLenOnSearchTip = tip;
|
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)
|
if (!isSuccessful)
|
||||||
{
|
{
|
||||||
@ -1994,7 +1994,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
|
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
|
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;
|
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)
|
if (!isSuccessful)
|
||||||
{
|
{
|
||||||
@ -2015,7 +2015,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
|
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
|
||||||
}
|
}
|
||||||
_maxLenOnSearchTip.show();
|
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user