diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index d1828e3d0..a66a2b6d1 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -932,3 +932,46 @@ generic_string GetLastErrorAsString(DWORD errorCode) return errorMsg; } + +HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText) +{ + if (!toolID || !hDlg || !pszText) + { + return NULL; + } + + // Get the window of the tool. + HWND hwndTool = GetDlgItem(hDlg, toolID); + if (!hwndTool) + { + return NULL; + } + + // Create the tooltip. g_hInst is the global instance handle. + HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, + WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hDlg, NULL, + hInst, NULL); + + if (!hwndTip) + { + return NULL; + } + + // Associate the tooltip with the tool. + TOOLINFO toolInfo = { 0 }; + toolInfo.cbSize = sizeof(toolInfo); + toolInfo.hwnd = hDlg; + toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + toolInfo.uId = (UINT_PTR)hwndTool; + toolInfo.lpszText = pszText; + if (!SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo)) + { + DestroyWindow(hwndTip); + return NULL; + } + + return hwndTip; +} diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index b0966e23a..16a8d22f8 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -186,4 +186,6 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd); generic_string GetLastErrorAsString(DWORD errorCode = 0); generic_string intToString(int val); -generic_string uintToString(unsigned int val); \ No newline at end of file +generic_string uintToString(unsigned int val); + +HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index ca1848564..b8a38200e 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -32,6 +32,7 @@ #include "Notepad_plus_msgs.h" #include "UniConversion.h" #include "LongRunningOperation.h" +#include "localization.h" using namespace std; @@ -235,6 +236,11 @@ FindReplaceDlg::~FindReplaceDlg() _findersOfFinder.erase(_findersOfFinder.begin() + n); } + if (_shiftTrickUpTip) + ::DestroyWindow(_shiftTrickUpTip); + if (_shiftTrickDownTip) + ::DestroyWindow(_shiftTrickDownTip); + delete[] _uniFileName; } @@ -697,6 +703,26 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM _findClosePos.left = p.x; _findClosePos.top = p.y + 10; + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); + generic_string tip2show = pNativeSpeaker->getLocalizedStrFromID("shift-change-direction-tip"); + if (tip2show.empty()) + tip2show = TEXT("Use Shift+Enter to search in the reverse set direction."); + + _shiftTrickUpTip = CreateToolTip(IDDIRECTIONUP, _hSelf, _hInst, const_cast(tip2show.c_str())); + _shiftTrickDownTip = CreateToolTip(IDDIRECTIONDOWN, _hSelf, _hInst, const_cast(tip2show.c_str())); + if (_shiftTrickUpTip && _shiftTrickDownTip) + { + SendMessage(_shiftTrickUpTip, TTM_ACTIVATE, TRUE, 0); + SendMessage(_shiftTrickUpTip, TTM_SETMAXTIPWIDTH, 0, 200); + // Make tip stay 30 seconds + SendMessage(_shiftTrickUpTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((30000), (0))); + + SendMessage(_shiftTrickDownTip, TTM_ACTIVATE, TRUE, 0); + SendMessage(_shiftTrickDownTip, TTM_SETMAXTIPWIDTH, 0, 200); + // Make tip stay 30 seconds + SendMessage(_shiftTrickDownTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((30000), (0))); + } + return TRUE; } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index c5fc6e04a..b6427d891 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -353,6 +353,9 @@ private : std::vector _findersOfFinder; + HWND _shiftTrickUpTip = nullptr; + HWND _shiftTrickDownTip = nullptr; + bool _isRTL; diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index f9342a880..43d5f2100 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2901,48 +2901,6 @@ void DelimiterSettingsDlg::detectSpace(const char *text2Check, int & nbSp, int & } } -HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText) -{ - if (!toolID || !hDlg || !pszText) - { - return NULL; - } - - // Get the window of the tool. - HWND hwndTool = GetDlgItem(hDlg, toolID); - if (!hwndTool) - { - return NULL; - } - - // Create the tooltip. g_hInst is the global instance handle. - HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, - WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - hDlg, NULL, - hInst, NULL); - - if (!hwndTip) - { - return NULL; - } - - // Associate the tooltip with the tool. - TOOLINFO toolInfo = { 0 }; - toolInfo.cbSize = sizeof(toolInfo); - toolInfo.hwnd = hDlg; - toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; - toolInfo.uId = (UINT_PTR)hwndTool; - toolInfo.lpszText = pszText; - if (!SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo)) - { - DestroyWindow(hwndTip); - return NULL; - } - - return hwndTip; -} generic_string DelimiterSettingsDlg::getWarningText(size_t nbSp, size_t nbTab) const {