Fórum Função de impressão naum funciona, o que pode ser #364910
11/10/2008
0
Estou tendo problemas na hora de fazer funcionar o seguinte código:
implementado em um .pas chamdo xprint
type
TTipoFonte = (negrito, italico, sublinhado, expandido, normal, comp12, comp17, comp20);
no meu form estou implementando assim:
XPrint.imp(tamanho_vd-03,01,´|´);
XPrint.impf(tamanho_vd-03,02,LhVencto3,[comp20]);
XPrint.imp(tamanho_vd-03,53,´|´);
Só que o atributo ´comp20´ simplesmente naum funciona na matricial, e o resultado que eu gostaria é que somente a variável ´lhVencto3´ saisse condesado
Desde já agradeço
Miltonfranca
Curtir tópico
+ 0Posts
12/10/2008
Emerson Nascimento
Gostei + 0
14/10/2008
Miltonfranca
var
iMax: byte;
i: Integer;
EscI,EscF: String;
begin
if not FPrinting then
Error(´A Impressora não está em estado de ´imprimindo´.´);
iMax := ord( FFontType );
case FPaper of
paBobbin75: iMax := FontSizeBobbin75[iMax];
paBobbin89:iMax := FontSizeBobbin89[iMax];
else
iMax := FontSizeLetter[iMax];
end;
Texto := copy(Texto,1,iMax);
case FAlignment of
taCenter:
begin
i := (iMax - length(Texto)) div 2;
Texto := replicate(´ ´,i)+Texto;
end;
taRight:
begin
i := (iMax - length(Texto));
Texto := replicate(´ ´,i)+Texto;
end;
else
Texto := replicate(´ ´,Coluna)+Texto;
end;
Convert(Texto);
case FFontType of
ftCondensed: begin EscI := a_Con ; EscF := d_Con; end;
ftSingle:begin EscI := d_Con+d_Exp ; EscF := ´´; end;
ftMiddle:begin EscI := a_Con+a_Exp ; EscF := d_Con+d_Exp; end;
else
begin
EscI := a_Exp;
EscF := d_Exp;
end;
end;
try
if FLinhaAtual < Linha then
for I:=0 to (Linha - FLinhaAtual)-1 do
Line;
FLinhaAtual := Linha;
Write( FHandle, p_Return);
Write( FHandle, EscI+Texto+EscF );
if Negrito in Fonte then
begin
Write( FHandle, p_Return);
Write( FHandle, EscI+Texto+EscF );
end;
except
on E: Exception do begin
Error(E.Message);
end;
end;
end;
vc poderia apontar onde estaria o erro
Gostei + 0
17/10/2008
Emerson Nascimento
seu código final deverá ficar parecido com este:
procedure TXPrint.Impf(Linha, Coluna: Integer; Texto: String; Fonte: TFonte); var iMax: byte; i: Integer; EscI, EscF: String; begin if not FPrinting then Error(´A Impressora não está em estado de "imprimindo".´); iMax := ord( FFontType ); case FPaper of paBobbin75: iMax := FontSizeBobbin75[iMax]; paBobbin89: iMax := FontSizeBobbin89[iMax]; else iMax := FontSizeLetter[iMax]; end; Texto := copy(Texto,1,iMax); case FAlignment of taCenter: begin i := (iMax - length(Texto)) div 2; Texto := replicate(´ ´,i)+Texto; end; taRight: begin i := (iMax - length(Texto)); Texto := replicate(´ ´,i)+Texto; end; else Texto := replicate(´ ´,Coluna)+Texto; end; Convert(Texto); EscI := ´´; EscF := ´´; // só pode ser passado um dos tipos, pois isso uso o if..else if comp12 in Fonte then begin EscI := a_Con12; EscF := d_Con12; end else if comp17 in Fonte then begin EscI := a_Con17; EscF := d_Con17; end else if comp20 in Fonte then begin EscI := a_Con; EscF := d_Con; end else if expandido in Fonte then begin EscI := a_Exp; EscF := d_Exp; end else if normal in Fonte then begin EscI := d_Exp+d_Con+d_Con12+d_Con17+d_Con20+ d_Negrito+d_Italico+d_Sublinhado; EscF := ´´; end; // aqui podem ser passados vários tipos simultaneamente if italico in Fonte then begin EscI := EscI + a_Italico; EscF := EscF + d_Italico; end; if sublinhado in Fonte then begin EscI := EscI + a_Sublinhado; EscF := EscF + d_Sublinhado; end; try if FLinhaAtual < Linha then for I:=0 to (Linha - FLinhaAtual)-1 do Line; FLinhaAtual := Linha; Write( FHandle, p_Return); Write( FHandle, EscI+Texto+EscF ); if Negrito in Fonte then begin Write( FHandle, p_Return); Write( FHandle, EscI+Texto+EscF ); end; except on E: Exception do begin Error(E.Message); end; end; end;
com certeza precisa de adaptações, pois não conheço todos os comendos diponibilizados (como a_Negrito, a_Com17, etc), mas a base é essa.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)