2016-09-23 65 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

這工作,謝謝 –