📄 flatboxs.pas
字号:
unit FlatBoxs;
interface
{$P+,S-,W-,R-,T-,X+,H+,B-}
{$I FlatStyle.inc}
uses
Windows, Messages, Classes, Forms, Controls, Graphics, StdCtrls, FlatUtilitys,
SysUtils, ShellApi, Commctrl, comctrls, Consts, ExtCtrls, DBCtrls, Dialogs,
DB;
type
{ TBOXLabel }
TBOXLabel = class(TCustomLabel)
private
function GetTop: Integer;
function GetLeft: Integer;
function GetWidth: Integer;
function GetHeight: Integer;
procedure SetHeight(const Value: Integer);
procedure SetWidth(const Value: Integer);
protected
procedure AdjustBounds; override;
public
constructor Create(AOwner: TComponent); override;
published
property BiDiMode;
property Caption;
property Color;
property DragCursor;
property DragKind;
property DragMode;
property Font;
property Height: Integer read GetHeight write SetHeight;
property Left: Integer read GetLeft;
property ParentBiDiMode;
property ParentColor;
property ParentFont;
property Top: Integer read GetTop;
property Transparent;
property Layout;
property WordWrap;
property Width: Integer read GetWidth write SetWidth;
{
property ParentShowHint;
property PopupMenu;
property ShowAccelChar;
property ShowHint;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;}
end;
TFlatComboBox = class(TCustomComboBox)
private
FArrowColor: TColor;
FArrowBackgroundColor: TColor;
FBorderColor: TColor;
FUseAdvColors: Boolean;
FAdvColorArrowBackground: TAdvColors;
FAdvColorBorder: TAdvColors;
FButtonWidth: Integer;
FChildHandle: HWND;
FDefListProc: Pointer;
FListHandle: HWND;
FListInstance: Pointer;
FSysBtnWidth: Integer;
FSolidBorder: Boolean;
FLabelSpacing: Integer;
FEditLabel: TBOXLabel;
MouseInControl: Boolean;
FLabelPosition: TLabelPosition;
FFocusedColor: TColor;
FFlatColor: TColor;
fParentColor: Boolean;
procedure SetColors (Index: Integer; Value: TColor);
procedure SetAdvColors (Index: Integer; Value: TAdvColors);
procedure SetUseAdvColors (Value: Boolean);
function GetButtonRect: TRect;
procedure PaintButton;
procedure PaintBorder;
procedure RedrawBorders;
procedure InvalidateSelection;
function GetSolidBorder: Boolean;
procedure SetSolidBorder;
procedure SetParentColor(const Value: Boolean);
protected
procedure ListWndProc (var Message: TMessage);
procedure WMSetFocus (var Message: TMessage); message WM_SETFOCUS;
procedure WMKillFocus (var Message: TMessage); message WM_KILLFOCUS;
procedure CMMouseEnter (var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave (var Message: TMessage); message CM_MOUSELEAVE;
procedure WMKeyDown (var Message: TMessage); message WM_KEYDOWN;
procedure WMPaint (var Message: TWMPaint); message WM_PAINT;
procedure WMNCPaint (var Message: TMessage); message WM_NCPAINT;
procedure CMEnabledChanged (var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure CNCommand (var Message: TWMCommand); message CN_COMMAND;
procedure CMFontChanged (var Message: TMessage); message CM_FONTCHANGED;
procedure CMSysColorChange (var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMParentColorChanged (var Message: TWMNoParams); message CM_PARENTCOLORCHANGED;
procedure CalcAdvColors;
procedure WndProc (var Message: TMessage); override;
procedure ComboWndProc (var Message: TMessage; ComboWnd: HWnd; ComboProc: Pointer); override;
procedure SetLBPosition(const Value: TLabelPosition);
procedure SetLabelSpacing(const Value: Integer);
procedure SetName(const Value: TComponentName); override;
procedure CMVisiblechanged(var Message: TMessage); message CM_VISIBLECHANGED;
procedure CMBidimodechanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure SetParent(AParent: TWinControl); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
property SolidBorder: Boolean read FSolidBorder;
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
procedure SetupInternalLabel;
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
published
property EditLabel: TBOXLabel read FEditLabel;
property LabelPosition: TLabelPosition read FLabelPosition write SetLBPosition default lpLeft;
property LabelSpacing: Integer read FLabelSpacing write SetLabelSpacing;
property Style;
// property Color default $00E1EAEB;
property ParentColor: Boolean read fParentColor write SetParentColor default true;
property ColorFlat: TColor index 3 read FFlatColor write SetColors default $00E1EAEB;
property ColorFocued: TColor index 4 read FFocusedColor write SetColors default clWhite;
property ColorArrow: TColor index 0 read FArrowColor write SetColors default clBlack;
property ColorArrowBackground: TColor index 1 read FArrowBackgroundColor write SetColors default $00C5D6D9;
property ColorBorder: TColor index 2 read FBorderColor write SetColors default $004080FF;
property AdvColorBorder: TAdvColors index 0 read FAdvColorBorder write SetAdvColors default 50;
property AdvColorArrowBackground: TAdvColors index 1 read FAdvColorArrowBackground write SetAdvColors default 10;
property UseAdvColors: Boolean read FUseAdvColors write SetUseAdvColors default false;
property DragMode;
property DragCursor;
property DropDownCount;
property Enabled;
property Font;
property ItemHeight;
property Items;
property MaxLength;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Text;
property Visible;
property ItemIndex;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDrawItem;
property OnDropDown;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnStartDrag;
{$IFDEF DFS_DELPHI_4_UP}
property Anchors;
property BiDiMode;
property Constraints;
property DragKind;
property ParentBiDiMode;
property OnEndDock;
property OnStartDock;
{$ENDIF}
end;
TFlatDBComboBox = class(TDBComboBox)
private
FArrowColor: TColor;
FArrowBackgroundColor: TColor;
FBorderColor: TColor;
FUseAdvColors: Boolean;
FAdvColorArrowBackground: TAdvColors;
FAdvColorBorder: TAdvColors;
FButtonWidth: Integer;
FChildHandle: HWND;
FDefListProc: Pointer;
FListHandle: HWND;
FListInstance: Pointer;
FSysBtnWidth: Integer;
FSolidBorder: Boolean;
procedure SetColors (Index: Integer; Value: TColor);
procedure SetAdvColors (Index: Integer; Value: TAdvColors);
procedure SetUseAdvColors (Value: Boolean);
function GetButtonRect: TRect;
procedure PaintButton;
procedure PaintBorder;
procedure RedrawBorders;
procedure InvalidateSelection;
function GetSolidBorder: Boolean;
procedure SetSolidBorder;
procedure ListWndProc (var Message: TMessage);
procedure WMSetFocus (var Message: TMessage); message WM_SETFOCUS;
procedure WMKillFocus (var Message: TMessage); message WM_KILLFOCUS;
procedure WMKeyDown (var Message: TMessage); message WM_KEYDOWN;
procedure WMPaint (var Message: TWMPaint); message WM_PAINT;
procedure WMNCPaint (var Message: TMessage); message WM_NCPAINT;
procedure CMEnabledChanged (var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure CNCommand (var Message: TWMCommand); message CN_COMMAND;
procedure CMFontChanged (var Message: TMessage); message CM_FONTCHANGED;
procedure CMSysColorChange (var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMParentColorChanged (var Message: TWMNoParams); message CM_PARENTCOLORCHANGED;
protected
procedure CalcAdvColors;
procedure WndProc (var Message: TMessage); override;
procedure ComboWndProc (var Message: TMessage; ComboWnd: HWnd; ComboProc: Pointer); override;
property SolidBorder: Boolean read FSolidBorder;
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
published
// property EditLabel;
// property LabelPosition;
// property LabelSpacing;
property Style;
property Color default $00E1EAEB;
property ColorArrow: TColor index 0 read FArrowColor write SetColors default clBlack;
property ColorArrowBackground: TColor index 1 read FArrowBackgroundColor write SetColors default $00C5D6D9;
property ColorBorder: TColor index 2 read FBorderColor write SetColors default $004080FF;
property AdvColorBorder: TAdvColors index 0 read FAdvColorBorder write SetAdvColors default 50;
property AdvColorArrowBackground: TAdvColors index 1 read FAdvColorArrowBackground write SetAdvColors default 10;
property UseAdvColors: Boolean read FUseAdvColors write SetUseAdvColors default false;
property DragMode;
property DragCursor;
property DropDownCount;
property Enabled;
property Font;
property ItemHeight;
property Items;
property MaxLength;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Text;
property Visible;
property ItemIndex;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDrawItem;
property OnDropDown;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnStartDrag;
{$IFDEF DFS_DELPHI_4_UP}
property Anchors;
property BiDiMode;
property Constraints;
property DragKind;
property ParentBiDiMode;
property OnEndDock;
property OnStartDock;
{$ENDIF}
end;
TFlatColorBox = class(TCustomComboBox)
private
FArrowColor: TColor;
FArrowBackgroundColor: TColor;
FBorderColor: TColor;
FHighlightColor: TColor;
FUseAdvColors: Boolean;
FAdvColorArrowBackground: TAdvColors;
FAdvColorBorder: TAdvColors;
FAdvColorHighlight: TAdvColors;
FButtonWidth: Integer;
FChildHandle: HWND;
FDefListProc: Pointer;
FListHandle: HWND;
FListInstance: Pointer;
FSysBtnWidth: Integer;
FSolidBorder: Boolean;
FShowNames: Boolean;
FValue: TColor;
FColorBoxWidth: Integer;
FColorDlg: TColorDialog;
FLabelSpacing: Integer;
FListLabel: TBOXLabel;
FLabelPosition: TLabelPosition;
procedure SetColors (Index: Integer; Value: TColor);
procedure SetAdvColors (Index: Integer; Value: TAdvColors);
procedure SetUseAdvColors (Value: Boolean);
function GetButtonRect: TRect;
procedure PaintButton;
procedure PaintBorder;
procedure RedrawBorders;
procedure InvalidateSelection;
function GetSolidBorder: Boolean;
procedure SetSolidBorder;
procedure ListWndProc (var Message: TMessage);
procedure WMSetFocus (var Message: TMessage); message WM_SETFOCUS;
procedure WMKillFocus (var Message: TMessage); message WM_KILLFOCUS;
procedure WMKeyDown (var Message: TMessage); message WM_KEYDOWN;
procedure WMPaint (var Message: TWMPaint); message WM_PAINT;
procedure WMNCPaint (var Message: TMessage); message WM_NCPAINT;
procedure CMEnabledChanged (var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure CNCommand (var Message: TWMCommand); message CN_COMMAND;
procedure CMFontChanged (var Message: TMessage); message CM_FONTCHANGED;
procedure CMSysColorChange (var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMParentColorChanged (var Message: TWMNoParams); message CM_PARENTCOLORCHANGED;
procedure SetShowNames(Value: Boolean);
procedure SetColorValue(Value: TColor);
procedure SetColorBoxWidth(Value: Integer);
procedure SetLBPosition(const Value: TLabelPosition);
procedure SetLabelSpacing(const Value: Integer);
protected
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
procedure CreateWnd; override;
procedure WndProc (var Message: TMessage); override;
procedure ComboWndProc (var Message: TMessage; ComboWnd: HWnd; ComboProc: Pointer); override;
procedure CalcAdvColors;
property SolidBorder: Boolean read FSolidBorder;
procedure Click; override;
procedure SetName(const Value: TComponentName); override;
procedure CMVisiblechanged(var Message: TMessage); message CM_VISIBLECHANGED;
procedure CMBidimodechanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure SetParent(AParent: TWinControl); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetupInternalLabel;
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
function AddColor(ColorName: String; Color: TColor): Boolean;
function DeleteColorByName(ColorName: String): Boolean;
function DeleteColorByColor(Color: TColor): Boolean;
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
published
property Color default $00E1EAEB;
property ColorArrow: TColor index 0 read FArrowColor write SetColors default clBlack;
property ColorArrowBackground: TColor index 1 read FArrowBackgroundColor write SetColors default $00C5D6D9;
property ColorBorder: TColor index 2 read FBorderColor write SetColors default $004080FF;
property ColorHighlight: TColor index 3 read FHighlightColor write SetColors default clHighlight;
property AdvColorBorder: TAdvColors index 0 read FAdvColorBorder write SetAdvColors default 50;
property AdvColorArrowBackground: TAdvColors index 1 read FAdvColorArrowBackground write SetAdvColors default 10;
property AdvColorHighlight: TAdvColors index 2 read FAdvColorHighlight write SetAdvColors default 50;
property UseAdvColors: Boolean read FUseAdvColors write SetUseAdvColors default False;
property BoxWidth: Integer read FColorBoxWidth write SetColorBoxWidth;
property ShowNames: Boolean read FShowNames write SetShowNames;
property Value: TColor read FValue write SetColorValue;
property ListLabel: TBOXLabel read FListLabel;
property LabelPosition: TLabelPosition read FLabelPosition write SetLBPosition default lpLeft;
property LabelSpacing: Integer read FLabelSpacing write SetLabelSpacing default 3;
property DragMode;
property DragCursor;
property DropDownCount;
property Enabled;
property Font;
property MaxLength;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Visible;
property OnChange;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -