Delete fonts out of TRVFontComboBox

General TRichView support forum. Please post your questions here
Post Reply
WLemmermeyer
Posts: 5
Joined: Fri Jun 06, 2014 5:32 am
Location: Germany

Delete fonts out of TRVFontComboBox

Post by WLemmermeyer » Tue Sep 25, 2018 8:23 am

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....

Sergey Tkachenko
Site Admin
Posts: 14562
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Delete fonts out of TRVFontComboBox

Post by Sergey Tkachenko » Tue Sep 25, 2018 9:19 am

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);

Post Reply