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!
Printable View
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!
If you have them stored, then I guess you can resize the stored images and then replace it by deleting/re-adding the image...
How can i do it this , in VB Code?
I know that it is too difficult but how to do it?
You could put them in an image control with the stretch property set to true (i think).
And how to put them(images) back in the same place in the Rich Text Box?
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:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _ hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Private Const WM_PASTE = &H302 Sub InsertPictureInRichTextBox(RTB As RichTextBox, Picture As StdPicture) ' clear the clipboard Clipboard.Clear ' Copy the picture into the clipboard. Clipboard.SetData Picture ' the position of the picture RTB.SelStart = 4 ' paste into the RichTextBox control SendMessage RTB.hwnd, WM_PASTE, 0, 0 End Sub Private Sub Command1_Click() Call InsertPictureInRichTextBox(RichTextBox1, pic1.Picture) End Sub
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!
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 ;)
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?
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 :D
Nice but i can't make sense of the program!
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 ;)
You might want to look at this : http://www.elitevb.com/content/01,0057,01/ ;)
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! (Íüìéæá üôé äåí èá óõíÝ÷éæåò íá ðñïóðáèåßò íá âñåßò êÜôé ãéá íá ìå âïçèÞóåéò! Åõ÷áñéóôþ)
Well, I know it's a bit off topic with the resizing but I thought it might be of interest for your project ;)
(Äåí óôáìÜôçóá íá øÜ÷íù ;) Áðëþò äåí âñÞêá :o )
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 , ãé'áõôü êáé äåí âïçèÜåé êáíåßò , Þ áðëÜ äåí ãíùñßæåé êáíåßò ôßðïôá!) :ehh:
Sure thing ;)
(¼íôùò, áðïñþ... Êáíåßò äåí áðáíôÜåé. Ðåñßåñãï :confused: )
Isn't there any way to resize the images? It can be done for sure!
Why not?