5,388
社区成员
发帖
与我相关
我的任务
分享
unit SkinScrollBox;
interface
uses
Windows,SysUtils,Classes,Controls,Forms,GdiPlus,Messages,Graphics,Types;
type
TSkinScrollBox=class(TScrollBox)
private
FBufferBitmap:TBitmap;
protected
procedure WMEraseBkGnd(var Message:TWMEraseBkGnd);message WM_ERASEBKGND;
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure PaintWindow(DC: HDC); override;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
public
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
published
property Align;
property Anchors;
property AutoScroll;
property AutoSize;
property BevelEdges;
property BevelInner;
property BevelOuter;
property BevelKind;
property BevelWidth;
property BiDiMode;
property BorderStyle;
property Constraints;
property DockSite;
property DoubleBuffered;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Color;
property Ctl3D;
property Font;
property Padding;
property ParentBiDiMode;
property ParentBackground default False;
property ParentColor;
property ParentCtl3D;
property ParentDoubleBuffered;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Touch;
property Visible;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGesture;
property OnGetSiteInfo;
property OnMouseActivate;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('SkinEngine',[TSkinScrollBox]);
end;
{ TSkinScrollBox }
constructor TSkinScrollBox.Create(AOwner: TComponent);
begin
inherited;
FBufferBitmap:=TBitmap.Create;
end;
destructor TSkinScrollBox.Destroy;
begin
FBufferBitmap.Free;
inherited;
end;
procedure TSkinScrollBox.PaintWindow(DC: HDC);
var
Brush:IGpLinearGradientBrush;
Graphics:IGPGraphics;
ClientWidth,ClientHeight:Integer;
GPRect:TGPRect;
begin
if (Height=0) or (Width=0) then Exit;
ClientWidth:=RectWidth(ClientRect);
ClientHeight:=RectHeight(ClientRect);
if (ClientHeight<>Self.FBufferBitmap.Height)
or (ClientWidth<>Self.FBufferBitmap.Width) then
begin
Self.FBufferBitmap.SetSize(ClientWidth,ClientHeight);
Graphics:=TGPGraphics.Create(Self.FBufferBitmap.Canvas.Handle);
GPRect:=TGPRect.Create(ClientRect);
Brush:=TGpLinearGradientBrush.Create(GPRect,
TGPColor.Blue,
TGPColor.Gray,
TGPLinearGradientMode.LinearGradientModeVertical);
Graphics.FillRectangle(Brush,GPRect);
end;
BitBlt(DC,0,0,ClientWidth,ClientHeight,
Self.FBufferBitmap.Canvas.Handle,0,0,SRCCOPY);
end;
procedure TSkinScrollBox.WMEraseBkGnd(var Message: TWMEraseBkGnd);
begin
Message.Result:=1;
end;
procedure TSkinScrollBox.WMHScroll(var Message: TWMHScroll);
begin
Inherited;
Invalidate;
end;
procedure TSkinScrollBox.WMPaint(var Message: TWMPaint);
begin
ControlState:=ControlState+[csCustomPaint];
inherited;
ControlState:=ControlState-[csCustomPaint];
end;
procedure TSkinScrollBox.WMSize(var Message: TWMSize);
begin
inherited;
Invalidate;
end;
procedure TSkinScrollBox.WMVScroll(var Message: TWMVScroll);
begin
Inherited;
Invalidate;
end;
end.