Changeset 61 for trunk/Packages/Common
- Timestamp:
- Dec 4, 2014, 11:26:54 AM (10 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.lpk
r59 r61 102 102 <Item20> 103 103 <Filename Value="UScaleDPI.pas"/> 104 <HasRegisterProc Value="True"/> 104 105 <UnitName Value="UScaleDPI"/> 105 106 </Item20> -
trunk/Packages/Common/Common.pas
r59 r61 24 24 RegisterUnit('UPersistentForm', @UPersistentForm.Register); 25 25 RegisterUnit('UFindFile', @UFindFile.Register); 26 RegisterUnit('UScaleDPI', @UScaleDPI.Register); 26 27 end; 27 28 -
trunk/Packages/Common/UScaleDPI.pas
r59 r61 14 14 { TScaleDPI } 15 15 16 TScaleDPI = class 16 TScaleDPI = class(TComponent) 17 17 private 18 18 FAutoDetect: Boolean; … … 27 27 function ScaleX(Size: Integer; FromDPI: Integer): Integer; 28 28 function ScaleY(Size: Integer; FromDPI: Integer): Integer; 29 constructor Create; 29 constructor Create(AOwner: TComponent); 30 published 30 31 property AutoDetect: Boolean read FAutoDetect write SetAutoDetect; 31 32 end; 32 33 34 procedure Register; 33 35 34 36 implementation 37 38 procedure Register; 39 begin 40 RegisterComponents('Common', [TScaleDPI]); 41 end; 35 42 36 43 procedure TScaleDPI.SetAutoDetect(AValue: Boolean); … … 59 66 I: Integer; 60 67 begin 61 if (DPI.X <= FromDPI.X * 1.1) or (DPI.Y <= FromDPI.Y * 1.1) then Exit;62 63 68 NewWidth := ScaleX(ImgList.Width, FromDPI.X); 64 69 NewHeight := ScaleY(ImgList.Height, FromDPI.Y); … … 97 102 function TScaleDPI.ScaleX(Size: Integer; FromDPI: Integer): Integer; 98 103 begin 99 if DPI.X <= FromDPI then 100 Result := Size 101 else 102 Result := MulDiv(Size, DPI.X, FromDPI); 104 Result := MulDiv(Size, DPI.X, FromDPI); 103 105 end; 104 106 105 107 function TScaleDPI.ScaleY(Size: Integer; FromDPI: Integer): Integer; 106 108 begin 107 if Screen.PixelsPerInch <= FromDPI then 108 Result := Size 109 else 110 Result := MulDiv(Size, DPI.Y, FromDPI); 109 Result := MulDiv(Size, DPI.Y, FromDPI); 111 110 end; 112 111 … … 117 116 end; 118 117 119 constructor TScaleDPI.Create ;118 constructor TScaleDPI.Create(AOwner: TComponent); 120 119 begin 120 inherited; 121 121 DPI := Point(96, 96); 122 122 DesignDPI := Point(96, 96); … … 129 129 ToolBarControl: TToolBar; 130 130 begin 131 if (DPI.X <= FromDPI.X) or (DPI.Y <= FromDPI.Y) then Exit;132 133 131 with Control do begin 134 132 Left := ScaleX(Left, FromDPI.X);
Note:
See TracChangeset
for help on using the changeset viewer.