473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I open the printer "Preference s" 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 8749
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.d ll" (ByVal handle As IntPtr) As IntPtr
Private Declare Auto Function GlobalUnlock _
Lib "kernel32.d ll" (ByVal handle As IntPtr) As Integer
Private Declare Auto Function GlobalFree _
Lib "kernel32.d ll" (ByVal handle As IntPtr) As IntPtr
Private Declare Auto Function DocumentPropert ies _
Lib "winspool.d rv" (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 ShowPrinterProp erties(ByVal Settings As PrinterSettings )
' PrinterSettings +PageSettings -hDEVMODE
Dim hDevMode As IntPtr
hDevMode = Settings.GetHde vmode(Settings. DefaultPageSett ings)
' Show Dialog ( [In,Out] pDEVMODE )
Dim pDevMode As IntPtr = GlobalLock(hDev Mode)
DocumentPropert ies(Me.Handle, IntPtr.Zero, _
Settings.Printe rName, pDevMode, pDevMode, _
DM_OUT_BUFFER Or DM_IN_BUFFER Or DM_IN_PROMPT)
GlobalUnlock(hD evMode)
' hDEVMODE -PrinterSettings +PageSettings
Settings.SetHde vmode(hDevMode)
Settings.Defaul tPageSettings.S etHdevmode(hDev Mode)
' cleanup
GlobalFree(hDev Mode)
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button1.Click
If (Me.PrintDocume nt1.PrinterSett ings.IsValid) Then
Me.ShowPrinterP roperties(Me.Pr intDocument1.Pr interSettings)
Else
MsgBox("Invalid Printer Name!", MsgBoxStyle.Inf ormation)
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
11032
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 created in the wrong folder on the hard drive. Before I discovered these files, .NET kept trying to create a new project with _1 following the project name. Deleting those files corrected that problem. I deleted the Virtual Directory, rebooted, and...
55
4650
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 not obvious how the code works if you don't know the intricacies of the Property Let/Get syntax. Likewise, I dislike (and code to minimize the use of) the VB/VBA syntax of returning a value by referring to the function name as if it were a...
2
3035
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 and then hitting CTL+P does produce the dialog box but I cannot get this to work via a command button. Most menu items are deactivated in this database BTW.
1
2028
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 print to and change the printer preferences, etc. I am using Access 2003. Is there a way to do this? Thanks, TD
1
6111
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 PRINTER_DEFAULTS Dim pinfo2 As PRINTER_INFO_2 Dim pinfo8 As PRINTER_INFO_8 Dim pinfo9 As PRINTER_INFO_9 Dim dm As DEVMODEW Dim yDevModeData() As Byte
1
1522
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 have a problem details: when i right click on printer icon & then on printing preferences then i got a document property sheets dialog box containing three tabs namely Layout, Paper/quality & Advance.so the problem is that i don't want these...
2
6959
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 reliable) way to have the link open in a new window/tab (using JS)? I have no control over the JS already on the page - this is for a selenium user extension that I'd like to write.
25
30905
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
4327
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 change this property. Thanks..
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.