Hello to all! Check out my TTreeViewEx derived code from TTreeView:
function TTreeViewEx.CustomDrawItem(Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage; var PaintImages: Boolean): Boolean; var NodeRect: TRect; procedure DrawSelection; begin if FSelectionBold then Canvas.Font.Style := Canvas.Font.Style + [fsBold]; if FFocused then Canvas.Brush.Color := GetShadowColor(clHighlight, 60) else Canvas.Brush.Color := GetShadowColor($F0F0F0, -10); end; begin Result := True; inherited CustomDrawItem(Node, State, Stage, PaintImages); if Result then begin if (Stage in [cdPrePaint]) then begin Canvas.Font.Color := clBlack; if FSelectionBold then Canvas.Font.Style := Canvas.Font.Style - [fsBold]; Canvas.Brush.Color := clWhite; if cdsHot in State then begin if Node Selected then Canvas.Brush.Color := ApproximateColor(clBtnHighlight, clHighlight, 256 / 9) else DrawSelection; end else if cdsSelected in State then DrawSelection; NodeRect := Node.DisplayRect(not RowSelect); if RowSelect then begin NodeRect.Right := BoundsRect.Right; NodeRect.Left := BoundsRect.Left; end; Canvas.FillRect(NodeRect); end; end; end;
Now how can you draw a frame around the selected as in the picture