CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 1999
    Posts
    11

    Print the Textbox



    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

    [email protected]

    Vacaville, Ca.





  2. #2
    Join Date
    Apr 1999
    Posts
    16

    Re: Print the Textbox



    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured