quand je bouge manuellement la scrollbar avec la souris le texte bouge (...). y a t il un moyen de bouger le texte quand je changer la position de la scrollbars ?
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function FlatSB_GetScrollInfo Lib "comctl32" (ByVal hwnd As Long, ByVal fnBar As Long, lpsi As SCROLLINFO) As Boolean Private Declare Function FlatSB_SetScrollInfo Lib "comctl32" (ByVal hwnd As Long, ByVal fnBar As Long, lpsi As SCROLLINFO, ByVal fRedraw As Boolean) As Long 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 Sub addtotext(msg) Dim SI As SCROLLINFO LockWindowUpdate RichTextBox1.hwnd 'Get the scrollbar information SI.cbSize = Len(SI) SI.fMask = SIF_ALL FlatSB_GetScrollInfo RichTextBox1.hwnd, SB_VERT, SI RichTextBox1.SelStart = Len(RichTextBox1.text) RichTextBox1.SelText = msg & vbCrLf 'Set the new scrollbar information FlatSB_SetScrollInfo RichTextBox1.hwnd, SB_VERT, SI, True LockWindowUpdate 0 End Sub Private Sub Timer1_Timer() addtotext Timer End Sub
a fait des mois que je cherche la solution et que j'essaie des codes et des codes
Private Sub Command1_Click() If Timer1.Enabled True Then Timer1.Enabled False Else Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Dim txt As String txt = "salut #c'est un message de &test " & vbCrLf addtexttortb RichTextBox1, txt End Sub Private Function addtexttortb(rtb As RichTextBox, txt As String) Dim spl As String, i As Long rtb.SelStart = Len(rtb.text) rtb.SelLength = Len(rtb.text) rtb.SelColor = vbBlack For i = 1 To Len(txt) spl = Mid(txt, i, 1) Select Case spl Case "#" rtb.SelStart = Len(rtb.text) rtb.SelLength = Len(txt) rtb.SelColor = vbRed Case "&" rtb.SelStart = Len(rtb.text) rtb.SelLength = Len(txt) rtb.SelColor = vbBlue Case Else rtb.SelStart = Len(rtb.text) rtb.SelLength = Len(txt) rtb.SelText = spl End Select Next End Function
Message envoyé à Claiyah le 11/08/2009 22:32:27 (Ajouter dans votre carnet d'adresses)
Sujet : couleur RTB
Message :
oui, bien sur...
Dim oRichEdit As IRichEditOle
Dim oTextDocument As ITextDocument
SendMessage .hWnd, EM_GETOLEINTERFACE, 0, oRichEdit
If Not Nothing Is oRichEdit Then
Set oTextDocument = oRichEdit
oTextDocument.Range(0, Len(.Text)).Font.ForeColor = vbBlack
....
après, tu peux couper les evenements change, invoquer un freeze...
jouer avec le "SelBackColor", etc.
je joue avec depuis une semaine, ca tourne nikel.
te suffit de prendre l'Olelib ici:
http://www.mvps.org/emorcillo/en/code/vb6/index.shtml