Skip to content

Commit 01252b3

Browse files
committed
Initial
1 parent 3f3e5a4 commit 01252b3

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

bins/VExtension/VExtension.dll

4 KB
Binary file not shown.

dllmain.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,29 @@ enum INL_Hooking
5151

5252
vu::INLHooking INLHooking[INL_Hooking::Count];
5353

54+
// UINT CWnd::GetSafeHwnd(CWnd* pWnd)
55+
56+
HWND CWnd_GetSafeHwnd(CWnd* pWnd)
57+
{
58+
if (pWnd == nullptr)
59+
{
60+
return nullptr;
61+
}
62+
63+
const ULONG_PTR Offset_MFC_CWnd_m_hWnd = 0x8;
64+
return HWND(*(QWORD*)(pWnd + Offset_MFC_CWnd_m_hWnd));
65+
}
66+
5467
// UINT CWnd::GetDlgCtrlID(CWnd* pWnd)
5568

5669
UINT CWnd_GetDlgCtrlID(CWnd* pWnd)
5770
{
58-
const ULONG_PTR Offset_MFC_CWnd_m_hWnd = 0x8;
59-
HWND hWnd = HWND(*(QWORD*)(pWnd + Offset_MFC_CWnd_m_hWnd));
71+
HWND hWnd = CWnd_GetSafeHwnd(pWnd);
72+
if (hWnd == nullptr)
73+
{
74+
return -1;
75+
}
76+
6077
return GetDlgCtrlID(hWnd);
6178
}
6279

@@ -72,6 +89,12 @@ void CGridCtrl_ExpandLastColumn_Ex(CWnd* pWnd)
7289
return;
7390
}
7491

92+
auto hWnd = CWnd_GetSafeHwnd(pWnd);
93+
if (!IsWindow(hWnd))
94+
{
95+
return;
96+
}
97+
7598
const auto ID = CWnd_GetDlgCtrlID(pWnd);
7699
if (ID != ImportExportDirectory_Below_Grid_ID)
77100
{
@@ -99,7 +122,10 @@ void __fastcall CGridCtrl_OnSize_hook(CWnd* pWnd, unsigned int nType, unsigned i
99122
bool auto_expand_last_column = json_get_option(g_prefs, "auto_expand_name_column_width", true);
100123
if (auto_expand_last_column)
101124
{
102-
CGridCtrl_ExpandLastColumn_Ex(pWnd);
125+
vu::Debouncer::instance().debounce(ImportExportDirectory_Below_Grid_ID, 100, [&]() // 100ms
126+
{
127+
CGridCtrl_ExpandLastColumn_Ex(ImportExportDirectory_Below_Grid);
128+
});
103129
}
104130
}
105131
}

0 commit comments

Comments
 (0)