Results 1 to 5 of 5

Thread: Chat app - send Font color

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Chat app - send Font color

    I have been working on a app and currently have got it working the user can set there font color so i want when the user sends the text it also send the color as well

    heres the code i use to collor the text

    vb Code:
    1. Private Sub DisplayT(ByVal text As String)
    2.         Dim sto As String
    3.         sto = "You say: "
    4.  
    5.  
    6.  
    7.  
    8.         Dim selectionStart As Integer = txtDisplay.TextLength
    9.  
    10.         txtDisplay.AppendText(sto)
    11.         txtDisplay.SelectionStart = selectionStart
    12.         txtDisplay.SelectionLength = sto.Length
    13.         txtDisplay.SelectionColor = Color.Green
    14.         stoco(text)
    15.     End Sub
    16.     Sub stoco(ByVal text As String)
    17.  
    18.  
    19.  
    20.         Dim selectionStart As Integer = txtDisplay.TextLength
    21.  
    22.         txtDisplay.AppendText(text)
    23.         txtDisplay.SelectionStart = selectionStart
    24.         txtDisplay.SelectionLength = text.Length
    25.         txtDisplay.SelectionColor = txtSend.ForeColor
    26.  
    27.         txtDisplay.AppendText(Environment.NewLine)
    28.  
    29.  
    30.     End Sub

    and heres the code i use to send the text to the server

    vb Code:
    1. If txtSend.Text <> "" Then
    2.             DisplayT(txtSend.Text)
    3.             SendData("CHAT|" & txtSend.Text)
    4.             txtSend.Text = ""
    5.         End If

    vb Code:
    1. Public Sub SendData(ByVal data As String)
    2.         Dim writer2 As New IO.StreamWriter(client.GetStream)
    3.         writer2.Write(data & vbCr)
    4.         writer2.Flush()
    5.     End Sub
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Chat app - send Font color

    Just send a code (a number) that represents the font colour and have the client side read that before it shows the message and then it can set the relevant font colour.
    So instead of sending CHAT|MessageHere you might send CHAT|10|MessageHere where 10 would represent a colour. There might be a better way of doing it but thats the only way I can think of.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Chat app - send Font color

    there is only one issue there they can pick any color and also set there own custom colors so i would need to set a number for every color OR restict the colors they can pick From
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Chat app - send Font color

    Use the ColorDialog control and just set the color to whatever has been selected from that.

    Much easier...

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Chat app - send Font color

    thats what im doing but when happens in the user selects there font color and then when the user hit send it shows up in that color on the other users screens
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width