VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Cheating the Printer

Jay Kreusch  (6 Submissions)   Files/File Controls/Input/Output   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Why mess around with the printer object if you don't have to? In my example, I print the contents of a richtextbox control to the printer with only a couple of lines of code. PERFECTLY formatted. Readily applies to just about any control or string, though.

Side Effects
Sometimes displays the splash screen of another program or a print dialog box

API Declarations
'Used for the shell printing
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal _
lpDirectory As String, ByVal nShowCmd As Long) As Long
'Used to come up with the temp file directory
Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
'used to come up with the temp file name
Private Declare Function GetTempFileName Lib "kernel32" _
Alias "GetTempFileNameA" (ByVal lpszPath As String, _
ByVal lpPrefixString As String, ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long

Rate Cheating the Printer (8(8 Vote))
Cheating the Printer.bas

Cheating the Printer Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters