|
-
Sep 7th, 2002, 07:26 PM
#1
Thread Starter
Addicted Member
Do you make printer drivers in C++? If so I need help...
I am just trying to make a printer driver that will just send txt to my receipt printer. I tried to use the Generic text only print driver that comes with windows but it must sent other info to the printer with the text. The printer I have uses codes that tell it to do things like cut the receipt or whatever. I have this working when I just sent the info to be printed to the LTP1 port since it doesn't use a printer driver at all. The thing is that I need to share this and without a driver the printer will not show up on a network. Any ideas or thoughts on what I should do? I don't know any C++... My program is in VB.
Thanks
-
Sep 7th, 2002, 09:32 PM
#2
Frenzied Member
In VB (I know this is a C forum)
Assume you wrote all of your commands to a text file, just send the file to the printer using the Escape api
Code:
Private Declare Function Escape Lib "gdi32" (ByVal hdc As Long, _
ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData _
As String, lpOutData As Any) As Long
Const PASSTHRU = 19
Sub printit()
open "myfile.txt" for input as #1
tmp = Input(LOF(1),1)
Escape Printer.hDC,PASSTHRU,Len(tmp), tmp, 0&
close #1
Printer.EndDoc ' if you need it.
End Sub
This is the same as direct printing - bypassing windows formatting & graphics.
-
Sep 7th, 2002, 11:38 PM
#3
Thread Starter
Addicted Member
I am not writing it to a txt file I am opening LTP1 for output. Is there a way to do what you are saying without writing to a txt file. The reason I want to share this is so 2 computers can enter in info to be printer at the same time and then printed to the same receipt printer. So if they are both trying to open the same file it may cause a problem. Is there a way to code it so I can just put in the following:
-------------------------------------------------
Open "LPT1:" For Output As #1
Print #1, Chr$(27) & "0"
Print #1, Widthbigger; emphasized; " Wheaton Meat Company"; WidthReset; unemphasized
-
Sep 7th, 2002, 11:53 PM
#4
Thread Starter
Addicted Member
I am trying to see if I can get your code to work but I get an error 52 "bad file name or Number" when I get to this line
tmp = Input(LOF(1),1)
-
Sep 8th, 2002, 12:14 AM
#5
Thread Starter
Addicted Member
I tried to just make a form to test this and nothing prints. Here is my code. Nothing happens... It reads the data but it doesn't print it. What am I doing wrong????
------------------------------------------------------------------------------------
Private Const PASSTHROUGH = 19
Private Declare Function Escape Lib "gdi32" (ByVal hdc As Long, _
ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData As _
String, lpOutData As Any) As Long
Sub printit()
Dim tmp As String
Open "testPrint.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, tmp
Escape Printer.hdc, PASSTHROUGH, Len(tmp), tmp, 0&
'Printer.Print tmp
Loop
Printer.EndDoc
Close #1
End Sub
Private Sub Command1_Click()
Call printit
End Sub
Last edited by TSur; Sep 8th, 2002 at 11:04 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|