Ignore:
Timestamp:
Jan 7, 2024, 10:24:51 PM (4 months ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
  • Added: High DPI aware SetWindowPos function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/DpiControls/Dpi.Common.pas

    r520 r522  
    2121function ScrollDC(Canvas: TCanvas; dx: Longint; dy: Longint; const lprcScroll: TRect;
    2222  const lprcClip:TRect; hrgnUpdate: Handle; lprcUpdate: PRect): Boolean; overload;
     23function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
     24  X, Y, cx, cy: Integer; uFlags: UINT): Boolean;
    2325function ScaleToNative(Value: Integer): Integer;
    2426function ScaleToNativeDist(Base, Value: Integer): Integer;
     
    8486end;
    8587
    86 function Ceil(const X: Single): Integer;
    87 begin
    88   if X > High(Integer) then
    89     Result := High(Integer)
    90   else if X < Low(Integer) then
    91     Result := Low(Integer)
    92   else begin
    93     Result := Trunc(X);
    94     if (Result <> X) then begin
    95       if (Result > 0) then Inc(Result) else Dec(Result);
    96     end;
    97   end;
     88function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND; X, Y, cx, cy: Integer;
     89  uFlags: UINT): Boolean;
     90begin
     91  LCLIntf.SetWindowPos(hWnd, hWndInsertAfter, ScaleToNative(X), ScaleToNative(Y),
     92    ScaleToNative(cx), ScaleToNative(cy), uFlags);
    9893end;
    9994
     
    110105function ScaleFromNative(Value: Integer): Integer;
    111106begin
    112   Result := Floor(Value * 96 / ScreenInfo.Dpi);
     107  Result := Round(Value * 96 / ScreenInfo.Dpi);
    113108end;
    114109
Note: See TracChangeset for help on using the changeset viewer.