Newsgroup: it.comp.lang.visual-basic
Titolo: Stampa ORIZZONTALE DATAREPORT

Immagino che sia una FAQ ma non riesco a trovare nulla (Deja) che mi aiuti.
Il quesito e' presto detto:
ho un progetto che utilizza varie stampe, sia verticali che orizzontali,
fino ad ora ho utilizzato il VS Report che pero' e' un controllo molto
pesante e lento, oltre ad essere commerciale. Ho notato che analoghi report
creati con il datareport di VB6 (SP4) sono molto piu' veloci ad essere
visualizzati (sono stampe a volte di qualche centinaio di pagine).
Il problema e' che avevo sentito che il SP4 di VB correggeva il noto
problema della stampa orizzontale e verticale nello stesso progetto, solo
che non riesco proprio a venirne a capo!!
Mi date una mano per favore?
Giuseppe de Simone
-- 
Posted from [212.239.0.39] 
via Mailgate.ORG Server - 
http://www.Mailgate.ORG

 il 03/08/2000.
Il subject del messaggio era: Re: R: DataReport Giuseppe
Il messaggio è stato recuperato con DejaNews (
www.deja.com
)
-----------------------------------------------------------
Per la stampa orizzontale......mettere questo codice in un modulo (.bas) 
 
 
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
 
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8
Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or
PRINTER_ACCESS_USE)
 
Private Const DM_MODIFY = 8
Private Const DM_IN_BUFFER = DM_MODIFY
Private Const DM_COPY = 2
Private Const DM_OUT_BUFFER = DM_COPY
Private Const DM_DUPLEX = &H1000&
Public Const DMDUP_SIMPLEX = 1
Private Const DMDUP_VERTICAL = 2
Private Const DMDUP_HORIZONTAL = 3
Private Const DM_ORIENTATION = &H1&
 
Private Type DEVMODE
    dmDeviceName As String * CCHDEVICENAME
    dmSpecVersion As Integer
    dmDriverVersion As Integer
    dmSize As Integer
    dmDriverExtra As Integer
    dmFields As Long
    dmOrientation As Integer
    dmPaperSize As Integer
    dmPaperLength As Integer
    dmPaperWidth As Integer
    dmScale As Integer
    dmCopies As Integer
    dmDefaultSource As Integer
    dmPrintQuality As Integer
    dmColor As Integer
    dmDuplex As Integer
    dmYResolution As Integer
    dmTTOption As Integer
    dmCollate As Integer
    dmFormName As String * CCHFORMNAME
    dmLogPixels As Integer
    dmBitsPerPel As Long
    dmPelsWidth As Long
    dmPelsHeight As Long
    dmDisplayFlags As Long
    dmDisplayFrequency As Long
    dmICMMethod As Long        '// SOLO x Windows 95
    dmICMIntent As Long        '// SOLO x Windows 95
    dmMediaType As Long        '// SOLO x Windows 95
    dmDitherType As Long      '// SOLO x Windows 95
    dmReserved1 As Long        '// SOLO x Windows 95
    dmReserved2 As Long        '// SOLO x Windows 95
End Type
 
Private Type PRINTER_DEFAULTS
    pDatatype As String
    pDevMode As Long
    DesiredAccess As Long
End Type
 
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As
String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
Private Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long,
ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long
Private Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long,
ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As
Any, ByVal cbCopy As Long)
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal
hwnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As Any,
ByVal pDevModeInput As Any, ByVal fMode As Long) As Long
 
Public Sub SetOrientation(NewSetting As Long, chng As Integer)
    Dim PrinterHandle As Long
    Dim PrinterName As String
    Dim pd As PRINTER_DEFAULTS
    Dim MyDevMode As DEVMODE
    Dim Result As Long
    Dim Needed As Long
    Dim pFullDevMode As Long
    Dim pi2_buffer() As Long
 
    PrinterName = Printer.DeviceName
    If PrinterName = "" Then
        Exit Sub
    End If
 
    pd.pDatatype = vbNullString
    pd.pDevMode = 0&
 
    pd.DesiredAccess = PRINTER_ALL_ACCESS
 
    Result = OpenPrinter(PrinterName, PrinterHandle, pd)
 
    Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)     ReDim pi2_buffer((Needed \ 4))
    Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed) 
 
    pFullDevMode = pi2_buffer(7)
 
    Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode)) 
 
    MyDevMode.dmDuplex = NewSetting
    MyDevMode.dmFields = DM_DUPLEX Or DM_ORIENTATION
    MyDevMode.dmOrientation = chng
 
    Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode)) 
 
    ' CAMBIARE ''Form1.hwnd'' con il nome del DATAREPORT
    Result = DocumentProperties(Form1.hwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal
pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER) 
 
    Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0&) 
 
    Call ClosePrinter(PrinterHandle)
 
    Dim p As Printer
    For Each p In Printers
        If p.DeviceName = PrinterName Then
            Set Printer = p
            Exit For
        End If
    Next p
    Printer.Duplex = MyDevMode.dmDuplex
End Sub
 
metti nella form.....
 
' ORIZZONTALE
    Call SetOrientation(DMDUP_SIMPLEX, 2)
oppre
    ' VERTICALE
    'Call SetOrientation(DMDUP_SIMPLEX, 1)
tuodatareport.show
 
 
ATTENZIONE LE COSE CAMBIANO SE SI PARLA DI WIN NT
 
Buon lavoro :)
-----------------------------------------------------------
Ciao,
Moreno
#sirri#@#morenosoft#.com
(togliete "#" dall'indirizzo)
Moreno Sirri VB Site - 
http://www.morenosoft.com/MSVBSite/
---------------------------------------------------------------------------
Le risposte alle tue domande le trovi sul Sito Comune di questo NewsGroup:
 
http://www.murialdo.it/it_lang_vb
---------------------------------------------------------------------------