读书人

CDirectoryOutline控件的帮助在哪?该

发布时间: 2012-03-19 22:03:05 作者: rapoo

CDirectoryOutline控件的帮助在哪?
我找半天没找着Sample控件组里CDirectoryOutline的帮助资料,不知道都有些什么properties methods

[解决办法]
这是一个示例控件,Delphi 的 Samples 文件夹下有它的源码的,你可以看看:


unit DirOutln;

{ Directory outline component }

interface

uses Classes, Forms, Controls, Outline, SysUtils, Graphics, Grids, StdCtrls,
Menus;

type
TTextCase = (tcLowerCase, tcUpperCase, tcAsIs);
TCaseFunction = function(const AString: string): string;

TDirectoryOutline = class(TCustomOutline)
private
FDrive: Char;
FDirectory: TFileName;
FOnChange: TNotifyEvent;
FTextCase: TTextCase;
FCaseFunction: TCaseFunction;
protected
procedure SetDrive(NewDrive: Char);
procedure SetDirectory(const NewDirectory: TFileName);
procedure SetTextCase(NewTextCase: TTextCase);
procedure AssignCaseProc;
procedure BuildOneLevel(RootItem: Longint); virtual;
procedure BuildTree; virtual;
procedure BuildSubTree(RootItem: Longint); virtual;
procedure Change; virtual;
procedure Click; override;
procedure CreateWnd; override;
procedure Expand(Index: Longint); override;
function FindIndex(RootNode: TOutLineNode; SearchName: TFileName): Longint;
procedure Loaded; override;
procedure WalkTree(const Dest: string);
public
constructor Create(AOwner: TComponent); override;
function ForceCase(const AString: string): string;
property Drive: Char read FDrive write SetDrive;
property Directory: TFileName read FDirectory write SetDirectory;
property Lines stored False;
published
property Align;
property Anchors;
property BorderStyle;
property Color;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property ItemHeight;
property Options default [ooStretchBitmaps, ooDrawFocusRect];
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PictureClosed;
property PictureLeaf;
property PictureOpen;
property PopupMenu;
property ScrollBars;
property Style;
property ShowHint;
property TabOrder;
property TabStop;
property TextCase: TTextCase read FTextCase write SetTextCase default tcLowerCase;
property Visible;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnClick;
property OnCollapse;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDrawItem;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnExpand;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;

function SameLetter(Letter1, Letter2: Char): Boolean;


implementation

const
InvalidIndex = -1;

constructor TDirectoryOutline.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
PictureLeaf := PictureClosed;
Options := [ooDrawFocusRect];
TextCase := tcLowerCase;
AssignCaseProc;
end;

procedure TDirectoryOutline.AssignCaseProc;
begin
case TextCase of


tcLowerCase: FCaseFunction := AnsiLowerCaseFileName;
tcUpperCase: FCaseFunction := AnsiUpperCaseFileName;
else FCaseFunction := nil;
end;
end;

type
PNodeInfo = ^TNodeInfo;
TNodeInfo = record
RootName: TFileName;
SearchRec: TSearchRec;
DosError: Integer;
RootNode: TOutlineNode;
TempChild, NewChild: Longint;
end;

function TDirectoryOutline.FindIndex(RootNode: TOutLineNode;
SearchName: TFileName): Longint;
var
FirstChild, LastChild, TempChild: Longint;
begin
FirstChild := RootNode.GetFirstChild;
if (FirstChild = InvalidIndex) or
(SearchName <= Items[FirstChild].Text) then
FindIndex := FirstChild
else
begin
LastChild := RootNode.GetLastChild;
if (SearchName > = Items[LastChild].Text) then
FindIndex := InvalidIndex
else
begin
repeat
TempChild := (FirstChild + LastChild) div 2; { binary search }
if (TempChild = FirstChild) then Inc(TempChild);
if (SearchName > Items[TempChild].Text) then
FirstChild := TempChild
else LastChild := TempChild
until FirstChild > = (LastChild - 1);
FindIndex := LastChild
end
end
end;

读书人网 >.NET

热点推荐