Changeset 178 for branches/highdpi/Packages/CevoComponents/DrawDlg.pas
- Timestamp:
- Jun 23, 2019, 3:15:29 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/DrawDlg.pas
r174 r178 7 7 uses 8 8 Classes, SysUtils, Forms, LCLIntf, LCLType, LMessages, Messages, Graphics, 9 Controls, ButtonBase, ButtonA, ButtonB, Area, ScreenTools ;9 Controls, ButtonBase, ButtonA, ButtonB, Area, ScreenTools, UDpiControls; 10 10 11 11 type 12 12 { TDrawDlg } 13 13 14 TDrawDlg = class(T Form)14 TDrawDlg = class(TDpiForm) 15 15 public 16 16 constructor Create(AOwner: TComponent); override; 17 destructor Destroy; override;18 17 procedure SmartInvalidate; virtual; 19 private20 MoveFormPos: TPoint;21 MoveMousePos: TPoint;22 MoveActive: Boolean;23 procedure VisibleChangedHandler(Sender: TObject);24 18 protected 25 TitleHeight: Integer;19 TitleHeight: integer; 26 20 // defines area to grip the window for moving (from top) 27 21 procedure InitButtons; 28 22 procedure OnEraseBkgnd(var m: TMessage); message WM_ERASEBKGND; 29 23 procedure OnHitTest(var Msg: TMessage); message WM_NCHITTEST; 30 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);31 override;32 procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;33 procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;34 procedure MouseLeave; override;35 24 end; 36 25 … … 69 58 inherited; 70 59 TitleHeight := 0; 71 MoveActive := False;72 AddHandlerOnVisibleChanged(VisibleChangedHandler);73 end;74 75 destructor TDrawDlg.Destroy;76 begin77 RemoveHandlerOnVisibleChanging(VisibleChangedHandler);78 inherited Destroy;79 60 end; 80 61 … … 117 98 end; 118 99 119 procedure TDrawDlg.MouseDown(Button: TMouseButton; Shift: TShiftState; X,120 Y: Integer);121 var122 MousePosNew: TPoint;123 NewFormPos: TPoint;124 begin125 inherited;126 {$IFDEF LINUX}127 // HitTest is not supported under Linux GTK2 so use form inside move mechanizm128 NewFormPos := ScreenToClient(Mouse.CursorPos);129 if (NewFormPos.X >= 0) and (NewFormPos.X < Width) and130 (NewFormPos.Y >= 0) and (NewFormPos.Y < Height) then begin131 MoveMousePos := ClientToScreen(Point(X, Y));132 MoveFormPos := Point(Left, Top);133 MousePosNew := Mouse.CursorPos;134 // Activate move only if mouse position was not changed during inherited call135 if (MousePosNew.X = MoveMousePos.X) and (MousePosNew.Y = MoveMousePos.Y) then begin136 MoveActive := True;137 end;138 end else MoveActive := False;139 {$ENDIF}140 end;141 142 procedure TDrawDlg.MouseMove(Shift: TShiftState; X, Y: Integer);143 var144 MousePos: TPoint;145 begin146 inherited;147 if MoveActive then begin148 MousePos := ClientToScreen(Point(X, Y));149 SetBounds(MoveFormPos.X + MousePos.X - MoveMousePos.X,150 MoveFormPos.Y + MousePos.Y - MoveMousePos.Y,151 Width, Height);152 end;153 end;154 155 procedure TDrawDlg.MouseUp(Button: TMouseButton; Shift: TShiftState; X,156 Y: Integer);157 begin158 MoveActive := False;159 inherited;160 end;161 162 procedure TDrawDlg.MouseLeave;163 begin164 MoveActive := False;165 inherited;166 end;167 168 procedure TDrawDlg.VisibleChangedHandler(Sender: TObject);169 begin170 MoveActive := False;171 end;172 173 100 procedure TDrawDlg.InitButtons; 174 101 var … … 230 157 begin 231 158 if csDesigning in ComponentState then Exit; 232 PaintBackground( self, 3 + Border, 3 + Border, ClientWidth - (6 + 2 * Border),159 PaintBackground(Self, 3 + Border, 3 + Border, ClientWidth - (6 + 2 * Border), 233 160 ClientHeight - (6 + 2 * Border)); 234 161 for i := 0 to Border do
Note:
See TracChangeset
for help on using the changeset viewer.