Results 1 to 18 of 18

Thread: Resize images in Rich Text Box

  1. #1

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Resize images in Rich Text Box

    Well, i have a Rich Text Box and i have loaded an image with height : 200 and width : 100! How can i resize the image through vb code so i can make it larger?

    For example to make the width of the image : 200!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    If you have them stored, then I guess you can resize the stored images and then replace it by deleting/re-adding the image...


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    How can i do it this , in VB Code?

    I know that it is too difficult but how to do it?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  4. #4
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    You could put them in an image control with the stretch property set to true (i think).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  5. #5

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    And how to put them(images) back in the same place in the Rich Text Box?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    I guess you can keep track of the SelStart property when you add the images and add them back there... I suppose you are adding the images somehow like this :

    VB Code:
    1. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    2. hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    3. lParam As Any) As Long
    4. Private Const WM_PASTE = &H302
    5.  
    6. Sub InsertPictureInRichTextBox(RTB As RichTextBox, Picture As StdPicture)
    7. ' clear the clipboard
    8. Clipboard.Clear
    9. ' Copy the picture into the clipboard.
    10. Clipboard.SetData Picture
    11. ' the position of the picture
    12. RTB.SelStart = 4
    13. ' paste into the RichTextBox control
    14. SendMessage RTB.hwnd, WM_PASTE, 0, 0
    15. End Sub
    16.  
    17. Private Sub Command1_Click()
    18.  Call InsertPictureInRichTextBox(RichTextBox1, pic1.Picture)
    19. End Sub


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Yes i know this! I am using this! I want to find out how to resize an image after pasting it with 'SendMessage' in a Rich Text Box. Or how to resize it before pasting it in the Rich Text Box!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  8. #8
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Is the problem actually resizing or extracting/re-adding in the RTB? If it's the first, you need the StretchBlt API. If it's the second I need to think


    Has someone helped you? Then you can Rate their helpful post.

  9. #9

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    The real problem is:

    Say that i have this html tag loaded already(in Rich Text Box):
    <img src="http://www.site.com/image1.jpg" width="717" height="573" />

    It is already loaded with width = 717 , height = 573, as found from the tag.


    How can i resize the image , when is already loaded in RTB and make for example its height to 400.

    Using Picture Box, i think, but how to load it and then change its settings?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  10. #10
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Based on this thread, I made this All you need to add (I think) is a way to store the SelStart property when you add an image so you know how to select it after
    Attached Files Attached Files


    Has someone helped you? Then you can Rate their helpful post.

  11. #11

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Nice but i can't make sense of the program!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  12. #12
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    I should have given an explenation I guess... If you hit Command1 it ads the picture in the RTB. After, if you put the caret right after the picture, click on the form. It does the resizing and reinserting


    Has someone helped you? Then you can Rate their helpful post.

  13. #13
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    You might want to look at this : http://www.elitevb.com/content/01,0057,01/


    Has someone helped you? Then you can Rate their helpful post.

  14. #14

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    I think that it doesn't help! It shows how to add images in RichTextBox, but i know a better way , faster and smaller way! Using "SendMessage"! It also works with gif images but it can't play the animation of its gif! But nice thought Manavo11!!!!!!!

    Very nice thought! (Íüìéæá üôé äåí èá óõíÝ÷éæåò íá ðñïóðáèåßò íá âñåßò êÜôé ãéá íá ìå âïçèÞóåéò! Åõ÷áñéóôþ)
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  15. #15
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Well, I know it's a bit off topic with the resizing but I thought it might be of interest for your project

    (Äåí óôáìÜôçóá íá øÜ÷íù Áðëþò äåí âñÞêá )


    Has someone helped you? Then you can Rate their helpful post.

  16. #16

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    It is a very good project Manavo11 but it is something that i already knew before! If you find something else then send me the link!

    (üðùò âëÝðåéò , Þ åßìáóôå ïé ìüíïé óå üëï ôï Forum ðïõ áó÷ïëïýìáóôå ìå ôï RichTextBox , ãé'áõôü êáé äåí âïçèÜåé êáíåßò , Þ áðëÜ äåí ãíùñßæåé êáíåßò ôßðïôá!)
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  17. #17
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Sure thing

    (¼íôùò, áðïñþ... Êáíåßò äåí áðáíôÜåé. Ðåñßåñãï )


    Has someone helped you? Then you can Rate their helpful post.

  18. #18

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Isn't there any way to resize the images? It can be done for sure!

    Why not?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

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