Skip to content

Commit dc58d41

Browse files
committed
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: notepad-plus-plus#16931 (comment) 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 notepad-plus-plus#16959
1 parent 0675091 commit dc58d41

3 files changed

Lines changed: 65 additions & 25 deletions

File tree

PowerEditor/src/ScintillaComponent/columnEditor.cpp

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ void ColumnEditorDlg::display(bool toShow) const
4242

4343
intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
4444
{
45-
static HBRUSH hRedBrush = NULL;
45+
static HBRUSH hRedBrush = nullptr;
4646
static int whichFlashRed = 0;
47-
static COLORREF rgbRed = RGB(255, 0, 0);
47+
constexpr COLORREF rgbRed = RGB(255, 0, 0);
48+
static HWND hCurrentBalloonTip = nullptr;
4849

4950
switch (message)
5051
{
@@ -166,9 +167,19 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
166167
{
167168
switch (LOWORD(wParam))
168169
{
169-
case IDCANCEL: // Close
170-
display(false);
170+
case IDCANCEL: // in case of ESC keystroke
171+
{
172+
if (hCurrentBalloonTip && IsWindowVisible(hCurrentBalloonTip)) // if current baloon tip shown, just hide it
173+
{
174+
ShowWindow(hCurrentBalloonTip, SW_HIDE);
175+
}
176+
else // if current baloon tip doesn't show, we hide Column Editor dialog
177+
{
178+
display(false);
179+
}
180+
171181
return TRUE;
182+
}
172183

173184
case IDOK:
174185
{
@@ -529,12 +540,38 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
529540

530541
case WM_TIMER:
531542
{
532-
if(wParam == IDT_COL_FLASH_TIMER)
543+
static int idRedraw = 0;
544+
545+
if (wParam == IDT_COL_FLASH_TIMER)
533546
{
534547
KillTimer(_hSelf, IDT_COL_FLASH_TIMER);
535-
int idRedraw = whichFlashRed; // keep the ID for the one whose flash is ending...
548+
549+
idRedraw = whichFlashRed; // keep the ID for the one whose flash is ending...
536550
whichFlashRed = 0; // must be 0 before the redraw, otherwise it will maintain color
537551
redrawDlgItem(idRedraw, true); // redraw the just the one that was flashed
552+
553+
// Remember the latest/current baloon tip handle
554+
hCurrentBalloonTip = [](HWND hEditControl) -> HWND {
555+
HWND hTooltip = FindWindowEx(NULL, NULL, L"tooltips_class32", NULL);
556+
557+
while (hTooltip)
558+
{
559+
HWND hParent = GetParent(hTooltip);
560+
if (hParent == hEditControl || hParent == GetParent(hEditControl))
561+
{
562+
return hTooltip;
563+
}
564+
hTooltip = FindWindowEx(NULL, hTooltip, L"tooltips_class32", NULL);
565+
}
566+
return NULL;
567+
}(GetDlgItem(_hSelf, idRedraw));
568+
}
569+
570+
if (wParam == IDC_COL_BALLONTIP_TIMER)
571+
{
572+
KillTimer(_hSelf, IDC_COL_BALLONTIP_TIMER);
573+
574+
SendMessage(GetDlgItem(_hSelf, idRedraw), EM_HIDEBALLOONTIP, 0, 0);
538575
}
539576

540577
break;
@@ -766,6 +803,8 @@ int ColumnEditorDlg::sendValidationErrorMessage(int whichFlashRed, int formatCho
766803
SendMessage(GetDlgItem(_hSelf, whichFlashRed), EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt);
767804

768805
SetTimer(_hSelf, IDT_COL_FLASH_TIMER, 250, NULL);
806+
SetTimer(_hSelf, IDC_COL_BALLONTIP_TIMER, 3500, NULL);
807+
769808
redrawDlgItem(whichFlashRed);
770809

771810
return whichFlashRed;

PowerEditor/src/ScintillaComponent/columnEditor.rc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
2525
CAPTION "Column / Multi-Selection Editor"
2626
FONT 8, L"MS Shell Dlg", 0, 0, 0x0
2727
BEGIN
28-
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,6,124,10
29-
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,68,204,10
28+
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,6,124,10
29+
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,68,204,10
3030

3131
GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46
3232
EDITTEXT IDC_COL_TEXT_EDIT,20,32,97,12,ES_AUTOHSCROLL
3333

34+
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,86,188,44,BS_CENTER
35+
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,99,50,10
36+
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,99,50,10
37+
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,114,50,10
38+
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,114,50,10
39+
COMBOBOX IDC_COL_HEXUC_COMBO,150,97,40,10,CBS_DROPDOWNLIST | WS_TABSTOP
40+
3441
GROUPBOX "",IDC_COL_NUM_GRP_STATIC,8,77,204,130
35-
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,89,76,8
36-
EDITTEXT IDC_COL_INITNUM_EDIT,90,87,38,12,ES_LEFT
37-
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,106,75,8
38-
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,104,38,12,ES_LEFT
39-
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,123,75,8
40-
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,121,38,12,ES_LEFT
41-
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,140,75,8
42-
COMBOBOX IDC_COL_LEADING_COMBO,90,138,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
43-
44-
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,155,188,44,BS_CENTER
45-
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,168,50,10
46-
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,168,50,10
47-
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,183,50,10
48-
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,183,50,10
49-
COMBOBOX IDC_COL_HEXUC_COMBO,150,166,40,10,CBS_DROPDOWNLIST | WS_TABSTOP
42+
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,140,76,8
43+
EDITTEXT IDC_COL_INITNUM_EDIT,90,138,38,12
44+
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,157,75,8
45+
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,155,38,12
46+
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,174,75,8
47+
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,172,38,12
48+
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,191,75,8
49+
COMBOBOX IDC_COL_LEADING_COMBO,90,189,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
5050

5151
DEFPUSHBUTTON "OK",IDOK,142,18,70,14
5252
PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14

PowerEditor/src/ScintillaComponent/columnEditor_rc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define IDC_COL_REPEATNUM_EDIT (IDD_COLUMNEDIT + 17)
3838
#define IDC_COL_LEADING_STATIC (IDD_COLUMNEDIT + 18)
3939
#define IDC_COL_LEADING_COMBO (IDD_COLUMNEDIT + 19)
40-
#define IDT_COL_FLASH_TIMER (IDD_COLUMNEDIT + 20)
41-
#define IDC_COL_HEXUC_COMBO (IDD_COLUMNEDIT + 21)
40+
#define IDC_COL_HEXUC_COMBO (IDD_COLUMNEDIT + 20)
41+
#define IDT_COL_FLASH_TIMER (IDD_COLUMNEDIT + 21)
42+
#define IDC_COL_BALLONTIP_TIMER (IDD_COLUMNEDIT + 22)
4243
#endif// COLUMNEDITOR_RC_H

0 commit comments

Comments
 (0)