dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 3 123 LastLast
Results 1 to 15 of 38

Thread: sending text through winsock with colors

  1. #1
    Join Date
    Jun 2006
    Posts
    290

    sending text through winsock with colors

    hi all, i wanted to see what i can do to accomplish this..

    i have a program setup with a chatroom on it, text is being sent just fine but i cant do anything with the color, how can i

    #1. send the data with the username and text where the username shows up bold and the text shows up with teh color that the user picks from a textbox ( blue = vbblue ) etc..

    and when it comes in from the server have it show the information in the chat text where the colors match what the user puts in there.

    Thanks!

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    a richtextbox control may help u .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Jun 2006
    Posts
    290
    im using RTB for both the input box and the chat text boxes just need to know now how i can either put a color picker on there ( right now im using a combobox with blue, green, red and black, listed as items, if combocolor = green then when it sends the data the text should show up to everyone in green) and i have 3 buttons, B U and I if b is pressed it should make it bold text etc... for now i want to start with the colors, how can i send it through with the colors? Thanks

  4. #4
    Join Date
    Jun 2006
    Posts
    290
    right now this is what its doing when they hit the send key (partial code)

    Winsock1.SendData frmLogin.Text1.Text + " : " + rtbInputText.Text

    frmlogin is where it gets the users username from, and inputtext is where they type in the room. i want to be able to have the username sent in bold, and the input color sent in the color they pick from the combobox.

    Thanks

  5. #5
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Well try to make a suitable separator like "@" , which usernames and text intred must not contains this character for example (or use anaother character that u will restrict)
    and send the data like that :
    text.text & "@" & text.ForeColor & "@" & text.FontBold & ... and so on
    and then in the server translate this by split the resived string and apply this all to the user sent text .
    a better method is to make constant flages which both client and server understand ...
    ex:
    text.text & "@" & "BOLD" & "@" & "BLUE" ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    RTF is just text, so you don't need to do any parsing or translation. Just send the RichTextBox's .TextRTF property from the server, and assign the property on the client to whatever you receive.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    yea u r right !
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  8. #8
    Join Date
    Jun 2006
    Posts
    290
    how would i go about doing that? so far i have the following...

    cmbColor.AddItem "Blue"
    cmbColor.AddItem "Green"
    cmbColor.AddItem "Red"
    cmbColor.AddItem "black"
    cmbSize.AddItem "Small"
    cmbSize.AddItem "Medium"
    cmbSize.AddItem "Large"

    and when they pick one i want it to send with the corrosponding formatting...

    small text should be 10 point, medium 12, and large 14, and then the colors, can you show me an example of lets say medium blue text and i can take it from there. Thanks so much!!!

  9. #9
    Join Date
    Jun 2006
    Posts
    290
    rtbInputText is the input box and rtbchattext is the output box

  10. #10
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    if u use rtb why not follow phil's answer :
    rtbchattext.textrtb = rtbInputText.textrtb
    or just send to the server yourtext.textrtb and assigne this value to the serverstext.textrtb
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  11. #11
    Join Date
    Jun 2006
    Posts
    290
    the server doesnt have the rtb's on it, its just a simple winsock control that throws the data to the clients. so what im thinking is this, if theres a way i can send something like the following.....

    BOLD Username : NoBOLD Formatted Text here

    ...that way the username is sent Black, Bold as Username : and then the text afterwards is formatted based on the users choices. Thanks

  12. #12
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    well the .textrtb is a string containing all the formats u need so it's much more easier to use it , just send to server the .textrtb , the server will hold it as a string and send it back to another client which will assign it to its rtb control ..
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  13. #13
    Join Date
    Jun 2006
    Posts
    290
    so with that said, how to i tell it what the formatting is.. if a user chooses large blue, how do i tell the .textrtb that its large blue? thanks

  14. #14
    Join Date
    Jun 2006
    Posts
    290
    would it be easier to make a button that opens a font chooser and let them pick font, color and size from there and use that in the RTB? can that be done? and if so whats the easiest way to make that happen, im curious to see how this works

  15. #15
    Join Date
    Jun 2006
    Posts
    290
    ok lets try this first.....

    when the send button is pressed, i want it to send the text ( which it does) with the username bolded. how can i accomplish this? since the username is pulled from frmlogin.text1.text standard textbox. Thanks

Similar Threads

  1. Importing text file using schema.ini
    By Kevin in forum VB Classic
    Replies: 3
    Last Post: 12-05-2005, 07:25 PM
  2. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM
  3. Double Text 1.0
    By George Gilbert in forum vb.announcements
    Replies: 0
    Last Post: 08-19-2001, 11:34 AM
  4. Sending text to another program's window...
    By EcliptiC in forum VB Classic
    Replies: 6
    Last Post: 10-21-2000, 11:17 PM
  5. Sending text to another program's window...
    By EcliptiC in forum VB Classic
    Replies: 0
    Last Post: 10-21-2000, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center