|
-
March 6th, 2000, 07:45 AM
#1
Printing a text Box
I have a text box in my application, and want to print it. I use the CommonDialog to get the informations about the printer. But how can I send the Text to the printer.
Can anyone tell how to do this.
mfG Florian
-
March 6th, 2000, 08:24 AM
#2
Re: Printing a text Box
If all you want is to print the contents of the textbox then just do the following.
Printer.print text1.text
printer.enddoc
This will send what text is in the textbox to the default printer.
Hope this helps.
-
January 17th, 2008, 06:00 PM
#3
Re: Printing a text Box
This is the exact question I came here to find, and the above solution did work oh so easily. However, the text in my texbox is large, and when it prints, it doesn't recognize the carriage returns and most of the paragraphs are cut off. Anyone know a way around this?
-
January 17th, 2008, 06:19 PM
#4
Re: Printing a text Box
Then it is a different question. Please start a new thread.
-
January 17th, 2008, 08:21 PM
#5
Re: Printing a text Box
I think I did that before:
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any _
) As Long
Private Const EM_GETLINE = &HC4
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINELENGTH = &HC1
Private Const EM_LINEINDEX = &HBB
Private Function GetTextBoxLine(TBox As TextBox, ByVal LineNr As Long) As String
' get one line out of a textbox
Dim LineLength As Long
Dim LineStart As Long
'get start of line and length
LineStart = SendMessage(TBox.hWnd, EM_LINEINDEX, LineNr, ByVal 0&)
LineLength = SendMessage(TBox.hWnd, EM_LINELENGTH, LineStart, ByVal 0&)
'return line
GetTextBoxLine = Mid$(TBox, LineStart + 1, LineLength)
End Function
Private Sub PrintTextBox(TBox As TextBox)
Dim nLines%, i%
nLines = SendMessage(TBox.hWnd, EM_GETLINECOUNT, 0, 0&)
For i = 0 To nLines - 1
Printer.Print GetTextBoxLine(TBox, i)
Next
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
|