Skip to content

Commit 32519b4

Browse files
committed
feat: Add support for dialog visibility events (#83)
1 parent 697a60a commit 32519b4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Explorer/Explorer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ extern "C" __declspec(dllexport) void setInfo(NppData notpadPlusData)
240240
optionDlg .init(g_hInst, g_nppData._nppHandle);
241241
helpDlg .init(g_hInst, g_nppData._nppHandle);
242242

243+
explorerDlg.VisibleChanged([](bool visible) {
244+
::SendMessage(g_nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[0]._cmdID, (LPARAM)visible);
245+
});
246+
favesDlg.VisibleChanged([](bool visible) {
247+
::SendMessage(g_nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[1]._cmdID, (LPARAM)visible);
248+
});
249+
243250
/* Subclassing for Notepad */
244251
wndProcNotepad = (WNDPROC)::SetWindowLongPtr(g_nppData._nppHandle, GWLP_WNDPROC, (LONG_PTR)SubWndProcNotepad);
245252
}

src/NppPlugin/DockingFeature/DockingDlgInterface.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <assert.h>
2424
#include <shlwapi.h>
2525
#include <string>
26+
#include <functional>
2627

2728
#include "StaticDialog.h"
2829
#include "../Notepad_plus_msgs.h"
@@ -70,6 +71,9 @@ class DockingDlgInterface : public StaticDialog
7071

7172
virtual void display(bool toShow = true) const {
7273
::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast<LPARAM>(_hSelf));
74+
if (_visibleChangedHandler) {
75+
_visibleChangedHandler(toShow);
76+
}
7377
}
7478

7579
bool isClosed() const {
@@ -84,13 +88,17 @@ class DockingDlgInterface : public StaticDialog
8488
return _moduleName.c_str();
8589
}
8690

91+
void VisibleChanged(std::function<void(bool)> visibleChangedHandler) {
92+
_visibleChangedHandler = visibleChangedHandler;
93+
}
8794
protected :
8895
int _dlgID = -1;
8996
bool _isFloating = true;
9097
int _iDockedPos = 0;
9198
std::wstring _moduleName;
9299
std::wstring _pluginName;
93100
bool _isClosed = false;
101+
std::function<void(bool)> _visibleChangedHandler;
94102

95103
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) {
96104
switch (message)
@@ -105,6 +113,9 @@ protected :
105113
{
106114
case DMN_CLOSE:
107115
{
116+
if (_visibleChangedHandler) {
117+
_visibleChangedHandler(false);
118+
}
108119
break;
109120
}
110121
case DMN_FLOAT:

0 commit comments

Comments
 (0)