Skip to content

Commit 7530cdf

Browse files
committed
2.0.9
Internal rearrange
1 parent 004fbd4 commit 7530cdf

5 files changed

Lines changed: 191 additions & 90 deletions

File tree

Source/FILELIST.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ winobjex64\excepth.h
2727
* Extras menu handler *
2828
winobjex64\extras\extras.c
2929
winobjex64\extras\extras.h
30-
winobjex64\extras\extrasHandlers.h
3130

3231
* Windows 7/8/8.1 missing API support *
3332
winobjex64\extapi.c

Source/Shared/treelist/treelist.c

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*
55
* TITLE: TREELIST.C
66
*
7-
* VERSION: 1.35
7+
* VERSION: 1.36
88
*
9-
* DATE: 10 Jun 2022
9+
* DATE: 20 Sep 2022
1010
*
1111
* TreeList control.
1212
*
@@ -474,6 +474,7 @@ LRESULT CALLBACK TreeListHookProc(
474474
PTL_SUBITEMS subitems;
475475
TOOLINFO tool;
476476
HDC dc;
477+
HGDIOBJ prevFont;
477478
ULONG_PTR subid;
478479

479480
switch (uMsg) {
@@ -550,8 +551,9 @@ LRESULT CALLBACK TreeListHookProc(
550551

551552
/*fake DrawText for calculating bounding rectangle*/
552553
dc = GetDC(hwnd);
553-
SelectObject(dc, (HGDIOBJ)SendMessage(hwnd, WM_GETFONT, 0, 0));
554+
prevFont = SelectObject(dc, (HGDIOBJ)SendMessage(hwnd, WM_GETFONT, 0, 0));
554555
DrawText(dc, subitems->Text[subid - 1], -1, &rc, DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);
556+
SelectObject(dc, prevFont);
555557
ReleaseDC(hwnd, dc);
556558

557559
if (rc.right < hr.right - 2) // no overflow
@@ -583,20 +585,30 @@ PTL_SUBITEMS PackSubitems(HANDLE hHeap, IN PTL_SUBITEMS Subitems)
583585
ULONG i;
584586
LPTSTR strings;
585587

588+
if (Subitems == NULL)
589+
return NULL;
590+
586591
/*
587592
size of header + variable length array .Text[1] part
588593
*/
589-
header_size = sizeof(TL_SUBITEMS) + (Subitems->Count * sizeof(LPTSTR));
594+
header_size = sizeof(TL_SUBITEMS);
595+
if (Subitems->Count > 1) {
596+
header_size += (Subitems->Count - 1) * sizeof(LPTSTR);
597+
}
590598

591599
/*
592600
total size of all strings including terminating zeros
593601
*/
594602

595603
strings_size = 0;
596-
for (i = 0; i < Subitems->Count; i++)
597-
strings_size += (_strlen(Subitems->Text[i]) + 1) * sizeof(TCHAR);
598-
599-
strings_size += (_strlen(Subitems->CustomTooltip) + 1) * sizeof(TCHAR);
604+
for (i = 0; i < Subitems->Count; i++) {
605+
if (Subitems->Text[i])
606+
strings_size += (_strlen(Subitems->Text[i]) + 1) * sizeof(TCHAR);
607+
}
608+
609+
if (Subitems->CustomTooltip != NULL) {
610+
strings_size += (_strlen(Subitems->CustomTooltip) + 1) * sizeof(TCHAR);
611+
}
600612

601613
newsubitems = (PTL_SUBITEMS)HeapAlloc(hHeap, 0, header_size + strings_size);
602614
if (!newsubitems)
@@ -606,16 +618,21 @@ PTL_SUBITEMS PackSubitems(HANDLE hHeap, IN PTL_SUBITEMS Subitems)
606618
*newsubitems = *Subitems;
607619

608620
for (i = 0; i < Subitems->Count; i++) {
609-
newsubitems->Text[i] = strings;
610-
_strcpy(strings, Subitems->Text[i]);
611-
strings += _strlen(Subitems->Text[i]) + 1;
621+
if (Subitems->Text[i]) {
622+
newsubitems->Text[i] = strings;
623+
_strcpy(strings, Subitems->Text[i]);
624+
strings += _strlen(Subitems->Text[i]) + 1;
625+
}
612626
}
613627

614628
if (Subitems->CustomTooltip != NULL)
615629
{
616630
newsubitems->CustomTooltip = strings;
617631
_strcpy(strings, Subitems->CustomTooltip);
618632
}
633+
else {
634+
newsubitems->CustomTooltip = NULL;
635+
}
619636

620637
return newsubitems;
621638
}
@@ -941,6 +958,10 @@ LRESULT CALLBACK TreeListWindowProc(
941958
break;
942959

943960
case WM_DESTROY:
961+
if (tl_theme) {
962+
CloseThemeData(tl_theme);
963+
tl_theme = NULL;
964+
}
944965
DestroyWindow((HWND)GetWindowLongPtr(hwnd, TL_TOOLTIPS_SLOT));
945966
HeapDestroy((HANDLE)GetWindowLongPtr(hwnd, TL_HEAP_SLOT));
946967
}

0 commit comments

Comments
 (0)