diff --git a/jvcl/run/JvParameterList.pas b/jvcl/run/JvParameterList.pas index e0f66c26b7..6aedaaf04b 100644 --- a/jvcl/run/JvParameterList.pas +++ b/jvcl/run/JvParameterList.pas @@ -532,6 +532,14 @@ implementation 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_'); + +//=== { Support function for DPI Aware apps } ================================ + +function PPIScale(Value: Integer): Integer; +begin + Result := MulDiv(Value, Screen.PixelsPerInch, 96); +end; + //=== { TJvParameterListMessages } =========================================== constructor TJvParameterListMessages.Create; @@ -1241,15 +1249,15 @@ constructor TJvParameterList.Create(AOwner: TComponent); FArrangeSettings.AutoArrange := True; FArrangeSettings.WrapControls := True; FArrangeSettings.AutoSize := asBoth; - FArrangeSettings.DistanceVertical := 3; - FArrangeSettings.DistanceHorizontal := 3; - FArrangeSettings.BorderLeft := 5; - FArrangeSettings.BorderTop := 5; + FArrangeSettings.DistanceVertical := PPIScale(3); + FArrangeSettings.DistanceHorizontal := PPIScale(3); + FArrangeSettings.BorderLeft := PPIScale(5); + FArrangeSettings.BorderTop := PPIScale(5); ScrollBox := nil; RightPanel := nil; ArrangePanel := nil; - FMaxWidth := 600; - FMaxHeight := 400; + FMaxWidth := PPIScale(600); + FMaxHeight := PPIScale(400); FDefaultParameterHeight := 0; FDefaultParameterWidth := 0; FDefaultParameterLabelWidth := 0; @@ -1507,7 +1515,7 @@ procedure TJvParameterList.CreateParameterDialog; TForm(ParameterDialog).Position := poOwnerFormCenter; {$ELSE} TForm(ParameterDialog).Position := poScreenCenter; - {$ENDIF COMPILER7_UP}; + {$ENDIF COMPILER7_UP}; TForm(ParameterDialog).ShowHint := True; TForm(ParameterDialog).OnShow := DialogShow; @@ -1524,7 +1532,7 @@ procedure TJvParameterList.CreateParameterDialog; MainPanel := DynControlEngine.CreatePanelControl(Self, ParameterDialog, 'MainPanel', '', alClient); if not Supports(MainPanel, IJvDynControlPanel, ITmpPanel) then raise EIntfCastError.CreateRes(@RsEIntfCastError); - ITmpPanel.ControlSetBorder(bvNone, bvRaised, 1, bsNone, 3); + ITmpPanel.ControlSetBorder(bvNone, bvRaised, 1, bsNone, PPIScale(3)); ButtonPanel := DynControlEngine.CreatePanelControl(Self, BottomPanel, 'BottonPanel', '', alRight); @@ -1538,26 +1546,28 @@ procedure TJvParameterList.CreateParameterDialog; Messages.CancelButton, '', OnCancelButtonClick, False, True); - BottomPanel.Height := OkButton.Height + 6 + 2; + BottomPanel.Height := PPIScale(22) + PPIScale(6 + 2); - OkButton.Top := 3; - OkButton.Left := 3; + OkButton.Top := PPIScale(3); + OkButton.Left := PPIScale(3); OkButton.Visible := OkButtonVisible; OkButton.Enabled := OkButtonVisible; + OkButton.Height := PPIScale(22); if OkButton.Visible then - ButtonLeft := OkButton.Left + OkButton.Width + 3 + ButtonLeft := OkButton.Left + OkButton.Width + PPIScale(3) else ButtonLeft := 0; - CancelButton.Top := 3; - CancelButton.Left := ButtonLeft + 3; + CancelButton.Top := PPIScale(3); + CancelButton.Left := ButtonLeft + PPIScale(3); CancelButton.Visible := CancelButtonVisible; CancelButton.Enabled := CancelButtonVisible; + CancelButton.Height := PPIScale(22); if CancelButton.Visible then - ButtonLeft := ButtonLeft + 3 + CancelButton.Width + 3; + ButtonLeft := ButtonLeft + PPIScale(3) + CancelButton.Width + PPIScale(3); - ButtonPanel.Width := ButtonLeft + 3; - OrgButtonPanelWidth := ButtonLeft + 3; + ButtonPanel.Width := ButtonLeft + PPIScale(3); + OrgButtonPanelWidth := ButtonLeft + PPIScale(3); OkButton.Anchors := [akTop, akRight]; CancelButton.Anchors := [akTop, akRight]; @@ -1569,13 +1579,13 @@ procedure TJvParameterList.CreateParameterDialog; if not Supports(HistoryPanel, IJvDynControlPanel, ITmpPanel) then raise EIntfCastError.CreateRes(@RsEIntfCastError); ITmpPanel.ControlSetBorder(bvNone, bvNone, 0, bsNone, 0); - HistoryPanel.Height := 25; + HistoryPanel.Height := PPIScale(25); LoadButton := DynControlEngine.CreateButton(Self, HistoryPanel, 'LoadButton', Messages.HistoryLoadButton, '', HistoryLoadClick, False, False); - LoadButton.Left := 6; - LoadButton.Top := 5; - LoadButton.Height := 20; + LoadButton.Left := PPIScale(6); + LoadButton.Top := PPIScale(5); + LoadButton.Height := PPIScale(20); LoadButton.Width := TCustomControlAccessProtected(HistoryPanel).Canvas.TextWidth(Messages.HistoryLoadButton) + 5; ButtonLeft := LoadButton.Left + LoadButton.Width + 5; @@ -1583,8 +1593,8 @@ procedure TJvParameterList.CreateParameterDialog; Messages.HistorySaveButton, '', HistorySaveClick, False, False); SaveButton.Left := ButtonLeft; - SaveButton.Top := 5; - SaveButton.Height := 20; + SaveButton.Top := PPIScale(5); + SaveButton.Height := PPIScale(20); SaveButton.Width := TCustomControlAccessProtected(HistoryPanel).Canvas.TextWidth(Messages.HistorySaveButton) + 5; ButtonLeft := SaveButton.Left + SaveButton.Width + 5; @@ -1592,12 +1602,12 @@ procedure TJvParameterList.CreateParameterDialog; Messages.HistoryClearButton, '', HistoryClearClick, False, False); ClearButton.Left := ButtonLeft; - ClearButton.Top := 5; - ClearButton.Height := 20; + ClearButton.Top := PPIScale(5); + ClearButton.Height := PPIScale(20); ClearButton.Width := TCustomControlAccessProtected(HistoryPanel).Canvas.TextWidth(Messages.HistoryClearButton) + - 5; - ButtonLeft := ClearButton.Left + ClearButton.Width + 5; + PPIScale(5); + ButtonLeft := ClearButton.Left + ClearButton.Width + PPIScale(5); HistoryPanel.Width := ButtonLeft; OrgHistoryPanelWidth := ButtonLeft; end @@ -1618,9 +1628,9 @@ procedure TJvParameterList.ResizeDialogAfterArrange(Sender: TObject; nLeft, nTop if ArrangePanel.Width > MaxWidth then TForm(ParameterDialog).ClientWidth := MaxWidth else - TForm(ParameterDialog).ClientWidth := ArrangePanel.Width + 5 + TForm(ParameterDialog).ClientWidth := ArrangePanel.Width + PPIScale(5) else - TForm(ParameterDialog).ClientWidth := ArrangePanel.Width + 5; + TForm(ParameterDialog).ClientWidth := ArrangePanel.Width + PPIScale(5); if Assigned(HistoryPanel) and (TForm(ParameterDialog).ClientWidth < HistoryPanel.Width) then TForm(ParameterDialog).ClientWidth := HistoryPanel.Width @@ -1631,17 +1641,17 @@ procedure TJvParameterList.ResizeDialogAfterArrange(Sender: TObject; nLeft, nTop if ArrangePanel.Height + BottomPanel.Height > MaxHeight then TForm(ParameterDialog).ClientHeight := MaxHeight + 10 else - TForm(ParameterDialog).ClientHeight := ArrangePanel.Height + BottomPanel.Height + 10 + TForm(ParameterDialog).ClientHeight := ArrangePanel.Height + BottomPanel.Height + PPIScale(10) else - TForm(ParameterDialog).ClientHeight := ArrangePanel.Height + BottomPanel.Height + 10; + TForm(ParameterDialog).ClientHeight := ArrangePanel.Height + BottomPanel.Height + PPIScale(10); end; if Assigned(HistoryPanel) then if (OrgButtonPanelWidth + OrgHistoryPanelWidth) > BottomPanel.Width then begin ButtonPanel.Align := alBottom; - ButtonPanel.Height := OkButton.Height + 6 + 2; - BottomPanel.Height := ButtonPanel.Height * 2 + 1; + ButtonPanel.Height := OkButton.Height + PPIScale(6 + 2); + BottomPanel.Height := ButtonPanel.Height * 2 + PPIScale(1); HistoryPanel.Align := alClient; end else @@ -1650,7 +1660,7 @@ procedure TJvParameterList.ResizeDialogAfterArrange(Sender: TObject; nLeft, nTop ButtonPanel.Width := OrgButtonPanelWidth; HistoryPanel.Align := alLeft; HistoryPanel.Width := OrgHistoryPanelWidth; - BottomPanel.Height := OkButton.Height + 6 + 2; + BottomPanel.Height := OkButton.Height + PPIScale(6 + 2); end; CheckScrollBoxAutoScroll; end; diff --git a/jvcl/run/JvParameterListParameter.pas b/jvcl/run/JvParameterListParameter.pas index c63074a488..3bb3ebc9ea 100644 --- a/jvcl/run/JvParameterListParameter.pas +++ b/jvcl/run/JvParameterListParameter.pas @@ -29,6 +29,7 @@ interface uses + Windows, {$IFDEF UNITVERSIONING} JclUnitVersioning, {$ENDIF UNITVERSIONING} @@ -661,6 +662,13 @@ implementation uses JvResources, JvJVCLUtils, JclSysUtils; +//=== { Support function for DPI Aware apps } ================================ + +function PPIScale(Value: Integer): Integer; +begin + Result := MulDiv(Value, Screen.PixelsPerInch, 96); +end; + function DSADialogsMessageDlg(const Msg: string; const DlgType: TMsgDlgType; const Buttons: TMsgDlgButtons; const HelpCtx: Longint; const Center: TDlgCenterKind = dckScreen; const Timeout: Integer = 0; const DefaultButton: TMsgDlgBtn = mbDefault; const CancelButton: TMsgDlgBtn = mbDefault; @@ -730,6 +738,7 @@ procedure TJvButtonParameter.CreateWinControlOnParent(ParameterParent: TWinContr GetParameterName, Caption, Hint, Click, False, False); Button.Action := Action; SetWinControl (Button); + WinControl.Height := PPIScale(WinControl.Height); if Height > 0 then WinControl.Height := Height; if Width > 0 then @@ -862,7 +871,7 @@ procedure TJvBasePanelEditParameter.ArrangeLabelAndWinControlOnPanelBefore; DynCtrlFont.ControlFont, Caption+'X'); t := LabelControl.Top; - l := LabelControl.Left + LabelControl.Width + 4; + l := LabelControl.Left + LabelControl.Width + PPIScale(4); if Height > 0 then h := Height @@ -889,25 +898,25 @@ procedure TJvBasePanelEditParameter.ArrangeLabelAndWinControlOnPanelGroupBox; var l, t, w, h: Integer; begin - t := 16; - l := 5; + t := PPIScale(16); + l := PPIScale(5); if Height > 0 then - h := Height - 20 + h := Height - PPIScale(20) else h := fOrgWinControlHeight; if EditWidth > 0 then w := EditWidth else if Width > 0 then - w := Width - 9 + w := Width - PPIScale(9) else w := 0; ArrangeWinControlsonPanel(l, t, w, h); - FrameControl.Height := h + 20; - FrameControl.Width := w + 9; + FrameControl.Height := h + PPIScale(20); + FrameControl.Width := w + PPIScale(9); end; procedure TJvBasePanelEditParameter.ArrangeLabelAndWinControlOnPanelNone; @@ -949,8 +958,8 @@ procedure TJvBasePanelEditParameter.ArrangeWinControlsonPanel(iLeft, iTop: FBeforeParameterControl.Left := l; FBeforeParameterControl.Top := iTop; FBeforeParameterControl.Height := iHeight; - l := FBeforeParameterControl.Left + FBeforeParameterControl.Width+ Space; - w := w + FBeforeParameterControl.Width+ Space; + l := FBeforeParameterControl.Left + FBeforeParameterControl.Width+ PPIScale(Space); + w := w + FBeforeParameterControl.Width+ PPIScale(Space); end; WinControl.Left := l; WinControl.Top := iTop; @@ -959,18 +968,18 @@ procedure TJvBasePanelEditParameter.ArrangeWinControlsonPanel(iLeft, iTop: begin WinControl.Width := iWidth-l+iLeft; if Assigned (FAfterParameterControl) then - WinControl.Width := WinControl.Width - (FAfterParameterControl.Width + Space); + WinControl.Width := WinControl.Width - (FAfterParameterControl.Width + PPIScale(Space)); end else WinControl.Width := FOrgWinControlWidth; w := w + WinControl.Width; if Assigned(FAfterParameterControl) then begin - l := WinControl.Left + WinControl.Width + Space; + l := WinControl.Left + WinControl.Width + PPIScale(Space); FAfterParameterControl.Left := l; FAfterParameterControl.Top := iTop; FAfterParameterControl.Height := iHeight; - w := w + FAfterParameterControl.Width+ Space; + w := w + FAfterParameterControl.Width+ PPIScale(Space); end; iWidth := w; end; @@ -1066,7 +1075,7 @@ procedure TJvBasePanelEditParameter.CreateLabelControl(AParameterParent: TWinCon IDynAutoSize.ControlSetAutosize(False); end else - LabelControl.Height := 16; + LabelControl.Height := PPIScale(16); end; @@ -1252,10 +1261,10 @@ constructor TJvArrangeParameter.Create(AParameterList: TJvParameterList); begin inherited Create(AParameterList); FArrangeSettings := TJvArrangeSettings.Create(Self); - FArrangeSettings.BorderLeft := 2; - FArrangeSettings.BorderTop := 2; - FArrangeSettings.DistanceVertical := 2; - FArrangeSettings.DistanceHorizontal := 2; + FArrangeSettings.BorderLeft := PPIScale(2); + FArrangeSettings.BorderTop := PPIScale(2); + FArrangeSettings.DistanceVertical := PPIScale(2); + FArrangeSettings.DistanceHorizontal := PPIScale(2); FArrangeSettings.AutoArrange := True; end; @@ -1395,9 +1404,9 @@ procedure TJvGroupBoxParameter.CreateWinControlOnParent(ParameterParent: TWinCon procedure TJvGroupBoxParameter.ReArrangeGroupbox(Sender: TObject; nLeft, nTop, nWidth, nHeight: Integer); begin if ArrangeSettings.AutoSize in [asWidth, asBoth] then - WinControl.Width := nWidth + 5; + WinControl.Width := nWidth + PPIScale(5); if ArrangeSettings.AutoSize in [asHeight, asBoth] then - WinControl.Height := nHeight + 22; + WinControl.Height := nHeight + PPIScale(22); end; procedure TJvGroupBoxParameter.SetWinControlProperties; @@ -2678,11 +2687,11 @@ procedure TJvPageControlParameter.RearrangePageControl(Sender: TObject; nLeft, if Assigned(Sender) and (Sender is TWinControl) then begin if (ArrangeSettings.AutoSize in [asWidth, asBoth]) - and (TWinControl(Sender).Width <> nWidth + 5) then - TWinControl(Sender).Width := nWidth + 5; + and (TWinControl(Sender).Width <> nWidth + PPIScale(5)) then + TWinControl(Sender).Width := nWidth + PPIScale(5); if (ArrangeSettings.AutoSize in [asHeight, asBoth]) - and (TWinControl(Sender).Height <> nHeight + 45) then - TWinControl(Sender).Height := nHeight + 45; + and (TWinControl(Sender).Height <> nHeight + PPIScale(45)) then + TWinControl(Sender).Height := nHeight + PPIScale(45); end; end; diff --git a/jvcl/run/JvProgramVersionCheck.pas b/jvcl/run/JvProgramVersionCheck.pas index 0d74f215b8..ccca5ee828 100644 --- a/jvcl/run/JvProgramVersionCheck.pas +++ b/jvcl/run/JvProgramVersionCheck.pas @@ -1,4 +1,4 @@ -{----------------------------------------------------------------------------- +{----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -661,6 +661,13 @@ function CompareVersionNumbers(AVersion1, AVersion2: string): Integer; until (AVersion1 = '') and (AVersion2 = ''); end; +//=== { Support function for DPI Aware apps } ================================ + +function PPIScale(Value: Integer): Integer; +begin + Result := MulDiv(Value, Screen.PixelsPerInch, 96); +end; + //=== { TJvProgramVersionsStringList } ======================================= function VersionNumberSortCompare(List: TStringList; Index1, Index2: Integer): Integer; @@ -1384,8 +1391,9 @@ procedure TJvProgramVersionCheck.DownloadThreadOnExecute(Sender: TObject; Params procedure TJvProgramVersionCheck.DownloadThreadOnFinishAll(Sender: TObject); begin + Application.ProcessMessages; if Assigned(FThreadExceptionClass) then - exit; + Exit; if DownloadError <> '' then JvDSADialogs.MessageDlg(DownloadError, mtError, [mbOK], 0) else @@ -1396,8 +1404,7 @@ procedure TJvProgramVersionCheck.DownloadThreadOnFinishAll(Sender: TObject); JvDSADialogs.MessageDlg(Format(RsPVCDownloadSuccessfulInstallManually, [FExecuteDownloadInstallFileName]), mtInformation, [mbOK], 0) else - if JvDSADialogs.MessageDlg(RsPVCDownloadSuccessfullInstallNow, - mtWarning, [mbYes, mbNo], 0) = mrYes then + if JvDSADialogs.MessageDlg(RsPVCDownloadSuccessfullInstallNow, mtWarning, [mbYes, mbNo], 0) = mrYes then if ShellExecEx(FExecuteDownloadInstallFileName, FExecuteVersionInfo.LocalInstallerParams) then PostMessage(Application.Handle, WM_CLOSE, 0, 0) else @@ -1484,7 +1491,7 @@ function TJvProgramVersionCheck.GetRemoteVersionOperation( Result := rvoIgnore; ParameterList := TJvParameterList.Create(Self); try - ParameterList.MaxWidth := 460; + ParameterList.MaxWidth := PPIScale(460); ParameterList.Messages.Caption := Format(RsPVCDialogCaption, [CurrentApplicationName]); ParameterList.Messages.OkButton := RsPVCDialogExecuteButton; @@ -1493,15 +1500,15 @@ function TJvProgramVersionCheck.GetRemoteVersionOperation( Parameter.SearchName := SParamNameNewVersionLabel; Parameter.Caption := Format(RsPVCNewVersionAvailable, [GetAllowedRemoteProgramVersionReleaseType, CurrentApplicationName]); - Parameter.Width := 350; - Parameter.Height := 45; + Parameter.Width := PPIScale(350); + Parameter.Height := PPIScale(45); ParameterList.AddParameter(Parameter); GroupParameter := TJvGroupBoxParameter.Create(ParameterList); GroupParameter.SearchName := SParamNameGroupBox; GroupParameter.Caption := RsPVCChooseWhichVersion; - GroupParameter.Width := 350; - GroupParameter.Height := 10; + GroupParameter.Width := PPIScale(350); + GroupParameter.Height := PPIScale(10); ParameterList.AddParameter(GroupParameter); for I := High(I) downto Low(I) do @@ -1514,20 +1521,20 @@ function TJvProgramVersionCheck.GetRemoteVersionOperation( Parameter.ParentParameterName := SParamNameGroupBox; Parameter.SearchName := SParamNameRadioButton + IntToStr(Ord(I)); Parameter.Caption := RemoteProgramVersionHistory.CurrentProgramVersion[I].ProgramVersionInfo; - Parameter.Width := 250; - Parameter.AsBoolean := GroupParameter.Height <= 10; + Parameter.Width := PPIScale(250); + Parameter.AsBoolean := GroupParameter.Height <= PPIScale(10); ParameterList.AddParameter(Parameter); Parameter := TJvBaseParameter(TJvButtonParameter.Create(ParameterList)); Parameter.ParentParameterName := SParamNameGroupBox; Parameter.SearchName := SParamNameVersionButtonInfo + IntToStr(Ord(I)); Parameter.Caption := RsPVInfoButtonCaption; - Parameter.Width := 80; + Parameter.Width := PPIScale(80); Parameter.Tag := Ord(I); TJvButtonParameter(Parameter).OnClick := VersionInfoButtonClick; ParameterList.AddParameter(Parameter); - GroupParameter.Height := GroupParameter.Height + 25; + GroupParameter.Height := GroupParameter.Height + PPIScale(25); end; Parameter := TJvBaseParameter(TJvRadioGroupParameter.Create(ParameterList)); Parameter.SearchName := SParamNameOperation; @@ -1536,8 +1543,8 @@ function TJvProgramVersionCheck.GetRemoteVersionOperation( TJvRadioGroupParameter(Parameter).ItemList.Add(RsPVCOperationDownloadOnly); TJvRadioGroupParameter(Parameter).ItemList.Add(RsPVCOperationDownloadInstall); TJvRadioGroupParameter(Parameter).ItemIndex := 2; - Parameter.Width := 350; - Parameter.Height := 79; + Parameter.Width := PPIScale(350); + Parameter.Height := PPIScale(79); ParameterList.AddParameter(Parameter); if ParameterList.ShowParameterDialog then @@ -1685,8 +1692,8 @@ procedure TJvProgramVersionCheck.ShowProgramVersionsDescription(const AFromVersi Parameter := TJvMemoParameter.Create(ParameterList); Parameter.SearchName := SParamNameMemo; Parameter.Caption := Format(RsPVCChangesBetween, [AFromVersion, AToVersion]); - Parameter.Width := 340; - Parameter.Height := 200; + Parameter.Width := PPIScale(340); + Parameter.Height := PPIScale(200); Parameter.AsString := RemoteProgramVersionHistory.GetVersionsDescription(AFromVersion, AToVersion); Parameter.Scrollbars := ssBoth; Parameter.ReadOnly := True;