Ver Mensaje Individual
  #1  
Antiguo 08-06-2006
[Gunman] [Gunman] is offline
Miembro
 
Registrado: dic 2004
Ubicación: Pedreguer.
Posts: 355
Reputación: 20
[Gunman] Va por buen camino
TFontStylesToInt y viceversa

Estas son dos pequeñas funciones que hice para cuando queremos guardar el estilo de una fuente en un archivo INI por ejemplo.
Función para convertir el estilo a entero:
Código Delphi [-]
function FontStylesToInt(FontStyles: TFontStyles): ShortInt;
var
  Res: ShortInt;
begin
  Res := 0;
  if fsBold in FontStyles then
    Res := Res+1;
  if fsItalic in FontStyles then
    Res := Res+2;
  if fsUnderline in FontStyles then
    Res := Res+5;
  if fsStrikeOut in FontStyles then
    Res := Res+10;
  Result := Res;
end;

Función para convertir el entero a stilo de fuente:
Código Delphi [-]
    function IntToFontStyles(ShInt: ShortInt): TFontStyles;
    begin
      case ShInt of
        0: Result := [];
        1: Result := [fsBold];
        2: Result := [fsItalic];
        3: Result := [fsBold, fsItalic];
        5: Result := [fsUnderline];
        6: Result := [fsBold, fsUnderline];
        7: Result := [fsItalic, fsUnderline];
        8: Result := [fsBold, fsItalic, fsUnderline];
       10: Result := [fsStrikeOut];
       11: Result := [fsBold, fsStrikeOut];
       12: Result := [fsItalic, fsStrikeOut];
       13: Result := [fsBold, fsItalic, fsStrikeOut];
       15: Result := [fsUnderline, fsStrikeOut];
       16: Result := [fsBold, fsUnderline, fsStrikeOut];
       17: Result := [fsItalic, fsUnderline, fsStrikeOut];
       18: Result := [fsBold, fsItalic, fsUnderline, fsStrikeOut];
      end;
    end;
Si algún usuario lee el truco y sabe como mejorarlo, que lo notifique a un moderador y el lo editará.
Responder Con Cita