AW: Formulare in hohen DPI korrekt anzeigen
20. Okt 2016, 17:01
Gute Idee, Danke dir =)
Delphi-Quellcode:
function calcSpacesNeeded(aControl: TControl): string;
var
i, iTmpWidth, iSpaceWidth: Integer;
sTmp: string;
Canvas: TCanvas;
begin
Canvas := TCanvas.Create;
try
Canvas.Handle := GetDC(0);
try
Canvas.Font := MainForm.Font;
iSpaceWidth := Canvas.TextWidth(' ');
finally
ReleaseDC(0, Canvas.Handle);
end;
finally
Canvas.Free;
end;
sTmp := '';
iTmpWidth := aControl.Width div iSpaceWidth;
for i := 0 to iTmpWidth do
begin
sTmp := sTmp + ' ';
end;
sTmp := sTmp + ' '; // 8 Leerzeichen, <Delphi> zeigt aber nur 1 an
Result := sTmp;
end;
Geändert von Jim Carrey (20. Okt 2016 um 17:07 Uhr)
|