Results 1 to 33 of 33

Thread: Show Images in RichText Box?

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Show Images in RichText Box?

    I need to be able to insert a picture into a RichText Box. Is it possible?
    Don't Rate my posts.

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Yes.... give me a sec.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Try this:
    Attached Files Attached Files
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Umm... doesn't work.

    I added the components Richtext Box and Windows Common Controls and I get my first error on
    Form_Load
    RTB.TextRTf
    Don't Rate my posts.

  5. #5
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    What's the error?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Let's try with the whole project...
    Attached Files Attached Files
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  7. #7

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    lol
    Sorry I forgot the most important part.

    Method or Data Member Not Found

    I'm guessing you haven't done whatever it is that you have to do to make the Picture box think its a Rich TextBox
    Don't Rate my posts.

  8. #8

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    What controls are meant to be on the form??

    Cause you didn't inlucde the Project file so....
    Don't Rate my posts.

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Download the last ZIP... I included the project file as well
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  10. #10

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Aah works perfectly!!!

    Thanks a million
    Don't Rate my posts.

  11. #11
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    You're welcome.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  12. #12

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Ohh.... I'm using the following code to send a picture to it


    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2. If KeyAscii = 13 Then
    3. RTB.Text = RTB.Text + "<(BugFix)>"
    4. PasteImages
    5. End If
    6. End Sub

    But it takes the Image which is already there any moves it to the new postion. Is it possible to have multiple images?
    Don't Rate my posts.

  13. #13
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Yes... but you should "load" all the "<(BugFix)>" first, and the call the PasteImages.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  14. #14
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    You might add images interactually with a similar code if you want.
    Last edited by Mc Brain; Jul 29th, 2002 at 11:45 PM.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  15. #15
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Try this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SendMessage Lib "user32" _
    4. Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
    5. wMsg As Long, ByVal wParam As Long, lParam As Any) _
    6. As Long
    7.  
    8. Private Const WM_PASTE = &H302
    9.  
    10. Private Sub Form_Load()
    11.     RTB.TextRTF = "This image <(BugFix)> is a BugFix"
    12.     PasteImages
    13.    
    14. End Sub
    15.  
    16. Private Function ParseFirst(Text As String, lStart As Long, lStop As Long) As String
    17.     ParseFirst = ""
    18.     lStart = InStr(Text, "<(")
    19.     If lStart Then
    20.         lStop = InStr(lStart, Text, ")>")
    21.        
    22.         ParseFirst = Mid$(Text, lStart + 2, lStop - lStart - 2)
    23.     End If
    24. End Function
    25.  
    26. Private Sub PasteImages()
    27.     Dim i As Integer
    28.     Dim e0 As String
    29.     Dim lStart As Long, lStop As Long
    30.    
    31.     RTB.Tag = RTB.Text
    32.     Do
    33.         e0 = ParseFirst(RTB.Text, lStart, lStop)
    34.         If e0 = "" Then Exit Do
    35.         'clear clipboard of any data
    36.         Clipboard.Clear
    37.        
    38.         'save pic to clipboard
    39.         Clipboard.SetData ImgLst.ListImages(e0).Picture, vbCFBitmap
    40.            
    41.         Do Until RTB.Find("<(" & e0 & ")>") = -1
    42.             RTB.Locked = False
    43.             RTB.SelStart = RTB.Find("<(" & e0 & ")>")
    44.             RTB.SelLength = Len("<(" & e0 & ")>")
    45.             SendMessage RTB.hwnd, WM_PASTE, 0, 0
    46.             RTB.Locked = True
    47.         Loop
    48.     Loop
    49. End Sub
    50. Private Sub Text1_KeyPress(KeyAscii As Integer)
    51.     If KeyAscii = 13 Then
    52.         RTB.TextRTF = RTB.Tag + "<(BugFix)>"
    53.         PasteImages
    54.     End If
    55. End Sub
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  16. #16

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Ok.... have u tried it with heaps of pictures.... it gets abit weird.

    I removes the icons from the screen and then redoes them... so you can see the <(BugFix)> Text. Scrolling works fine... but everytime the user enters some thing

    An example might be holding Enter in the above example.

    I'm guessing its not possible to fix this.
    Don't Rate my posts.

  17. #17
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    My computer is too fast to see that, anyway!!
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  18. #18

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Oh ok

    I'm running a Cel 1.1.

    Its because your clearing the text and reinserting the pictures

    The problem is is that I have to run this on a P110

    Hopefully it'll be usable.
    Don't Rate my posts.

  19. #19

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    I've replaced the Bitmap with a Gif and I get an error on,
    VB Code:
    1. Clipboard.SetData ImgLst.ListImages(e0).Picture, vbCFBitmap

    What do I need to change it 2? I had a look under help and it didn't show me anything to useful.


    Should I just convert the Gifs to Bitmaps?
    Don't Rate my posts.

  20. #20

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Come on Guys, nearly done!!
    Don't Rate my posts.

  21. #21

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Ok... I tried to put this in my Chat Program, and I got an error when I try to insert a Gif or Bmp instead the image that you included in the Image List.

    Urgh what do I need to change???

    Heres the my Project is you guys are feeling really helpful.
    http://www.vbforums.com/showthread.p...hreadid=188577
    Don't Rate my posts.

  22. #22

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Ok, I've gotten rid of the Image List, so now I'm just using a Picture Box.

    Now the Problem is that its possible to resize the picture

    Is it possible to change this?
    Don't Rate my posts.

  23. #23
    Addicted Member Zealot's Avatar
    Join Date
    Jul 2002
    Location
    Lisboa, Portugal
    Posts
    206
    Are you talking about the Autosize property?

  24. #24

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    No...

    When the image is pasted into the RichtextBox, the user can resize it, which is not good.


    Also, how can be able handle more than one picture? (like what do I need to change in the parser?

    Thanks in Advance.
    Don't Rate my posts.

  25. #25

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Bump
    Don't Rate my posts.

  26. #26
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    ok i had the same problem with "resizability". The only way i was able to get around this was to prevent people from highlighting the text. Whenever they would onmousedown or onmouseup, i would set the selection length to zero. This prevents resizing.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  27. #27

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Yeah... good idea.

    But how can I allow for more than one picture?? Just create multiple parsers??

    Thanks in Advance.
    Don't Rate my posts.

  28. #28
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    i had them in the onmousedown and onmouseup properties of the richtextbox. However, it prevente highlighting ANY text.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  29. #29

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    For what I want to use it for, locking it is fine.... can't believe that I didn't think of that early.

    But now all I need is the above code being able to handle mutliple pictures.


    Its easier to replace the imagelist with picture boxs I found.... if anyone cares.
    Don't Rate my posts.

  30. #30

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Yet another *--------BuMp--------*
    Don't Rate my posts.

  31. #31

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Noone...?? Surely it can't be that hard.....
    Don't Rate my posts.

  32. #32
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I guess, you can paste it anywhere... the secret are in these lines:
    VB Code:
    1. RTB.SelStart = RTB.Find("<(" & e0 & ")>")
    2.     RTB.SelLength = Len("<(" & e0 & ")>")
    3.     SendMessage RTB.hwnd, WM_PASTE, 0, 0

    You have to select the place where you want to place your image, and paste it
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  33. #33
    Addicted Member
    Join Date
    Dec 2004
    Posts
    129

    Question Re: Show Images in RichText Box?

    I reallize that this thread is very old but i was wondering if somthign can be changed with this solution? This code processes all the richtextbox text and then researches it to replace the given strings with an image by paisting. What i was wondering is if you can make this process only the text between the last 2 vbCrLf and still keep the original text and images before these 2 vbCrLf

    Any ideas?

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