Ignore:
Timestamp:
Jun 23, 2019, 3:15:29 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Use DpiControls package for High DPI support.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/CevoComponents/DrawDlg.pas

    r174 r178  
    77uses
    88  Classes, SysUtils, Forms, LCLIntf, LCLType, LMessages, Messages, Graphics,
    9   Controls, ButtonBase, ButtonA, ButtonB, Area, ScreenTools;
     9  Controls, ButtonBase, ButtonA, ButtonB, Area, ScreenTools, UDpiControls;
    1010
    1111type
    1212  { TDrawDlg }
    1313
    14   TDrawDlg = class(TForm)
     14  TDrawDlg = class(TDpiForm)
    1515  public
    1616    constructor Create(AOwner: TComponent); override;
    17     destructor Destroy; override;
    1817    procedure SmartInvalidate; virtual;
    19   private
    20     MoveFormPos: TPoint;
    21     MoveMousePos: TPoint;
    22     MoveActive: Boolean;
    23     procedure VisibleChangedHandler(Sender: TObject);
    2418  protected
    25     TitleHeight: Integer;
     19    TitleHeight: integer;
    2620    // defines area to grip the window for moving (from top)
    2721    procedure InitButtons;
    2822    procedure OnEraseBkgnd(var m: TMessage); message WM_ERASEBKGND;
    2923    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;
    3524  end;
    3625
     
    6958  inherited;
    7059  TitleHeight := 0;
    71   MoveActive := False;
    72   AddHandlerOnVisibleChanged(VisibleChangedHandler);
    73 end;
    74 
    75 destructor TDrawDlg.Destroy;
    76 begin
    77   RemoveHandlerOnVisibleChanging(VisibleChangedHandler);
    78   inherited Destroy;
    7960end;
    8061
     
    11798end;
    11899
    119 procedure TDrawDlg.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
    120   Y: Integer);
    121 var
    122   MousePosNew: TPoint;
    123   NewFormPos: TPoint;
    124 begin
    125   inherited;
    126   {$IFDEF LINUX}
    127   // HitTest is not supported under Linux GTK2 so use form inside move mechanizm
    128   NewFormPos := ScreenToClient(Mouse.CursorPos);
    129   if (NewFormPos.X >= 0) and (NewFormPos.X < Width) and
    130     (NewFormPos.Y >= 0) and (NewFormPos.Y < Height) then begin
    131     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 call
    135     if (MousePosNew.X = MoveMousePos.X) and (MousePosNew.Y = MoveMousePos.Y) then begin
    136       MoveActive := True;
    137     end;
    138   end else MoveActive := False;
    139   {$ENDIF}
    140 end;
    141 
    142 procedure TDrawDlg.MouseMove(Shift: TShiftState; X, Y: Integer);
    143 var
    144   MousePos: TPoint;
    145 begin
    146   inherited;
    147   if MoveActive then begin
    148     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 begin
    158   MoveActive := False;
    159   inherited;
    160 end;
    161 
    162 procedure TDrawDlg.MouseLeave;
    163 begin
    164   MoveActive := False;
    165   inherited;
    166 end;
    167 
    168 procedure TDrawDlg.VisibleChangedHandler(Sender: TObject);
    169 begin
    170   MoveActive := False;
    171 end;
    172 
    173100procedure TDrawDlg.InitButtons;
    174101var
     
    230157begin
    231158  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),
    233160    ClientHeight - (6 + 2 * Border));
    234161  for i := 0 to Border do
Note: See TracChangeset for help on using the changeset viewer.