Option Strict On Imports System.Printing Imports System.Drawing.Printing Public Class Form1 Private Declare Auto Function GlobalLock Lib "kernel32.dll" _ (ByVal handle As IntPtr) As IntPtr Private Declare Auto Function GlobalUnlock Lib "kernel32.dll" _ (ByVal handle As IntPtr) As Integer Private Declare Auto Function GlobalFree Lib "kernel32.dll" _ (ByVal handle As IntPtr) As IntPtr Private Declare Auto Function DocumentProperties Lib "winspool.drv" _ (ByVal hWnd As IntPtr, ByVal hPrinter As IntPtr, _ ByVal pDeviceName As String, ByVal pDevModeOutput As IntPtr, _ ByVal pDevModeInput As IntPtr, ByVal fMode As Int32) As Integer Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim PrintDocument As PrintDocument = New PrintDocument Me.OpenPrinterPropertiesDialog(PrintDocument.PrinterSettings) End Sub Sub OpenPrinterPropertiesDialog(ByVal Settings As PrinterSettings) Dim hDevMode As IntPtr = _ Settings.GetHdevmode(Settings.DefaultPageSettings) Dim pDevMode As IntPtr = GlobalLock(hDevMode) DocumentProperties(Me.Handle, IntPtr.Zero, _ Settings.PrinterName, pDevMode, pDevMode, 14) GlobalUnlock(hDevMode) Settings.SetHdevmode(hDevMode) Settings.DefaultPageSettings.SetHdevmode(hDevMode) GlobalFree(hDevMode) End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question