RichTextBox1.SelectionStart = RichTextBox1.Text.Length RichTextBox1.ScrollToCaret() MsgBox("fin du texte")
Option Explicit Private Declare Function GetScrollPos Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long) As Long Dim posfin As Long, deja As Boolean Private Sub Form_Initialize() toto End Sub Private Sub Text1_Change() toto End Sub Private Sub Text1_GotFocus() toto End Sub Private Sub toto() Dim titi As Long titi = Text1.SelStart Text1.SelStart = Len(Text1.Text) posfin = GetScrollPos(Text1.hwnd, 1) Text1.SelStart = titi Timer1.Enabled = True Timer1.Interval = 10 End Sub Private Sub Timer1_Timer() If GetScrollPos(Text1.hwnd, 1) posfin And Not deja Then MsgBox "stop": Timer1.Enabled False End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionIf GetScrollPos(Text1.hwnd, 1) >posfin And Not deja Then MsgBox "stop": Timer1.Enabled False
nul utilisateur n'a besoin d'un message pour savoir qu'il est arrivé à la fin d'un scrollLorsqu'un logiciel ordonne à un utilisateur de lire une licence jusqu'au bout par exemple (donc en déplaçant la scollbar jusqu'en bas), ton code peut trouver toute sa place. Du coup, fini la 'bébelle' et le superflu.
Private Type SCROLLINFO cbSize As Long fMask As Long nMin As Long nMax As Long nPage As Long nPos As Long nTrackPos As Long End Type Private Declare Function GetScrollInfo Lib "user32" (ByVal hwnd As Long, ByVal n As Long, lpScrollInfo As SCROLLINFO) As Long Private Sub Form_Initialize() Timer1.Enabled = True Timer1.Interval = 10 End Sub Private Sub Timer1_Timer() Static ant As Long Dim titi As SCROLLINFO, toto As Long With titi .cbSize = Len(si) .fMask = 1 Or 2 Or 4 Or 16 toto = GetScrollInfo(RichTextBox1.hwnd, 1, titi) If toto <> 0 Then If .nPos > ant And .nPos >= .nMax - .nPage Then MsgBox "stop" ant = .nPos End If End With End Sub
Dim titi As SCROLLINFO
With titi .cbSize = Len(titi)
toto = GetScrollInfo(RichTextBox1.hwnd, 1, titi)