Page 1 of 1

Delete fonts out of TRVFontComboBox

Posted: Tue Sep 25, 2018 8:23 am
by WLemmermeyer
Hello,

We use right now V15.3.2 of TRichview, Upgrade to V17 maybe in the next Months
we try to eliminate some Fonts out of TRVFontComboBox. In the TRVFontComboBox.Build method there is a filter:

Code: Select all

procedure TRVFontComboBox.Build;
var SL: {$IFDEF USERVTNT}TTntStringList{$ELSE}TStringList{$ENDIF};
  i: Integer;
begin
  SL := {$IFDEF USERVTNT}TTntStringList{$ELSE}TStringList{$ENDIF}.Create;
  SL.Assign(Screen.Fonts);
  SL.BeginUpdate;
  for i := SL.Count-1 downto 0 do
    if (SL[i]='') or (SL[i][1]='@') then
      SL.Delete(i);
  SL.EndUpdate;
  Items := SL;
  SL.Free;
end;
to eliminate @ Fonts. Is it possible somehow to delete specific Fonts (eg FixedSys)? I try to delete the font in the Combobox-Items, but this doesn't work....

Re: Delete fonts out of TRVFontComboBox

Posted: Tue Sep 25, 2018 9:19 am
by Sergey Tkachenko
Probably you tried to delete items before they were added.
The combobox creates a list of fonts when its window handle is created.
So, if you want to access items, make sure that the handle is created:

Code: Select all

  RVFontComboBox1.HandleNeeded;
  Index := RVFontComboBox1.Items.IndexOf('Fixedsys');
  if Index >=0 then
    RVFontComboBox1.Items.Delete(Index);