Einzelnen Beitrag anzeigen

Schokohase
(Gast)

n/a Beiträge
 
#4

AW: Merkwürdige Bildschirmkoordinaten

  Alt 23. Jul 2019, 09:33
Diese 8 Pixel sind eine System-Einstellung und könnten sich auch je nach Einstellung des Systems ändern.

Darum sollte man diese auch abfragen
https://docs.microsoft.com/en-us/win...tsystemmetrics

Hier mal eine Form mit 4 Shapes in den Ecken, damit man auch sehen kann, dass der Inhalt bis auf das letzte Pixel angezeigt wird.

DFM:
Delphi-Quellcode:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 411
  ClientWidth = 852
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  DesignSize = (
    852
    411)
  PixelsPerInch = 96
  TextHeight = 13
  object Shape1: TShape
    Left = 0
    Top = 0
    Width = 65
    Height = 65
    Pen.Color = clRed
  end
  object Shape2: TShape
    Left = 0
    Top = 346
    Width = 65
    Height = 65
    Anchors = [akLeft, akBottom]
    Pen.Color = clRed
  end
  object Shape3: TShape
    Left = 787
    Top = 0
    Width = 65
    Height = 65
    Anchors = [akTop, akRight]
    Pen.Color = clRed
  end
  object Shape4: TShape
    Left = 787
    Top = 346
    Width = 65
    Height = 65
    Anchors = [akRight, akBottom]
    Pen.Color = clRed
  end
  object Button1: TButton
    Left = 360
    Top = 120
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
end
Code:
Delphi-Quellcode:
type
  TForm1 = class(TForm)
    Button1: TButton;
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    Shape4: TShape;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  OffsetX, OffsetY: Integer;
  WorkArea: TRect;
begin
  OffsetX := GetSystemMetrics(SM_CXSIZEFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);
  OffsetY := GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);

  WorkArea := Screen.MonitorFromWindow(Self.Handle).WorkareaRect;

  WorkArea.Inflate(OffsetX, 0, OffsetX, OffsetY);

  Self.Left := WorkArea.Left;
  Self.Top := WorkArea.Top;
  Self.Width := WorkArea.Width;
  Self.Height := WorkArea.Height;
end;
Diese Metrics sind für diese Form wohl die richtigen (weil sizable und captioned).

Man sieht trotzdem einen kleinen Unterschied zwischen echtem Vollbild und vollflächiger normaler Anzeige - beim Vollbild wird die Titelzeile kleiner dargestellt und es gibt ein paar Pixel mehr Fläche für den Inhalt.

Hinweis

Ich weiß nur theoretisch warum und wie es funktionieren muss. Bislang hatte ich keinen Bedarf das in einer Anwendung wirklich umzusetzen. Wenn ich hier also einen Aspekt vergessen habe, dann liegt das genau daran.

Geändert von Schokohase (23. Jul 2019 um 09:36 Uhr)
  Mit Zitat antworten Zitat