FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Printersetup()
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Printersetup()
Posted: Mon Jan 26, 2015 06:34 PM
Hasta ahora ven铆a usando la funci贸n Printersetup() para seleccionar la impresora a la que mandar los listados.
Desde que he actualizado cuando se selecciona la impresora no hace caso a la selecci贸n y se elija la que se elija siempre manda la impresi贸n a la que est谩 marcada como predeterminada por el windows.
驴Hay alguna otra manera nueva de hacerlo?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Printersetup()
Posted: Mon Jan 26, 2015 06:44 PM
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Printersetup()
Posted: Mon Jan 26, 2015 07:55 PM

No me vale esa soluci贸n porque lo que hace es cambiar la impresora predeterminada en windows.
Y porque adem谩s, el primer documento que se manda a imprimir despu茅s de cambiarla, aun sigue saliendo por la impresora primera que estaba como predeterminada.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printersetup()
Posted: Tue Jan 27, 2015 06:17 AM

Paz,

Puedes poner un peque帽o ejemplo completo que muestre el problema ? gracias

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Printersetup()
Posted: Fri Jan 30, 2015 08:28 PM
En el siguiente ejemplo se imprimen cuatro documentos.
Al seleccionar la impresora (distinta de la predeterminada de windows) antes de empezar con el bucle de impresi贸n de los cuatro documentos se obtiene como resultado que el primero se imprime en la impresora seleccionada y el resto en la predeterminada de windows:

Code (fw): Select all Collapse
#include 'inkey.ch'
#include 'set.ch'
#include 'report.ch'
#include 'fivewin.ch'
#include 'rddsys.ch'       
#include "common.ch"
#include "DLL.ch"
#include 'ord.ch'                                    //Para CDX
#include 'Image.ch'
#include "fileio.ch"

external dbfcdx, ordkeyno, ordkeycount, ordkeygoto   //Para CDX

REQUEST HB_Lang_ES
REQUEST HB_CODEPAGE_ESWIN   //Comentar en xHarbour

static oWnd

function main()
    HB_Langselect("ES") 
    HB_SetCodePage("ESWIN")

    setHandleCount(50)
    set 3DLOOK ON
    
    DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0,-14 //BOLD //SIZE 8,16
    DEFINE FONT oFontDoble NAME "MS Sans Serif" SIZE 0,-16
    public nSizeCond:= 8
    public nSizeNorm:=10

    rddsetdefault('DBFCDX')
    set AUTOSHARE TO 1   //CDX Modo Multiusuario.

    DEFINE BRUSH oBru COLOR rgb(0,0,135) //Fondo de color

    DEFINE WINDOW oWnd TITLE 'GESTION DE ESTACIONES' BRUSH oBru MENU MenuPpal() 
    
    set MESSAGE OF oWnd TO 'Prueba'+CurDir() CLOCK DATE KEYBOARD
    ACTIVATE WINDOW oWnd MAXIMIZED ON INIT ( oWnd:setfont(oFont) )
return NIL

static function MenuPpal()
    local oMenu

    MENU oMenu
       MENUITEM '&PruebaPRN' ACTION imprimelotedocs()
       MENUITEM '&SALIR' ACTION oWnd:end()
    ENDMENU
return oMenu

function imprimelotedocs()
 local nDocs:=4, i:=0
 if PrinterSetup() <> 0
  for i=1 TO 4
   FImprime_Test(i, .F.)
  next i
 endif
return nil


/** Funcion para imprimir FACTURAS de CONTADO a clientes.
 **  Devuelve el nombre de la factura impresa por si se usa para PDF.
 **/
function FImprime_Test(nNumeroDoc, lPrever)
  local nl:=0           // numero de linea que se est谩聽 imprimiendo.
  local texto:=Space(62)      // texto de la l铆nea a imprimir.
 
  local oPrn, oFont1, oFont2, oFontCond
  local nsl, nColStep
  local fontsize:=-10
  local mrgiz:=2, mrgsu:=2  // En cent铆metros.
   
  local oPen1, oPen2
  local salir:=.f.
   
  nsl := 4 * (-1)*fontsize / 100  // Alto en cm para el salto de linea
  
  if lPrever = .f. .or. lPrever=NIL
     PRINT oPrn NAME "PruebaPRN"+alltrim(str(nNumeroDoc))
    else
     PRINT oPrn NAME "PruebaPRN"+alltrim(str(nNumeroDoc)) PREVIEW
  endif  
     
    DEFINE FONT oFont1 NAME "COURIER NEW" SIZE 0, fontsize OF oPrn
    DEFINE FONT oFont2 NAME "COURIER NEW" SIZE 0, fontsize BOLD OF oPrn
    DEFINE FONT oFontCond NAME "COURIER NEW" SIZE 0, 8 OF oPrn
    DEFINE PEN oPen1 width 1
    DEFINE PEN oPen2 width 2
    
    if empty( oPrn:hDC )
      msgstop( "No hay impresora preparada" )
      salir=.t.
    endif

  msgwait("IMPRIMIENDO Doc.: PruebaPRN"+alltrim(str(nNumeroDoc)),,1)

  PAGE
   
    nl=mrgsu + 3*nsl
    // Datos del emisor 
    oPrn:CmSay(nl,mrgiz, "Campo 1",oFont2)
    oPrn:CmSay(nl+1*nsl,mrgiz,"Campo 2",oFont1)
    oPrn:CmSay(nl+2*nsl,mrgiz,"Campo 3",oFont1)
    
    nl=nl+7*nsl
    
    oPrn:line(nl,mrgiz,nl,19,oPen2)
    nl=nl+1*nsl

    texto='PRUEBA DE TEXTO'
    oPrn:CmSay(nl,mrgiz,texto,oFont1)
    oPrn:CmSay(nl,15,'FECHA: '+dtoc(date()),oFont1)
    nl=nl+1*nsl

  ENDPAGE //EJECT

 ENDPRINT // Apaga la impresora

 //oFont1:end()
 //oFont2:end()
 //oFontCond:end()
 oPen1:end()
 oPen2:end()
 
return "PruebaPRN"+alltrim(str(nNumeroDoc))
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printersetup()
Posted: Sun Feb 01, 2015 07:57 AM

Paz,

> Al seleccionar la impresora (distinta de la predeterminada de windows) antes de empezar con el bucle de impresi贸n

Donde seleccionas la impresora en tu c贸digo ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Printersetup()
Posted: Sun Feb 01, 2015 04:45 PM

Lo hago con la funci贸n PrinterSetup().
Aparece en una sola de las l铆neas del c贸digo que he puesto.

Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Printersetup()
Posted: Sun Feb 01, 2015 04:48 PM

En concreto dentro de la funci贸n llamada imprime llamada imprimelotedocs

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printersetup()
Posted: Mon Feb 02, 2015 11:38 AM
Paz,

Prueba asi:

Code (fw): Select all Collapse
function imprimelotedocs()
 local nDocs:=4, i:=0, cPrnName
 if PrinterSetup() <> 0
   cPrnName = PrnGetName()
  for i=1 TO 4
   FImprime_Test(i, .F., cPrnName)
  next i
 endif
return nil


y luego al crear el objeto PRINT haz asi:

Code (fw): Select all Collapse
  if lPrever = .f. .or. lPrever=NIL
     PRINT oPrn NAME "PruebaPRN"+alltrim(str(nNumeroDoc)) TO cPrnName
    else
     PRINT oPrn NAME "PruebaPRN"+alltrim(str(nNumeroDoc)) PREVIEW TO cPrnName
  endif
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion