2016-09-23 51 views
0

我设法将文本转换为richtextbox中的表情符号,但我遇到了问题。vb.net richtextbox transparancy中的表情

当我改变文本表情符号与下面的代码,那么就不会显示GIF文件的transparancy:

If LCase(MainWindow.RichTextBoxChatRoom.Text).IndexOf(":d") <> -1 Then 
       MainWindow.RichTextBoxChatRoom.Select(LCase(MainWindow.RichTextBoxChatRoom.Text).IndexOf(":d"), 2) 
       Clipboard.SetImage(My.Resources.teeth_smile) 
       MainWindow.RichTextBoxChatRoom.ReadOnly = False 
       MainWindow.RichTextBoxChatRoom.Paste() 
       MainWindow.RichTextBoxChatRoom.ReadOnly = True 
       Empty = Empty + 1 
      End If 

奇怪的是,当我复制完全相同的图标拖出一个Word文档我粘贴到richtextbox中。它完美的作品。看到下面的图片:

Screenshot RichTextBox

有人能解释这是为什么hapening,也许一个解决方案。

回答

0

如果您RichTextBox有那么一个图片作为背景(只是一些颜色):

Using bmp As Bitmap = New Bitmap(My.Resources.teeth_smile.Width, My.Resources.teeth_smile.Height) 'use a bitmap with the same size of your image 
    Using g As Graphics = Graphics.FromImage(bmp) 
     g.Clear(MainWindow.RichTextBoxChatRoom.BackColor) 'set the color of the bitmap the same as RichTextBox 

     g.DrawImage(My.Resources.teeth_smile, 0, 0, My.Resources.teeth_smile.Width, My.Resources.teeth_smile.Height) 'draw your image to bmp 

     Clipboard.SetImage(bmp) 'use the bmp bitmap to paste in RichTextBox 

     MainWindow.RichTextBoxChatRoom.Paste() 
    End Using 
End Using 
+0

这工作,谢谢 –