473,385 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I open the printer "Preferences" dialog?

have customized PageSetup and Print dialogs that emulate the standard
dialogs. I would like to be able to open the "Printer Preferences" dialog by
clicking a button (just like can be done on the standard dialogs).

(On some Print dialogs (such as in Word and Excel) this button is labelled
"Properties". And just to avoid being too consistent, it is labelled
"Options" on the Excel PageSetup dialog.)

I thought that this would be trivial, but so far I haven't been able to
figure out how to do this. Does anyone know of an easy way to open this
"Printer Preferences" dialog box?

Thanks,
Randy

Nov 1 '08 #1
1 8681
For anyone else who may be interested, I finally found the answer here:

http://bytes.com/forum/thread389569.html

This answer is provided by (and with my thanks to) Bart Mermuys. The
following snippet shows the essence of the solution.

Cheers,
Randy

Imports System.Drawing.Printing
Public Class Form1
Private Const DM_IN_BUFFER As Integer = 8
Private Const DM_OUT_BUFFER As Integer = 2
Private Const DM_IN_PROMPT As Integer = 4

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

Sub ShowPrinterProperties(ByVal Settings As PrinterSettings)
' PrinterSettings+PageSettings -hDEVMODE
Dim hDevMode As IntPtr
hDevMode = Settings.GetHdevmode(Settings.DefaultPageSettings)
' Show Dialog ( [In,Out] pDEVMODE )
Dim pDevMode As IntPtr = GlobalLock(hDevMode)
DocumentProperties(Me.Handle, IntPtr.Zero, _
Settings.PrinterName, pDevMode, pDevMode, _
DM_OUT_BUFFER Or DM_IN_BUFFER Or DM_IN_PROMPT)
GlobalUnlock(hDevMode)
' hDEVMODE -PrinterSettings+PageSettings
Settings.SetHdevmode(hDevMode)
Settings.DefaultPageSettings.SetHdevmode(hDevMode)
' cleanup
GlobalFree(hDevMode)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If (Me.PrintDocument1.PrinterSettings.IsValid) Then
Me.ShowPrinterProperties(Me.PrintDocument1.Printer Settings)
Else
MsgBox("Invalid Printer Name!", MsgBoxStyle.Information)
End If
End Sub

End Class
Nov 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
55
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's...
2
by: Eagle | last post by:
Is there any way to make a print button on a form show the printer properties dialog before actual printing the report linked to the command button in AC97 ? I've noticed that opening the report...
1
by: TD | last post by:
I created a new toolbar for my reports and need a button on it that opens (I'm not sure what the offical name of this window is) the Windows printer window where you can select which printer to...
1
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As...
1
by: pradeeppj | last post by:
i am a software engineer working on UNIDRV printer driver using Microsoft Plug-ins IPRINTOEMUI & IPRINTOEMUNI using VC++ as editor, OS win 2000 server. i am using NTDDK driver development kit. i...
2
by: wpollans | last post by:
Hello, I need to able to write JS that will click on a link with the middle mouse button - so that the link target will open in a new window or tab - using firefox. Or is there a better (more...
25
by: Peng Yu | last post by:
Hi, It is possible to change the length of "\t" to a number other than 8. std::cout << "\t"; Thanks, Peng
1
by: Sadik Eser | last post by:
Hi, I want to change the printer setting before printing, i.e. using grayscale printing, instead of colorfull printing. However, I should do it programatically, the users of my program would not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.