Hi,
Is there a way to show the printer properties dialog throught VB ?
Like when you right-click in the printer icon in "Control Panel->Printers->xxxx" and choose properties.
Thanks in advance,
Printable View
Hi,
Is there a way to show the printer properties dialog throught VB ?
Like when you right-click in the printer icon in "Control Panel->Printers->xxxx" and choose properties.
Thanks in advance,
Sorry for asking and answering but I manage to do what I wanted with this api call for if anyone is interested.
Declarations:
Option Explicit
Private Declare Function PrinterProperties Lib "winspool.drv" _
(ByVal hwnd As Long, ByVal hPrinter As Long) As Long
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 ClosePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Private Type PRINTER_DEFAULTS
pDatatype As Long ' String
pDevMode As Long
pDesiredAccess As Long
End Type
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)
Code:
Public Function DisplayPrinterProperties(DeviceName As String) _
As Boolean
'PURPOSE: Displays the property sheet for the printer
'Specified by Device Name
'PARAMETER: DeviceName: DeviceName of Printer to
'Display Properties of
'EXAMPLE USAGE: DisplayPrinterProperties Printer.DeviceName
'NOTES: As Written, you must put this function into a form
'module. To put into a .bas or .cls module, add a parameter for
'the form or the form's hwnd.
On Error GoTo ErrorHandler
Dim lAns As Long, hPrinter As Long
Dim typPD As PRINTER_DEFAULTS
typPD.pDatatype = 0
typPD.pDesiredAccess = PRINTER_ALL_ACCESS
typPD.pDevMode = 0
lAns = OpenPrinter(Printer.DeviceName, hPrinter, typPD)
If lAns <> 0 Then
lAns = PrinterProperties(Me.hwnd, hPrinter)
DisplayPrinterProperties = lAns <> 0
End If
ErrorHandler:
If hPrinter <> 0 Then ClosePrinter hPrinter
End Function
Alternativley you could use the Common Dialog Control. This has the usual ShowOpen, ShowSave, ShowFont and ShowColor dialogs.
The one you want though is the ShowPrinter Method.