Click here to Skip to main content
15,886,810 members

Comments by Andre Oosthuizen (Top 200 by date)

Andre Oosthuizen 6hrs 15mins ago View    
I am not sure what your comment means...
Andre Oosthuizen 9hrs 10mins ago View    
Show us what output you are expecting and what output you are getting, we have absolutely no idea what your query looks like, what it does where and why.
Andre Oosthuizen 17-Apr-24 12:59pm View    
Using the values from the pointers is not entirely possible and WAY over even my head. Without testing, you can try the following but I personally think that is just paving the way for even more questions and less answers -
To calculate the width of the selection border indirectly you can use the information given by 'EM_GETMARGINS' and some additional Windows messages and properties -
Left and right margins using 'EM_GETMARGINS' -
Dim margins As New RECT()
Dim lParam As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(margins))
SendMessage(Me.Handle, EM_GETMARGINS, IntPtr.Zero, lParam)
margins = Marshal.PtrToStructure(lParam, GetType(RECT))
Marshal.FreeHGlobal(lParam)
Dim leftMargin As Integer = margins.Left
Dim rightMargin As Integer = margins.Right


Width of the rich text box control's client area by subtracting the left and right margins from the control's width -
Dim clientAreaWidth As Integer = Me.RichTextBox1.Width - leftMargin - rightMargin


Width of the rich text box control itself (including borders) by sending the 'EM_GETRECT' message -
Dim controlRect As New RECT()
Dim rectParam As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(controlRect))
SendMessage(Me.Handle, EM_GETRECT, 0, rectParam)
controlRect = Marshal.PtrToStructure(rectParam, GetType(RECT))
Marshal.FreeHGlobal(rectParam)
Dim controlWidth As Integer = controlRect.Right - controlRect.Left


Lastly, calculate the width of the selection border by subtracting the client area width from the control's width -
Dim selectionBorderWidth As Integer = controlWidth - clientAreaWidth
Andre Oosthuizen 17-Apr-24 11:43am View    
You're welcome, glad you found the correct method.
Andre Oosthuizen 17-Apr-24 11:42am View    
These values are actually not meaningless, they are memory addresses or pointers returned that are being used internally by the SendMessage API call. "Doesn't work" is actually meaningless :) as you need to be specific on what does not work.