mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 15:54:17 +02:00
Apply dark mode on treeview edit controls
- simplify code Fix #16418, clos #16419
This commit is contained in:
parent
1657dbbc53
commit
714eeafc45
@ -64,9 +64,28 @@ void TreeView::destroy()
|
|||||||
_hSelf = NULL;
|
_hSelf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT TreeView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
LRESULT TreeView::staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||||
{
|
{
|
||||||
if (Message == TVM_EXPAND)
|
auto treeViewData = reinterpret_cast<TreeView*>(dwRefData);
|
||||||
|
|
||||||
|
switch (Message)
|
||||||
|
{
|
||||||
|
case WM_NCDESTROY:
|
||||||
|
{
|
||||||
|
::RemoveWindowSubclass(hwnd, staticProc, uIdSubclass);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_CTLCOLOREDIT:
|
||||||
|
{
|
||||||
|
if (NppDarkMode::isEnabled())
|
||||||
|
{
|
||||||
|
return NppDarkMode::onCtlColorCtrl(reinterpret_cast<HDC>(wParam));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TVM_EXPAND:
|
||||||
{
|
{
|
||||||
if (wParam & (TVE_COLLAPSE | TVE_EXPAND))
|
if (wParam & (TVE_COLLAPSE | TVE_EXPAND))
|
||||||
{
|
{
|
||||||
@ -80,7 +99,7 @@ LRESULT TreeView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
tvItem.hItem = reinterpret_cast<HTREEITEM>(lParam);
|
tvItem.hItem = reinterpret_cast<HTREEITEM>(lParam);
|
||||||
tvItem.mask = TVIF_STATE | TVIF_HANDLE | TVIF_PARAM;
|
tvItem.mask = TVIF_STATE | TVIF_HANDLE | TVIF_PARAM;
|
||||||
tvItem.stateMask = TVIS_EXPANDEDONCE;
|
tvItem.stateMask = TVIS_EXPANDEDONCE;
|
||||||
TreeView_GetItem(_hSelf, &tvItem);
|
TreeView_GetItem(treeViewData->_hSelf, &tvItem);
|
||||||
// Check if a flag is set.
|
// Check if a flag is set.
|
||||||
if (tvItem.state & TVIS_EXPANDEDONCE)
|
if (tvItem.state & TVIS_EXPANDEDONCE)
|
||||||
{
|
{
|
||||||
@ -88,31 +107,20 @@ LRESULT TreeView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
// so that it can change icon, etc.
|
// so that it can change icon, etc.
|
||||||
NMTREEVIEW nmtv{};
|
NMTREEVIEW nmtv{};
|
||||||
nmtv.hdr.code = TVN_ITEMEXPANDED;
|
nmtv.hdr.code = TVN_ITEMEXPANDED;
|
||||||
nmtv.hdr.hwndFrom = _hSelf;
|
nmtv.hdr.hwndFrom = treeViewData->_hSelf;
|
||||||
nmtv.hdr.idFrom = 0;
|
nmtv.hdr.idFrom = 0;
|
||||||
nmtv.action = (wParam & TVE_COLLAPSE) ? TVE_COLLAPSE : TVE_EXPAND;
|
nmtv.action = (wParam & TVE_COLLAPSE) ? TVE_COLLAPSE : TVE_EXPAND;
|
||||||
nmtv.itemNew.hItem = tvItem.hItem;
|
nmtv.itemNew.hItem = tvItem.hItem;
|
||||||
::SendMessage(_hParent, WM_NOTIFY, nmtv.hdr.idFrom, reinterpret_cast<LPARAM>(&nmtv));
|
::SendMessage(treeViewData->_hParent, WM_NOTIFY, nmtv.hdr.idFrom, reinterpret_cast<LPARAM>(&nmtv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ::DefSubclassProc(hwnd, Message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT TreeView::staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
|
||||||
{
|
|
||||||
switch (Message)
|
|
||||||
{
|
|
||||||
case WM_NCDESTROY:
|
|
||||||
{
|
|
||||||
::RemoveWindowSubclass(hwnd, staticProc, uIdSubclass);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return reinterpret_cast<TreeView*>(dwRefData)->runProc(hwnd, Message, wParam, lParam);
|
return ::DefSubclassProc(hwnd, Message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeView::makeLabelEditable(bool toBeEnabled)
|
void TreeView::makeLabelEditable(bool toBeEnabled)
|
||||||
|
@ -123,7 +123,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
HIMAGELIST _hImaLst = nullptr;
|
HIMAGELIST _hImaLst = nullptr;
|
||||||
NppDarkMode::TreeViewStyle _tvStyleType = NppDarkMode::TreeViewStyle::classic;
|
NppDarkMode::TreeViewStyle _tvStyleType = NppDarkMode::TreeViewStyle::classic;
|
||||||
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
static LRESULT CALLBACK staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
|
static LRESULT CALLBACK staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user