Results 1 to 5 of 5

Thread: winsock "fred is typing." question :) [resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    the UK
    Posts
    265

    Smile winsock "fred is typing." question :) [resolved]

    Hi,

    I have a winsock p2p chat app and want to replicate the common messenger feature that tells a user when the other is typing.

    What do you think the best way to do this would be? I've tried playing with

    Private Sub txtMessage_Change()

    but with little or no luck.

    Any ideas?

    Simon
    Last edited by simonp; Apr 12th, 2004 at 11:27 AM.

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I suggest having a timer on the form, that looks at the current text in your textbox, if it changed from the last time it looked (and it's not empty), then send a small amount of data saying 'User is typing'.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Probably best to set a timer, for say, 1 second, before you send the blank message. If you have 2 PC's next to each other, and have them both on msn, youll see that even when you stop typing, it doesn't automatically inform the other user.

    VB Code:
    1. Dim kDown As Boolean
    2.  
    3. Private Sub Timer1_Timer()
    4. If Not kDown Then
    5. 'send the blank message
    6. Else
    7. 'send the typing message
    8. End If
    9. End Sub
    10.  
    11. Private Sub txtMessage_KeyDown(KeyCode As Integer, Shift As Integer)
    12. kDown = True
    13. End Sub
    14.  
    15. Private Sub txtMessage_KeyUp(KeyCode As Integer, Shift As Integer)
    16. kDown = False
    17. End Sub

    It might not be the best way, but give it a shot..

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Or reset the flag in the timer
    VB Code:
    1. Private IsTyping
    2.  
    3. Private Text1_Keypress(KeyAscii As Integer)
    4.    IsTyping = True
    5. End Sub
    6.  
    7. Private Timer1_Timer()
    8.    If IsTyping Then
    9.       WinSock.Send "Is typing."
    10.       IsTyping = False  '<------
    11.    Else
    12.       Winsock.Send "No longer typing
    13.    End If
    14. End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    the UK
    Posts
    265
    Thanks everyone.

    leinad31 - your solution was great and is working perfectly.

    Simon

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