Siema, chciałbym rysować po swoim scrollbarze, ale on nie ma klasy canvas, ale wiem że rysować się da, jednak nie znalazłem żadnego info o tym:)
0
0
Stworzyć komponent dziedziczący po TScrollBar i dodać mu taką własność oraz jego obsługę. Poniżej prosty przykład jak srobiłem to kiedyś dla TScrollBoxa. Myślę, że raczej powinieneś kombinować w tym kierunku.
unit canvasedscrollbox;
interface
uses
Windows, Messages, Classes, Controls, Forms, Graphics;
type
TCanvasedScrollBox = class(TScrollBox)
private
FBmp : TBitmap;
FCanvas : TCanvas;
procedure SetBitmap(Value : TBitmap);
protected
procedure WMPaint(var Message : TMessage); message WM_PAINT;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
property Bitmap : TBitmap read FBmp write SetBitmap;
property Canvas : TCanvas read FCanvas;
end;
implementation
constructor TCanvasedScrollBox.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csSetCaption, csDoubleClicks];
Width := 185;
Height := 41;
BorderStyle := bsSingle;
FBmp := TBitmap.Create;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
end;
destructor TCanvasedScrollBox.Destroy;
begin
FBmp.Free;
FCanvas.Free;
inherited Destroy;
end;
procedure TCanvasedScrollBox.SetBitmap(Value : TBitmap);
begin
FBmp.Assign(Value);
SendMessage(Handle, WM_PAINT, 0, 0);
end;
procedure TCanvasedScrollBox.WMPaint(var Message : TMessage);
begin
if Assigned(FBmp) then
Canvas.Draw(0, 0, FBmp);
inherited;
end;
end.