I am working on updating an application originally done in Delphi. As I have been working through debugging various issues, the compiler began giving an error from the Grids procedures shown beginning at line 2239:
procedure CfgSetFontValue(cfg: TXMLConfig; AKey: WideString; AFont: TFont);
begin
cfg.SetValue(AKey + '/name/value', AFont.Name);
cfg.SetValue(AKey + '/size/value', AFont.Size);
cfg.SetValue(AKey + '/color/value', ColorToString(AFont.Color));
cfg.SetValue(AKey + '/style/value', Integer(AFont.Style));
end;
procedure CfgGetFontValue(cfg: TXMLConfig; AKey: WideString; AFont: TFont);
begin
AFont.Name := cfg.GetValue(AKey + '/name/value', 'default');
AFont.Size := cfg.GetValue(AKey + '/size/value', 0);
AFont.Color:= StringToColor(cfg.GetValue(AKey + '/color/value', 'clWindowText'));
AFont.Style:= TFontStyles(cfg.GetValue(AKey + '/style/value', 0));
end;
The two problems arise from Integer(AFont.Style) shown in the first procedure and AFont.Style:= TFontStyles(cfg.GetValue(AKey + '/style/value', 0)); in the second procedure. TFontStyles comes from the Graphics unit shown at lines 71-72:
TFontStyle = (fsBold, fsItalic, fsUnderline, fsStrikeOut);
TFontStyles = set of TFontStyle;
I looked in Pascal Reference Guide and found the following: "The compiler stores small sets (less than 32 elements) in a LongInt if the Type Range allows it." The error message that I am getting is : grids.pas(2044,39) Error: Illegal type conversion: "TFontStyles" to "LongInt" and "grids.pas(2052,17) Error: Illegal type conversion: "LongInt" to "TFontStyles".
I am perplexed. I don't see anything wrong in the Grids unit coding, yet I get the errors.