Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Fuente (https://www.clubdelphi.com/foros/showthread.php?t=3067)

superhopi 20-08-2003 11:51:54

Fuente
 
Estoy haciendo un diario y una de las opciones es la fuente.
Cambio la fuente y me funciona correctamente, pero cierro la aplicacion y al abrirla de nuevo se me pone la fuente por defecto... ¿como podria guardar el estilo de fuente para que se me cargara? ¿lo hago en una tabla o existe algun componente que lo almacene?
Gracias.

marcoszorrilla 20-08-2003 12:54:24

Como el nombre de la fuente es tipo texto, yo lo guardo en una tabla en un campo texto, luego no tienes mas que recuperarla.

Un saludo

superhopi 20-08-2003 13:10:06

Eso lo tengo claro; cuando guardo el tamaño tb, pero en el tema del color y del stilo... no puedo guardarlos ni cargarlos... :(
Voy a hacer unas cuantas pruebas,,, si teneis alguna idea de como puedo hacerlo os agradeceria que me ayudarais :)
saludos, cristian

marcoszorrilla 20-08-2003 13:15:42

El tamaño en un campo de tipo entero y el estilo creo que tambien esto ultimo no puedo confirmarlo porque no tengo Delphi a mano

Un Saludo

superhopi 20-08-2003 13:57:03

Ok, el tamaño un entero, el tipo de letra es texto, el color un entero (0 es el negro por ejemplo) y ahora solo me falta el estilo.
El estilo, segun veo en el inspector de objetos es un boolean, pero no se como introducirlo en la tabla, ya que esta:
- bold, italic, undeline y strikeout.
en el caso de la tabla seria un campo boolano para cada uno, pero no se como guardarlo...

Lmas 20-08-2003 21:29:23

Hola superhopi.

Con estas dos funciones podrás guardar y recuperar el estilo de una fuente como un entero.

Código:

const
  FNT_STYLE_BOLD = $0001;
  FNT_STYLE_ITALIC = $0002;
  FNT_STYLE_UNDERLINE = $0004;
  FNT_STYLE_STRIKEOUT = $0008;

function FontStyleToInt(AFontStyle: TFontStyles): Integer;
begin
  Result := 0;
  if fsBold in AFontStyle then Result := Result or FNT_STYLE_BOLD;
  if fsItalic in AFontStyle then Result := Result or FNT_STYLE_ITALIC;
  if fsUnderline in AFontStyle then Result := Result or FNT_STYLE_UNDERLINE;
  if fsStrikeOut in AFontStyle then Result := Result or FNT_STYLE_STRIKEOUT;
end;

function IntToFontStyle(AValue: Integer): TFontStyles;
begin
  Result := [];
  if (AValue and FNT_STYLE_BOLD) <> 0 then Include(Result, fsBold);
  if (AValue and FNT_STYLE_ITALIC) <> 0 then Include(Result, fsItalic);
  if (AValue and FNT_STYLE_UNDERLINE) <> 0 then Include(Result, fsUnderline);
  if (AValue and FNT_STYLE_STRIKEOUT) <> 0 then Include(Result, fsStrikeOut);
end;

SalU2.


La franja horaria es GMT +2. Ahora son las 17:06:11.

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