Results 1 to 17 of 17

Thread: Picture in rtb with a tag?

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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:
    1. For X = 0 To picSmile.UBound
    2.             If RTB1.Find(picSmile(X).Tag, tLoc, , rtfMatchCase) <> -1 Then
    3.                 RTB1.SelStart = RTB1.Find(picSmile(X).Tag, tLoc, , rtfMatchCase)
    4.                 RTB1.SelLength = Len(picSmile(X).Tag)
    5.                 Clipboard.Clear
    6.                 Clipboard.SetData picSmile(X).Image
    7.                 SendMessage RTB1.hWnd, WM_PASTE, 0, 0
    8.             End If
    9.         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!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Picture in rtb with a tag?

    bump... 1 more round.. anyone?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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)

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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)
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.
    Attached Files Attached Files

  8. #8

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Picture in rtb with a tag?

    no problem.. just need the idea behind it THANKS!!!
    time to play
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  9. #9
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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:
    1. Private Sub Form_Load()
    2.     WebBrowser1.Navigate "about:Press the EditMode button and type some text"
    3. End Sub
    4.  
    5. '=====================================================================
    6.  
    7. Private Sub cmdEditMode_Click()
    8.     '[b]EditMode[/b] - webbrowser acts like a DHTMLEdit control
    9.     WebBrowser1.Document.execcommand "EditMode"
    10. End Sub
    11.  
    12. '=====================================================================
    13.  
    14. Private Sub cmdBrowseMode_Click()
    15.     '[b]BrowseMode[/b] - Normal browsing mode
    16.     WebBrowser1.Document.execcommand "BrowseMode"
    17. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  10. #10

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  11. #11

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Picture in rtb with a tag?

    3) how do I scroll it to the bottom automatically...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Picture in rtb with a tag?

    scroll is resolved:

    wb1.Document.parentWindow.window.scrollTo 0, 100000
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  13. #13
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  14. #14

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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??
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  15. #15
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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 (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)
    Last edited by iPrank; Apr 3rd, 2006 at 10:35 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  16. #16

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  17. #17
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Picture in rtb with a tag?

    In its simpliest form:
    VB Code:
    1. Option Explicit
    2. ' needs a webbrower and 2 RTBs
    3. Private Sub Form_Load()
    4.     RichTextBox2.Visible = False
    5.     WebBrowser1.Navigate "about:blank"
    6.     RichTextBox1.TextRTF = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}" & _
    7. "{\*\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" & _
    8. "}"
    9.  
    10.    
    11. End Sub
    12.  
    13. Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
    14.  
    15.     If KeyAscii = 13 Then
    16.         Dim tempRTF As String
    17.         tempRTF = RichTextBox1.TextRTF
    18.        
    19.         tempRTF = Replace(tempRTF, "\b ", "\b <B>")
    20.         tempRTF = Replace(tempRTF, "\b0 ", "\b </B>")
    21.         tempRTF = Replace(tempRTF, "\i ", "\i <I>")
    22.         tempRTF = Replace(tempRTF, "\i0 ", "\i </I>")
    23.         tempRTF = Replace(tempRTF, "\ul ", "\ul <U>")
    24.         tempRTF = Replace(tempRTF, "\ulnone ", "\ulnone </U>")
    25.        
    26.         tempRTF = Replace(tempRTF, "\b\", "\b <B> \")
    27.         tempRTF = Replace(tempRTF, "\b0\", "\b </B> \")
    28.         tempRTF = Replace(tempRTF, "\i\", "\i <I> \")
    29.         tempRTF = Replace(tempRTF, "\i0\", "\i </I> \")
    30.         tempRTF = Replace(tempRTF, "\ul\", "\ul <U> \")
    31.         tempRTF = Replace(tempRTF, "\ulnone\", "\ulnone </U> \")
    32.        
    33.         RichTextBox2.TextRTF = tempRTF
    34.  
    35.         WebBrowser1.Document.Body.InnerHTML = WebBrowser1.Document.Body.InnerHTML & RichTextBox2.Text
    36.         RichTextBox1.Text = ""
    37.         RichTextBox2.Text = ""
    38.  
    39.     End If
    40.  
    41. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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