void __fastcall MTreeView::MTreeView_DrawItem( TCustomTreeView *Sender, TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw) { TTreeView * tv = (TTreeView * )Sender; TRect r; TTreeNode * node = (TTreeNode *) Node; r = node->DisplayRect(false); tv->Canvas->Brush->Style = bsSolid; tv->Canvas->Brush->Color = 0xf3f3f2; tv->Canvas->CopyMode=cmMergeCopy ; tv->Canvas->FillRect(r); //这里的背景色怎么也修改不了,估计是cb的漏洞 if(tv->HideSelection==true) tv->HideSelection=false; ////////////////////////////////////////////////////////////////////////////// //2021-01-26 修改,把画布的字体设小,用来使得间隔增大 int f; /* f = tv->Font->Height; if(f<0) f++; else f--; tv->Canvas->Font->Height=f; */ f = tv->Font->Size - 1; if(f>=8) tv->Canvas->Font->Size=f; // tv->Canvas->Brush->Color = 0xf2f2f3; ////////////////////////////////////////////////////////////////////////////// //if(State.Contains(cdsSelected)) if (State.Contains(cdsSelected) ) { //TreeView1->Canvas->Font->Assign(SelectedFontDialog->Font); tv->Canvas->Brush->Color = clRed; tv->Canvas->Font->Color = clBlue; tv->Canvas->Brush->Style = bsSolid; DefaultDraw=true; } if(Node==this->Selected ) { //DefaultDraw=false; tv->Canvas->Brush->Color = clWhite; tv->Canvas->Font->Color = clBlue; tv->Canvas->Brush->Style = bsSolid; DefaultDraw=true; /* if(tv->Focused()) tv->Canvas->Font->Color = clBlue; else tv->Canvas->Font->Color = clBlue; //0xa0a0ff; */ }; /* TTreeView * tv = (TTreeView * )Sender; if(tv->HideSelection==true) tv->HideSelection=false; if(!State.Contains(cdsHot )) if(State.Contains(cdsSelected)) { if(tv->Focused()) tv->Canvas->Font->Color = clWhite; else tv->Canvas->Font->Color = 0xf1f1f1; }; */ } |