|
Always ensure that a printer is installed
|
Total Hit (2908) |
Many developers incorrectly assume that a printer is always installed on their customers' machines, and therefore omit to check that this is actually the case. The following function, deceiptively trivial, returns False and displays an error message if no printer has been installed:
«Code LangId=
....Read More |
Rating
|
|
|
Display the Connect To Printer dialog
|
Total Hit (5043) |
Under Windows NT you can programmatically display the Connect To Printer dialog using one simple API function:
«Code LangId=1»
' This works only under Windows NT and 2000
Private Declare Function ConnectToPrinterDlg Lib "winspool.drv" (ByVal hWnd As _
Long, ByVal flags As Long) As Long
....Read More |
Rating
|
|
|
|
|
|
|
|
|
|
How to Paint a ScanBar CODE39 on Printer or PictureBox
|
Total Hit (2882) |
«Code LangId=1»'Put this code at a module.
'Usage: PaintCodeBar39 Printer, Xpos, Ypos, BarsHeight, WidthFactor, Text, HumanRead
' Printer.EndDoc
Public Type C39
char As String * 1
bar(1 To 5) As Boolean
spe(1 To 5) As Boolean ' 5th space for character gap
End Type
Dim CODE39(
....Read More |
Rating
|
|
|
|
|
|
|
|
Print a Text File
|
Total Hit (2496) |
Module
«Code LangId=1» Option Explicit
Public Sub PrintTXTFile(FileName As String)
Dim x As Integer
Dim s As String
x = FreeFile
On Error GoTo HandleError
Open FileName For Input As x
Do While Not EOF(x)
Line Input #x, s
Printer.Print s
L
....Read More |
Rating
|
|
|
Get the Default Printer
|
Total Hit (5617) |
API Declarations
«Code LangId=1»
Option Explicit
'MS Windows API Function Prototypes
Private Declare Function GetProfileString Lib "kernel32.dll" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVa
....Read More |
Rating
|
|
|
Print an Image contained in a Picture Box or a Form
|
Total Hit (2446) |
Module
«Code LangId=1» 'Print the Picture contained in a PictureBox or a Form
Public Sub PrintImage(p As IPictureDisp, Optional ByVal x, Optional ByVal y, Optional ByVal resize)
If IsMissing(x) Then x = Printer.CurrentX
If IsMissing(y) Then y = Printer.CurrentY
If IsMissing(resiz
....Read More |
Rating
|
|
|
How to Print a Multiline TextBox with Alignment!
|
Total Hit (5093) |
API Declarations
«Code LangId=1» 'Add this to your Declarations Section:
Public Declare Function SetTextAlign Lib "gdi32.dll" (ByVal hdc As Long, ByVal wFlags As Long) As Long
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wmsg As Long, ByV
....Read More |
Rating
|
|
|
How to Print Full Justified Text
|
Total Hit (3138) |
Module
«Code LangId=1» Option Explicit
Public Sub PrintLine(Text As String, SpaceWidth As Single, Target As Object)
'Print a justified line to the Target object
Dim i As Integer
Dim cx As Single
Dim OldBold As Boolean
Dim OldUnderLine As Boolean
Dim OldItalic As
....Read More |
Rating
|
|
|
Print a Picture to Fit a Page!
|
Total Hit (2998) |
Module
«Code LangId=1» Option Explicit
Public Sub PrintPictureToFitPage(Pic As Picture)
Dim PicRatio As Double
Dim printerWidth As Double
Dim printerHeight As Double
Dim printerRatio As Double
Dim printerPicWidth As Double
Dim printerPicHeight As Double
'
....Read More |
Rating
|
|
|
|
Setting Custom Paper Size using Printer API
|
Total Hit (34056) |
Here is the alternate method which shows how to use printer APIs to set custom papersize and other printer properties using API. This code will work with Win9x and WinNT both.
|
Rating
|
|
|
|
How to Cancel Printing job sent to Printer.
|
Total Hit (3127) |
To learn more about Printing Using API click on the folloing link
«a href='http://msdn.microsoft.com/library/en-us/gdi/prntspol_0r1j.asp'»http://msdn.microsoft.com/library/en-us/gdi/prntspol_0r1j.asp«/a»
|
Rating
|
|
|
|
How To Print Using Custom Page Sizes on Windows NT and Windows 2000
|
Total Hit (6750) |
Have you ever tried to set custom paper size using VB inbuilt Printer object ??? You can set custom papersize by setting Printer.PaperSize = 256 and then Printer.Height = 4500 , Printer.Width = 7500 but unfortunately this wont work under NT/2000 because in NT each paper size is considered as a "Form
....Read More |
Rating
|
|
|
How to monitor Printer Queue using printer API
|
Total Hit (19891) |
This article will show you how you can use OpenPrinter, EnumJobs and ClosePrinter API to monitor selected printer's queue.
To implement Quick Demo perform the following steps
- Create a standard exe project
- Add module1
- Place 1 commandbutton, 1 textbox, 1 combobox 1 timer and 1 ListView
....Read More |
Rating
|
|
|
|
How to Add/Delete Printer Programatically using API?
|
Total Hit (29101) |
This article will show you step by step approch to Add and Delete Printer Programatically without any user interaction.
When writing a Win32 application that installs a network printer connection, you must take into consideration differences in printing if the application will be run under both W
....Read More |
Rating
|
|