unit CHFrame;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TFrameCH =
class(TFrame)
private
{ Private-Deklarationen }
FCreate:Boolean;
FDPIStart:integer;
protected
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent);
override;
procedure ScaleForPPI(NewPPI: Integer);
override;
end;
implementation
{$R *.dfm}
constructor TFrameCH.Create(AOwner: TComponent);
var m:TMonitor;
begin
FCreate:=true;
m:=Screen.MonitorFromWindow(Application.MainForm.Handle, mdNearest);
FDPIStart:=m.PixelsPerInch;
inherited Create(AOwner);
if Self.PixelsPerInch <> m.PixelsPerInch
then
begin
ScaleControls(96, Self.PixelsPerInch);
end;
end;
procedure TFrameCH.ScaleForPPI(NewPPI: Integer);
var m:TMonitor;
begin
m:=Screen.MonitorFromWindow(Application.MainForm.Handle, mdNearest);
if not FCreate
then
begin
ScaleControls(m.PixelsPerInch, FDPIStart);
FDPIStart:=m.PixelsPerInch;
end
else
begin
Inherited;
FCreate:=false;
end;
end;
end.