Picture in rtb with a tag?
is there a way to "attach" or assign a tooltiptext or a tag to a picture inserted into a richtextbox??
im using this code to replace smiles with the picture of the smile (chat program)
VB Code:
For X = 0 To picSmile.UBound
If RTB1.Find(picSmile(X).Tag, tLoc, , rtfMatchCase) <> -1 Then
RTB1.SelStart = RTB1.Find(picSmile(X).Tag, tLoc, , rtfMatchCase)
RTB1.SelLength = Len(picSmile(X).Tag)
Clipboard.Clear
Clipboard.SetData picSmile(X).Image
SendMessage RTB1.hWnd, WM_PASTE, 0, 0
End If
Next
what I would like is to have the smile show in the message textbox (where u enter the message...) which I can do, but when sending the message I need to be able to convert it back to text to send... (or is there an easy way to just trans the text and picture at the same time??)
Thanks!
Re: Picture in rtb with a tag?
bump... 1 more round.. anyone?
Re: Picture in rtb with a tag?
Just a thought, would it be possible to save the real text (whitout the images) but with the text representation of the images, to a string variable, so when you have to send it you send this variable instead of the RTB contents? For doing something like this each change in the RTB must be updated in the variable (adding just the text shortcut for those images)
Re: Picture in rtb with a tag?
What I do in my VBForums Editor is create a Pictures class and a ColPictures Collection class. The picture class has a tag property (such as ":)") and an rtfText property. When a picture is inserted, a picture class is added to the collection class, its rtfText property is set to the RTF text that is actually inserted and the tag property contains... well you know.
When the document is converted to VBForums code I do a series of replaces where I replace each rtftext with the corresponding tag.
Re: Picture in rtb with a tag?
Do you really have to use RTB ?
For this you can use a Webbrowser control more easily and with more features. (like Yahoo Messander)
Re: Picture in rtb with a tag?
moeur... do u have some code samples handy?
iPrank? how could I use a webbrowser control to type into it??
Either way my chat app is done... I just wanted to change the one feature..
I kinda like the idea of "storing" whats in the RTF as a string in the background.. then just send that thru...
Thanks!
1 Attachment(s)
Re: Picture in rtb with a tag?
Here is a little demo. It might be a little buggy since I just cut and paste from the VBForums editor.
Re: Picture in rtb with a tag?
no problem.. just need the idea behind it :) THANKS!!!
time to play ;)
Use Webbrowser as DHTMLEdit Control (EditMode)
Quote:
Originally Posted by Static
iPrank? how could I use a webbrowser control to type into it??
VB Code:
Private Sub Form_Load()
WebBrowser1.Navigate "about:Press the EditMode button and type some text"
End Sub
'=====================================================================
Private Sub cmdEditMode_Click()
'[b]EditMode[/b] - webbrowser acts like a DHTMLEdit control
WebBrowser1.Document.execcommand "EditMode"
End Sub
'=====================================================================
Private Sub cmdBrowseMode_Click()
'[b]BrowseMode[/b] - Normal browsing mode
WebBrowser1.Document.execcommand "BrowseMode"
End Sub
Re: Picture in rtb with a tag?
ok.. the webbrowser could be a cool solution .. need some more info...
I am using it for the main "message window" works well... just need to insert HTML for images which will be fine..
but using edit mode as suggested... I have questions:
1) how do I insert an image while in edit mode....
2) how do remove the scrollbar....
thanks!
Re: Picture in rtb with a tag?
3) how do I scroll it to the bottom automatically...
Re: Picture in rtb with a tag?
scroll is resolved:
wb1.Document.parentWindow.window.scrollTo 0, 100000
Re: Picture in rtb with a tag?
Static, you could also use the DHTMLEdit control. I think it will be easier than using a webbrowser control.
Some links you may find usefull:
Web Workshop - DHTML Editing Component - I can't find it online. In my MSDN January 2001 installation, it is at mk:@MSITStore:MSDNDRIVE:\MSDNFOLDER\2001JAN\1033\inet.chm::/workshop/author/dhtml/edit/ref/cncpt.htm . The only downloadable version I found is this. I'm not sure if it is the original file.
The Vader's articles on VBWM: Using the Web Browser Control, Using the DHTML Document Object Model
wiz126's Webbrowser Control Tip and Examples in Codebank.
Here is my unfinished WYSIWYG HTML Edit control that may find useful.
But, I think, the easiest way would be,
Use an RTB for user input. When user presses Enter, convert the rtf text to html and add it to the webbrowser contrl. It will be easier than building an HTMLEditor. You just need to convert bold/italic etc fomatting code and some special text for smilies.
As a side note, the DHTMLEdit contol isn't supported by MS anymore. But this doesn't mean anythig now, as VB6 itself is not supported. :(
Re: Picture in rtb with a tag?
ok.. RTF convert sounds good.. but how do i capture any smiles in the RTF?
I guess Im kinda back to square one with that.. I need to take the smile from the RTF (message enter textbox) and put it into the main window either an RTF or webbrowser??
Re: Picture in rtb with a tag?
I see. You are an MSN messanger user. Be a Yahoo Mesanger user, you'll understand what i'm saying.
JK. YM acts like vBulletin, you enter :)) in the 'input' box and YM converts it to adress of an image http://us.i1.yimg.com/us.yimg.com/i/...ticons7/21.gif (located in ..\Media\Smileys folder). Then it adds the converted html to the main window.
Unlike MSN, it doesn't show images in input window. (atleast not in my version)
Re: Picture in rtb with a tag?
AIM converts it as well... (I actually use trillian..it converts in all the inputs) YIM AIM and MSN
Re: Picture in rtb with a tag?
In its simpliest form:
VB Code:
Option Explicit
' needs a webbrower and 2 RTBs
Private Sub Form_Load()
RichTextBox2.Visible = False
WebBrowser1.Navigate "about:blank"
RichTextBox1.TextRTF = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}" & _
"{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\f0\fs20 Normal \b Bold\b0 \i Italic\i0 \ul Underline\ulnone \ul\b\i All\ulnone\b0\i0\par" & _
"}"
End Sub
Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim tempRTF As String
tempRTF = RichTextBox1.TextRTF
tempRTF = Replace(tempRTF, "\b ", "\b <B>")
tempRTF = Replace(tempRTF, "\b0 ", "\b </B>")
tempRTF = Replace(tempRTF, "\i ", "\i <I>")
tempRTF = Replace(tempRTF, "\i0 ", "\i </I>")
tempRTF = Replace(tempRTF, "\ul ", "\ul <U>")
tempRTF = Replace(tempRTF, "\ulnone ", "\ulnone </U>")
tempRTF = Replace(tempRTF, "\b\", "\b <B> \")
tempRTF = Replace(tempRTF, "\b0\", "\b </B> \")
tempRTF = Replace(tempRTF, "\i\", "\i <I> \")
tempRTF = Replace(tempRTF, "\i0\", "\i </I> \")
tempRTF = Replace(tempRTF, "\ul\", "\ul <U> \")
tempRTF = Replace(tempRTF, "\ulnone\", "\ulnone </U> \")
RichTextBox2.TextRTF = tempRTF
WebBrowser1.Document.Body.InnerHTML = WebBrowser1.Document.Body.InnerHTML & RichTextBox2.Text
RichTextBox1.Text = ""
RichTextBox2.Text = ""
End If
End Sub