Segue teste funcionando. Minigui extended com harbour.
/*****************************************************************************
* SISTEMA : ROTINA EVENTUAL *
* PROGRAMA : ETQ_ELGIN.PRG *
* OBJETIVO : Etiqueta com Código de Barras na Impressora Elgin + Lib hbwin *
* AUTOR : Marcelo Antonio Lázzaro Carli *
* DATA : 24.11.2014 *
* ULT. ALT.: 28.11.2014 *
*****************************************************************************/
#include <minigui.ch>
Function Main()
REQUEST HB_LANG_PT
HB_LangSelect([PT])
REQUEST HB_CODEPAGE_PT850 &&& PARA INDEXAR CAMPOS ACENTUADOS
HB_SETCODEPAGE([PT850]) &&& PARA INDEXAR CAMPOS ACENTUADOS
Set wrap on
Set talk off
Set date briti &&& data no formato dd/mm/aaaa
Set dele on &&& ignora registros marcados por deleção
Set score off
Set exact on
Set ToolTip on
Setcancel(.F.) &&& evitar cancelar sistema c/ ALT + C
Set cent on &&& ano com 4 dígitos
Set epoch to 2000 &&& ano a partir de 2000
Set excl off &&& abre arquivos em modo compartilhado
Set navigation extended &&& enter no lugar do tab
Set language to portuguese &&& mensagens em português
Set multiple off warning &&& abrir 1 cópia somente
Set browsesync on &&& para o comando browse funcionar ok
Set tooltipstyle balloon &&& para mensagem dos campos em forma de balão
Set menustyle extended &&& padrão é standard, extended estilo office 2007
Set programmaticchange off &&& introduzida na build 1.9.94
Define window main at 0, 0 width 300 height 300 title [Impressão de Etiquetas - Elgin 2 Carreiras] ICON [demo.ico] NOTIFYICON [demo.ico] MAIN NOSIZE NOMAXIMIZE ON INIT {|| Criar_Arquivos()} ON Release {|| Fechar_Arquivos()}
@ 50, 90 BUTTON btn_imprimir caption [&Imprimir] action {|| fImprimir()} WIDTH 120 TOOLTIP [Selecione] BOLD
on key escape action {|| thiswindow.release}
End window
main.center
main.activate
Return (Nil)
Function Criar_Arquivos()
Local n
If !File([teste.dbf])
DBCreate([teste], {{[Codigo], [C], 13, 0}, {[Produto], [C], 40, 0}, {[Estoque], [N], 4, 0}, {[Valor], [N], 7, 2}})
use teste
For n:= 1 To 13
teste->(DbAppend())
teste->Codigo := str(n, 13)
teste->Produto:= [Produto ] + ltrim(str(n))
teste->Estoque:= 1
teste->Valor := n
Next
Else
use teste
Endif
Return (Nil)
Procedure Fechar_Arquivos()
Close DataBases
AEval(Directory([*.ntx]), {|file| Ferase( file[1])})
Return (Nil)
Procedure fImprimir()
Local aDados:= {}, aHEtiquetas:= {} , lPrimeiro:= .T., j:= y:= 0, cPrinter:= GetPrinter()
If Empty(cPrinter)
MsgStop([Impressora não Selecionada!], [Erro])
Return (Nil)
EndIf
If [ELGIN] $ UPPER(cPrinter)
Do while teste->(!Eof())
For y:= 1 to teste->estoque
aadd(aDados, {[], [], [], []})
aDados[len(aDados), 1]:= teste->Codigo
aDados[len(aDados), 2]:= teste->Produto
aDados[len(aDados), 3]:= [R$ ] + transf(teste->valor, [@EB 9,999.99])
Next
teste->(dbskip())
Enddo
If !Empty(aDados)
aHEtiquetas:= array(2, 3) /// COORDENADA X
*** etiqueta a ESQUERDA
aHEtiquetas[1, 1]:= aHEtiquetas[1, 2]:= aHEtiquetas[1, 3]:= [00]
*** etiqueta a DIREITA
aHEtiquetas[2, 1]:= aHEtiquetas[2, 2]:= aHEtiquetas[2, 3]:= [200]
y:= 1
ferase([COD_BARRA.TXT])
Setalternate([COD_BARRA.TXT])
For j:= 1 to Len(aDados)
If y == 1 .or. lPrimeiro
? "N"
? "D9"
? "S3"
? "JF"
? "ZT"
? "Q240,24" // Medidas da etiqueta (Altura 30 mm * 8 dots = 240, Distância entre etiquetas 3 mm * 8 = 24)
? "q320" // Medidas da etiqueta (Largura 40 mm * 8 = 320)
lPrimeiro:= .F.
Endif
? 'A' + aHEtiquetas[y, 1] + ',30,0,2,1,1,N,"' + aDados[j, 2] + '"' // primeira linha da descrição
? 'A' + aHEtiquetas[y, 2] + ',70,0,2,1,1,N,"' + aDados[j, 3] + '"' // preço
? 'B' + aHEtiquetas[y, 3] + ',110,0,1,1,2,80,B,"' + aDados[j, 1] + '"' // código de barras ean 128
y++
If y > 2
? "P1" // Quantidade de cópias
? "N" // Este comando apaga a imagem buffer antes de construir uma nova imagem.
y:= 1
Endif
Next
If y > 1
? "P1" // Quantidade de cópias
? "N" // Este comando apaga a imagem buffer antes de construir uma nova imagem.
Endif
Setalternate()
WIN_PrintFileRaw(cPrinter, [COD_BARRA.TXT], [BARRA])
Endif
Else
MsgStop([Não é a Impressora Correta.], [Erro])
Return (Nil)
Endif
Return (Nil)
Procedure Setalternate(cParam)
If cParam == Nil
Set Cons on
Set Alter to
Set Alter off
Else
Set cons off
Set Alter to &cParam
Set Alter on
Endif
Return (Nil)