Visual Basic - Usar la Propiedad RTF con WINSOCK

Life is soft - evento anual de software empresarial
 
Vista:

Usar la Propiedad RTF con WINSOCK

Publicado por DarthRPG (3 intervenciones) el 01/07/2008 20:27:00
Mi Problema es el siguiente, estoy haciendo un chat, y tengo la opcion de darle formato al texto (color, fuente, tamaño) lo que se dice texto erriquecido. Con la propiedad TextRTF puedo recuperar el string con los datos, y lo puedo enviar, pero no puedo cargarlo en el RichTextBox donde se cargan todos los mensajes.
Para enviar tengo el siguiente Codigo:

-----------------------------------------------------------------------------------------------------------------------------
Private Sub txtMensaje_KeyPress(KeyAscii As Integer)
On Error GoTo ErrSub

Dim Contador As Integer

If KeyAscii = 13 Then
KeyAscii = 8
If Trim$(txtMensaje.Text) <> "" Then
Mensaje = "MESSAGE " & IIf(lstUsuarios.ListIndex = -1, " ", lstUsuarios.List(lstUsuarios.ListIndex)) & "" & NombreUsuario & ": " & Trim$(txtMensaje.TextRTF)
txtTexto.Text = txtTexto.Text & vbNewLine & Mid$(Mensaje, 21)
txtTexto.SelStart = Len(txtTexto.Text)

txtMensaje.Text = ""

lstUsuarios.ListIndex = -1

If Anfitrion Then
For Contador = 1 To NConecciones - 1
'Winsock1(Contador).SendData (MensajeRTF)
Call Winsock1(Contador).SendData(Mensaje)
DoEvents
Next Contador
Else
'Winsock1(0).SendData (MensajeRTF)
Call Winsock1(0).SendData(Mensaje)
End If
End If
End If

ErrSub:
If Err.Number = 40006 Then
'Winsock1.Close ' cierra la conexión
MsgBox "Se ha caido la Conexion, consulte por el Administrador", vbCritical
End If
End Sub
-------------------------------------------------------------------------------------------------------------------------

Y para recivir uso el siguiente:

-------------------------------------------------------------------------------------------------------------------------
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim Contador As Integer

'Winsock1(Index).GetData (MensajeRTF)
'Me.txtTexto.TextRTF = MensajeRTF

Call Winsock1(Index).GetData(Mensaje)

If Not isNullOrBlank(Mensaje) Then
ClientFrm.IP = Mensaje
ClientFrm.Show
End If


If Trim$(Mensaje) <> "" Then
If Trim$(Mid$(Mensaje, 1, 10)) = "NEWUSER" Then
lstUsuarios.AddItem Mid$(Mensaje, 11, 10)
Else
If Trim$(Mid$(Mensaje, 11, 10)) = "" Or Trim$(Mid$(Mensaje, 11, 10)) = NombreUsuario Then
txtTexto.TextRTF = txtTexto.Text & vbNewLine & Mid$(Mensaje, 21)
txtTexto.SelStart = Len(txtTexto.Text)
End If
End If
End If

If Anfitrion Then
For Contador = 1 To NConecciones - 1
If Contador <> Index Then
Call Winsock1(Contador).SendData(Mensaje)
DoEvents
End If
Next Contador
End If
End Sub
-------------------------------------------------------------------------------------------------------------------

En realidad no se como hacer bien para recivirlo, igualmente probe de varias maneras y ninguna me funciona. Me envia el texto sin ningun tipo de formato

Tanto los campos txtMensaje como txtTexto son RichTextBox.

Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder