RichTextBox Images Can Stretch  
Author Message
PsychUK





PostPosted: Visual Basic Express Edition, RichTextBox Images Can Stretch Top

Hi, I'm using the paste method to insert images in a RichTextBox, the trouble is the user can stretch the images by dragging them with the mouse.

Is there anyway to stop this behaviour Or is there another way to insert images into a RichTextBox control that pastes the images with fixed dimensions




Visual Studio Express Editions33  
 
 
Tall Dude





PostPosted: Visual Basic Express Edition, RichTextBox Images Can Stretch Top

I also use the paste method, but I don't do any size checking

or resizing of the picture. (Which the real pros probably do.)

Anyway, my RTB pasted pictures show the dots around the

corners when selected, but I am unable to resize them with

the mouse. The code I use to put in the picture looks like this:

Private Sub insertpicture()

Dim picture As Image = Nothing

Dim ofd As New OpenFileDialog

ofd.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.TIF)|*.BMP;*.JPG;*.GIF;*.TIF"

ofd.Multiselect = False

If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then

Try

picture = Image.FromFile(ofd.FileName)

Catch ex As Exception

MsgBox("Error opening file > " & ofd.FileName)

Exit Sub

End Try

Else

Exit Sub

End If

Clipboard.Clear()

Clipboard.SetImage(picture)

Do While Clipboard.ContainsImage = False

Loop

RichTextBox1.Paste()

End Sub



 
 
Neotech





PostPosted: Visual Basic Express Edition, RichTextBox Images Can Stretch Top

Ive been using this code

dim this as object
this=clipboard.getdataobject
dim d as new openfiledialog
d.showdialog
if not d.filename="" Then
clipboard.setimage(image.fromfile(d.filename))
page.paste
clipboard.setdataobject
End If

Thats probably not the best way but it seems to work ;-)


 
 
Tall Dude





PostPosted: Visual Basic Express Edition, RichTextBox Images Can Stretch Top

I am looking for the opposite answer.

How can you resize them and I can't



 
 
Tall Dude





PostPosted: Visual Basic Express Edition, RichTextBox Images Can Stretch Top

Well, I take back everything I said.

After some more testing, I see that I am able to resize

the picture. (It threw me initially because the 'grab spot' is

hard to grasp in some places and the cursor never changes

shape.)



 
 
Tall Dude





PostPosted: Visual Basic Express Edition, RichTextBox Images Can Stretch Top

Okay, the following code seems to 'undo' a picture resize.

I don't know if it has any bad side effects.

Private Sub RichTextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

'MsgBox(RichTextBox1.UndoActionName)

If RichTextBox1.UndoActionName = "Unknown" Then

RichTextBox1.Undo()

End If

End Sub