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

📄 dcoutbar.pas

📁 XP风格的outbar.rar.有DELPHI,C++BULIDER的例子及源码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    Procedure ReDrawItem(Item:TListItem);
    Procedure RemoveHook;
    Procedure ScrollBy(Count:Integer);
    Procedure ScrollDown;
    Procedure ScrollUp;
    Procedure SelectItem(Item:TListItem;IsDown:Boolean);
    Procedure SelectItems;
    Procedure SetBkColor(Value:TColor);
    Procedure SetCursor(ACursor:Integer);
    Procedure SetFont(Value:TFont);
    Procedure SetHook;
    Procedure SetHotItem(Value:TListItem);
    Procedure SetItemSpace(Value:Integer);
    Procedure SetSelectedItem(Value:TListItem);
    Procedure UpdateDragCursor;
    Procedure UpdateHotItem(X,Y:Integer);
    Procedure UpdateHotItemByCursor;
    Procedure UpdateScroll;
    Procedure UpdateSelected;
    Procedure DoBeforeMouseDown(X, Y : integer);
    Property SelectedItem:TListItem read GetSelectedItem write SetSelectedItem;
    Procedure InternalSetViewStyle(Value:TViewStyle);
  protected
    Procedure Change(Item:TListItem;Change:Integer);override;
    Procedure CMColorChanged(Var Message:TMessage);message CM_COLORCHANGED;
    Procedure CMDrag(Var Message:TCMDrag);message CM_DRAG;
    Procedure CMFontChanged(Var Message:TMessage);message CM_FONTCHANGED;
    Procedure CNNotify(Var Message:TWMNotify);message CN_NOTIFY;
    Function CreateListItem:TListItem;override;
    Procedure CreateParams(Var Params:TCreateParams);override;
    Procedure CreateWnd;override;
    Procedure DoButtonClick(Item:TListItem);virtual;
    Procedure DoEndDrag(Target:TObject;X,Y:Integer);override;
    Procedure DoAfterScroll;dynamic;
    Procedure DoBeforeScroll;dynamic;
    Function DoExecuteItem(Item:TDCVertListItem):Boolean;virtual;
    Procedure DoHotTrackItem(Item:TListItem);virtual;
    Function DoPopupMenu(Item:TListItem):TPopupMenu;virtual;
    Procedure DragOver(Source:TObject;X,Y:Integer;
                       State:TDragState;Var Accept:Boolean);override;
    Function GetPopupMenu:TPopupMenu;override;
    Procedure KeyDown(Var Key:Word;Shift:TShiftState);override;
    Procedure LastPaint;override;
    Procedure Loaded;override;
    Procedure CMMouseLeave(Var Message:TMessage);message CM_MOUSELEAVE;
    Procedure LVMArrange(Var Message:TMessage);message LVM_ARRANGE;
    Procedure LVMDeleteItem(Var Message:TMessage);message LVM_DELETEITEM;
    Procedure LVMEditLabel(Var Message:TMessage);message LVM_EDITLABEL;
    Procedure LVMEnsureVisible(Var Message:TMessage);message LVM_ENSUREVISIBLE;
    Procedure LVMGetItemRect(Var Message:TMessage);message LVM_GETITEMRECT;
    Procedure LVMGetOrigin(Var Message:TMessage);message LVM_GETORIGIN;
    Procedure LVMHitTest(Var Message:TMessage);message LVM_HITTEST;
    Procedure LVMInsertItem(Var Message:TMessage);message LVM_INSERTITEM;
    Procedure LVMScroll(Var Message:TMessage);message LVM_SCROLL;
    Procedure LVMSetImageList(Var Message:TMessage);message LVM_SETIMAGELIST;
    Procedure MouseMove(Shift:TShiftState;X,Y:Integer);override;
    Procedure SelectedItemChanged;virtual;
    Procedure SetDragEnabled(Value:Boolean);virtual;
    Procedure SetDragPlaceColor(Value:TColor);virtual;
    Procedure SetHighlightColor(Value:TColor);virtual;
    Procedure SetHighlightFontColor(Value:TColor);virtual;
    Procedure SetHighlightSelection(Value:Boolean);virtual;
    Procedure SetScrollButtonsPos(Value:TScrollButtonsPos);virtual;
    Procedure SetSelectionType(Value:TSelectionType);virtual;
    Procedure SetSunkSelected(Value:Boolean);virtual;
    Procedure SetUseDblClick(Value:Boolean);virtual;
    Procedure SetWrapLineCount(Value:Integer);virtual;
    Procedure WMActivateApp(Var Message:TMessage);message WM_ACTIVATEAPP;
    Procedure WMCancelMode(Var Message:TMessage);message WM_CANCELMODE;
    Procedure WMCaptureChanged(Var Message:TMessage);message WM_CAPTURECHANGED;
    Procedure WMEraseBkGnd(Var Message:TMessage); message WM_ERASEBKGND;
    Procedure WMLButtonDblClick(Var Message:TWMMouse);message WM_LBUTTONDBLCLK;
    Procedure WMLButtonDown(Var Message:TWMMouse); message WM_LBUTTONDOWN;
    Procedure WMLButtonUp(Var Message:TWMMouse); message WM_LBUTTONUP;
    Procedure WMMouseWheel(Var Message:TMessage);message WM_MOUSEWHEEL;
    Procedure WMRButtonDblClick(Var Message:TWMMouse);message WM_RBUTTONDBLCLK;
    Procedure WMRButtonDown(Var Message:TWMMouse); message WM_RBUTTONDOWN;
    Procedure WMRButtonUp(Var Message:TWMMouse); message WM_RBUTTONUP;
    Procedure WMSetRedraw(Var Message:TMessage);message WM_SETREDRAW;
    Procedure WMSize(Var Message:TMessage);message WM_SIZE;
    Procedure WMStyleChanged(Var Message:TMessage);message WM_STYLECHANGED;
  public
    Constructor Create(AOwner:TComponent);override;
    Destructor Destroy;override;

    Procedure AddShortcut(const ACaption,AFileName,AParameters:String);
    Procedure CancelEdit;
    Procedure DeselectItem(Item:TListItem;IsDown:Boolean);
    Procedure DragDrop(Sender:TObject;X,Y:Integer);override;
    Procedure SelectItemImmediatly(Item:TListItem;IsDown:Boolean);

    Property DragItem:TListItem read FDragItem;
    Property DragPlace:Integer read FDragPlace;
    Property TopItem:TListItem read GetTopItem;

    Property HotItem:TListItem read FHotItem write SetHotItem;
  published
    Property DragEnabled:Boolean read FDragEnabled write SetDragEnabled default True;
    Property DragPlaceColor:TColor read FDragPlaceColor write SetDragPlaceColor default clBlack;
    Property Font:TFont read GetFont write SetFont;
    Property HighlightColor:TColor read FHighlightColor write SetHighlightColor default clBtnFace;
    Property HighlightFontColor:TColor read FHighlightFontColor write SetHighlightFontColor default clBlack;
    Property HighlightSelection:Boolean read FHighlightSelection write SetHighlightSelection default False;
    Property ItemSpace:Integer read FItemSpace write SetItemSpace default 10;
    Property OnAfterScroll:TNotifyEvent read FOnAfterScroll write FOnAfterScroll;
    Property OnBeforeScroll:TNotifyEvent read FOnBeforeScroll write FOnBeforeScroll;
    Property OnBeforeMouseDown : TBeforeMouseDownEvent read FOnBeforeMouseDown write FOnBeforeMouseDown;
    Property OnButtonClick:TListItemEvent read FOnButtonClick write FOnButtonClick;
    Property OnExecuteItem:TExecuteItemEvent read FOnExecuteItem write FOnExecuteItem;
    Property OnHotTrackItem:TListItemEvent read FOnHotTrackItem write FOnHotTrackItem;
    Property OnPopupMenu:TPopupMenuEvent read FOnPopupMenu write FOnPopupMenu;
    Property ScrollButtonsPos:TScrollButtonsPos read FScrollButtonsPos write SetScrollButtonsPos default spTopAndBottom;
    Property SelectionType:TSelectionType read FSelectionType write SetSelectionType default stStandard;
    Property SunkSelected:Boolean read FSunkSelected write SetSunkSelected default False;
    Property UseDblClick:Boolean read FuseDblClick write SetUseDblClick default False;
    Property ViewStyle:TViewStyle read GetViewStyle write InternalSetViewStyle default vsIcon;
    Property Version:TDCVersion read FVersion write FVersion stored False;
    Property WrapLineCount:Integer read FWrapLineCount write SetWrapLineCount default 1;

    Property Align;
    Property Color;
    Property DragCursor;
    Property Enabled;
    Property LargeImages;
    Property Items;
    Property OnChange;
    Property OnChanging;
    Property OnClick;
    Property OnDblClick;
    Property OnDeletion;
    Property OnDragDrop;
    Property OnDragOver;
    Property OnEdited;
    Property OnEditing;
    Property OnEndDrag;
    Property OnEnter;
    Property OnExit;
    Property OnInsert;
    Property OnKeyDown;
    Property OnKeyPress;
    Property OnKeyUp;
    Property OnMouseDown;
    Property OnMouseMove;
    Property OnMouseUp;
    Property ParentColor;
    Property ParentFont;
    Property ParentShowHint;
    Property PopupMenu;
    Property ReadOnly;
    Property ShowHint;
    Property SmallImages;
    Property Visible;

    {$IFDEF D4}
    Property Anchors;
    Property BiDiMode;
    Property Constraints;
    Property ParentBiDiMode;
    Property OnResize;
    Property OnSelectItem;
    {$ENDIF}
  end;

  TCustomDCGroupBar = Class ;

  TDCOutBarGroup=Class(TCustomControl)
  Private
    FCaption          : TCaption;
    FCaptionAlignment : TAlignment;
    FCaptionAutoSize  : Boolean;
    FCaptionHeight    : Integer;
    FOutBar           : TCustomDCGroupBar ;
    FVersion          : TDCVersion;

    Function GetListView:TDCVertListView;
    Procedure InitCaption;
    Procedure SetCaption (Const Value :TCaption) ;
    Procedure SetCaptionAlignment(Value:TAlignment);
    Procedure SetCaptionAutoSize(Value:Boolean);
    Procedure SetCaptionHeight(Value:Integer);
    Function  GetIndex:Integer ;
    Procedure SetIndex(Value:Integer);
    Procedure SetOutBar (Value : TCustomDCGroupBar) ;
    Procedure UpdateRects;
    Procedure WMEraseBkgnd (Var Message : TWMEraseBkgnd) ; Message WM_ERASEBKGND ;
  Protected
    Procedure CMColorChanged(Var Message:TMessage);message CM_COLORCHANGED;
    Procedure CMEnabledChanged(Var Message:TMessage);message CM_ENABLEDCHANGED;
    Procedure CMFontChanged(Var Message:TMessage);message CM_FONTCHANGED;
    Procedure CMShowingChanged(Var Message:TMessage);message CM_SHOWINGCHANGED;
    Procedure DoCaptionChanged;virtual;
    Function DoCaptionChanging(const NewCaption:TCaption):Boolean;virtual;
    Procedure Notification(Component:TComponent;Operation:TOperation);override;
    Procedure ReadState (Reader : TReader) ; Override ;
    Procedure Paint ; Override ;
    Procedure WMRButtonDown(Var Message:TMessage);message WM_RBUTTONDOWN;
  Public
    Constructor Create (AOwner : TComponent) ; Override ;
    Destructor Destroy;override;
    Procedure SetBounds (ALeft, ATop, AWidth, AHeight : Integer) ; Override ;
    Function  GetControlFromType (InstanceClass: TComponentClass) : TControl ;
    property  ListView:TDCVertListView read GetListView;

    Property OutBar : TCustomDCGroupBar Read FOutBar Write SetOutBar ;

  Published
    Property Caption:TCaption Read FCaption Write SetCaption ;
    Property CaptionAlignment:TAlignment read FCaptionAlignment write SetCaptionAlignment default taCenter;
    Property CaptionAutoSize:Boolean read FCaptionAutoSize write SetCaptionAutoSize default True;
    Property CaptionHeight:Integer read FCaptionHeight write SetCaptionHeight default 20;
    Property GroupIndex : Integer Read GetIndex write SetIndex stored False;
    Property Version:TDCVersion read FVersion write FVersion stored False;

    Property Canvas;
    Property HelpContext ;
    Property Enabled ;
    Property Cursor ;
    Property Font ;
    Property ParentFont ;
    Property Color ;
    Property Hint ;
    Property ShowHint ;
    Property ParentColor;
    Property ParentShowHint ;
    Property PopupMenu ;
    Property Left  ;
    Property Top ;
    Property Height ;
    Property Width ;
    Property OnMouseMove ;
    Property OnMouseDown ;
    Property OnMouseUp ;
    Property OnExit ;
    Property OnEnter ;
    Property OnDragDrop ;
    Property OnDragOver ;

  End ;

  TDCOutBarGroupEdit = Class (TCustomEdit)
  private
    FNGroup : Integer ;
    FCancelEdit : Boolean ;
    Procedure UpdateGroupCaption;
  Protected
    Procedure WMKillFocus (Var Message : TWMSetFocus) ; Message WM_KILLFOCUS ;
  Public
    Constructor Create (AOwner : TComponent) ; Override ;
    Procedure CreateParams (Var Params : TCreateParams) ; Override ;
    Procedure KeyPress (Var Key : Char) ; Override ;
    Procedure Show ;

  End ;

  TGroupCaptionChangeEvent=Procedure(Sender:TObject;Group:TDCOutbarGroup) Of Object;
  TGroupCaptionChangingEvent=Procedure(Sender:TObject;Group:TDCOutbarGroup;
                                       const NewGroupCaption:TCaption;Var CanChange:Boolean) Of Object;
  TGroupDrawEvent=Procedure(Sender:TObject;Group:TDCOutbarGroup;Const ARect:TRect;Var OwnerDraw:Boolean) Of Object;

  TGroupChangingEvent=Procedure(Sender:TObject;NewGroup:TDCOutbarGroup;Var AllowChange:Boolean) Of Object;

  TCustomDCGroupBar = Class (TCustomControl)
  Private
    FBorderStyle:TBorderStyle;
    FDragTimer : TTimer ;
    FDragGroup : Integer ;
    FGroups : TList ;
    FFlatGroups : Boolean ;
    FHotTrack : Boolean ;
    FOnGroupCaptionChanged:TGroupCaptionChangeEvent;
    FOnGroupCaptionChanging:TGroupCaptionChangingEvent;
    FOnGroupDraw:TGroupDrawEvent;
    FLoaded:Boolean;
    FActiveGroupIndex : Integer ;
    FLoadedCurrGroup : Integer ;
    FButtonSpace : Integer ;
    FButtonSpaceColor : TColor ;
    FHotColor : TColor ;
    FOnChange : TNotifyEvent ;
    FOnChanging : TGroupChangingEvent;
    FFrequency : Integer ;
    FCurrHotGroup : Integer ;
    FCurrCaptureGroup : Integer ;
    FActiveCaptureGroup : Boolean ;
    FTimerActive : Boolean ;
    FGroupEdit : TDCOutBarGroupEdit ;
    FVersion:TDCVersion;

    Procedure CancelEdit;
    Function  GetGroup (Index: Integer) : TDCOutBarGroup ;
    Function  GetGroupCount : Integer ;
    Procedure SetActiveGroup (Value : TDCOutBarGroup) ;
    Function  GetActiveGroup : TDCOutBarGroup ;
    procedure SetActiveGroupIndex (Value: Integer);
    Procedure SetFlatGroups (Value : Boolean) ;
    Procedure SetHotTrack (Value : Boolean) ;
    Procedure SetButtonSpace (Value : Integer) ;
    Procedure SetHotColor (Value : TColor) ;
    Procedure SetFrequency (Value : Integer) ;
    Procedure SetButtonSpaceColor (Value : TColor) ;
    Procedure OnDragTimer (Sender : TObject) ;

    Procedure CMCtl3dChanged(Var Message:TMessage);message CM_CTL3DCHANGED;
    Procedure SetBorderStyle(Value:TBorderStyle);
    Procedure WMCancelMode(Var Message:TMessage);message WM_CANCELMODE;
    Procedure WMCaptureChanged(Var Message:TMessage);message WM_CAPTURECHANGED;
    Procedure WMEraseBkgnd  (Var Message : TWmEraseBkgnd) ; Message WM_ERASEBKGND ;
    Procedure WMTimer (Var Msg : TWMTimer) ; Message WM_TIMER ;
    Procedure WMSize (Var Message : TWMSize) ; Message WM_SIZE ;
    Procedure WMSetCursor (Var Message : TWMSetCursor) ; Message WM_SETCURSOR ;
    Procedure CMFontChanged (Var Message : TMessage) ; Message CM_FONTCHANGED ;

    Function  GetButtonHeight(Group:Integer):Integer ;
    Function GroupEnabled(GroupIndex:Integer):Boolean;
    Function  GetActiveGroupRect : TRect ;
    Function  GetButtonRect (Index : Integer) : TRect ;
    Procedure UpdateButton (Index : Integer) ;
    Function  GetNGroupFromXY (X : Integer ; Y : Integer) : Integer ;
    Procedure InitGroupSize ;
    Procedure PaintBorder(Rect:TRect);
    Procedure UpdateHotGroup;
  Protected
    Procedure GetChildren (Proc : TGetChildProc{$IFDEF D3} ; Root : TComponent{$ENDIF}) ; Override ;
    Procedure CMDesignHitTest(Var Message:TCMDesignHitTest);message CM_DESIGNHITTEST;
    Procedure CreateParams (Var Params : TCreateParams) ; Override ;
    Function DoDrawGroup(Group:TDCOutbarGroup;Const ARect:TRect):Boolean;virtual;
    Procedure DoGroupCaptionChanged(Group:TDCOutbarGroup);virtual;
    Function DoGroupCaptionChanging(Group:TDCOutbarGroup;const NewGroupCaption:TCaption):Boolean;virtual;
    Procedure DoChange;dynamic;
    Function DoChanging(Group:TDCOutbarGroup):Boolean;dynamic;
    Procedure Loaded ; Override ;
    Procedure Paint ; 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 DragOver (Source : TObject ; X, Y : Integer ; State : TDragState ;
                        Var Accept : Boolean) ; Override ;

    Procedure SafeRemoveGroup (Group : TDCOutBarGroup) ;
    Procedure WMRButtonDown(Var Message:TWMMouse);message WM_RBUTTONDOWN;

    Property BorderStyle:TBorderStyle read FBorderStyle write SetBorderStyle;
  Public
    Constructor Create (AOwner : TComponent) ; Override ;
    Destructor  Destroy ; Override ;
    function AddNewGroup:TDCOutBarGroup;
    Procedure ExchangeGroup(Index1,Index2:Integer);
    Function GroupByName(const GroupName:String):TDCOutBarGroup;
    Procedure InsertGroup (Group : TDCOutBarGroup) ;
    Function  NewGroup:TDCOutBarGroup;Virtual;
    Procedure RemoveGroup (Group : TDCOutBarGroup) ;
    Procedure EditGroupCaption (Index : Integer) ;
    Procedure EditActiveGroupCaption ;
    procedure SelectNextGroup(GoForward : boolean);

    Property Canvas;
    Property Frequency : Integer Read FFrequency Write SetFrequency default 10;
    Property Groups[Index: Integer] : TDCOutBarGroup Read GetGroup ;
    Property GroupCount : Integer Read GetGroupCount ;
    Property ActiveGroup : TDCOutBarGroup Read GetActiveGroup Write SetActiveGroup ;
    Property ActiveGroupIndex : Integer Read FActiveGroupIndex Write SetActiveGroupIndex ;
    Property FlatGroups : Boolean Read FFlatGroups Write SetFlatGroups default True;
    Property HotTrack : Boolean Read FHotTrack Write SetHotTrack default False;
    Property ButtonSpace : Integer Read FButtonSpace Write SetButtonSpace default 1;
    Property ButtonSpaceColor : TColor Read FButtonSpaceColor Write SetButtonSpaceColor default clGray;
    Property HotColor : TColor Read FHotColor Write SetHotColor default clNavy;
    Property OnChange : TNotifyEvent Read FOnChange Write FOnChange ;
    Property OnChanging : TGroupChangingEvent Read FOnChanging Write FOnChanging ;
    Property OnGroupCaptionChanged:TGroupCaptionChangeEvent read FOnGroupCaptionChanged
                                                            write FOnGroupCaptionChanged;
    Property OnGroupCaptionChanging:TGroupCaptionChangingEvent read FOnGroupCaptionChanging
                                                            write FOnGroupCaptionChanging;
    Property OnGroupDraw:TGroupDrawEvent read FOnGroupDraw write FOnGroupDraw;
  Published
    Property Version:TDCVersion read FVersion write FVersion stored False;
  End ;

  TDCGroupBar = Class (TCustomDCGroupBar)
  Published
    Property ActiveGroupIndex ;
    Property BorderStyle;

⌨️ 快捷键说明

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