I am porting a C++Builder 2009 project to C++Builder 11.
For some strange reason overlay icons are painted stretched in a custom made object that inherits from TTreeView
.
It obviously works properly when built with C++Builder 2009.
I don't do any custom painting in it.
When I create a new project, add a TTreeView and TImageList at design time, don't change any default settings, just add two icons and two items, per below image and code, everything appears to work fine:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ImageList1->Overlay(0, 0) ;
TreeView1->Items->Item[1]->OverlayIndex = 0 ;
}
When I create my own TTreeView
descendant and do the same, the overlay icon is stretched out (on the right):
//---------------------------------------------------------------------------
class MyTreeView : public TTreeView
{
public :
MyTreeView(TPanel *TreeViewLocation)
: TTreeView(TreeViewLocation)
{
Parent = TreeViewLocation ;
Align = alClient ;
}
virtual __fastcall ~MyTreeView() {}
};
//---------------------------------------------------------------------------
MyTreeView *TreeView2 ;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ImageList1->Overlay(0, 0) ;
TreeView1->Items->Item[1]->OverlayIndex = 0 ;
TreeView2 = new MyTreeView(Panel1) ;
TreeView2->Items->Add(NULL, L"Item1")->ImageIndex = 1 ;
TreeView2->Items->Add(NULL, L"Item2")->ImageIndex = 1 ;
TreeView2->Images = ImageList1 ;
TreeView2->Items->Item[1]->OverlayIndex = 0 ;
}
//---------------------------------------------------------------------------
Using the same icon and ImageList in the ported project:
It's as if TTreeView
asks TImageList
to paint the overlay icon with wrong Canvas dimensions ?
FYI, here's the result from the exact same code built with C++Builder 2009:
EDIT
The plot thickens
I just tested this on a range of OS (in a VM VirtualBox) and I did not see the problem on older OS (XP, Vista, W7, W8 and even W10 (older not up to date version)). However, I do see it on my W10 development system (up to date) I also tested it on W11 in a VirtualBox and there the the problem also exists. So it's not just my system, it's related to latest Windows updates. Super annoying ..