Results 1 to 7 of 7

Thread: [RESOLVED] TextBox API functions (for bypassing 64K limit)

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    461

    Resolved [RESOLVED] TextBox API functions (for bypassing 64K limit)

    I have found only one function here (to load huge file into textbox): https://www.planet-source-code.com/v...69294&lngWId=1

    But I also need functions for selecting all text, because native VB functions (.SelStart, .SelLength) can't do that due to 64K characters limit. I know it has to do with SendMessage API but I'm not expert in that field.

    Can someone help me to write such replacement functions?

    EDIT: Found it, here are functions for loading and selecting huge text into TextBox:
    VB Code:
    1. Private Declare Function SendMessage Lib "user32" _
    2.       Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    3.       ByVal wParam As Long, lParam As Any) As Long
    4.      
    5.    'Private Declare Function GetWindowTextLength Lib "user32" _
    6.       Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
    7.  
    8.    Private Const WM_SETTEXT = &HC
    9.    'Private Const WM_GETTEXTLENGTH = &HE
    10.    Private Const EM_SETSEL = &HB1
    11.  
    12. Function LoadBig(txt As TextBox, FileOrString As String, Optional IsString As Boolean, Optional Pre As String)
    13.     On Error GoTo E
    14.    
    15.     Dim TempText As String
    16.     Dim iret As Long
    17.     If Not IsString Then
    18.     Dim FileNum As Integer
    19.     FileNum = FreeFile
    20.     ' Open the selected file.
    21.     Open FileOrString For Input As #FileNum
    22.     TempText = Pre & StrConv(InputB(LOF(FileNum), FileNum), vbUnicode)
    23.     Else: TempText = Pre & FileOrString
    24.     End If
    25.     DoEvents
    26.     txt.Text = ""
    27.    
    28.     iret = SendMessage(txt.hWnd, WM_SETTEXT, 0&, ByVal TempText)
    29.     'iret = SendMessage(txt.hWnd, WM_GETTEXTLENGTH, 0&, ByVal 0&)
    30.     'Debug.Print "WM_GETTEXTLENGTH: " & iret
    31.     TempText = ""
    32. E:  If Not IsString Then Close #FileNum
    33. End Function
    34.  
    35. Function SelectT(txt As TextBox, SelStart As Long, SelEnd As Long)
    36.     Dim iret As Long
    37.     Res = SendMessage(txt.hWnd, EM_SETSEL, SelStart, SelEnd)
    38. End Function
    Last edited by MikiSoft; Feb 1st, 2015 at 02:35 PM.

Tags for this Thread

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