1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
TKMultiPanel = class(TWinControl)
private
FPanel1 : TPanel;
FPanel2 : TPanel;
FTransparent:boolean;
FOnPaint: TNotifyEvent;
procedure SetPanel1(const Value: TPanel);
procedure SetPanel2(const Value: TPanel);
function GetTransparent: Boolean;
procedure SetTransparent(const Value: Boolean);
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
property DockManager;
published
property Panel1 : TPanel read FPanel1 Write SetPanel1;
property Panel2 : TPanel read FPanel2 Write SetPanel2;
property Transparent: Boolean read GetTransparent write SetTransparent
default True;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
property Align;
property Anchors;
property AutoSize;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BiDiMode;
property BorderWidth;
property Caption;
property Color;
property Constraints;
property Ctl3D;
property UseDockManager default True;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property ParentBiDiMode;
property ParentBackground;
//property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
procedure TKMultiPanel.Paint;
begin
if Assigned(FOnPaint) then
begin
FOnPaint(Self);
Exit;
end;
Canvas.Font := Self.Font;
Canvas.Brush.Color := Color;
if not Transparent or ThemeServices.ThemesEnabled then
DrawThemedBackground(Self, Canvas, ClientRect)
else
Canvas.Brush.Style := bsClear;
end;
procedure TKMultiPanel.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if Transparent and not ThemeServices.ThemesEnabled then
begin
// (rom) gives a better look in IDE if always set (not fully correct though)
//if not (csDesigning in ComponentState) then
Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
ControlStyle := ControlStyle - [csOpaque];
end
else
begin
//if not (csDesigning in ComponentState) then
Params.ExStyle := Params.ExStyle and not WS_EX_TRANSPARENT;
ControlStyle := ControlStyle + [csOpaque];
end;
end;
procedure TKMultiPanel.SetTransparent(const Value: Boolean);
begin
if Value <> FTransparent then
begin
FTransparent := Value;
with ThemeServices do
if not ThemesEnabled then
begin
RecreateWnd;
end;
end;
end;
function TKMultiPanel.GetTransparent: Boolean;
begin
Result := not (csOpaque in ControlStyle);
end;
procedure TKMultiPanel.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
//Ici tu gère le placement de tes Panels et leur taille
...
end; |
Partager