WoW-like Chat Links

I’ve been doing some major remodeling of the chat system and coming up with features that will make chatting faster and easier. One of the things I’ve always wanted to do is find a way to make chat “links” like in WoW. If you’ve played, you realize what I mean. The premise is that a player can create said link, which will be clickable in the chat box, triggering a popup with various stats and whatnot. I’m pretty adequate with the source code, so I don’t need any help with implementing the popups or the creation of the link. The trouble I’m having is how to make the link clickable. As it is, a RichTextBox doesn’t offer any (that I know of) way to pinpoint clicked text.

So, the question I pose is how do I do this? I don’t need a tutorial or anything. Just point me in the right direction. I’ve got nothing to go on right about now.

You’re going to have to load up the RTB to handle hypertext tags.

You can probably find a set of classes which handle all this anyway, try looking around PSCode and the like.

I remember seeing something like this a while back that allowed a very simple initialisation:

Set Hypertext = New clsHyperText
Hypertext.Initialize txtChat

Then, for example, if you wanted it to find Item names, and allow people to view the details through a chat link, you’d need to do a command check anytime the txtChat was changed, and change it into a hyperlink:

sLength = InStr(start, Msg, "[" & ItemName & "]") + Len("[" & ItemName & "]")
sStart = InStr(sLength, Msg, "[")
sEnd = InStr(sLength, Msg, "]")

That’ll calculate the start, length and end of the “hyperlink” (which we haven’t added.)

Now you need to make it a link!

ItemNum = GetItemNumFromName(ItemName)
If ItemNum > 0 Then
     txtChat.Find "[" & ItemName & "]", start
     Hypertext.InsertHyperlink ItemNum
     txtChat.SelStart = Len(txtChat.Text) - 1
End If

You could try asking Jacob for some help. He’s had this working in his game for a while.

http://web.miragesource.com/forums/memberlist.php?mode=viewprofile&u=1380

Thanks a ton, Robin. I found the class you mentioned. It makes it really easy to accomplish this. I just need to code up the rest of this system and I should be good to go.

http://www.vbforums.com/showpost.php?p=2810599&postcount=61

🙂 Thanks!

Log in to reply