Ver Mensaje Individual
  #2  
Antiguo 29-05-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
sac,

Cita:
Empezado por sac
...crear un procedure donde le pueda asignar propiedades Name, Color, Size y Style a una fuente...


Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure ChangeFont(F : TFont; Name : String; Color : TColor; Size : Byte; Style : TFontStyles);
begin
   F.Name := Name;
   F.Color := Color;
   F.Size := Size;
   F.Style := Style;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
   S : String;

begin

   S := 'Ejemplo de cambio de propiedades de un Font';

   Label1.Caption := S;
   Edit1.Text := S;
   Memo1.Lines.Add(S)

end;

procedure TForm1.Button1Click(Sender: TObject);
var
   FontName : String;
   FontColor : TColor;
   FontSize : Byte;
   FontStyle : TFontStyles;

begin

   FontName := 'Arial';;
   FontColor := clNavy;
   FontSize := 12;
   FontStyle := [];

   ChangeFont(Label1.Font, FontName, FontColor, FontSize, FontStyle);
   ChangeFont(Edit1.Font, FontName, FontColor, FontSize, FontStyle);
   ChangeFont(Memo1.Font, FontName, FontColor, FontSize, FontStyle);

end;

procedure TForm1.Button2Click(Sender: TObject);
var
   FontName : String;
   FontColor : TColor;
   FontSize : Byte;
   FontStyle : TFontStyles;

begin

   FontName := 'Arial Rounded MT';
   FontColor := clGreen;
   FontSize := 10;
   FontStyle := [fsBold];

   ChangeFont(Label1.Font, FontName, FontColor, FontSize, FontStyle);
   ChangeFont(Edit1.Font, FontName, FontColor, FontSize, FontStyle);
   ChangeFont(Memo1.Font, FontName, FontColor, FontSize, FontStyle);

end;

procedure TForm1.Button3Click(Sender: TObject);
var
   FontName : String;
   FontColor : TColor;
   FontSize : Byte;
   FontStyle : TFontStyles;

begin

   FontName := 'Elephant';
   FontColor := clBlue;
   FontSize := 10;
   FontStyle := [fsItalic, fsUnderline];

   ChangeFont(Label1.Font, FontName, FontColor, FontSize, FontStyle);
   ChangeFont(Edit1.Font, FontName, FontColor, FontSize, FontStyle);
   ChangeFont(Memo1.Font, FontName, FontColor, FontSize, FontStyle);

end;

end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32, Permite modificar selectivamente las propiedades de un TFont, como se muestra en la siguiente imagen:



Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 29-05-2015 a las 20:28:52.
Responder Con Cita