Enhance Column Editor

1. Change the order of GUI items to make the insert mode (dec/hex/oct/bin) more explicit.
2. Reduce the showing time of the warning baloon tip from ~10 seconds to 3.5 seconds.
3. Use ESC keystroke to cancel the warning baloon tip.

ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16931#issuecomment-3236582042

Note that while the baloon tip showing then clicking on the upper-right 'X', the dialog won't be closed. Instead, the baloon tip will be cancel.
Curiously, clicking on the "Cancel" button under the same context closes the dialog.
The reason could be, while the "Cancel" button being clicked, the focus is changed and the system hides the baloon tip. Whereas the click on the upper-right 'X' doesn't make the focus changed, then the system does nothing.
Anyway such behaviour is a bug, but can happen very rarily.

Close #16959
This commit is contained in:
Don HO 2025-08-30 17:29:58 +02:00
parent 06750919ac
commit dc58d41359
3 changed files with 65 additions and 25 deletions

View File

@ -42,9 +42,10 @@ void ColumnEditorDlg::display(bool toShow) const
intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
static HBRUSH hRedBrush = NULL; static HBRUSH hRedBrush = nullptr;
static int whichFlashRed = 0; static int whichFlashRed = 0;
static COLORREF rgbRed = RGB(255, 0, 0); constexpr COLORREF rgbRed = RGB(255, 0, 0);
static HWND hCurrentBalloonTip = nullptr;
switch (message) switch (message)
{ {
@ -166,9 +167,19 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{ {
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDCANCEL: // Close case IDCANCEL: // in case of ESC keystroke
display(false); {
if (hCurrentBalloonTip && IsWindowVisible(hCurrentBalloonTip)) // if current baloon tip shown, just hide it
{
ShowWindow(hCurrentBalloonTip, SW_HIDE);
}
else // if current baloon tip doesn't show, we hide Column Editor dialog
{
display(false);
}
return TRUE; return TRUE;
}
case IDOK: case IDOK:
{ {
@ -529,12 +540,38 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
case WM_TIMER: case WM_TIMER:
{ {
if(wParam == IDT_COL_FLASH_TIMER) static int idRedraw = 0;
if (wParam == IDT_COL_FLASH_TIMER)
{ {
KillTimer(_hSelf, IDT_COL_FLASH_TIMER); KillTimer(_hSelf, IDT_COL_FLASH_TIMER);
int idRedraw = whichFlashRed; // keep the ID for the one whose flash is ending...
idRedraw = whichFlashRed; // keep the ID for the one whose flash is ending...
whichFlashRed = 0; // must be 0 before the redraw, otherwise it will maintain color whichFlashRed = 0; // must be 0 before the redraw, otherwise it will maintain color
redrawDlgItem(idRedraw, true); // redraw the just the one that was flashed redrawDlgItem(idRedraw, true); // redraw the just the one that was flashed
// Remember the latest/current baloon tip handle
hCurrentBalloonTip = [](HWND hEditControl) -> HWND {
HWND hTooltip = FindWindowEx(NULL, NULL, L"tooltips_class32", NULL);
while (hTooltip)
{
HWND hParent = GetParent(hTooltip);
if (hParent == hEditControl || hParent == GetParent(hEditControl))
{
return hTooltip;
}
hTooltip = FindWindowEx(NULL, hTooltip, L"tooltips_class32", NULL);
}
return NULL;
}(GetDlgItem(_hSelf, idRedraw));
}
if (wParam == IDC_COL_BALLONTIP_TIMER)
{
KillTimer(_hSelf, IDC_COL_BALLONTIP_TIMER);
SendMessage(GetDlgItem(_hSelf, idRedraw), EM_HIDEBALLOONTIP, 0, 0);
} }
break; break;
@ -766,6 +803,8 @@ int ColumnEditorDlg::sendValidationErrorMessage(int whichFlashRed, int formatCho
SendMessage(GetDlgItem(_hSelf, whichFlashRed), EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt); SendMessage(GetDlgItem(_hSelf, whichFlashRed), EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt);
SetTimer(_hSelf, IDT_COL_FLASH_TIMER, 250, NULL); SetTimer(_hSelf, IDT_COL_FLASH_TIMER, 250, NULL);
SetTimer(_hSelf, IDC_COL_BALLONTIP_TIMER, 3500, NULL);
redrawDlgItem(whichFlashRed); redrawDlgItem(whichFlashRed);
return whichFlashRed; return whichFlashRed;

View File

@ -25,28 +25,28 @@ EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Column / Multi-Selection Editor" CAPTION "Column / Multi-Selection Editor"
FONT 8, L"MS Shell Dlg", 0, 0, 0x0 FONT 8, L"MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,6,124,10 CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,6,124,10
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,68,204,10 CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,68,204,10
GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46 GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46
EDITTEXT IDC_COL_TEXT_EDIT,20,32,97,12,ES_AUTOHSCROLL EDITTEXT IDC_COL_TEXT_EDIT,20,32,97,12,ES_AUTOHSCROLL
GROUPBOX "",IDC_COL_NUM_GRP_STATIC,8,77,204,130 GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,86,188,44,BS_CENTER
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,89,76,8 CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,99,50,10
EDITTEXT IDC_COL_INITNUM_EDIT,90,87,38,12,ES_LEFT CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,99,50,10
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,106,75,8 CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,114,50,10
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,104,38,12,ES_LEFT CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,114,50,10
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,123,75,8 COMBOBOX IDC_COL_HEXUC_COMBO,150,97,40,10,CBS_DROPDOWNLIST | WS_TABSTOP
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,121,38,12,ES_LEFT
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,140,75,8
COMBOBOX IDC_COL_LEADING_COMBO,90,138,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,155,188,44,BS_CENTER GROUPBOX "",IDC_COL_NUM_GRP_STATIC,8,77,204,130
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,168,50,10 RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,140,76,8
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,168,50,10 EDITTEXT IDC_COL_INITNUM_EDIT,90,138,38,12
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,183,50,10 RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,157,75,8
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,183,50,10 EDITTEXT IDC_COL_INCREASENUM_EDIT,90,155,38,12
COMBOBOX IDC_COL_HEXUC_COMBO,150,166,40,10,CBS_DROPDOWNLIST | WS_TABSTOP RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,174,75,8
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,172,38,12
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,191,75,8
COMBOBOX IDC_COL_LEADING_COMBO,90,189,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,142,18,70,14 DEFPUSHBUTTON "OK",IDOK,142,18,70,14
PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14 PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14

View File

@ -37,6 +37,7 @@
#define IDC_COL_REPEATNUM_EDIT (IDD_COLUMNEDIT + 17) #define IDC_COL_REPEATNUM_EDIT (IDD_COLUMNEDIT + 17)
#define IDC_COL_LEADING_STATIC (IDD_COLUMNEDIT + 18) #define IDC_COL_LEADING_STATIC (IDD_COLUMNEDIT + 18)
#define IDC_COL_LEADING_COMBO (IDD_COLUMNEDIT + 19) #define IDC_COL_LEADING_COMBO (IDD_COLUMNEDIT + 19)
#define IDT_COL_FLASH_TIMER (IDD_COLUMNEDIT + 20) #define IDC_COL_HEXUC_COMBO (IDD_COLUMNEDIT + 20)
#define IDC_COL_HEXUC_COMBO (IDD_COLUMNEDIT + 21) #define IDT_COL_FLASH_TIMER (IDD_COLUMNEDIT + 21)
#define IDC_COL_BALLONTIP_TIMER (IDD_COLUMNEDIT + 22)
#endif// COLUMNEDITOR_RC_H #endif// COLUMNEDITOR_RC_H