Print Page | Close Window

Emoticons In Chat

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=176
Printed Date: 20 December 2006 at 5:52pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Emoticons In Chat
Posted By: Sync
Subject: Emoticons In Chat
Date Posted: 11 February 2006 at 3:17pm
Difficulty: Hard 5/5

Originaly Posted By: Xentar

Who made it... nice question xD
~WARNING~ This took me 4 hours to do, and i would make a back up copy of modTEXT.bas if i were you, just in case, you know? AND this is USE AT YOR OWN RISK ALSO! it is commented, so i dont think that I should get to bombarded with Questions... *PLEASE leave suggestions or comments on if this works for you also!*


Allrighty then, this Will add Emo support to your client, BUT... If the users actually click on an emoticon, they will see that they can "play" with it a bit, that is the only draw back so far, i am trying to come up with a way to use HTML and the IE control for better support...

Open frmMirage in Visual mode

1> Add in a picture box, named picBuffer, .visible to FALSE

2> Add in a frame, named frmIcon, visible = FALSE

3> on frmIcon, make an INDEXED image (as many as you want for Emo faces...), named imgIcon.

Ok, now go to modText, and find AddText, and Delete everything in there, and put this in.

Code:
Public Sub AddText(ByVal Msg As String, ByVal Color As Integer)

Dim s As String
Dim NewColor As Integer

Dim lImagePos As Long
Dim lStartMessage As Long
Dim i As Integer, iCC As Integer
Dim CharCombo() As String
Dim ClipboardContents As Variant
Dim bClipHasImage As Boolean
Dim checkForMessage As Integer
Dim chkChar As String
Dim KillNullChar As Integer


s = vbNewLine & Msg

NewColor = Color

bClipHasImage = Clipboard.GetFormat(vbCFBitmap) 'If there's an image in the clipboard
If bClipHasImage Then frmMirage.picBuffer.Picture = Clipboard.GetData 'Store it to picBuffer


frmMirage.txtChat.SelColor = QBColor(Color)
frmMirage.txtChat.Locked = False 'Must be unlocked for SendMessage() to work
frmMirage.txtChat.SelText = s
frmMirage.txtChat.SelStart = Len(frmMirage.txtChat.Text) - 1

lStartMessage = Len(s) - 1

frmMirage.txtChat.SelStart = Len(frmMirage.txtChat.Text) - 1


For i = 0 To frmMirage.imgIcon.Count - 1 'Loop through each icon
CharCombo = Split(frmMirage.imgIcon(i).Tag, " ") 'Get the valid character combinations
' which should be delimited by spaces
' in the .Tag property

For iCC = 0 To UBound(CharCombo) 'Loop through those character combos

lImagePos = InStr(lStartMessage, frmMirage.txtChat.Text, CharCombo(iCC))


While lImagePos > 0 'While the char combo is present
frmMirage.txtChat.SelStart = lImagePos - 1
frmMirage.txtChat.SelLength = Len(CharCombo(iCC)) 'Clear the char combo text
frmMirage.txtChat.SelText = ""

Clipboard.Clear 'Clear the clipboard (required)
Clipboard.SetData frmMirage.imgIcon(i).Picture 'Set the icon in it
SendMessage frmMirage.txtChat.hWnd, WM_PASTE, 0, 0 'Paste it to the frmMirage.txtChat

'Find any more of that same icon
lImagePos = InStr(lImagePos, frmMirage.txtChat.Text, CharCombo(iCC))
Wend
Next iCC
Next i

frmMirage.txtChat.Locked = True 'Lock the chat back up

If bClipHasImage Then
Clipboard.SetData frmMirage.picBuffer.Picture 'Put the old clipboard contents back
Else
Clipboard.Clear 'If there were none, then clear it. There's no use in leaving
End If ' an icon sitting in there

frmMirage.txtChat.SelStart = Len(frmMirage.txtChat.Text)

ResumeNormalOps:
frmMirage.txtChat.Locked = True

End Sub

ok, in the client, in modText, add this up to the top, ok? It is the API and the Const for it to work, ok?

Public Const WM_PASTE = &H302
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Ok, now, here is the catch. imgIcon MUST have BMPs, JPGs or GIFs in it, with there back ground colors done to the same color as your txtChat backcolor. AND i suggest nothing bigger than a 16 * 16 pixel format.

Ok! you Guys have fun!


OH! and sorry for the spaghetti-style coding! But this works!



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info