- unit DrawPanel;
- interface
- uses
- Windows, SysUtils, Messages, Classes, Controls, ExtCtrls;
- type
- TMsgProc=procedure (var Msg:TMessage; DefaultProcess:Boolean) of Object;
- TDrawPanel = class(TCustomPanel)
- private
- FOnPaint: TNotifyEvent;
- FEraseBackground: Boolean;
- FOnBeforeMsg: TMsgProc;
- FOnAfterMsg: TMsgProc;
- procedure SetOnPaint(const Value: TNotifyEvent);
- procedure WMERASEBKGND(var Msg:TWMERASEBKGND); Message WM_ERASEBKGND;
- procedure SetEraseBackground(const Value: Boolean);
- procedure SetOnAfterMsg(const Value: TMsgProc);
- procedure SetOnBeforeMsg(const Value: TMsgProc);
- { Private declarations }
- protected
- procedure Paint;override;
- procedure WndProc(var Msg:TMessage); override;
- { Protected declarations }
- public
- Constructor Create(Owner:TComponent);override;
- property DockManager;
- property Canvas;
- published
- property EraseBackground:Boolean read FEraseBackground write SetEraseBackground;
- property OnPaint:TNotifyEvent read FOnPaint write SetOnPaint;
- property Align;
- property Alignment;
- property Anchors;
- property AutoSize;
- property BevelInner;
- property BevelOuter;
- property BevelWidth;
- property BiDiMode;
- property BorderWidth;
- property BorderStyle;
- property Caption;
- property Color;
- property Constraints;
- property Ctl3D;
- property UseDockManager default True;
- property DockSite;
- property DragCursor;
- property DragKind;
- property DragMode;
- property Enabled;
- property FullRepaint;
- property Font;
- property Locked;
- 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;
- property OnBeforeMsg:TMsgProc read FOnBeforeMsg write SetOnBeforeMsg;
- property OnAfterMsg:TMsgProc read FOnAfterMsg write SetOnAfterMsg;
- end;
- procedure Register;
- implementation
- procedure Register;
- begin
- RegisterComponents('WH', [TDrawPanel]);
- end;
- { TDrawPanel }
- constructor TDrawPanel.Create(Owner: TComponent);
- begin
- inherited;
- FEraseBackground:=true;
- end;
- procedure TDrawPanel.Paint;
- begin
- inherited;
- if Assigned(FOnPaint) then
- FOnPaint(Self);
- end;
- procedure TDrawPanel.SetEraseBackground(const Value: Boolean);
- begin
- FEraseBackground := Value;
- end;
- procedure TDrawPanel.SetOnAfterMsg(const Value: TMsgProc);
- begin
- FOnAfterMsg := Value;
- end;
- procedure TDrawPanel.SetOnBeforeMsg(const Value: TMsgProc);
- begin
- FOnBeforeMsg := Value;
- end;
- procedure TDrawPanel.SetOnPaint(const Value: TNotifyEvent);
- begin
- FOnPaint := Value;
- end;
- procedure TDrawPanel.WMERASEBKGND(var Msg: TWMERASEBKGND);
- Var
- Rec:TRect;
- begin
- if FEraseBackground then
- begin
- Inherited;
- end
- else
- begin
- Rec:=Self.GetClientRect();
- ValidateRect(Handle,@Rec);
- end;
- end;
- procedure TDrawPanel.WndProc(var Msg: TMessage);
- Var
- b:Boolean;
- begin
- b:=true;
- if Assigned(FOnBeforeMsg) then
- begin
- FOnBeforeMsg(Msg,b);
- if Not b then
- Exit;
- end;
- inherited;
- b:=true;
- if Assigned(FOnAfterMsg) then
- begin
- FOnAfterMsg(Msg,b);
- if Not b then
- Exit;
- end;
- end;
- end.