Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-06-2006
[Gunman] [Gunman] is offline
Miembro
 
Registrado: dic 2004
Ubicación: Pedreguer.
Posts: 355
Poder: 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
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 12:31:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi