IDE: project options: more values for Win Vista DPI awarness. Issue #30170, modified patch by AlexeyT

git-svn-id: trunk@53325 -
This commit is contained in:
ondrej 2016-11-09 09:15:34 +00:00
parent d725d7f542
commit 31944eda39
5 changed files with 183 additions and 106 deletions

View File

@ -15,7 +15,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Width = 487
Align = alTop
Caption = 'AppSettingsGroupBox'
ClientHeight = 449
ClientHeight = 450
ClientWidth = 483
TabOrder = 0
object TitleLabel: TLabel
@ -23,9 +23,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = TitleEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 10
Width = 51
Height = 17
Top = 11
Width = 67
BorderSpacing.Left = 6
Caption = 'TitleLabel'
ParentColor = False
@ -34,9 +34,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideLeft.Control = AppSettingsGroupBox
AnchorSideTop.Control = IconPanel
Left = 6
Height = 15
Top = 35
Width = 51
Height = 17
Top = 39
Width = 65
BorderSpacing.Left = 6
Caption = 'IconLabel'
ParentColor = False
@ -48,9 +48,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = IconTrack
Left = 240
Height = 15
Top = 176
Width = 80
Height = 17
Top = 182
Width = 101
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'IconTrackLabel'
@ -58,7 +58,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
end
object TitleEdit: TEdit
Left = 106
Height = 23
Height = 27
Top = 6
Width = 371
Align = alTop
@ -72,9 +72,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = DarwinDividerBevel
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 337
Width = 150
Height = 24
Top = 381
Width = 191
BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'UseAppBundleCheckBox'
@ -85,9 +85,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = WindowsDividerBevel
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 224
Width = 151
Height = 24
Top = 236
Width = 195
BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'UseXPManifestCheckBox'
@ -100,7 +100,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 106
Height = 128
Top = 35
Top = 39
Width = 128
BorderSpacing.Left = 106
BorderSpacing.Top = 6
@ -108,14 +108,14 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
BevelOuter = bvNone
BorderWidth = 1
BorderStyle = bsSingle
ClientHeight = 124
ClientWidth = 124
ClientHeight = 126
ClientWidth = 126
TabOrder = 1
object IconImage: TImage
Left = 1
Height = 122
Height = 124
Top = 1
Width = 122
Width = 124
Align = alClient
Center = True
OnPictureChanged = IconImagePictureChanged
@ -128,9 +128,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideBottom.Control = IconPanel
AnchorSideBottom.Side = asrBottom
Left = 240
Height = 25
Top = 35
Width = 111
Height = 29
Top = 39
Width = 120
AutoSize = True
BorderSpacing.Left = 6
Caption = 'LoadIconButton'
@ -142,9 +142,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = DefaultIconButton
AnchorSideTop.Side = asrBottom
Left = 240
Height = 25
Top = 97
Width = 109
Height = 29
Top = 109
Width = 117
AutoSize = True
BorderSpacing.Top = 6
Caption = 'SaveIconButton'
@ -156,9 +156,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = SaveIconButton
AnchorSideTop.Side = asrBottom
Left = 240
Height = 25
Top = 128
Width = 112
Height = 29
Top = 144
Width = 121
AutoSize = True
BorderSpacing.Top = 6
Caption = 'ClearIconButton'
@ -172,8 +172,8 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideRight.Control = IconPanel
AnchorSideRight.Side = asrBottom
Left = 106
Height = 40
Top = 163
Height = 46
Top = 167
Width = 128
Max = 0
OnChange = IconTrackChange
@ -182,55 +182,40 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Anchors = [akTop, akLeft, akRight]
TabOrder = 2
end
object DpiAwareCheckBox: TCheckBox
AnchorSideLeft.Control = UseXPManifestCheckBox
AnchorSideTop.Control = UseXPManifestCheckBox
AnchorSideTop.Side = asrBottom
Left = 27
Height = 19
Top = 246
Width = 123
BorderSpacing.Left = 21
BorderSpacing.Top = 3
Caption = 'DpiAwareCheckBox'
TabOrder = 8
end
object UIAccessCheckBox: TCheckBox
AnchorSideLeft.Control = DpiAwareCheckBox
AnchorSideTop.Control = ExecutionLevelComboBox
AnchorSideTop.Side = asrBottom
Left = 27
Height = 19
Top = 294
Width = 119
Height = 24
Top = 331
Width = 152
BorderSpacing.Top = 3
Caption = 'UIAccessCheckBox'
TabOrder = 10
end
object ExecutionLevelComboBox: TComboBox
AnchorSideLeft.Control = ExecutionLevelLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DpiAwareCheckBox
AnchorSideLeft.Control = DpiAwareComboBox
AnchorSideTop.Control = DpiAwareComboBox
AnchorSideTop.Side = asrBottom
Left = 139
Height = 23
Top = 268
Width = 338
AnchorSideRight.Control = DpiAwareComboBox
AnchorSideRight.Side = asrBottom
Left = 195
Height = 31
Top = 297
Width = 282
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 3
ItemHeight = 15
ItemHeight = 0
Style = csDropDownList
TabOrder = 9
end
object ExecutionLevelLabel: TLabel
AnchorSideLeft.Control = DpiAwareCheckBox
AnchorSideTop.Control = ExecutionLevelComboBox
AnchorSideTop.Side = asrCenter
Left = 27
Height = 15
Top = 272
Width = 106
Height = 17
Top = 304
Width = 138
Caption = 'ExecutionLevelLabel'
ParentColor = False
end
@ -239,9 +224,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = LoadIconButton
AnchorSideTop.Side = asrBottom
Left = 240
Height = 25
Top = 66
Width = 123
Height = 29
Top = 74
Width = 136
AutoSize = True
BorderSpacing.Top = 6
Caption = 'DefaultIconButton'
@ -252,8 +237,8 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = IconTrack
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 206
Height = 17
Top = 216
Width = 471
Caption = 'For Windows'
Anchors = [akTop, akLeft, akRight]
@ -265,8 +250,8 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = UIAccessCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 319
Height = 17
Top = 361
Width = 471
Caption = 'For Darwin'
Anchors = [akTop, akLeft, akRight]
@ -279,9 +264,9 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Control = UseAppBundleCheckBox
AnchorSideTop.Side = asrBottom
Left = 27
Height = 25
Top = 362
Width = 155
Height = 29
Top = 411
Width = 177
AutoSize = True
BorderSpacing.Left = 21
BorderSpacing.Top = 6
@ -289,6 +274,37 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
OnClick = CreateAppBundleButtonClick
TabOrder = 12
end
object DpiAwareLabel: TLabel
AnchorSideLeft.Control = UseXPManifestCheckBox
AnchorSideTop.Control = DpiAwareComboBox
AnchorSideTop.Side = asrCenter
Left = 27
Height = 17
Top = 270
Width = 103
BorderSpacing.Left = 21
BorderSpacing.Top = 3
Caption = 'DpiAwareLabel'
ParentColor = False
end
object DpiAwareComboBox: TComboBox
AnchorSideLeft.Control = ExecutionLevelLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UseXPManifestCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 195
Height = 31
Top = 263
Width = 282
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 30
BorderSpacing.Top = 3
ItemHeight = 0
Style = csDropDownList
TabOrder = 8
end
end
object OpenPictureDialog1: TOpenPictureDialog
left = 385

View File

@ -18,11 +18,12 @@ type
AppSettingsGroupBox: TGroupBox;
CreateAppBundleButton: TBitBtn;
DefaultIconButton: TButton;
DpiAwareLabel: TLabel;
DpiAwareComboBox: TComboBox;
WindowsDividerBevel: TDividerBevel;
DarwinDividerBevel: TDividerBevel;
UIAccessCheckBox: TCheckBox;
ExecutionLevelComboBox: TComboBox;
DpiAwareCheckBox: TCheckBox;
ClearIconButton: TBitBtn;
IconImage: TImage;
IconLabel: TLabel;
@ -172,7 +173,8 @@ end;
procedure TProjectApplicationOptionsFrame.UseXPManifestCheckBoxChange(Sender: TObject);
begin
DpiAwareCheckBox.Enabled := UseXPManifestCheckBox.Checked;
DpiAwareLabel.Enabled := UseXPManifestCheckBox.Checked;
DpiAwareComboBox.Enabled := UseXPManifestCheckBox.Checked;
ExecutionLevelLabel.Enabled := UseXPManifestCheckBox.Checked;
ExecutionLevelComboBox.Enabled := UseXPManifestCheckBox.Checked;
UIAccessCheckBox.Enabled := UseXPManifestCheckBox.Checked;
@ -209,6 +211,8 @@ end;
procedure TProjectApplicationOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
var
ExecutionLevel: TXPManifestExecutionLevel;
DpiLevel: TXPManifestDpiAware;
DpiLevelNames: array[TXPManifestDpiAware] of string;
begin
AppSettingsGroupBox.Caption := dlgApplicationSettings;
TitleLabel.Caption := dlgPOTitle;
@ -219,10 +223,18 @@ begin
// Windows specific, Manifest
WindowsDividerBevel.Caption := lisForWindows;
UseXPManifestCheckBox.Caption := dlgPOUseManifest;
DpiAwareCheckBox.Caption := dlgPODpiAware;
DpiAwareLabel.Caption := dlgPODpiAwareness;
DpiLevelNames[xmdaFalse] := dlgPODpiAwarenessOff;
DpiLevelNames[xmdaTrue] := dlgPODpiAwarenessOn;
DpiLevelNames[xmdaPerMonitor] := dlgPODpiAwarenessOldOffNewPerMonitor;
DpiLevelNames[xmdaTruePM] := dlgPODpiAwarenessOldOnNewPerMonitor;
ExecutionLevelLabel.Caption := dlgPOExecutionLevel;
for ExecutionLevel := Low(TXPManifestExecutionLevel) to High(TXPManifestExecutionLevel) do
for ExecutionLevel in TXPManifestExecutionLevel do
ExecutionLevelComboBox.Items.Add(ExecutionLevelToCaption[ExecutionLevel]^);
for DpiLevel in TXPManifestDpiAware do
DpiAwareComboBox.Items.Add(DpiLevelNames[DpiLevel] + ' (' + ManifestDpiAwareValues[DpiLevel] + ')');
UIAccessCheckBox.Caption := dlgPOUIAccess;
// Darwin specific, Application Bundle
@ -260,11 +272,12 @@ begin
with ProjResources.XPManifest do
begin
UseXPManifestCheckBox.Checked := UseManifest;
DpiAwareCheckBox.Checked := DpiAware;
DpiAwareComboBox.ItemIndex := Ord(DpiAware);
ExecutionLevelComboBox.ItemIndex := Ord(ExecutionLevel);
UIAccessCheckBox.Checked := UIAccess;
end;
DpiAwareCheckBox.Enabled := UseXPManifestCheckBox.Checked;
DpiAwareLabel.Enabled := UseXPManifestCheckBox.Checked;
DpiAwareComboBox.Enabled := UseXPManifestCheckBox.Checked;
ExecutionLevelLabel.Enabled := UseXPManifestCheckBox.Checked;
ExecutionLevelComboBox.Enabled := UseXPManifestCheckBox.Checked;
UIAccessCheckBox.Enabled := UseXPManifestCheckBox.Checked;
@ -298,7 +311,7 @@ begin
with ProjResources.XPManifest do
begin
UseManifest := UseXPManifestCheckBox.Checked;
DpiAware := DpiAwareCheckBox.Checked;
DpiAware := TXPManifestDpiAware(DpiAwareComboBox.ItemIndex);
ExecutionLevel := TXPManifestExecutionLevel(ExecutionLevelComboBox.ItemIndex);
UIAccess := UIAccessCheckBox.Checked;
end;

View File

@ -2548,7 +2548,11 @@ resourcestring
dlgPOUseAppBundle = 'Use Application Bundle for running and debugging';
dlgPOCreateAppBundle = 'Create Application Bundle';
dlgPOUseManifest = 'Use manifest file to enable themes';
dlgPODpiAware = 'Enabled DPI Awareness (for Vista+)';
dlgPODpiAwareness = 'DPI awareness';
dlgPODpiAwarenessOff = 'off';
dlgPODpiAwarenessOn = 'on';
dlgPODpiAwarenessOldOffNewPerMonitor = 'Vista-8: off, 8.1+: per monitor';
dlgPODpiAwarenessOldOnNewPerMonitor = 'Vista-8: on, 8.1+: per monitor';
dlgPOUIAccess = 'UI Access (uiAccess)';
dlgPOAsInvoker = 'as invoker (asInvoker)';
dlgPOHighestAvailable = 'highest available (highestAvailable)';

View File

@ -1133,7 +1133,7 @@ function dbgs(Flags: TUnitInfoFlags): string; overload;
implementation
const
ProjectInfoFileVersion = 9;
ProjectInfoFileVersion = 10;
ProjOptionsPath = 'ProjectOptions/';

View File

@ -48,15 +48,23 @@ type
xmelRequireAdministrator
);
TXPManifestDpiAware = (
xmdaFalse,
xmdaTrue,
xmdaPerMonitor,
xmdaTruePM
);
type
{ TProjectXPManifest }
TProjectXPManifest = class(TAbstractProjectResource)
private
FExecutionLevel: TXPManifestExecutionLevel;
FIsDpiaAware: boolean;
FDpiAware: TXPManifestDpiAware;
FUIAccess: Boolean;
FUseManifest: boolean;
procedure SetDpiAware(const AValue: boolean);
procedure SetDpiAware(AValue: TXPManifestDpiAware);
procedure SetExecutionLevel(AValue: TXPManifestExecutionLevel);
procedure SetUIAccess(AValue: Boolean);
procedure SetUseManifest(const AValue: boolean);
@ -67,7 +75,7 @@ type
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
property UseManifest: boolean read FUseManifest write SetUseManifest;
property DpiAware: boolean read FIsDpiaAware write SetDpiAware;
property DpiAware: TXPManifestDpiAware read FDpiAware write SetDpiAware;
property ExecutionLevel: TXPManifestExecutionLevel read FExecutionLevel write SetExecutionLevel;
property UIAccess: Boolean read FUIAccess write SetUIAccess;
end;
@ -78,10 +86,18 @@ const
'highestAvailable',
'requireAdministrator'
);
ManifestDpiAwareValues: array[TXPManifestDpiAware] of string = (
'False',
'True',
'Per-monitor',
'True/PM'
);
implementation
const
sManifestFileDataStart: String =
sManifestFileData: String =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'#$D#$A+
'<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">'#$D#$A+
' <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="CompanyName.ProductName.YourApp" type="win32"/>'#$D#$A+
@ -111,15 +127,27 @@ const
' <!-- Windows 10 -->'#$D#$A+
' <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />'#$D#$A+
' </application>'#$D#$A+
' </compatibility>'#$D#$A;
sManifestFileDataEnd: String =
'</assembly>';
sManifestFileDataDpiAware: String =
' </compatibility>'#$D#$A+
' <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">'#$D#$A+
' <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">'#$D#$A+
' <dpiAware>true</dpiAware>'#$D#$A+
' <dpiAware>%s</dpiAware>'#$D#$A+
' </asmv3:windowsSettings>'#$D#$A+
' </asmv3:application>'#$D#$A;
' </asmv3:application>'#$D#$A+
'</assembly>';
function StrToXPManifestDpiAware(const s: string): TXPManifestDpiAware;
begin
for Result:=Low(TXPManifestDpiAware) to High(TXPManifestDpiAware) do
if CompareText(s,ManifestDpiAwareValues[Result])=0 then exit;
Result:=xmdaFalse;
end;
function StrToXPManifestExecutionLevel(const s: string): TXPManifestExecutionLevel;
begin
for Result:=Low(TXPManifestExecutionLevel) to High(TXPManifestExecutionLevel) do
if CompareText(s,ExecutionLevelToStr[Result])=0 then exit;
Result:=xmelAsInvoker;
end;
procedure TProjectXPManifest.SetUseManifest(const AValue: boolean);
begin
@ -128,10 +156,10 @@ begin
Modified := True;
end;
procedure TProjectXPManifest.SetDpiAware(const AValue: boolean);
procedure TProjectXPManifest.SetDpiAware(AValue: TXPManifestDpiAware);
begin
if FIsDpiaAware = AValue then exit;
FIsDpiaAware := AValue;
if FDpiAware = AValue then Exit;
FDpiAware := AValue;
Modified := True;
end;
@ -154,7 +182,7 @@ begin
inherited Create;
FIsDefaultOption := True;
UseManifest := False;
DpiAware := False;
DpiAware := xmdaFalse;
ExecutionLevel := xmelAsInvoker;
UIAccess := False;
end;
@ -174,10 +202,10 @@ begin
Res := TGenericResource.Create(RType, RName);
RType.Free; //no longer needed
RName.Free;
ManifestFileData := Format(sManifestFileDataStart, [ExecutionLevelToStr[ExecutionLevel], BoolToStr(UIAccess, 'true', 'false')]);
if DpiAware then
ManifestFileData := ManifestFileData + sManifestFileDataDpiAware;
ManifestFileData := ManifestFileData + sManifestFileDataEnd;
ManifestFileData := Format(sManifestFileData, [
ExecutionLevelToStr[ExecutionLevel],
BoolToStr(UIAccess, 'true', 'false'),
ManifestDpiAwareValues[DpiAware]]);
Res.RawData.Write(ManifestFileData[1], Length(ManifestFileData));
AResources.AddSystemResource(Res);
end;
@ -187,18 +215,34 @@ procedure TProjectXPManifest.WriteToProjectFile(AConfig: TObject;
const Path: String);
begin
TXMLConfig(AConfig).SetDeleteValue(Path+'General/UseXPManifest/Value', UseManifest, False);
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/DpiAware/Value', DpiAware, False);
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/ExecutionLevel/Value', Ord(ExecutionLevel), 0);
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/DpiAware/Value', ManifestDpiAwareValues[DpiAware], ManifestDpiAwareValues[xmdaFalse]);
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/ExecutionLevel/Value', ExecutionLevelToStr[ExecutionLevel], ExecutionLevelToStr[xmelAsInvoker]);
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/UIAccess/Value', UIAccess, False);
end;
procedure TProjectXPManifest.ReadFromProjectFile(AConfig: TObject;
const Path: String);
var
Cfg: TXMLConfig;
begin
UseManifest := TXMLConfig(AConfig).GetValue(Path+'General/UseXPManifest/Value', False);
DpiAware := TXMLConfig(AConfig).GetValue(Path+'General/XPManifest/DpiAware/Value', False);
ExecutionLevel := TXPManifestExecutionLevel(TXMLConfig(AConfig).GetValue(Path+'General/XPManifest/ExecutionLevel/Value', 0));
UIAccess := TXMLConfig(AConfig).GetValue(Path+'General/XPManifest/UIAccess/Value', False);
Cfg := TXMLConfig(AConfig);
UseManifest := Cfg.GetValue(Path+'General/UseXPManifest/Value', False);
//support prev values "True/False"
if Cfg.GetValue(Path+'Version/Value',0)<=9 then
begin
if Cfg.GetValue(Path+'General/XPManifest/DpiAware/Value', False) then
DpiAware := xmdaTrue
else
DpiAware := xmdaFalse;
end else
DpiAware := StrToXPManifestDpiAware(Cfg.GetValue(Path+'General/XPManifest/DpiAware/Value', ''));
if Cfg.GetValue(Path+'Version/Value',0)<=9 then
ExecutionLevel := TXPManifestExecutionLevel(Cfg.GetValue(Path+'General/XPManifest/ExecutionLevel/Value', 0))
else
ExecutionLevel := StrToXPManifestExecutionLevel(Cfg.GetValue(Path+'General/XPManifest/ExecutionLevel/Value', ''));
UIAccess := Cfg.GetValue(Path+'General/XPManifest/UIAccess/Value', False);
end;
initialization