Click to See Complete Forum and Search --> : Print the Textbox


Russ Dodge
November 26th, 1998, 05:22 PM
I am looking for some help converting a "short" API function,

printing textbox data to the printer exactly as seen on screen.


The following code works in VB4 16 but not in VB4 32.

The printer spools takes the paper and spits it out but

does not print any text.


I'm using a Form, textbox, Bas module, and command button.


************------------------------*******************


'Module1 (General Declarations):


Declare Function GetFocus% Lib "user" ()

Declare Function SendMessage% Lib "user" (ByVal hWnd%, ByVal wMsg%, _

ByVal wParam%, ByVal lParam As Any)


'(Form 1):


Private Sub Command3_Click()


Printer.CurrentY = Printer.CurrentY + 400

Text1.SetFocus

lnz% = SendMessage(GetFocus(), &H40A, 0&, 0&)

For ii = 0 To lnz%

Printer.CurrentX = 1000

Text1.SetFocus

tem$ = Space(80)

w% = SendMessage(GetFocus(), &H414, ii, tem$)

Printer.print tem$

Next ii

Printer.EndDoc


End Sub


************------------------------******************


The above code works in VB16 I've changed the declaration below

for Win32 - but still does not work.


Option Explicit

Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Long

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As _

Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


Thank You I appreciate any input.

Russ Dodge

rdodge@mathouse.com

Vacaville, Ca.

James Grant
November 27th, 1998, 11:12 AM
You don't need all of those crazy API calls, just try this:



With Printer

'' You might want to just force to Arial; Sans Serif doesn't print well

.FontName = Text1.FontName

.FontSize = Text1.FontSize

.CurrentY = .CurrentY + 400



'' .Print doesn't work with the "With Printer"

Printer.Print Text1.Text



.EndDoc

End With