0

I'm using a RichTextBox control to simulate a basic editor. Everything if functioning very well.

But after I insert any image, how can I change the cursor caret whenever the user try to resize that image? I mean, how detect the hover event of the mouse (and change its caret) when it is over an image?

Thank you all!

EDIT1:

Follows the code I'm using to allow users to put images within RTB:

Private Sub ContextMenuStrip1Items_Click(sender As Object, e As ToolStripItemClickedEventArgs)
    Select Case e.ClickedItem.Text


        Case "Colar", "Paste"
            Try
                ContextMenuStrip1.Close()
                Dim Formato As DataFormats.Format = Nothing

                If **Clipboard.ContainsImage** Then
                    Formato = DataFormats.GetFormat(DataFormats.Bitmap)
                    If RichTextBox1.CanPaste(Formato) Then
                        RichTextBox1.Paste(Formato)
                    End If**

                ElseIf Clipboard.ContainsText(TextDataFormat.Html) Then
                    Formato = DataFormats.GetFormat(DataFormats.Html)
                    If RichTextBox1.CanPaste(Formato) Then
                        RichTextBox1.Paste(Formato)
                    Else
                        RichTextBox1.Paste

                    End If

                ElseIf Clipboard.ContainsText(TextDataFormat.Rtf) Then
                    Formato = DataFormats.GetFormat(DataFormats.Rtf)
                    If RichTextBox1.CanPaste(Formato) Then
                        RichTextBox1.Paste(Formato)
                    Else
                        RichTextBox1.Paste
                    End If


                elseif clipboard.ContainsText
                    RichTextBox1.Paste


                Else
                    MsgBox("Formato não suportado")
                End If


            Catch ex As Exception
            End Try




        Case "Imagem", "Image"
            Using OFD As New OpenFileDialog
                With OFD
                    .Multiselect = False
                    .InitialDirectory = "C:\Documents"
                    .Filter = "Image files (*.Bmp, *.Gif, *.Jpg, *.Png, *.Tif)|*.Bmp;*.Gif;*.Jpg;*.Png;*.Tif"
                End With
                ContextMenuStrip1.Close()
                If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
                    If OFD.FileName <> "" Then
                        Clipboard.SetImage(Image.FromFile(OFD.FileName))
                        RichTextBox1.Paste()
                    End If
                End If
            End Using

         End Case

End Sub
David BS
  • 1,822
  • 1
  • 19
  • 35
  • also this is for WPF and for resizing, this might help in order to trigger the event. : https://stackoverflow.com/questions/2035782/wpf-allow-user-to-resize-images-in-richtextbox – user1234433222 Jul 26 '17 at 04:06
  • add some code how you are adding picture to RichtextBox than we can find a way – Ramankingdom Jul 26 '17 at 08:31
  • @Ramankingdom : The `RichTextBox` natively supports having pictures inside it, there is no code to show. You can simply drag and drop a picture onto it. – Visual Vincent Jul 26 '17 at 09:35
  • Thanks all for comments. My problem is NOT how to insert the picture (see the code above) but HOW change the cursor whenever the user try to resize the picture. – David BS Jul 26 '17 at 12:26
  • @Werdna, the code is interesting but how add a handler for MouseMove for an inserted image? And will it function on "copy/paste" method? Thanks anyway, I will try something based onto your tip. – David BS Jul 26 '17 at 12:33
  • What if you save the pictures width and height and then if any of those values are to change, then change the cursor that way? – user1234433222 Jul 26 '17 at 12:35
  • @Wedna, my problem is, AFTER the user had put the image inside his text (within RTF box), and once trying to resize the image (it is possible), I change the cursor caret to ArrowSize or anything else. – David BS Jul 26 '17 at 12:49

0 Answers0