cxshelltreeview.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,164 行 · 第 1/3 页
PAS
1,164 行
{********************************************************************}
{ }
{ Developer Express Visual Component Library }
{ ExpressEditors }
{ }
{ Copyright (c) 1998-2008 Developer Express Inc. }
{ ALL RIGHTS RESERVED }
{ }
{ The entire contents of this file is protected by U.S. and }
{ International Copyright Laws. Unauthorized reproduction, }
{ reverse-engineering, and distribution of all or any portion of }
{ the code contained in this file is strictly prohibited and may }
{ result in severe civil and criminal penalties and will be }
{ prosecuted to the maximum extent possible under the law. }
{ }
{ RESTRICTIONS }
{ }
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
{ LICENSED TO DISTRIBUTE THE EXPRESSEDITORS AND ALL }
{ ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
{ }
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
{ }
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
{ ADDITIONAL RESTRICTIONS. }
{ }
{********************************************************************}
unit cxShellTreeView;
{$I cxVer.inc}
interface
uses
Windows, Messages, Classes, ComCtrls, CommCtrl, Controls, Forms, Graphics,
ImgList, Menus, ShlObj, StdCtrls, cxContainer, cxDataUtils, cxShellListView,
cxShellCommon, cxShellControls;
type
TcxCustomShellTreeView = class;
{ TcxInnerShellTreeView }
TcxInnerShellTreeView = class(TcxCustomInnerShellTreeView, IUnknown,
IcxContainerInnerControl)
private
// IcxContainerInnerControl
function GetControl: TWinControl;
function GetControlContainer: TcxContainer;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure DSMShellChangeNotify(var Message: TMessage); message DSM_SHELLCHANGENOTIFY;
procedure TVMEnsureVisible(var Message: TMessage); message TVM_ENSUREVISIBLE;
protected
FContainer: TcxCustomShellTreeView;
procedure Click; override;
procedure DblClick; override;
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
MousePos: TPoint): Boolean; override;
procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
var Accept: Boolean); override;
function GetPopupMenu: TPopupMenu; override;
function IsLoading: Boolean; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
procedure WndProc(var Message: TMessage); override;
procedure MouseEnter(AControl: TControl); dynamic;
procedure MouseLeave(AControl: TControl); dynamic;
property Container: TcxCustomShellTreeView read FContainer;
public
constructor Create(AOwner: TComponent); override;
function CanFocus: Boolean; override;
procedure DragDrop(Source: TObject; X, Y: Integer); override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
function UpdateAction(Action: TBasicAction): Boolean; override;
property Align;
property Anchors;
property AutoExpand;
property BorderStyle;
property ChangeDelay;
property Color;
property Ctl3D;
property Cursor;
property DragDropSettings;
property Enabled;
property Font;
property HideSelection;
property HotTrack;
property Indent;
property Items;
property ListView;
property Options;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RightClickSelect;
property Root;
property ShowButtons;
property ShowHint;
property ShowLines;
property ShowRoot;
property StateImages;
property TabOrder;
property TabStop default True;
property Visible;
property OnAddFolder;
property OnChange;
property OnChanging;
property OnClick;
property OnCollapsed;
property OnCollapsing;
property OnDblClick;
property OnEdited;
property OnEditing;
property OnEnter;
property OnExit;
property OnExpanded;
property OnExpanding;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnRootChanged;
property OnShellChange;
end;
{ TcxCustomShellTreeView }
TcxCustomShellTreeView = class(TcxContainer)
private
FInnerTreeView: TcxInnerShellTreeView;
FIsExitProcessing: Boolean;
FScrollBarsCalculating: Boolean;
FOnAddFolder: TcxShellAddFolderEvent;
FOnChange: TTVChangedEvent;
FOnChanging: TTVChangingEvent;
FOnCollapsed: TTVExpandedEvent;
FOnCollapsing: TTVCollapsingEvent;
FOnEdited: TTVEditedEvent;
FOnEditing: TTVEditingEvent;
FOnExpanded: TTVExpandedEvent;
FOnExpanding: TTVExpandingEvent;
FOnShellChange: TcxShellChangeEvent;
procedure AddFolderHandler(Sender: TObject; AFolder: TcxShellFolder;
var ACanAdd: Boolean);
procedure ChangeHandler(Sender: TObject; Node: TTreeNode);
procedure ChangingHandler(Sender: TObject; Node: TTreeNode;
var AllowChange: Boolean);
procedure CollapsedHandler(Sender: TObject; Node: TTreeNode);
procedure CollapsingHandler(Sender: TObject; Node: TTreeNode;
var AllowCollapse: Boolean);
procedure EditedHandler(Sender: TObject; Node: TTreeNode; var S: string);
procedure EditingHandler(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean);
procedure ExpandedHandler(Sender: TObject; Node: TTreeNode);
procedure ExpandingHandler(Sender: TObject; Node: TTreeNode;
var AllowExpansion: Boolean);
procedure ShellChangeHandler(Sender: TObject; AEventID: DWORD;
APIDL1, APIDL2: PItemIDList);
function GetAbsolutePIDL: PItemIDList;
function GetAutoExpand: Boolean;
function GetChangeDelay: Integer;
function GetDragDropSettings: TcxDragDropSettings;
function GetFolder(AIndex: Integer): TcxShellFolder;
function GetFolderCount: Integer;
function GetHideSelection: Boolean;
function GetIndent: Integer;
function GetOptions: TcxShellTreeViewOptions;
function GetPath: string;
function GetRightClickSelect: Boolean;
function GetRoot: TcxShellTreeRoot;
function GetShellListView: TcxCustomShellListView;
function GetShowButtons: Boolean;
function GetShowInfoTips: Boolean;
function GetShowLines: Boolean;
function GetShowRoot: Boolean;
function GetStateImages: TCustomImageList;
function GetTreeHotTrack: Boolean;
procedure SetAbsolutePIDL(Value: PItemIDList);
procedure SetAutoExpand(Value: Boolean);
procedure SetChangeDelay(Value: Integer);
procedure SetDragDropSettings(Value: TcxDragDropSettings);
procedure SetHideSelection(Value: Boolean);
procedure SetIndent(Value: Integer);
procedure SetOptions(Value: TcxShellTreeViewOptions);
procedure SetPath(const Value: string);
procedure SetRightClickSelect(Value: Boolean);
procedure SetRoot(Value: TcxShellTreeRoot);
procedure SetShellListView(Value: TcxCustomShellListView);
procedure SetShowButtons(Value: Boolean);
procedure SetShowInfoTips(Value: Boolean);
procedure SetShowLines(Value: Boolean);
procedure SetShowRoot(Value: Boolean);
procedure SetStateImages(Value: TCustomImageList);
procedure SetTreeHotTrack(Value: Boolean);
protected
FDataBinding: TcxCustomDataBinding;
procedure DoExit; override;
procedure Loaded; override;
function NeedsScrollBars: Boolean; override;
procedure Scroll(AScrollBarKind: TScrollBarKind; AScrollCode: TScrollCode;
var AScrollPos: Integer); override;
procedure CurrentFolderChangedHandler(Sender: TObject; Root: TcxCustomShellRoot); virtual;
function GetDataBindingClass: TcxCustomDataBindingClass; virtual;
function GetViewOptions(AForNavigation: Boolean = False): TcxShellViewOptions;
property AutoExpand: Boolean read GetAutoExpand write SetAutoExpand default False;
property ChangeDelay: Integer read GetChangeDelay write SetChangeDelay default 0;
property DataBinding: TcxCustomDataBinding read FDataBinding;
property DragDropSettings: TcxDragDropSettings read GetDragDropSettings write SetDragDropSettings;
property HideSelection: Boolean read GetHideSelection write SetHideSelection default True;
property Indent: Integer read GetIndent write SetIndent;
property Options: TcxShellTreeViewOptions read GetOptions write SetOptions;
property RightClickSelect: Boolean read GetRightClickSelect
write SetRightClickSelect default False;
property Root: TcxShellTreeRoot read GetRoot write SetRoot;
property ShellListView: TcxCustomShellListView read GetShellListView write SetShellListView;
property ShowButtons: Boolean read GetShowButtons write SetShowButtons default True;
property ShowInfoTips: Boolean read GetShowInfoTips
write SetShowInfoTips default False;
property ShowLines: Boolean read GetShowLines write SetShowLines default True;
property ShowRoot: Boolean read GetShowRoot write SetShowRoot default True;
property StateImages: TCustomImageList read GetStateImages write SetStateImages;
property TreeHotTrack: Boolean read GetTreeHotTrack write SetTreeHotTrack default False;
property OnAddFolder: TcxShellAddFolderEvent read FOnAddFolder write FOnAddFolder;
property OnChange: TTVChangedEvent read FOnChange write FOnChange;
property OnChanging: TTVChangingEvent read FOnChanging write FOnChanging;
property OnCollapsed: TTVExpandedEvent read FOnCollapsed write FOnCollapsed;
property OnCollapsing: TTVCollapsingEvent read FOnCollapsing write FOnCollapsing;
property OnEdited: TTVEditedEvent read FOnEdited write FOnEdited;
property OnEditing: TTVEditingEvent read FOnEditing write FOnEditing;
property OnExpanded: TTVExpandedEvent read FOnExpanded write FOnExpanded;
property OnExpanding: TTVExpandingEvent read FOnExpanding write FOnExpanding;
property OnShellChange: TcxShellChangeEvent read FOnShellChange write FOnShellChange;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
procedure SetFocus; override;
function UpdateAction(Action: TBasicAction): Boolean; override;
function GetNodeAbsolutePIDL(ANode: TTreeNode): PItemIDList;
procedure UpdateContent;
property AbsolutePath: string read GetPath write SetPath; // deprecated;
property AbsolutePIDL: PItemIDList read GetAbsolutePIDL write SetAbsolutePIDL;
property FolderCount: Integer read GetFolderCount;
property Folders[AIndex: Integer]: TcxShellFolder read GetFolder;
property InnerTreeView: TcxInnerShellTreeView read FInnerTreeView;
property Path: string read GetPath write SetPath;
// property RelativePIDL: PItemIDList write SetRelativePIDL; // TODO
end;
{ TcxShellTreeView }
TcxShellTreeView = class(TcxCustomShellTreeView)
published
property Align;
property Anchors;
property AutoExpand;
property ChangeDelay;
property Constraints;
property DragDropSettings;
property Enabled;
property HideSelection;
property Indent;
property Options;
property ParentColor default False;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RightClickSelect;
property Root;
property ShellListView;
property ShowButtons;
property ShowHint;
property ShowInfoTips;
property ShowLines;
property ShowRoot;
property StateImages;
property Style;
property StyleDisabled;
property StyleFocused;
property StyleHot;
property TabOrder;
property TabStop;
property TreeHotTrack;
property Visible;
property OnAddFolder;
property OnChange;
property OnChanging;
property OnClick;
property OnCollapsed;
property OnCollapsing;
property OnDblClick;
property OnEdited;
property OnEditing;
property OnEnter;
property OnExit;
property OnExpanded;
property OnExpanding;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnShellChange;
end;
implementation
uses
SysUtils, cxClasses, cxEdit, cxScrollBar;
type
TcxContainerAccess = class(TcxContainer);
TcxCustomDataBindingAccess = class(TcxCustomDataBinding);
TcxInnerShellListViewAccess = class(TcxInnerShellListView);
TcxShellTreeItemProducerAccess = class(TcxShellTreeItemProducer);
{ TcxInnerShellTreeView }
constructor TcxInnerShellTreeView.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BorderStyle := bsNone;
ControlStyle := ControlStyle + [csDoubleClicks];
ParentColor := False;
ParentFont := True;
end;
function TcxInnerShellTreeView.CanFocus: Boolean;
begin
Result := Container.CanFocusEx;
end;
procedure TcxInnerShellTreeView.DragDrop(Source: TObject; X, Y: Integer);
begin
if Container <> nil then
Container.DragDrop(Source, Left + X, Top + Y);
end;
function TcxInnerShellTreeView.ExecuteAction(Action: TBasicAction): Boolean;
begin
Result := inherited ExecuteAction(Action) or
TcxCustomDataBindingAccess(Container.FDataBinding).ExecuteAction(Action);
end;
function TcxInnerShellTreeView.UpdateAction(Action: TBasicAction): Boolean;
begin
Result := inherited UpdateAction(Action) or
TcxCustomDataBindingAccess(Container.FDataBinding).UpdateAction(Action);
end;
procedure TcxInnerShellTreeView.Click;
begin
inherited Click;
if Container <> nil then
Container.Click;
end;
procedure TcxInnerShellTreeView.DblClick;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?