473,468 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ESC/POS Command

I create VB program that must print to the dot matrix printer. I'm
using printer object, but cannot send ESC/POS Command that my printer
recognise to set the layout of the print out.

How can i send ESC/POS Command using printer object in VB?

Thanks
Jul 17 '05 #1
1 19003
On 28 Jul 2003 21:41:50 -0700, ce****@hotmail.com (Ceming) wrote:
I create VB program that must print to the dot matrix printer. I'm
using printer object, but cannot send ESC/POS Command that my printer
recognise to set the layout of the print out.

How can i send ESC/POS Command using printer object in VB?

Thanks


The best method I know of is to bypass the VB Printer Object and send
data directly into the Spooler

Here is a Class that will do just that :-

Option Explicit: DefObj A-Z

Private Type DOC_INFO_1
pDocName As String
pOutputFile As String
pDatatype As String
End Type

Private Declare Function OpenPrinter& Lib "winspool.drv" _
Alias "OpenPrinterA" (ByVal pPrinterName As String, _
phPrinter As Long, _
ByVal pDefault As Long) ' Third param
changed to long
Private Declare Function StartDocPrinter& Lib "winspool.drv" _
Alias "StartDocPrinterA" (ByVal hPrinter As Long, _
ByVal Level As Long, _
pDocInfo As DOC_INFO_1)
Private Declare Function StartPagePrinter& Lib "winspool.drv" _
(ByVal hPrinter As Long)
Private Declare Function WritePrinter& Lib "winspool.drv" _
(ByVal hPrinter As Long, _
pBuf As Any, _
ByVal cdBuf As Long, _
pcWritten As Long)
Private Declare Function EndDocPrinter& Lib "winspool.drv" _
(ByVal hPrinter As Long)
Private Declare Function EndPagePrinter& Lib "winspool.drv" _
(ByVal hPrinter As Long)
Private Declare Function ClosePrinter& Lib "winspool.drv" _
(ByVal hPrinter As Long)

Private hPrinter&, _
docinfo As DOC_INFO_1, _
PrinterName$
Public Function OpenJob(JobName$, Er As Boolean)
Dim JobId&
Er = False

If OpenPrinter(Printer.DeviceName$, hPrinter, 0) = 0 Then
Er = True
Exit Function
End If
docinfo.pDocName = JobName$
docinfo.pOutputFile = vbNullString
docinfo.pDatatype = vbNullString
JobId = StartDocPrinter(hPrinter, 1, docinfo)
End Function

Public Sub StartPage()
Call StartPagePrinter(hPrinter)
End Sub

Public Sub PrintData(S$)
Dim written&
Call WritePrinter(hPrinter, ByVal S$, Len(S$), written)
End Sub

Public Sub EndPage()
Call EndPagePrinter(hPrinter)
End Sub

Public Sub CloseJob()
Call EndDocPrinter(hPrinter)
Call ClosePrinter(hPrinter) ' Close when done
End Sub

Jul 17 '05 #2

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

Similar topics

1
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
2
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal...
34
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: ...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: czerwww | last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that? Code: Imports System.Data.SqlClient Imports System.Data Public Class...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.