expertcad/POWERCAD30/UNITS/PaintBoxExt.pas
2025-05-12 10:07:51 +03:00

75 lines
1.9 KiB
ObjectPascal

unit PaintBoxExt;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls,Buttons,CanvasPanel;
type
TPaintBoxExt = class(TPaintbox)
private
{ Private declarations }
FOnMouseLeave: TNotifyEvent;
FOnMiddleDblClick: TNotifyEvent;
protected
{ Protected declarations }
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure WMMButtonDblClk(var Message: TWMMButtonDblClk); message WM_MBUTTONDBLCLK;
procedure MouseWheelHandler(var Message: TMessage); override;
public
{ Public declarations }
Wnd: HWND;
Constructor Create(AOwner:TComponent);override;
property WheelAccumulator;
published
{ Published declarations }
(*Property OnMouseMove;
Property OnClick;
Property OnDblClick;
Property OnDragDrop;
Property OnEndDrag;
Property OnDragOver;
Property OnStartDrag;
Property OnMouseUp;
Property OnMouseDown;
*)
property OnMouseLeave:TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
property OnMiddleDblClick:TNotifyEvent read FOnMiddleDblClick write FOnMiddleDblClick;
property OnMouseWheel;
end;
implementation
Procedure TPaintBoxExt.CMMouseLeave(var Message: TMessage);
begin
if assigned(FOnMouseLeave) then FOnMouseLeave(self);
end;
constructor TPaintBoxExt.Create(AOwner: TComponent);
begin
inherited;
//ControlStyle := ControlStyle - [csOpaque];
end;
procedure TPaintBoxExt.MouseWheelHandler(var Message: TMessage);
begin
//Form := GetParentForm(Self);
//if (Form <> nil) and (Form <> Self) then Form.MouseWheelHandler(TMessage(Message))
//else
with TMessage(Message) do
Result := Perform(CM_MOUSEWHEEL, WParam, LParam);
end;
procedure TPaintBoxExt.WMMButtonDblClk(var Message: TWMMButtonDblClk);
begin
FOnMiddleDblClick(Self);
end;
end.