⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dccomctrls.pas

📁 获取硬盘相关详细信息
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{$ENDIF}
    property OnChange;
    property OnChanging;
    property OnClick;
    property OnColumnClick;
{$IFDEF D5}
    property OnColumnRightClick;
{$ENDIF}
    property OnCompare;
{$IFDEF D5}
    property OnContextPopup;
{$ENDIF}
{$IFDEF D4}
    property OnCustomDraw;
    property OnCustomDrawItem;
    property OnCustomDrawSubItem;
    property OnData;
    property OnDataFind;
    property OnDataHint;
    property OnDataStateChange;
{$ENDIF}
    property OnDblClick;
    property OnDeletion;
{$IFDEF D4}
    property OnDrawItem;
{$ENDIF}
    property OnEdited;
    property OnEditing;
    property OnEnter;
    property OnExit;
{$IFDEF D4}
    property OnGetImageIndex;
{$ENDIF}
{$IFDEF D5}
    property OnGetSubItemImage;
{$ENDIF}
{$IFDEF D5}
    property OnInfoTip;
{$ENDIF}
    property OnInsert;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
{$IFDEF D4}
    property OnMouseWheel;
    property OnResize;
    property OnSelectItem;
{$ENDIF}

    // new properties/events
    property About: String read FAbout write FAbout stored False;
    property ViewStyle: TViewStyle read GetViewStyle write SetViewStyle default vsReport;
    property SortType: TSortType read GetSortType write SetSortType default stData;

    property Cursors: TdcListViewCursors read FCursors write FCursors;
    property HeaderColor: TColor read FHeaderColor write SetHeaderColor default clNone;
    property HeaderStyle: THeaderStyle read FHeaderStyle write SetHeaderStyle default hsButtons;
    property HeaderMenu: TdcListViewHeaderMenu read FHeaderMenu write FHeaderMenu;
    property ShowHeaderMenu: Boolean read FShowHeaderMenu write FShowHeaderMenu default True;
    property ShowSortMark: Boolean read FShowSortMark write SetShowSortMark default True;
    property SortDirection: TdcListViewSortDirection read FSortDirection write SetSortDirection default sdAscending;
    property SortColumn: Word read FSortColumn write SetSortColumn default 0;
    property SortMarkAlign: TdcListViewSortMarkAlign read FSortMarkAlign write SetSortMarkAlign default maText;
    property SortMarkKind: TdcListViewSortMarkKind read FSortMarkKind write SetSortMarkKind default mkSunken;
    property SortMarkImageAsc: TPicture read FSortMarkImageAsc write SetSortMarkImageAsc;
    property SortMarkImageDesc: TPicture read FSortMarkImageDesc write SetSortMarkImageDesc;
    property RegistrySaver: TdcListViewRegistrySaver read FRegistrySaver write FRegistrySaver;

{$IFDEF D3}
    property CheckOnClick: Boolean read FCheckOnClick write FCheckOnClick default False;
{$ELSE}
    property GridLines: Boolean read FGridLines write SetGridLines default False;
    property HotTrack: Boolean read FHotTrack write SetHotTrack default False;
    property RowSelect: Boolean read FRowSelect write SetRowSelect default False;
{$ENDIF}
{$IFNDEF D4}
    property FlatScrollBars: Boolean read FFlatScrollBars write SetFlatScrollBars default False;
    property FullDrag: Boolean read FFullDrag write SetFullDrag default False;
    property HotTrackStyles: TListHotTrackStyles read FHotTrackStyles write SetHotTrackStyles default [];
{$ENDIF}
{$IFNDEF D5}
    property HoverTime: Integer read GetHoverTime write SetHoverTime default -1;
{$ENDIF}

    property ShowScrollTips: Boolean read FShowScrollTips write FShowScrollTips default True; 
    property ShowToolTips: Boolean read GetToolTips write SetToolTips default True;
    property ToolTipOptions: TdcListViewToolTipOptions read FToolTipOptions write SetToolTipOptions default [];

    property OnAlignmentChanged: TLVColumnClickEvent read FOnAlignmentChanged write FOnAlignmentChanged;
    property OnDrawHeaderSection: TdcListViewDrawHeaderSection read FOnDrawHeaderSection write FOnDrawHeaderSection;
    property OnToolTip: TdcListViewToolTipEvent read FOnToolTip write FOnToolTip;
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    property OnSettingsChanged: TNotifyEvent read FOnSettingsChanged write FOnSettingsChanged;
    property OnColumnResizeBegin: TdcListViewColumnResizeBeginEvent read FOnColumnResizeBegin write FOnColumnResizeBegin;
    property OnColumnResizeEnd: TLVColumnClickEvent read FOnColumnResizeEnd write FOnColumnResizeEnd;    
    {$IFDEF D4}
    property OnCustomDrawSubItemEx: TdcListViewCustomDrawSubItemExEvent read FOnCustomDrawSubItemEx write SetOnCustomDrawSubItemEx;
    property OnColumnDragged: TdcListViewColumnDragEvent read FOnColumnDragged write FOnColumnDragged;
    {$ENDIF}
  end;


{$IFDEF APPCONTROLS}
type
  TdcListView = class(TumCustomListView)
  published
    property Columns;
    property Items;
    property LargeImages;
    property SmallImages;
    property StateImages;
    
    property DragCursor;
    property DragMode;
{$IFDEF D4}
    property DragKind;
    property OnStartDock;
    property OnEndDock;
{$ENDIF}
    property OnStartDrag;
    property OnEndDrag;
    property OnDragDrop;
    property OnDragOver;
  end;

// -- TreeView -------------------------

  { TdcTreeViewCursors }
  TdcTreeViewCursors = class(TPersistent)
  private
    FBorder,
    FScrollHorz,
    FScrollVert: TCursor;
  published
    property Border: TCursor read FBorder write FBorder default crDefault;
    property ScrollHorz: TCursor read FScrollHorz write FScrollHorz default crDefault;
    property ScrollVert: TCursor read FScrollVert write FScrollVert default crDefault;
  end;

  { acTreeView }
  TdcTreeViewCustomPopupMenuEvent = procedure(Sender: TObject; ScreenX, ScreenY: Integer;
     ClickedNode: TTreeNode) of object;
  TdcTreeView = class(TTreeView)
  private
    FAbout: String;
    FCursors: TdcTreeViewCursors;
    FDragForm: Boolean;
    FMouseTrack: Boolean;

    FOnMouseEnter, FOnMouseLeave: TNotifyEvent;
    FOnCustomPopupMenu: TdcTreeViewCustomPopupMenuEvent;

    // for internal use
    FLastPoint: TPoint;

  {$IFNDEF D4}
    FAutoExpand,
    FHotTrack,
    FRowSelect,
    FToolTips: Boolean;

    procedure SetAutoExpand(Value: Boolean);
    procedure SetHotTrack(Value: Boolean);
    procedure SetRowSelect(Value: Boolean);
    procedure SetToolTips(Value: Boolean);
  {$ENDIF}
    function  GetItemHeight: ShortInt;
    procedure SetItemHeight(Value: ShortInt);
    function  GetSelectedAbsoluteIndex: Integer;
    procedure SetSelectedAbsoluteIndex(Value: Integer);

    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
    procedure WMSysColorChange(var Message: TWMSysColorChange); message WM_SYSCOLORCHANGE;
  protected
    procedure WndProc(var Message: TMessage); override;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
  public
    constructor Create(aOwner: TComponent); override;
    destructor Destroy; override;

    function ImportFromTXT(const FileName: String; RootNode: TTreeNode {$IFDEF D4} = nil;
       FirstLevelImageIndex: Integer = 0; SecondLevelImageIndex: Integer = -1;
       ThirdLevelImageIndex: Integer = -1 {$ENDIF}): Boolean;
    procedure ImportFromTreeView(SourceTreeView: TCustomTreeView;
       SourceRootNode: TTreeNode {$IFDEF D4} = nil {$ENDIF};
       TargetRootNode: TTreeNode {$IFDEF D4} = nil {$ENDIF});

    function FindNode(const Text: String): TTreeNode;
    function FindNodeByAbsoluteIndex(AbsoluteIndex: Integer): TTreeNode;

    property ItemHeight: ShortInt read GetItemHeight write SetItemHeight;
    property SelectedAbsoluteIndex: Integer read GetSelectedAbsoluteIndex write SetSelectedAbsoluteIndex default -1;
  published
    property About: String read FAbout write FAbout stored False;
    property Cursors: TdcTreeViewCursors read FCursors write FCursors;
    property DragForm: Boolean read FDragForm write FDragForm default False;
    property MouseTrack: Boolean read FMouseTrack write FMouseTrack default False;

    {$IFNDEF D4}
    property AutoExpand: Boolean read FAutoExpand write SetAutoExpand default False;
    property HotTrack: Boolean read FHotTrack write SetHotTrack default False;
    property RowSelect: Boolean read FRowSelect write SetRowSelect default False;
    property ToolTips: Boolean read FToolTips write SetToolTips default True;
    {$ENDIF}

    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    property OnCustomPopupMenu: TdcTreeViewCustomPopupMenuEvent read FOnCustomPopupMenu write FOnCustomPopupMenu;
  end;
{$ENDIF APPCONTROLS}

function UMDefaultListViewSort(Item1, Item2: TListItem;
  lParam: Integer): Integer; stdcall;

implementation

{$J+}{$I-}

uses Forms, StdCtrls, SysUtils, ShellAPI,
     {$IFDEF SUBITEMSBUGFIX} ImgList, {$ENDIF}
     {$IFDEF APPCONTROLS} acPropUtils, acUtils, acXPThemes
     {$ELSE} dcPropUtils, dcUtils, dcXPThemes {$ENDIF};

var
  ScrollHintWnd: THintWindow;
  ClickedColumn: Integer; // static only. do not put it to class.

function GetScrollHint: THintWindow;
begin
  if ScrollHintWnd = nil then
   begin
    ScrollHintWnd := HintWindowClass.Create(Application);
    ScrollHintWnd.Visible := False;
   end;
  Result := ScrollHintWnd;
end;

const
  DEF_SORT_ASCENDING  = 'Sort &Ascending';
  DEF_SORT_DESCENDING = 'Sort &Descending';

  { http://msdn.microsoft.com/library/sdkdoc/shellcc/CommCtls/ToolTip/ToolTip.htm }
  { http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/ListView/Messages/messages.asp }
  LVM_FIRST                     = $1000;
  LVM_GETITEMRECT               = LVM_FIRST + 14;
  LVM_GETEDITCONTROL            = LVM_FIRST + 24;
  LVM_SETEXTENDEDLISTVIEWSTYLE  = LVM_FIRST + 54;
  LVM_GETEXTENDEDLISTVIEWSTYLE  = LVM_FIRST + 55;
  LVM_SUBITEMHITTEST            = LVM_FIRST + 57;
  LVM_SETHOTCURSOR              = LVM_FIRST + 62;  
  LVM_SETHOVERTIME              = LVM_FIRST + 71;
  LVM_GETHOVERTIME              = LVM_FIRST + 72;
  LVM_GETTOOLTIPS               = LVM_FIRST + 78;

  LVN_GETINFOTIPW               = LVN_FIRST - 58;

  TTDT_AUTOMATIC                = 0;
  TTDT_AUTOPOP                  = 2;
  TTM_SETDELAYTIME              = WM_USER + 3;
  TTM_TRACKPOSITION             = WM_USER + 18;
  TTM_SETMAXTIPWIDTH            = WM_USER + 24;
  TTN_FIRST                     = -520;
  TTN_GETDISPINFOW              = TTN_FIRST - 10;

{$IFNDEF D3}
  WM_MOUSELEAVE                 = $02A3; // Exists since Win98

  { List View Extended Styles }
  LVS_EX_GRIDLINES        = $00000001;
  LVS_EX_SUBITEMIMAGES    = $00000002;
  LVS_EX_CHECKBOXES       = $00000004;
  LVS_EX_TRACKSELECT      = $00000008;
  LVS_EX_HEADERDRAGDROP   = $00000010;
  LVS_EX_FULLROWSELECT    = $00000020; // applies to report mode only
  LVS_EX_ONECLICKACTIVATE = $00000040;
  LVS_EX_TWOCLICKACTIVATE = $00000080;
{$ENDIF}
{$IFNDEF D4}
  LVS_EX_FLATSB           = $00000100;
  LVS_EX_REGIONAL         = $00000200;
  LVS_EX_INFOTIP          = $00000400; // listview does InfoTips for you
  LVS_EX_UNDERLINEHOT     = $00000800;
  LVS_EX_UNDERLINECOLD    = $00001000;
  LVS_EX_MULTIWORKAREAS   = $00002000;

  { TreeView }
  TVS_NOTOOLTIPS          = $0080;
  TVS_CHECKBOXES          = $0100;
  TVS_TRACKSELECT         = $0200;
  TVS_SINGLEEXPAND        = $0400;
  TVS_FULLROWSELECT       = $1000;
  TVM_SETITEMHEIGHT       = TV_FIRST + 27;
  TVM_GETITEMHEIGHT       = TV_FIRST + 28;

  { Header }
  HDN_BEGINDRAG           = HDN_FIRST - 10;
  HDN_ENDDRAG             = HDN_FIRST - 11;
{$ENDIF}

  { Definitions for the RegistrySaver }
  RSSortColumn    = 'SortColumn';
  RSSortDirection = 'SortDirection';
  RSViewStyle     = 'ViewStyle';

type
  NMTTDISPINFOW = packed record
    hdr: TNMHdr;
    lpszText: PWideChar;
    szText: Array[0..79] of WideChar;
    hinst: HINST;
    uFlags: UINT;
    lParam: LPARAM;
  end;
  PNMTTDispInfoW = ^TNMTTDispInfoW;
  TNMTTDispInfoW = NMTTDISPINFOW;

type
  tagLVHITTESTINFO = packed record
    pt: TPoint;
    flags: UINT;
    iItem: Integer;
    iSubItem: Integer;
  end;
  TLVHitTestInfo = tagLVHITTESTINFO;

{$IFNDEF D3}
function ListView_SetExtendedListViewStyle(hwndLV: HWND; dw: DWORD): BOOL;
begin
  Result := BOOL(SendMessage(hwndLV, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dw));
end;

{$IFDEF APPCONTROLS}
function ListView_SetHotCursor(hwndLV: HWND; hcur: HCURSOR): HCURSOR;
begin
  Result := SendMessage(hwndLV, LVM_SETHOTCURSOR, 0, hcur);
end;
{$ENDIF}
{$ENDIF}

{$IFNDEF D4}
function ListView_SetHoverTime(hwndLV: HWND; dwHoverTimeMs: DWORD): DWORD;
begin
  Result := SendMessage(hwndLV, LVM_SETHOVERTIME, 0, dwHoverTimeMs);
end;

function ListView_GetHoverTime(hwndLV: HWND): Integer;
begin
  Result := SendMessage(hwndLV, LVM_GETHOVERTIME, 0, 0);
end;

{$IFDEF APPCONTROLS}
function TreeView_SetItemHeight(hwnd: HWND; iHeight: Integer): Integer;
begin
  Result := SendMessage(hwnd, TVM_SETITEMHEIGHT, iHeight, 0);
end;

function TreeView_GetItemHeight(hwnd: HWND): Integer;
begin
  Result := SendMessage(hwnd, TVM_GETITEMHEIGHT, 0, 0);
end;
{$ENDIF}
{$ENDIF}


{$IFDEF SUBITEMSBUGFIX} // Delphi 5 memory leak bugfix
type
{$HINTS OFF}
   TdcHackListItem = class(TPersistent)
   private
     FOwner: TListItems;
     FSubItems: TStrings;
   end;
{$HINTS ON}   

   TdcHackListItems = class(TListItems)
   end;

   TdcFixedListItem = class(TListItem)
   public
     constructor Create(AOwner: TListItems);
   end;

   TdcFixedSubItems = class(TStringList)
   private
     FOwner: TListItem;
     FImageIndices: TList;
     procedure SetColumnWidth(Index: Integer);
     procedure RefreshItem(Index: Integer);
   protected
     function GetHandle: HWND;
     function Add(const S: string): Integer; override;
     procedure Delete(Index: Integer); override;
     procedure Put(Index: Integer; const St: String); override;
     procedure SetUpdateState(Updating: Boolean); override;
   public
     constructor Create(AOwner: TListItem);
     destructor Destroy; override;

     procedure Clear; override;
     procedure Insert(Index: Integer; const St: String); override;
     property Handle: HWND read GetHandle;
     property Owner: TListItem read FOwner;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -