Função de impressão naum funciona, o que pode ser

Delphi

11/10/2008

Prezados, desculpem a ignorancia... mas acredito muito neste forum, td q postei aqui tive soluçã imediato.
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

Miltonfranca

Curtidas 0

Respostas

Emerson Nascimento

Emerson Nascimento

11/10/2008

o problema deve estar na rotina [i:b2ff3e114a]impf[/i:b2ff3e114a].


GOSTEI 0
Miltonfranca

Miltonfranca

11/10/2008

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);
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
Emerson Nascimento

Emerson Nascimento

11/10/2008

você está enviando o parâmetro comp20, mas em nenhum momento a procedure avalia esse valor. onde trata da fonte, a procedure espera por ftCondensed, ftSingle, ftMiddle ou vazio. faça uma pequena adaptação para não precisar alterar todas as suas rotinas de impressão.
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
POSTAR