Ver la Versión Completa : Intento dotar al TShape de Texto pero no consigo que funcione
He encontrado este código que me vendría muy bien pero no consigo hacerlo funcionar. ¿Seríais tan amables de decirme por qué no funciona?
type
TShape = class(ExtCtrls.TShape); //interposer class
TForm1 = class(TForm)
Shape1: TShape;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Shape1.Canvas.Font.Name :='Arial';// set the font
Shape1.Canvas.Font.Size :=20;//set the size of the font
Shape1.Canvas.Font.Color:=clBlue;//set the color of the text
Shape1.Canvas.TextOut(10,10,'1999');
end;
Gracias
bulc
Casimiro Notevi
24-05-2015, 09:52:14
¿Por qué no funciona, qué sale, qué dice, qué muestra...?
nlsgarcia
24-05-2015, 14:19:14
bulc,
...este código que me vendría muy bien pero no consigo hacerlo funcionar...
:rolleyes:
Pregunto:
1- ¿Que versión de Windows y de cuantos bits (32/64) utiliza tu aplicación?.
2- ¿Que versión de Delphi utiliza tu aplicación?.
3- ¿Puedes detallar o mostrar el problema señalado?.
Revisa este código:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Math;
type
TShape = class(ExtCtrls.TShape);
TForm1 = class(TForm)
Shape1: TShape;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Number : Integer;
begin
Randomize;
Number := RandomRange(1999,2016);
Shape1.Canvas.Brush.Color := clSkyBlue;
Shape1.Canvas.Font.Name :='Arial';
Shape1.Canvas.Font.Size := 30;
Shape1.Canvas.Font.Color := clBlue;
Shape1.Canvas.TextOut(10,10,IntToStr(Number));
end;
end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32, Implementa un TShape e imprime texto sobre el mismo de forma dinámica, como se muestra en la siguiente imagen:
http://i42.photobucket.com/albums/e305/nlsgarcia/ShapeNumber_zpsa79bimh6.gif
Espero sea útil :)
Nelson.
Ya veo que no veo. He puesto en el Uses Vcl.ExtCtrls, System.Math; y funciona. !Qué cosas!
No sé qué decir así que te doy las gracias. Se me quita un peso de encima.
Saludos,
bulc
vBulletin v3.6.8, Derechos ©2000-2024, Jelsoft Enterprises Ltd.