|
-
Jan 13th, 2000, 01:20 AM
#1
When i try to print a text box, it all just runs off my page. how can i set boundries of the print so that it will type the whole text box?
-
Jan 13th, 2000, 01:45 AM
#2
That's because the Contents of the Textbox is held in a Single String, so unless you Press Return at the end of every line, (inserting a CRLF), the text will Wrap to the next line in the Textbox, but will still be all on the same line in the String.
If you want to Print the Contents of a Textbox exactly as it appears in the Textbox, try this:
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_GETLINECOUNT = &HBA
Private Const EM_GETLINE = &HC4
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1
Private Sub Command1_Click()
Dim lLines As Long
Dim lIndex As Long
Dim sLine As String
Dim lLen As Long
Dim lHwnd As Long
lHwnd = Text1.hwnd
For lLines = 0 To SendMessage(lHwnd, EM_GETLINECOUNT, 0&, ByVal 0&) - 1
lIndex = SendMessage(lHwnd, EM_LINEINDEX, lLines, ByVal 0&)
lLen = SendMessage(lHwnd, EM_LINELENGTH, lIndex, ByVal 0&)
sLine = Space(lLen)
Call SendMessage(lHwnd, EM_GETLINE, lLines, ByVal sLine)
Printer.Print Left$(sLine, lLen)
Next
Printer.EndDoc
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
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
|