Thema: Delphi TreeView im Vista Style

Einzelnen Beitrag anzeigen

Benutzerbild von Cylence
Cylence

Registriert seit: 2. Sep 2004
Ort: Allgäu
246 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: TreeView im Vista Style

  Alt 22. Jul 2009, 10:11
Hi,

das geht nur wenn du auch ein XPManifest im Projekt hast.
Ansonsten bau dir selber ein Vistastyle Treeview. Mit ein paar Dreiecksbildern, wie in vista und dann on AdvancedCustomDrawItem über die alten Plus NodeButtons zeichnen.

So hab ichs gemacht:

Delphi-Quellcode:
procedure TForm1.TreeView1AdvancedCustomDrawItem(Sender: TCustomTreeView;
   Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
   var PaintImages, DefaultDraw: Boolean);
var
  NodeRect : TRect;
begin
 DefaultDraw := True;
 if Stage = cdPostPaint then begin
  if Node.IsVisible then begin
   NodeRect := Node.DisplayRect(True);
   if Node.HasChildren then begin
     if Node.Expanded then begin
        if (cdsHot in state) and (not (cdsFocused in state)) then (Sender as TTreeview).Canvas.Draw(NodeRect.Left+Treeview1.Indent - 53, node.DisplayRect(False).TopLeft.Y+1, Image2.Picture.Bitmap)
         else if (cdsFocused in state) then (Sender as TTreeview).Canvas.Draw(NodeRect.Left+Treeview1.Indent - 54, node.DisplayRect(False).Top+2, Image5.Picture.Bitmap)
          else (Sender as TTreeview).Canvas.Draw(NodeRect.Left+Treeview1.Indent - 54, node.DisplayRect(False).Top+2, Image3.Picture.Bitmap);
     end
     else begin
       if (cdsHot in state) and (not (cdsFocused in state)) then (Sender as TTreeview).Canvas.Draw(NodeRect.Left +Treeview1.Indent - 54, node.DisplayRect(False).Top+1, Image4.Picture.Bitmap)
       else if (cdsFocused in state) then (Sender as TTreeview).Canvas.Draw(NodeRect.Left +Treeview1.Indent - 53, node.DisplayRect(False).Top+1, Image6.Picture.Bitmap)
         else (Sender as TTreeview).Canvas.Draw(NodeRect.Left +Treeview1.Indent - 53, node.DisplayRect(False).Top+1, Image1.Picture.Bitmap);

     end;
   end
  end;
 end;
end;
Tom
Just DO it
  Mit Zitat antworten Zitat