|
-
Sep 14th, 2000, 04:29 PM
#1
Thread Starter
Hyperactive Member
I have a chat application I made in VB . The main window is a richtextbox . I want to add color to the "Nick" the person is using and I tried this
Code:
Public Sub colorize()
Dim posEnd, posStart, x, i As Integer
x = 0
i = 0
For i = 0 To Len(RichTextBox1.Text)
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 1
If RichTextBox1.SelText = ">" Then 'start tag
posStart = i
RichTextBox1.SelColor = vbRed
End If
Next i
End Sub
The Probem with that is that evertime something new is put in the box it scrolls through the whole RTB contents and it looks ugly . How do they do it in Mirc ? Should I write all the chat strings to a file and reload it evertime something new is entered ? Any ideas would be great ! Thanks again .
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Sep 14th, 2000, 05:43 PM
#2
What is it you are trying to do? (I haven't used Mirc before, so I'm unsure)
-
Sep 14th, 2000, 05:56 PM
#3
Thread Starter
Hyperactive Member
When a message comes in from the client It's Formatted like this
<NickA> some message here
<Nick2> another message here
as People talk the more lines get into the RTB
What I want is to have the <Nick> in one color and the message in another . The function in the above is what I was using . I called it everytime new text was added to the
RTB , but it led to the whole RTB being parsed everytime
which in turn led to it scrolling through it every time .
Did that make more sense ?
Private
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Sep 14th, 2000, 06:02 PM
#4
Fanatic Member
I've done it with this code:
Code:
'put an "L" infront of the username for it to show up in red
'(local), nothing for Blue(remote)
Private Sub NewMessage(User As String, Message As String)
Dim PostColor As ColorConstants
Dim NewUser As String
If Left(User, 1) = "L" Then
NewUser = Mid(User, 2, Len(User) - 1)
PostColor = vbRed
Else
PostColor = vbBlue
NewUser = User
End If
With txtClient
.SelStart = Len(.Text)
.SelBold = True
.SelColor = PostColor
.SelText = NewUser & ": "
.SelBold = False
.SelColor = vbBlack
.SelText = Message & vbNewLine
End With
End Sub
Modify as you wish
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 14th, 2000, 07:25 PM
#5
Try the following. Add a RichTextBox, TextBox and CommandButton. When you press the button, the message in the TextBox will be added to the RichTextBox.
Insert this code into the Button.
Code:
Private Sub Command1_Click()
RichTextBox1.SelText = vbNewLine
'Draw the Nick name is blue
RichTextBox1.SelColor = vbBlue
RichTextBox1.SelText = "<Nick> "
'Change the colour to red when the message is displayed
RichTextBox1.SelColor = vbRed
RichTextBox1.SelText = Text1
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|