Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a rich text box that get scroll position with the code below

VB
Private Declare Auto Function RtfScroll _
                Lib "user32.dll" Alias "SendMessage" ( _
                ByVal hWnd As IntPtr, _
                ByVal Msg As Integer, _
                ByVal wParam As IntPtr, _
                ByRef lParam As System.Drawing.Point) As Integer

Private Const WM_USER = &H400
Private Const EM_GETSCROLLPOS = WM_USER + 221
Private Const EM_SETSCROLLPOS = WM_USER + 222


To get scroll position:
VB
Dim pt As New System.Drawing.Point()
RtfScroll(rt.Handle, EM_GETSCROLLPOS, 0, pt)


to set scroll position to x=0, y =100:
VB
RtfScroll(RichTextCtl.Handle, EM_SETSCROLLPOS, 0, New System.Drawing.Point(0, 100))


Quote:
I want to create a bookmark right in this position on scrollbar like scrollbar enhanced in visual studio in cod view.


What I have tried:

I have no idea how I can do this
Posted
Updated 7-Feb-22 2:46am
Comments
CHill60 7-Feb-22 5:11am    
I think you will have to create your own control extending the functionality of RichTextBpx
Member 12617947 7-Feb-22 8:21am    
Dear CHiLL60 how can I do that?
Can you help me?
I have no idea how I can do this

1 solution

There are some articles here on CP that can guide you into building your own Custom Control

WinForms Custom Container Control[^]
Writing Your Custom Control: Step by Step[^]

There is also this article https://www.w3computing.com/vb2008/building-custom-windows-controls/[^] but it is a bit old plus there are a lot of advert pop-ups
 
Share this answer
 
Comments
Member 12617947 7-Feb-22 8:49am    
Dear CHiLL60 thank's a lot for help me
CHill60 7-Feb-22 10:03am    
My pleasure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900