Gord P 14 Posted May 17, 2023 I was unable to use styles to change the background color of a TreeView node, so I am trying an alternate route but once again have hit a road block. I found some code in Delphi and converted it (I think) to C++. void __fastcall TForm1::TreeView1CustomDrawItem(TCustomTreeView *Sender, TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw) { if(State.Contains(cdsSelected)) { Sender->Canvas->Brush->Color = clBlack; Sender->Canvas->Font->Color = clWhite; } } The problem is that it never fires true. When I set breakpoint at the "if" line, State shows up as "{ }" What am I doing wrong here? BTW, if I get rid of the "if" statement" so that it fires all the time, all the items show up as expected (white font on black background) except the selected node (which I don't know why). Share this post Link to post
PeaShooter_OMO 11 Posted May 18, 2023 (edited) I am no C++ expert but shouldn't the asterisks of the parameters be immediately following the types and not precede the parameter names? Edited May 18, 2023 by PeaShooter_OMO Share this post Link to post
Gord P 14 Posted May 18, 2023 Turns out you need to turn off theming for the treeview control. void __fastcall TForm1::FormCreate(TObject *Sender) { SetWindowTheme(TreeView1->Handle, L"", L""); } It allows you to control the color but unfortunately when you do so, you get old school buttons on the treeview. It is kind of ridiculous why you have to go through so many hoops and hurdles just to adjust a color to match a specific theme. It should be easily done through the Bitmap Style Designer so the developer can focus on other things. Share this post Link to post
Remy Lebeau 1436 Posted May 18, 2023 (edited) 13 hours ago, PeaShooter_OMO said: I am no C++ expert but shouldn't the asterisks of the parameters be immediately following the types and not precede the parameter names? Whitespace between tokens doesn't matter in C/C++. Thus, "Type* VarName" and "Type *VarName" and "Type * VarName" all mean the same thing. Edited May 18, 2023 by Remy Lebeau Share this post Link to post