Sección de controles Ocx para Visual basic , Dll , Activex
<Volver> - Anterior - Siguiente
Este Activex dll contiene algunas propiedades que no posee el control CommonDialog de vb
Por ejemplo algunas de las propiedades que tiene implementadas son:
La propiedad PrinterName para establecer la impresora, la propiedad Port y Driver para el puerto y el driver, la propiedad PaperBin, propiedad Duplex, PaperSize y PrintQuality, y alguna otra
El enlace del artículo : Printerdlg.dll
El ejemplo lo podés descargar desde dicho enlace, junto con el dll ( registrarlo en el sistema )
O también desde este link
(Lo que hace el código de muestra es abrir el cuadro de diálogo de impresión, y luego visualiza todas las propiedades que se han seleccionado)
Código fuente en un formulario con un Command1 y un List1
Private Sub Command1_Click()
Dim m_Printer As New PrinterDlg
' Establece las propiedades desde el objeto printer para el dll
With m_Printer
.PrinterName = Printer.DeviceName
.DriverName = Printer.DriverName
.Port = Printer.Port
.PaperBin = Printer.PaperBin
.Flags = VBPrinterConstants.cdlPDNoSelection _
Or VBPrinterConstants.cdlPDNoPageNums _
Or VBPrinterConstants.cdlPDReturnDC
End With
Printer.TrackDefault = False
' verifica si se presiono el Cancelar , si es si sale
If Not m_Printer.ShowPrinter(Me.hWnd) Then
MsgBox "Se presionó cancelar", vbInformation
Exit Sub
End If
Dim NewPrinterName As String
Dim objPrinter As Printer
' setea el objeto printer con los valores que se seleccionó _
cantidad de copias, la orientación, el tamaño de la hoja, _
la impresora , etc..
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' el nombre
NewPrinterName = UCase$(m_Printer.PrinterName)
If Printer.DeviceName <> NewPrinterName Then
For Each objPrinter In Printers
If UCase$(objPrinter.DeviceName) = NewPrinterName Then
Set Printer = objPrinter
End If
Next
End If
' establece
With Printer
.Copies = m_Printer.Copies
.Orientation = m_Printer.Orientation
.ColorMode = m_Printer.ColorMode
.Duplex = m_Printer.Duplex
.PaperBin = m_Printer.PaperBin
.PaperSize = m_Printer.PaperSize
.PrintQuality = m_Printer.PrintQuality
End With
' visualiza en el ListBox las opciones
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With Printer
List1.AddItem "DeviceName: " & .DeviceName ' la impresora
' la orientación
If .Orientation = 1 Then
List1.AddItem "Orientación : Portrait."
Else
List1.AddItem "Orientación : Landscape."
End If
List1.AddItem "Copias: " & .Copies
If .ColorMode = 1 Then
List1.AddItem "Color Mode: Blanco y negro"
Else
List1.AddItem "Color Mode: a Color"
End If
If .Duplex = 1 Then
sOpciones = sOpciones & "Duplex" & "No"
List1.AddItem "Duplex : No"
ElseIf .Duplex = 2 Then
List1.AddItem "Duplex : Horizontal"
ElseIf .Duplex = 3 Then
List1.AddItem "Duplex : Vertical"
Else
List1.AddItem "Duplex : desconocido"
End If
List1.AddItem "PaperBin " & .PaperBin
List1.AddItem "Tamaño de la hoja " & .PaperSize
List1.AddItem "Calidad " & .PrintQuality
If (m_Printer.Flags And VBPrinterConstants.cdlPDPrintToFile) = _
VBPrinterConstants.cdlPDPrintToFile Then
Debug.Print "Print to File Selected"
Else
Debug.Print "Print to File Not Selected"
End If
End With
Exit Sub
End Sub
Private Sub Form_Load()
Command1.Caption = "Abrir"
End Sub
Buscar en Recursos vb con Google
Recursos visual basic - Buscar - Privacidad - Copyright © 2005 - 2009 - www.recursosvisualbasic.com.ar