Never worked with printer
I have never worked with printers in VB. Can anyone please tell me how to show printer setup and printer dialog box in Vb.
Thanks in advance
Shyamli
[166 byte] By [
shprog] at [2007-11-18 19:17:17]

# 1 Re: Never worked with printer
From api-guide (a free tool you can download at www.allapi.net)
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function PrinterProperties Lib "winspool.drv" (ByVal hwnd As Long, ByVal hPrinter As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim hPrinter As Long
OpenPrinter Printer.DeviceName, hPrinter, ByVal 0&
PrinterProperties Me.hwnd, hPrinter
ClosePrinter hPrinter
End Sub
In api guide there is also a good example on commondialogs
The PrintDialog function displays a Print dialog box or a Print
Setup dialog box. The Print dialog box enables the user to specify
the properties of a particular print job.
serach for: PrintDialog Api
Related: have a look at these codes in www.Microsoft.com
(put code in search field...)
set system default printer
Q266767
retrieve settings from a printer driver
Q190218
# 2 Re: Never worked with printer
You can use the CommonDialog Control. With that, you can get PrinterDialog, OpenDialog, SaveDialog, FontDialog, and ColorDialog (I think I got them all!).
I don't have any example code, but it's something like CommonDialog1.ShowPrinter. The CommonDialog doesn't actually send anything to the printer, so you'll have to write additional code for that.
Just be careful, the CommonDialog will change your default printer to whatever you pick. See here for details:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;198712
# 3 Re: Never worked with printer
Can you please help me with the code for real printing too.
i know this sounds real silly but i am very new to all this and learning thru dev-archive only.
Thanks in advance.
Shyamli
shprog at 2007-11-9 23:14:29 >

# 4 Re: Never worked with printer
Basic of printing:
http://www.dev-archive.com/forum/showthread.php?s=&threadid=253457&highlight=printer
Some suggestments
Do not forget Printer.enddoc
http://www.dev-archive.com/forum/showthread.php?s=&threadid=272467&highlight=printer
Print to a picturebox (then paintpicture to printer)
http://www.dev-archive.com/forum/showthread.php?s=&threadid=262768&highlight=printer
Print form RichTextBox
http://www.dev-archive.com/forum/showthread.php?s=&threadid=279493&highlight=printer
Set default printer
http://www.dev-archive.com/forum/showthread.php?s=&postid=747772#post747772
Need more help? use the search option on "Print"