|
ActiveDelphi .: O site do programador Delphi! :.
|
Exibir mensagem anterior :: Exibir próxima mensagem |
Autor |
Mensagem |
Kirk_guitar Aprendiz
Registrado: Sábado, 24 de Junho de 2006 Mensagens: 105 Localização: Belo Horizonte
|
Enviada: Sáb Jun 28, 2008 6:18 pm Assunto: Mostrar um número elevado a outro no quick report[Resolvido] |
|
|
Oi pessoal,
Eu estou com um problema grande. Estou precisando saber como posso fazer para mostrar no meu relatorio uma potência, tipo: 10² .
Isso porque tenho um cliente que precisa digitar em um campo valores com potências que podem ser de qualquer número tipo: 10 elevado a 5 ou a 6 ou a 10 e às vezes tem dois ou três números elevados também
ex: "10² mg com 10³ mg".
Como posso fazer isso??
Editado pela última vez por Kirk_guitar em Qui Dez 17, 2015 2:40 pm, num total de 1 vez |
|
Voltar ao Topo |
|
|
Diogo_Cury Aprendiz
Registrado: Sexta-Feira, 9 de Junho de 2006 Mensagens: 139
|
Enviada: Dom Jun 29, 2008 3:16 am Assunto: |
|
|
DTDELPHI 2.8:
Código: |
794 - Função para Criar Subescrito e Sobrecrito
procedure SuperSubLabelOut(Canvas:TCanvas; const aRect:TRect; X, Y:integer; text:String);
var
i,xx:integer;
// s:string[16];
subScript, superScript:boolean;
DefFont:TFont;
begin
Canvas.FillRect(aRect);
DefFont:=TFont.Create;
DefFont.Assign(Canvas.Font);
with Canvas do
begin
xx:=X;
for i:=1 to length(text) do
begin
if text[i-1] = '_' then
subScript:=true
else
subScript:=false;
if text[i-1] = '^' then
superScript:=true
else
superScript:=false;
if (text[i] < '_' ) and (text[i] < '^' ) then
begin
if ( subScript ) then
begin
Canvas.Font.Height:=Canvas.Font.Height*8 div 10;
TextRect(Rect(xx,aRect.Top,xx+TextWidth(text[i]),aRect.Bottom),xx,Y+abs(8*Canvas.Font.Height-10*DefFont.Height) div 10, text[i]);
inc(xx,TextWidth(text[i]));
end;
if ( not subScript) and ( not superScript ) then
begin
Canvas.Font:=DefFont;
TextRect(Rect(xx,aRect.Top,xx+TextWidth(text[i]),aRect.Bottom),xx, Y, text[i]);
inc(xx,TextWidth(text[i]));
end;
if ( superScript ) then
begin
Canvas.Font.Height:=Canvas.Font.Height*9 div 10;
TextRect(Rect(xx,aRect.Top,xx+TextWidth(text[i]),aRect.Bottom),xx, Y-abs(8*Canvas.Font.Height-10*DefFont.Height) div 20, text[i]);
inc(xx,TextWidth(text[i]));
end;
Canvas.Font:=DefFont;
end;
end; //for loop
end; // with
DefFont.Free;
end;
Exemplo de uso:
Coloque um Label com propriedade Caption com: "Formula da Agua H_2O" ou "medida 3000 cm^3"
procedure TForm1.Button1Click(Sender: TObject);
begin
SuperSubLabelOut(Canvas,ClientRect ,100,100,Label1.Caption);
end;
|
------------------------------
usa a função com qrimage. nao testei + deve funfa _________________ Solução Completa pra Nota Fiscal Eletrônica:
Componentes em Delphi com manual completo,
intereçados: diogo_cury_flores@hotmail.com |
|
Voltar ao Topo |
|
|
Kirk_guitar Aprendiz
Registrado: Sábado, 24 de Junho de 2006 Mensagens: 105 Localização: Belo Horizonte
|
Enviada: Dom Jun 29, 2008 4:05 pm Assunto: |
|
|
Mas como que eu posso usar um QRImage nessa função??
não entendi como funciona.
Será que você poderia me explicar??
Diogo_Cury escreveu: | DTDELPHI 2.8:
Código: |
794 - Função para Criar Subescrito e Sobrecrito
procedure SuperSubLabelOut(Canvas:TCanvas; const aRect:TRect; X, Y:integer; text:String);
var
i,xx:integer;
// s:string[16];
subScript, superScript:boolean;
DefFont:TFont;
begin
Canvas.FillRect(aRect);
DefFont:=TFont.Create;
DefFont.Assign(Canvas.Font);
with Canvas do
begin
xx:=X;
for i:=1 to length(text) do
begin
if text[i-1] = '_' then
subScript:=true
else
subScript:=false;
if text[i-1] = '^' then
superScript:=true
else
superScript:=false;
if (text[i] < '_' ) and (text[i] < '^' ) then
begin
if ( subScript ) then
begin
Canvas.Font.Height:=Canvas.Font.Height*8 div 10;
TextRect(Rect(xx,aRect.Top,xx+TextWidth(text[i]),aRect.Bottom),xx,Y+abs(8*Canvas.Font.Height-10*DefFont.Height) div 10, text[i]);
inc(xx,TextWidth(text[i]));
end;
if ( not subScript) and ( not superScript ) then
begin
Canvas.Font:=DefFont;
TextRect(Rect(xx,aRect.Top,xx+TextWidth(text[i]),aRect.Bottom),xx, Y, text[i]);
inc(xx,TextWidth(text[i]));
end;
if ( superScript ) then
begin
Canvas.Font.Height:=Canvas.Font.Height*9 div 10;
TextRect(Rect(xx,aRect.Top,xx+TextWidth(text[i]),aRect.Bottom),xx, Y-abs(8*Canvas.Font.Height-10*DefFont.Height) div 20, text[i]);
inc(xx,TextWidth(text[i]));
end;
Canvas.Font:=DefFont;
end;
end; //for loop
end; // with
DefFont.Free;
end;
Exemplo de uso:
Coloque um Label com propriedade Caption com: "Formula da Agua H_2O" ou "medida 3000 cm^3"
procedure TForm1.Button1Click(Sender: TObject);
begin
SuperSubLabelOut(Canvas,ClientRect ,100,100,Label1.Caption);
end;
|
------------------------------
usa a função com qrimage. nao testei + deve funfa |
|
|
Voltar ao Topo |
|
|
Diogo_Cury Aprendiz
Registrado: Sexta-Feira, 9 de Junho de 2006 Mensagens: 139
|
Enviada: Qua Jul 02, 2008 8:29 pm Assunto: |
|
|
QRImage1.Canvas.Font.Assign(QuickRep1.Font);
SuperSubLabelOut(QRImage1.Canvas,QRImage1.ClientRect ,1,1,'H_2O é 10^2'); _________________ Solução Completa pra Nota Fiscal Eletrônica:
Componentes em Delphi com manual completo,
intereçados: diogo_cury_flores@hotmail.com |
|
Voltar ao Topo |
|
|
Kirk_guitar Aprendiz
Registrado: Sábado, 24 de Junho de 2006 Mensagens: 105 Localização: Belo Horizonte
|
Enviada: Qua Set 16, 2009 6:02 pm Assunto: |
|
|
Diogo_Cury escreveu: | QRImage1.Canvas.Font.Assign(QuickRep1.Font);
SuperSubLabelOut(QRImage1.Canvas,QRImage1.ClientRect ,1,1,'H_2O é 10^2'); |
Blz. Funfou! |
|
Voltar ao Topo |
|
|
|
|
Enviar Mensagens Novas: Proibido. Responder Tópicos Proibido Editar Mensagens: Proibido. Excluir Mensagens: Proibido. Votar em Enquetes: Proibido.
|
|