home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
COMCTRLS.INT
< prev
next >
Wrap
Text File
|
1997-02-28
|
39KB
|
1,168 lines
{*******************************************************}
{ }
{ Delphi Visual Component Library }
{ }
{ Copyright (c) 1996-1997 Borland International }
{ }
{*******************************************************}
unit ComCtrls; // $Revision: 1.15 $
{$R-}
interface
uses Messages, Windows, SysUtils, CommCtrl, Classes, Controls, Forms,
Menus, Graphics, StdCtrls, RichEdit;
type
TTabChangingEvent = procedure(Sender: TObject;
var AllowChange: Boolean) of object;
TCustomTabControl = class(TWinControl)
protected
procedure AlignControls(AControl: TControl; var Rect: TRect); override;
function CanChange: Boolean; dynamic;
procedure Change; dynamic;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
property DisplayRect: TRect;
property MultiLine: Boolean default False;
property TabHeight: Smallint default 0;
property TabIndex: Integer default -1;
property Tabs: TStrings;
property TabWidth: Smallint default 0;
property OnChange: TNotifyEvent;
property OnChanging: TTabChangingEvent;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property TabStop default True;
end;
TTabControl = class(TCustomTabControl)
public
property DisplayRect;
published
property Align;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property MultiLine;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabHeight;
property TabIndex;
property TabOrder;
property Tabs;
property TabStop;
property TabWidth;
property Visible;
property OnChange;
property OnChanging;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
end;
TPageControl = class;
TTabSheet = class(TWinControl)
protected
procedure ReadState(Reader: TReader); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property PageControl: TPageControl;
property TabIndex: Integer;
published
property Caption;
property Enabled;
property Font;
property Height stored False;
property Left stored False;
property PageIndex: Integer;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabVisible: Boolean default True;
property Top stored False;
property Visible stored False;
property Width stored False;
property OnDragDrop;
property OnDragOver;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
TPageControl = class(TCustomTabControl)
protected
procedure Change; override;
procedure GetChildren(Proc: TGetChildProc); override;
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
procedure ShowControl(AControl: TControl); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function FindNextPage(CurPage: TTabSheet;
GoForward, CheckTabVisible: Boolean): TTabSheet;
procedure SelectNextPage(GoForward: Boolean);
property PageCount: Integer;
property Pages[Index: Integer]: TTabSheet;
published
property ActivePage: TTabSheet;
property Align;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property MultiLine;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabHeight;
property TabOrder;
property TabStop;
property TabWidth;
property Visible;
property OnChange;
property OnChanging;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
end;
TStatusBar = class;
TStatusPanelStyle = (psText, psOwnerDraw);
TStatusPanelBevel = (pbNone, pbLowered, pbRaised);
TStatusPanel = class(TCollectionItem)
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
published
property Alignment: TAlignment default taLeftJustify;
property Bevel: TStatusPanelBevel default pbLowered;
property Style: TStatusPanelStyle default psText;
property Text: string;
property Width: Integer;
end;
TStatusPanels = class(TCollection)
protected
procedure Update(Item: TCollectionItem); override;
public
constructor Create(StatusBar: TStatusBar);
function Add: TStatusPanel;
property Items[Index: Integer]: TStatusPanel; default;
end;
TDrawPanelEvent = procedure(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect) of object;
TStatusBar = class(TWinControl)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DrawPanel(Panel: TStatusPanel; const Rect: TRect); dynamic;
procedure Resize; dynamic;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas: TCanvas;
published
property Align default alBottom;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property Panels: TStatusPanels;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property SimplePanel: Boolean;
property SimpleText: string;
property SizeGrip: Boolean default True;
property Visible;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnDrawPanel: TDrawPanelEvent;
property OnResize: TNotifyEvent;
property OnStartDrag;
end;
THeaderControl = class;
THeaderSectionStyle = (hsText, hsOwnerDraw);
THeaderSection = class(TCollectionItem)
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
property Left: Integer;
property Right: Integer;
published
property Alignment: TAlignment default taLeftJustify;
property AllowClick: Boolean default True;
property MaxWidth: Integer default 10000;
property MinWidth: Integer default 0;
property Style: THeaderSectionStyle default hsText;
property Text: string;
property Width: Integer;
end;
THeaderSections = class(TCollection)
protected
procedure Update(Item: TCollectionItem); override;
public
constructor Create(HeaderControl: THeaderControl);
function Add: THeaderSection;
property Items[Index: Integer]: THeaderSection; default;
end;
TSectionTrackState = (tsTrackBegin, tsTrackMove, tsTrackEnd);
TDrawSectionEvent = procedure(HeaderControl: THeaderControl;
Section: THeaderSection; const Rect: TRect; Pressed: Boolean) of object;
TSectionNotifyEvent = procedure(HeaderControl: THeaderControl;
Section: THeaderSection) of object;
TSectionTrackEvent = procedure(HeaderControl: THeaderControl;
Section: THeaderSection; Width: Integer;
State: TSectionTrackState) of object;
THeaderControl = class(TWinControl)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DrawSection(Section: THeaderSection; const Rect: TRect;
Pressed: Boolean); dynamic;
procedure Resize; dynamic;
procedure SectionClick(Section: THeaderSection); dynamic;
procedure SectionResize(Section: THeaderSection); dynamic;
procedure SectionTrack(Section: THeaderSection; Width: Integer;
State: TSectionTrackState); dynamic;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas: TCanvas;
published
property Align default alTop;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property Sections: THeaderSections;
property ShowHint;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property Visible;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnDrawSection: TDrawSectionEvent;
property OnResize: TNotifyEvent;
property OnSectionClick: TSectionNotifyEvent;
property OnSectionResize: TSectionNotifyEvent;
property OnSectionTrack: TSectionTrackEvent;
property OnStartDrag;
end;
{ TTreeNode }
TCustomTreeView = class;
TTreeNodes = class;
TNodeState = (nsCut, nsDropHilited, nsFocused, nsSelected, nsExpanded);
TNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);
TAddMode = (taAddFirst, taAdd, taInsert);
PNodeInfo = ^TNodeInfo;
TNodeInfo = packed record
ImageIndex: Integer;
SelectedIndex: Integer;
StateIndex: Integer;
OverlayIndex: Integer;
Data: Pointer;
Count: Integer;
Text: string[255];
end;
TTreeNode = class(TPersistent)
public
constructor Create(AOwner: TTreeNodes);
destructor Destroy; override;
function AlphaSort: Boolean;
procedure Assign(Source: TPersistent); override;
procedure Collapse(Recurse: Boolean);
function CustomSort(SortProc: TTVCompare; Data: Longint): Boolean;
procedure Delete;
procedure DeleteChildren;
function DisplayRect(TextOnly: Boolean): TRect;
function EditText: Boolean;
procedure EndEdit(Cancel: Boolean);
procedure Expand(Recurse: Boolean);
function getFirstChild: TTreeNode;
function GetHandle: HWND;
function GetLastChild: TTreeNode;
function GetNext: TTreeNode;
function GetNextChild(Value: TTreeNode): TTreeNode;
function getNextSibling: TTreeNode;
function GetNextVisible: TTreeNode;
function GetPrev: TTreeNode;
function GetPrevChild(Value: TTreeNode): TTreeNode;
function getPrevSibling: TTreeNode;
function GetPrevVisible: TTreeNode;
function HasAsParent(Value: TTreeNode): Boolean;
function IndexOf(Value: TTreeNode): Integer;
procedure MakeVisible;
procedure MoveTo(Destination: TTreeNode; Mode: TNodeAttachMode);
property AbsoluteIndex: Integer;
property Count: Integer;
property Cut: Boolean;
property Data: Pointer;
property Deleting: Boolean;
property Focused: Boolean;
property DropTarget: Boolean;
property Selected: Boolean;
property Expanded: Boolean;
property Handle: HWND;
property HasChildren: Boolean;
property ImageIndex: Integer;
property Index: Integer;
property IsVisible: Boolean;
property Item[Index: Integer]: TTreeNode; default;
property ItemId: HTreeItem;
property Level: Integer;
property OverlayIndex: Integer;
property Owner: TTreeNodes;
property Parent: TTreeNode;
property SelectedIndex: Integer;
property StateIndex: Integer;
property Text: string;
property TreeView: TCustomTreeView;
end;
{ TTreeNodes }
TTreeNodes = class(TPersistent)
protected
function AddItem(Parent, Target: HTreeItem; const Item: TTVItem;
AddMode: TAddMode): HTreeItem;
function InternalAddObject(Node: TTreeNode; const S: string;
Ptr: Pointer; AddMode: TAddMode): TTreeNode;
procedure DefineProperties(Filer: TFiler); override;
function CreateItem(Node: TTreeNode): TTVItem;
function GetCount: Integer;
procedure SetItem(Index: Integer; Value: TTreeNode);
procedure SetUpdateState(Updating: Boolean);
public
constructor Create(AOwner: TCustomTreeView);
destructor Destroy; override;
function AddChildFirst(Node: TTreeNode; const S: string): TTreeNode;
function AddChild(Node: TTreeNode; const S: string): TTreeNode;
function AddChildObjectFirst(Node: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
function AddChildObject(Node: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
function AddFirst(Node: TTreeNode; const S: string): TTreeNode;
function Add(Node: TTreeNode; const S: string): TTreeNode;
function AddObjectFirst(Node: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
function AddObject(Node: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
procedure Assign(Source: TPersistent); override;
procedure BeginUpdate;
procedure Clear;
procedure Delete(Node: TTreeNode);
procedure EndUpdate;
function GetFirstNode: TTreeNode;
function GetNode(ItemId: HTreeItem): TTreeNode;
function Insert(Node: TTreeNode; const S: string): TTreeNode;
function InsertObject(Node: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
property Count: Integer;
property Handle: HWND;
property Item[Index: Integer]: TTreeNode; default;
property Owner: TCustomTreeView;
end;
{ TCustomTreeView }
THitTest = (htAbove, htBelow, htNowhere, htOnItem, htOnButton,
htOnIcon, htOnIndent, htOnLabel, htOnRight,
htOnStateIcon, htToLeft, htToRight);
THitTests = set of THitTest;
ETreeViewError = class(Exception);
TTVChangingEvent = procedure(Sender: TObject; Node: TTreeNode;
var AllowChange: Boolean) of object;
TTVChangedEvent = procedure(Sender: TObject; Node: TTreeNode) of object;
TTVEditingEvent = procedure(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean) of object;
TTVEditedEvent = procedure(Sender: TObject; Node: TTreeNode; var S: string) of object;
TTVExpandingEvent = procedure(Sender: TObject; Node: TTreeNode;
var AllowExpansion: Boolean) of object;
TTVCollapsingEvent = procedure(Sender: TObject; Node: TTreeNode;
var AllowCollapse: Boolean) of object;
TTVExpandedEvent = procedure(Sender: TObject; Node: TTreeNode) of object;
TTVCompareEvent = procedure(Sender: TObject; Node1, Node2: TTreeNode;
Data: Integer; var Compare: Integer) of object;
TSortType = (stNone, stData, stText, stBoth);
TCustomTreeView = class(TWinControl)
protected
function CanEdit(Node: TTreeNode): Boolean; dynamic;
function CanChange(Node: TTreeNode): Boolean; dynamic;
function CanCollapse(Node: TTreeNode): Boolean; dynamic;
function CanExpand(Node: TTreeNode): Boolean; dynamic;
procedure Change(Node: TTreeNode); dynamic;
procedure Collapse(Node: TTreeNode); dynamic;
function CreateNode: TTreeNode; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
procedure DoEndDrag(Target: TObject; X, Y: Integer); dynamic;
procedure DoStartDrag(var DragObject: TDragObject); override;
procedure Edit(const Item: TTVItem); dynamic;
procedure Expand(Node: TTreeNode); dynamic;
function GetDragImages: TCustomImageList; override;
procedure Loaded; override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure SetDragMode(Value: TDragMode); override;
procedure WndProc(var Message: TMessage); override;
property OnEditing: TTVEditingEvent;
property OnEdited: TTVEditedEvent;
property OnExpanding: TTVExpandingEvent;
property OnExpanded: TTVExpandedEvent;
property OnCollapsing: TTVCollapsingEvent;
property OnCollapsed: TTVExpandedEvent;
property OnChanging: TTVChangingEvent;
property OnChange: TTVChangedEvent;
property OnCompare: TTVCompareEvent;
property OnDeletion: TTVExpandedEvent;
property OnGetImageIndex: TTVExpandedEvent;
property OnGetSelectedIndex: TTVExpandedEvent;
property ShowButtons: Boolean default True;
property BorderStyle: TBorderStyle default bsSingle;
property ShowLines: Boolean default True;
property ShowRoot: Boolean default True;
property ReadOnly: Boolean default False;
property Indent: Integer;
property Items: TTreeNodes;
property SortType: TSortType default stNone;
property HideSelection: Boolean default True;
property Images: TImageList;
property StateImages: TImageList;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function AlphaSort: Boolean;
function CustomSort(SortProc: TTVCompare; Data: Longint): Boolean;
procedure FullCollapse;
procedure FullExpand;
function GetHitTestInfoAt(X, Y: Integer): THitTests;
function GetNodeAt(X, Y: Integer): TTreeNode;
function IsEditing: Boolean;
procedure LoadFromFile(const FileName: string);
procedure LoadFromStream(Stream: TStream);
procedure SaveToFile(const FileName: string);
procedure SaveToStream(Stream: TStream);
property DropTarget: TTreeNode;
property Selected: TTreeNode;
property TopItem: TTreeNode;
end;
TTreeView = class(TCustomTreeView)
published
property ShowButtons;
property BorderStyle;
property DragCursor;
property ShowLines;
property ShowRoot;
property ReadOnly;
property DragMode;
property HideSelection;
property Indent;
property Items;
property OnEditing;
property OnEdited;
property OnExpanding;
property OnExpanded;
property OnCollapsing;
property OnCompare;
property OnCollapsed;
property OnChanging;
property OnChange;
property OnDeletion;
property OnGetImageIndex;
property OnGetSelectedIndex;
property Align;
property Enabled;
property Font;
property Color;
property ParentColor;
property ParentCtl3D;
property Ctl3D;
property SortType;
property TabOrder;
property TabStop default True;
property Visible;
property OnClick;
property OnEnter;
property OnExit;
property OnDragDrop;
property OnDragOver;
property OnStartDrag;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnDblClick;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property PopupMenu;
property ParentFont;
property ParentShowHint;
property ShowHint;
property Images;
property StateImages;
end;
{ TTrackBar }
TTrackBarOrientation = (trHorizontal, trVertical);
TTickMark = (tmBottomRight, tmTopLeft, tmBoth);
TTickStyle = (tsNone, tsAuto, tsManual);
TTrackBar = class(TWinControl)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
public
constructor Create(AOwner: TComponent); override;
procedure SetTick(Value: Integer);
published
property Ctl3D;
property DragCursor;
property DragMode;
property Enabled;
property LineSize: Integer default 1;
property Max: Integer default 10;
property Min: Integer default 0;
property Orientation: TTrackBarOrientation;
property ParentCtl3D;
property ParentShowHint;
property PageSize: Integer default 2;
property PopupMenu;
property Frequency: Integer;
property Position: Integer;
property SelEnd: Integer;
property SelStart: Integer;
property ShowHint;
property TabOrder;
property TabStop default True;
property TickMarks: TTickMark;
property TickStyle: TTickStyle;
property Visible;
property OnChange: TNotifyEvent;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnStartDrag;
end;
{ TProgressBar }
TProgressRange = 0..65535; // max & position limitation of Progess Bar
TProgressBar = class(TWinControl)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
public
constructor Create(AOwner: TComponent); override;
procedure StepIt;
procedure StepBy(Delta: TProgressRange);
published
property Align;
property Enabled;
property Hint;
property Min: TProgressRange;
property Max: TProgressRange;
property ParentShowHint;
property PopupMenu;
property Position: TProgressRange default 0;
property Step: TProgressRange default 10;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
end;
{ TTextAttributes }
TCustomRichEdit = class;
TAttributeType = (atSelected, atDefaultText);
TConsistentAttribute = (caBold, caColor, caFace, caItalic,
caSize, caStrikeOut, caUnderline, caProtected);
TConsistentAttributes = set of TConsistentAttribute;
TTextAttributes = class(TPersistent)
protected
procedure InitFormat(var Format: TCharFormat);
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(AOwner: TCustomRichEdit; AttributeType: TAttributeType);
procedure Assign(Source: TPersistent); override;
property Color: TColor;
property ConsistentAttributes: TConsistentAttributes;
property Name: TFontName;
property Pitch: TFontPitch;
property Protected: Boolean;
property Size: Integer;
property Style: TFontStyles;
property Height: Integer;
end;
{ TParaAttributes }
TNumberingStyle = (nsNone, nsBullet);
TParaAttributes = class(TPersistent)
public
constructor Create(AOwner: TCustomRichEdit);
procedure Assign(Source: TPersistent); override;
property Alignment: TAlignment;
property FirstIndent: Longint;
property LeftIndent: Longint;
property Numbering: TNumberingStyle;
property RightIndent: Longint;
property Tab[Index: Byte]: Longint;
property TabCount: Integer;
end;
{ TCustomRichEdit }
TRichEditResizeEvent = procedure(Sender: TObject; Rect: TRect) of object;
TRichEditProtectChange = procedure(Sender: TObject;
StartPos, EndPos: Integer; var AllowChange: Boolean) of object;
TRichEditSaveClipboard = procedure(Sender: TObject;
NumObjects, NumChars: Integer; var SaveClipboard: Boolean) of object;
TSearchType = (stWholeWord, stMatchCase);
TSearchTypes = set of TSearchType;
TConversion = class(TObject)
public
function ConvertReadStream(Stream: TStream; Buffer: PChar; BufSize: Integer): Integer; virtual;
function ConvertWriteStream(Stream: TStream; Buffer: PChar; BufSize: Integer): Integer; virtual;
end;
TConversionClass = class of TConversion;
PConversionFormat = ^TConversionFormat;
TConversionFormat = record
ConversionClass: TConversionClass;
Extension: string;
Next: PConversionFormat;
end;
PRichEditStreamInfo = ^TRichEditStreamInfo;
TRichEditStreamInfo = record
Converter: TConversion;
Stream: TStream;
end;
TCustomRichEdit = class(TCustomMemo)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
procedure RequestSize(const Rect: TRect); virtual;
procedure SelectionChange; dynamic;
property HideSelection: Boolean default True;
property HideScrollBars: Boolean default True;
property Lines: TStrings;
property OnSaveClipboard: TRichEditSaveClipboard;
property OnSelectionChange: TNotifyEvent;
property OnProtectChange: TRichEditProtectChange;
property OnResizeRequest: TRichEditResizeEvent;
property PlainText: Boolean default False;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function FindText(const SearchStr: string;
StartPos, Length: Integer; Options: TSearchTypes): Integer;
procedure Print(const Caption: string);
class procedure RegisterConversionFormat(const AExtension: string;
AConversionClass: TConversionClass);
property DefaultConverter: TConversionClass;
property DefAttributes: TTextAttributes;
property SelAttributes: TTextAttributes;
property PageRect: TRect;
property Paragraph: TParaAttributes;
end;
TRichEdit = class(TCustomRichEdit)
published
property Align;
property Alignment;
property BorderStyle;
property Color;
property Ctl3D;
property DragMode;
property Enabled;
property Font;
property HideSelection;
property HideScrollBars;
property ImeMode;
property ImeName;
property Lines;
property MaxLength;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property PlainText;
property PopupMenu;
property ReadOnly;
property ScrollBars;
property ShowHint;
property TabOrder;
property TabStop default True;
property Visible;
property WantTabs;
property WantReturns;
property WordWrap;
property OnChange;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResizeRequest;
property OnSelectionChange;
property OnStartDrag;
property OnProtectChange;
property OnSaveClipboard;
end;
{ TUpDown }
TUDAlignButton = (udLeft, udRight);
TUDOrientation = (udHorizontal, udVertical);
TUDBtnType = (btNext, btPrev);
TUDClickEvent = procedure (Sender: TObject; Button: TUDBtnType) of object;
TUDChangingEvent = procedure (Sender: TObject; var AllowChange: Boolean) of object;
TCustomUpDown = class(TWinControl)
protected
function CanChange: Boolean;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Click(Button: TUDBtnType); dynamic;
property AlignButton: TUDAlignButton default udRight;
property ArrowKeys: Boolean default True;
property Associate: TWinControl;
property Min: SmallInt;
property Max: SmallInt default 100;
property Increment: Integer default 1;
property Orientation: TUDOrientation default udVertical;
property Position: SmallInt;
property Thousands: Boolean default True;
property Wrap: Boolean;
property OnChanging: TUDChangingEvent;
property OnClick: TUDClickEvent;
public
constructor Create(AOwner: TComponent); override;
end;
TUpDown = class(TCustomUpDown)
published
property AlignButton;
property Associate;
property ArrowKeys;
property Enabled;
property Hint;
property Min;
property Max;
property Increment;
property Orientation;
property ParentShowHint;
property PopupMenu;
property Position;
property ShowHint;
property TabOrder;
property TabStop;
property Thousands;
property Visible;
property Wrap;
property OnChanging;
property OnClick;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
{ THotKey }
THKModifier = (hkShift, hkCtrl, hkAlt, hkExt);
THKModifiers = set of THKModifier;
THKInvalidKey = (hcNone, hcShift, hcCtrl, hcAlt, hcShiftCtrl,
hcShiftAlt, hcCtrlAlt, hcShiftCtrlAlt);
THKInvalidKeys = set of THKInvalidKey;
TCustomHotKey = class(TWinControl)
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
property AutoSize: Boolean default True;
property InvalidKeys: THKInvalidKeys;
property Modifiers: THKModifiers;
property HotKey: TShortCut;
property TabStop default True;
public
constructor Create(AOwner: TComponent); override;
end;
THotKey = class(TCustomHotKey)
published
property AutoSize;
property Enabled;
property Hint;
property HotKey;
property InvalidKeys;
property Modifiers;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
const
ColumnHeaderWidth = LVSCW_AUTOSIZE_USEHEADER;
ColumnTextWidth = LVSCW_AUTOSIZE;
type
TListColumns = class;
TListItems = class;
TCustomListView = class;
TWidth = ColumnHeaderWidth..MaxInt;
TListColumn = class(TCollectionItem)
protected
procedure DefineProperties(Filer: TFiler); override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property WidthType: TWidth;
published
property Alignment: TAlignment default taLeftJustify;
property Caption: string;
property Width: TWidth default 50;
end;
TListColumns = class(TCollection)
protected
procedure Update(Item: TCollectionItem); override;
public
constructor Create(AOwner: TCustomListView);
function Add: TListColumn;
property Owner: TCustomListView;
property Items[Index: Integer]: TListColumn; default;
end;
TDisplayCode = (drBounds, drIcon, drLabel, drSelectBounds);
{ TListItem }
TListItem = class(TPersistent)
protected
procedure Assign(Source: TPersistent); override;
public
constructor Create(AOwner: TListItems);
destructor Destroy; override;
procedure CancelEdit;
procedure Delete;
function DisplayRect(Code: TDisplayCode): TRect;
function EditCaption: Boolean;
function GetPosition: TPoint;
procedure MakeVisible(PartialOK: Boolean);
procedure Update;
procedure SetPosition(const Value: TPoint);
property Caption: string;
property Cut: Boolean index 0;
property Data: Pointer;
property DropTarget: Boolean index 1;
property Focused: Boolean index 2;
property Handle: HWND;
property ImageIndex: Integer index 0;
property Index: Integer;
property Left: Integer;
property ListView: TCustomListView;
property Owner: TListItems;
property OverlayIndex: Integer index 1;
property Selected: Boolean index 3;
property StateIndex: Integer index 2;
property SubItems: TStrings;
property Top: Integer;
end;
{ TListItems }
TListItems = class(TPersistent)
protected
procedure DefineProperties(Filer: TFiler); override;
function CreateItem(Index: Integer; ListItem: TListItem): TLVItem;
function GetCount: Integer;
function GetHandle: HWND;
function GetItem(Index: Integer): TListItem;
procedure SetItem(Index: Integer; Value: TListItem);
procedure SetUpdateState(Updating: Boolean);
public
constructor Create(AOwner: TCustomListView);
destructor Destroy; override;
function Add: TListItem;
procedure Assign(Source: TPersistent); override;
procedure BeginUpdate;
procedure Clear;
procedure Delete(Index: Integer);
procedure EndUpdate;
function IndexOf(Value: TListItem): Integer;
function Insert(Index: Integer): TListItem;
property Count: Integer;
property Handle: HWND;
property Item[Index: Integer]: TListItem; default;
property Owner: TCustomListView;
end;
{ TIconOptions }
TIconArrangement = (iaTop, iaLeft);
TIconOptions = class(TPersistent)
public
constructor Create(AOwner: TCustomListView);
published
property Arrangement: TIconArrangement default iaTop;
property AutoArrange: Boolean default False;
property WrapText: Boolean default True;
end;
TListArrangement = (arAlignBottom, arAlignLeft, arAlignRight,
arAlignTop, arDefault, arSnapToGrid);
TViewStyle = (vsIcon, vsSmallIcon, vsList, vsReport);
TItemState = (isNone, isCut, isDropHilited, isFocused, isSelected);
TItemStates = set of TItemState;
TItemChange = (ctText, ctImage, ctState);
TLVDeletedEvent = procedure(Sender: TObject; Item: TListItem) of object;
TLVEditingEvent = procedure(Sender: TObject; Item: TListItem;
var AllowEdit: Boolean) of object;
TLVEditedEvent = procedure(Sender: TObject; Item: TListItem; var S: string) of object;
TLVChangeEvent = procedure(Sender: TObject; Item: TListItem;
Change: TItemChange) of object;
TLVChangingEvent = procedure(Sender: TObject; Item: TListItem;
Change: TItemChange; var AllowChange: Boolean) of object;
TLVColumnClickEvent = procedure(Sender: TObject; Column: TListColumn) of object;
TLVCompareEvent = procedure(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer) of object;
TSearchDirection = (sdLeft, sdRight, sdAbove, sdBelow, sdAll);
{ TCustomListView }
TCustomListView = class(TWinControl)
protected
function CanChange(Item: TListItem; Change: Integer): Boolean; dynamic;
function CanEdit(Item: TListItem): Boolean; dynamic;
procedure Change(Item: TListItem; Change: Integer); dynamic;
procedure ColClick(Column: TListColumn); dynamic;
function ColumnsShowing: Boolean;
function CreateListItem: TListItem; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure Delete(Item: TListItem); dynamic;
procedure DestroyWnd; override;
procedure DoEndDrag(Target: TObject; X, Y: Integer); dynamic;
procedure DoStartDrag(var DragObject: TDragObject); override;
procedure Edit(const Item: TLVItem); dynamic;
function GetDragImages: TCustomImageList; override;
function GetItemIndex(Value: TListItem): Integer;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure UpdateColumn(Index: Integer);
procedure UpdateColumns;
procedure WndProc(var Message: TMessage); override;
property BorderStyle: TBorderStyle default bsSingle;
property Columns: TListColumns;
property ColumnClick: Boolean default True;
property ReadOnly: Boolean;
property HideSelection: Boolean default True;
property IconOptions: TIconOptions;
property Items: TListItems;
property AllocBy: Integer default 0;
property LargeImages: TImageList;
property MultiSelect: Boolean default False;
property OnChange: TLVChangeEvent;
property OnChanging: TLVChangingEvent;
property OnColumnClick: TLVColumnClickEvent;
property OnCompare: TLVCompareEvent;
property OnDeletion: TLVDeletedEvent;
property OnEdited: TLVEditedEvent;
property OnEditing: TLVEditingEvent;
property OnInsert: TLVDeletedEvent;
property ShowColumnHeaders: Boolean default True;
property SmallImages: TImageList;
property SortType: TSortType default stNone;
property StateImages: TImageList;
property ViewStyle: TViewStyle default vsIcon;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function AlphaSort: Boolean;
procedure Arrange(Code: TListArrangement);
function FindCaption(StartIndex: Integer; Value: string;
Partial, Inclusive, Wrap: Boolean): TListItem;
function FindData(StartIndex: Integer; Value: Pointer;
Inclusive, Wrap: Boolean): TListItem;
function GetItemAt(X, Y: Integer): TListItem;
function GetNearestItem(Point: TPoint;
Direction: TSearchDirection): TListItem;
function GetNextItem(StartItem: TListItem;
Direction: TSearchDirection; States: TItemStates): TListItem;
function GetSearchString: string;
function IsEditing: Boolean;
procedure Scroll(DX, DY: Integer);
property Column[Index: Integer]: TListColumn;
property DropTarget: TListItem;
property ItemFocused: TListItem;
property SelCount: Integer;
property Selected: TListItem;
function CustomSort(SortProc: TLVCompare; lParam: Longint): Boolean;
function StringWidth(S: string): Integer;
procedure UpdateItems(FirstIndex, LastIndex: Integer);
property TopItem: TListItem;
property ViewOrigin: TPoint;
property VisibleRowCount: Integer;
property BoundingRect: TRect;
end;
{ TListView }
TListView = class(TCustomListView)
published
property Align;
property BorderStyle;
property Color;
property ColumnClick;
property OnClick;
property OnDblClick;
property Columns;
property Ctl3D;
property DragMode;
property ReadOnly;
property Font;
property HideSelection;
property IconOptions;
property Items;
property AllocBy;
property MultiSelect;
property OnChange;
property OnChanging;
property OnColumnClick;
property OnCompare;
property OnDeletion;
property OnEdited;
property OnEditing;
property OnEnter;
property OnExit;
property OnInsert;
property OnDragDrop;
property OnDragOver;
property DragCursor;
property OnStartDrag;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property ParentShowHint;
property ShowHint;
property PopupMenu;
property ShowColumnHeaders;
property SortType;
property TabOrder;
property TabStop default True;
property ViewStyle;
property Visible;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property LargeImages;
property SmallImages;
property StateImages;
end;
implementation