Results 1 to 19 of 19

Thread: Inserting images in a richtextbox, how?

  1. #1

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130

    Inserting images in a richtextbox, how?

    How can I insert an image in a richtextbox?

    Thanx in advance.

  2. #2
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    use the search feature on the boards, this question has been posted hundreds of times
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  3. #3
    DaoK
    Guest
    Try this :

    VB Code:
    1. Private Declare Function SendMessage Lib "user32" _
    2. Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
    3. wMsg As Long, ByVal wParam As Long, lParam As Any) _
    4. As Long
    5.  
    6. Private Const WM_PASTE = &H302
    7.  
    8. Private Sub Command1_Click()
    9.     Clipboard.SetData Picture1.Picture, vbCFBitmap
    10.     DoEvents
    11.     SendMessage RichTextBox1.hwnd, WM_PASTE, 0, 0
    12. End Sub

  4. #4
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    yeah, but that also clears any images the user might have on the clipboard.
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  5. #5
    DaoK
    Guest
    That just a suggestion

  6. #6
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    i know... another possibility is to put the contents of the clipboard's data property into a picbox, running that code, and then copying the old data back into the clipboard.
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  7. #7
    DaoK
    Guest
    Thye might have a way to do it without the clipboard.

  8. #8
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    i know there is, but obviously he couldn't think to search the boards first so u gave him a good answer that he can use
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  9. #9
    DaoK
    Guest
    Yes

  10. #10
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Without the clipboard....

    VB Code:
    1. rtb.OLEObjects.Add , , "C:\Windows\bubbles.bmp"
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  11. #11
    DaoK
    Guest
    Yes it work well thx YoungBuck

  12. #12
    DaoK
    Guest
    it not working with JPEG

  13. #13
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    because VB is a flaming homosexual, and it only likes Bitmaps, you have to first find code to conver the JPG into a BMP, and then load the BMP
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

  14. #14
    DaoK
    Guest
    ahahahahaha

  15. #15

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130
    Thanx DaoK & YoungBuck appreciate the help but {rtb.OLEObjects.Add , , "C:\Windows\bubbles.bmp"} opens the default program for that image. Do you know to fix this.

    Btw, I searched on the board for it I couldn't find the solution to this problem. And don't go flaming me, I'm only a kid.

  16. #16
    DaoK
    Guest
    rtb.OLEObjects.Add , , "C:\Windows\bubbles.bmp"


    Did not open paint. but when i try something like

    rtb.OLEObjects.Add , , "C:\Windows\bubbles.JPG"
    I have an icon and my paint program open... maybe the file you try to open is not BMP.

  17. #17

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130
    It is a bitmap. Second, i can't load images from a resource file.

    Best regards

  18. #18
    Fanatic Member Kings's Avatar
    Join Date
    Aug 2001
    Posts
    673

    to change from gif/jpg to bmp (hope that works)

    Originally posted by Patoooey
    Been a while since I've had to put an image into an RTB. Used this back them. Might be a better way now-a-days but this does work.

    VB Code:
    1. ' character pos to insert at
    2.     RichTextBox1.SelStart = 235
    3.  
    4.     ' load pix
    5.     Picture1.Picture = LoadPicture("d:\myimage.gif")
    6.  
    7.     DoEvents
    8.  
    9.     ' save as BMP
    10.     SavePicture Picture1.Picture, "d:\c663dn5a.bmp"
    11.  
    12.     DoEvents
    13.  
    14.     ' Load BMP
    15.     RichTextBox1.OLEObjects.Add , , "d:\c663dn5a.bmp"
    16.  
    17.     DoEvents
    K i n g s

  19. #19
    DaoK
    Guest
    Kings your code work but you can do it in reverse ( BMp to jpeg/gif).

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