Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.058 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: IOTA-Neuerung ab Delphi 10.4: Schriftgröße änderbar! Wie abfragen?

  Alt 17. Jun 2021, 08:31
Ich nehme an, du meinst diese neue Möglichkeit mit der TTrackbar und den beiden TButtons für kleiner und größer unterhalb des Editorsfensters.
Das sind ja nur Controls, die auf die bisherige Schrifteinstellung über Tools | Options | IDE | User Interface | Editor | Display mappen.

Da die Wizards vom CnPack das schon gefühlt schon immer konnten, lohnt sich ein Blick ins öffentliche GitHub-Repository:
https://github.com/cnpack/cnwizards/...orFontZoom.pas
https://github.com/cnpack/cnwizards/...CnWizUtils.pas

Daraus folgt für größer:
Delphi-Quellcode:
procedure TCnEditorFontInc.Execute;
var
  Option: IOTAEditOptions;
begin
  Option := CnOtaGetEditOptions;
  if Assigned(Option) then
    Option.FontSize := Round(Option.FontSize * 1.1);
end;

Und für kleiner:
Delphi-Quellcode:
procedure TCnEditorFontDec.Execute;
var
  Option: IOTAEditOptions;
begin
  Option := CnOtaGetEditOptions;
  if Assigned(Option) then
    Option.FontSize := Round(Option.FontSize / 1.1);
end;

Natürlich mithilfe von:
Delphi-Quellcode:
function CnOtaGetEditOptions: IOTAEditOptions;
var
  Svcs: IOTAEditorServices;
begin
  QuerySvcs(BorlandIDEServices, IOTAEditorServices, Svcs);
  if Assigned(Svcs) then
  begin
  {$IFDEF COMPILER7_UP}
    if Assigned(Svcs.GetTopBuffer) then
      Result := Svcs.GetTopBuffer.EditOptions
    else if Svcs.EditOptionsCount > 0 then
      Result := Svcs.GetEditOptionsIndex(0)
    else
      Result := nil;
  {$ELSE}
    Result := Svcs.GetEditOptions;
  {$ENDIF}
  end
  else
    Result := nil;
end;
QuerySvcs ist hier nur ein Wrapper mit Logmöglichkeit für das normale Supports() und kann damit ersetzt werden.
  Mit Zitat antworten Zitat