Results 1 to 3 of 3

Thread: Printer properties diallog.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Question

    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,
    Jorge Ledo
    [email protected]
    Portugal were the sun allways shine... for programmers.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Reply by myself.

    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
    Jorge Ledo
    [email protected]
    Portugal were the sun allways shine... for programmers.

  3. #3
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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.
    Iain, thats with an i by the way!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width