Results 1 to 40 of 4199

Thread: CommonControls (Replacement of the MS common controls)

Threaded View

  1. #11

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: CommonControls (Replacement of the MS common controls)

    I could have implemented in last update.. However, if I would implement anytime soon (maybe with something other so it would be worth to upgrade type lib version) then as following:

    Code:
    Public Function GetTextRange(ByVal Min As Long, ByVal Max As Long) As String
    If Min > Max Then Err.Raise 380
    If RichTextBoxHandle <> 0 Then
        Dim RETR As RETEXTRANGE, Buffer As String, Length As Long
        RETR.CharRange.Min = Min
        RETR.CharRange.Max = Max
        Buffer = String$(RETR.CharRange.Max - RETR.CharRange.Min + 1, vbNullChar)
        RETR.lpstrText = StrPtr(Buffer)
        Length = SendMessage(RichTextBoxHandle, EM_GETTEXTRANGE, 0, ByVal VarPtr(RETR))
        If Length > 0 Then GetTextRange = Left$(Buffer, Length)
    End If
    End Function
    Code:
    Private Type RECHARRANGE
    Min As Long
    Max As Long
    End Type
    Private Type RETEXTRANGE
    CharRange As RECHARRANGE
    lpstrText As Long
    End Type
    Private Const EM_GETTEXTRANGE as Long = (WM_USER + 75)
    EDIT: some other implemented above function not with Min and Max but rather with Start and Length (similar to SelStart and SelLength), so Min = Start and Max = Start + Length
    Last edited by Krool; Oct 15th, 2021 at 12:35 AM.

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