AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi Formulare in hohen DPI korrekt anzeigen
Thema durchsuchen
Ansicht
Themen-Optionen

Formulare in hohen DPI korrekt anzeigen

Ein Thema von Jim Carrey · begonnen am 19. Okt 2016 · letzter Beitrag vom 21. Okt 2016
Antwort Antwort
Seite 3 von 3     123   
Aviator

Registriert seit: 3. Jun 2010
1.610 Beiträge
 
Delphi 10.3 Rio
 
#21

AW: Formulare in hohen DPI korrekt anzeigen

  Alt 20. Okt 2016, 22:54
Format('%s.*', [' ', BlankCount]); , aber sicher, daß es nach dem "s" stehen soll?
Ne. War nur mal so dahin geschrieben weil ich nicht genau wusste, ob Format auf das Auffüllen von Leerzeichen unterstützt. Habe deine Zeile auch nicht ausgeführt und weiß dementsprechend immer noch nicht ob es geht.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.136 Beiträge
 
Delphi 12 Athens
 
#22

AW: Formulare in hohen DPI korrekt anzeigen

  Alt 21. Okt 2016, 09:43
Nja, grundsätzlich meinte ich auch nur, dass die "Format-Formatierungen" zwischen "%" und Typ stehen.

Im Wiki steht nur was vom Abschneiden, also ob auch aufgefüllt wird, könnte man einfach mal probieren.
http://docwiki.embarcadero.com/Libra...Format-Strings

Delphi-Quellcode:
ShowMessage(Format('a#%.8s#', ['x']) + sLineBreak
  + Format('b#%.8s#', ['xxxxxxxxxxxxxxxxxxxxxxx']) + sLineBreak
  + Format('c#%8.s#', ['x']) + sLineBreak
//+ Format('d#%.-8s#', ['x']) + sLineBreak // gibt's net
  + Format('e#%-8.s#', ['x']) + sLineBreak
  + Format('f#%8.8s#', ['x']) + sLineBreak
//+ Format('g#%8.-8s#', ['x']) + sLineBreak
  + Format('h#%-8.8s#', ['x']) + sLineBreak);
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Jim Carrey
(Gast)

n/a Beiträge
 
#23

AW: Formulare in hohen DPI korrekt anzeigen

  Alt 21. Okt 2016, 12:02
Meine aktuelle Lösung ist die folgende, für alle die, die es interessiert.
Mein Einsatzzweck ist eine multilinguale Software, wo ich die Edits und ComboBoxen nicht am Ende eines Satzes (CheckBox) haben sollte sondern grammatikalisch korrekt mittendrin.

So war es vorher:
Delphi-Quellcode:
LabelX.Caption := 'Das hier ist ein ganz langer Satz mit gefühlt....................völlig nutzlosen Zeichen!'; // statt den Punkten natürlich Leerzeichen
Edit1.Left := 123;
So ist es jetzt:
Delphi-Quellcode:
LabelX.Caption := 'Das hier ist ein ganz langer Satz mit gefühlt ' + calcSpacesNeeded(Edit1) + ' völlig nutzlosen Zeichen!';
setControlToPosition(Edit1, LabelX);
Delphi-Quellcode:
function getTextWidth(const aString: string; aForm: TForm): Integer;
var
 iRes: Integer;
 // Canvas: TCanvas;
begin
 iRes := 0;

 if aString <> 'then
  begin
   // Canvas := TCanvas.Create;

   // try
   // Canvas.Handle := GetDC(0);

   // try
   // Canvas.Font := aForm.Font;
   iRes := aForm.Canvas.TextWidth(aString); // nur diese Zeile wird benötigt, da aForm schon ein Canvas hat
   // finally
   // ReleaseDC(0, Canvas.Handle);
   // end;
   // finally
   // Canvas.Free;
   // end;
  end;

 Result := iRes;
end;

function calcSpacesNeeded(aControl: TControl): string;
var
 i, iTmpWidth, iSpaceWidth: Integer;
 sTmp: string;
begin
 iSpaceWidth := getTextWidth(' ', TForm(GetParentForm(aControl)));

 sTmp := '';
 iTmpWidth := aControl.Width div iSpaceWidth;

 for i := 0 to iTmpWidth do
  begin
   sTmp := sTmp + ' ';
  end;

 if aControl.ClassType = TEdit then
  sTmp := sTmp + ' // 6
 else if aControl.ClassType = TComboBox then
  sTmp := sTmp + ' // 4
 else
  sTmp := sTmp + ' '; // 2

 Result := sTmp;
end;

procedure setControlToPosition(aControlToSet, aControlSource: TControl);
var
 iSpacePosition, iCaptionWidth, iTmp: Integer;
 sCaption, sTmp: string;
begin
 if aControlSource.ClassType = TEdit then
  sCaption := (aControlSource as TEdit).Text
 else if (aControlSource.ClassType = TCheckBox) or (aControlSource.ClassType = TRadioButton) then
  sCaption := (aControlSource as TCheckBox).Caption
 else if (aControlSource.ClassType = TLabel) then
  sCaption := (aControlSource as TLabel).Caption;

 iSpacePosition := PosEx(' ', sCaption, 1) + 2;

 if iSpacePosition > 0 then
  begin
   sTmp := Copy(sCaption, 1, iSpacePosition);

   iCaptionWidth := getTextWidth(sTmp, TForm(GetParentForm(aControlToSet)));

   iTmp := aControlToSet.Width;
   if aControlSource.ClassType = TLabel then
    iTmp := aControlToSet.Width div 2;

   if aControlToSet.ClassType = TEdit then
    iTmp := iTmp + 2
   else if aControlToSet.ClassType = TComboBox then
    iTmp := iTmp - 4
   else
    iTmp := iTmp - 6;

   aControlToSet.Left := iCaptionWidth + iTmp;
  end;
end;
Das Resultat ist, dass Edit1 immer korrekt bei jeglicher DPI genau da im darunterliegenden Text-Control angezeigt wird, wo die Leerzeichen sind.

Geändert von Jim Carrey (21. Okt 2016 um 15:21 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 3     123   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:56 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz