Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Conexión con bases de datos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-08-2015
Avatar de GerTorresM
GerTorresM GerTorresM is offline
Miembro
 
Registrado: nov 2005
Ubicación: Tunja - Boyacá
Posts: 210
Poder: 19
GerTorresM Va por buen camino
Tu ejemplo al 100%

Me parecio muy bueno tu código, tal solo una cosa como puedo guardar ek color y el Estilo ??
Responder Con Cita
  #2  
Antiguo 19-08-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola GerTorresM.

Código Delphi [-]
procedure SaveFieldFont(aDataSet: TDataSet; aFont: TFont;
  const BlobFieldName: string);
var
  ms: TStream;
  LogFont: TLogFont;
  sColor: TColor;
begin
  ZeroMemory(@LogFont, SizeOf(LogFont));
  GetObject(aFont.Handle, SizeOf(LogFont), @LogFont);
  sColor := aFont.Color;
  ms := TMemoryStream.Create;
  try
    ms.WriteBuffer(LogFont, SizeOf(LogFont));
    ms.WriteBuffer(sColor, SizeOf(TColor));
    with aDataSet do
    begin
      if not (State in [dsEdit,dsInsert]) then Edit;
      TBlobField(FieldByName(BlobFieldName)).LoadFromStream(ms);
    end;
  finally
    ms.Free;
  end;
end;

procedure LoadFieldFont(aDataSet: TDataSet; aFont: TFont;
  const BlobFieldName: string);
var
  ms: TStream;
  LogFont: TLogFont;
  sColor: TColor;
begin
  ms := TMemoryStream.Create;
  try
    TBlobField(aDataSet.FieldByName(BlobFieldName)).SaveToStream(ms);
    ms.Seek(soFromBeginning, 0);
    ZeroMemory(@LogFont, SizeOf(LogFont));
    ms.ReadBuffer(LogFont, SizeOf(LogFont));
    ms.ReadBuffer(sColor, SizeOf(TColor));
    aFont.Color := sColor;
    aFont.Handle := CreateFontIndirect(LogFont);
    aFont.Height := LogFont.lfHeight;
    if Boolean(LogFont.lfItalic) then
      aFont.Style := aFont.Style + [fsItalic];
    if Boolean(LogFont.lfUnderline) then
      aFont.Style := aFont.Style + [fsUnderline];
    if Boolean(LogFont.lfStrikeOut) then
      aFont.Style := aFont.Style + [fsStrikeOut];
    if Boolean(LogFont.lfWeight and 700) then
      aFont.Style := aFont.Style + [fsBold];
  finally
    ms.Free;
  end;
end;

Ejemplo de uso:
Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
begin
  Table1.Open;
  Label1.Font.Name  := 'Segoe Print';
  Label1.Font.Size  := 18;
  Label1.Font.Color := clRed;
  Label1.Font.Style := [fsItalic, fsStrikeOut, fsBold];
  Label1.Caption    := 'Caption Label1';
end;

procedure TForm1.btSaveClick(Sender: TObject);
begin
  Table1.Edit;
  Table1.FieldByName('Texto').AsString := Label1.Caption;
  SaveFieldFont(Table1, Label1.Font, 'Fuente');
  Table1.Post;
end;

procedure TForm1.btLoadClick(Sender: TObject);
begin
  Label2.Caption := Table1.FieldByName('Texto').AsString;
  LoadFieldFont(Table1, Label2.Font, 'Fuente');
end;



Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Guardar mas de 24:00:00 en Paradox Iskariote0087 Varios 4 24-07-2007 23:24:59
Guardar jpg en paradox Gabriel2 Varios 1 12-09-2005 15:17:35
Error al guardar modificaciones tabla paradox Sayuri Tablas planas 2 29-07-2005 20:48:10
Guardar datos leidos de dbedits en una tabla paradox vhirginia Tablas planas 4 15-04-2004 17:28:58
Guardar datos en una tabla paradox vhirginia Conexión con bases de datos 3 15-04-2004 17:15:59


La franja horaria es GMT +2. Ahora son las 05:03:55.


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