diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 8ea86b317..883c5689e 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -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(_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)); diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 5ff3b21fd..782ec9711 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -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(); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index dcd34ba90..c64a125fb 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -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 {