专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

请问:自己扩展的RichTextBox实现插入QQ表情(附源码)的有关问题

发布时间:2011-06-23 16:04:34 文章来源:www.iduyao.cn 采编人员:星星草
请教:自己扩展的RichTextBox实现插入QQ表情(附源码)的问题
自己尝试着扩展.Net的RichTextBox控件,能够实现插入QQ表情,
1. 可是我想写入的文本显示不出来
2. 如何实现在RichTextBox的中的文本末尾插入该表情,且能够用BackSpace键实现删除该表情,就像删除文本一样?
3. 插入多个表情时如何实现?

Imports System.Windows.Forms
Imports System.Drawing


Public Class ExRichTextBox
  Inherits RichTextBox

  'Create a Bitmpap Object.
  Private animatedImage As New Bitmap("shy.gif")
  'Private animatedImage As Image
  Private currentlyAnimating As Boolean = False


  Public Sub New()

  Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  Me.SetStyle(ControlStyles.UserPaint, True)
  AnimateImage()
  End Sub


  'This method begins the animation.
  Public Sub AnimateImage()

  If Not currentlyAnimating Then

  'Begin the animation only once.
  ImageAnimator.Animate(animatedImage, New EventHandler(AddressOf Me.OnFrameChanged))
  currentlyAnimating = True
  End If
  End Sub

  Private Sub OnFrameChanged(ByVal o As Object, ByVal e As EventArgs)

  'Force a call to the Paint event handler.
  Me.Invalidate()
  End Sub

  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  MyBase.OnPaint(e)

  'Get the next frame ready for rendering.
  ImageAnimator.UpdateFrames(animatedImage)

  'Draw the next frame in the animation.
  e.Graphics.DrawImage(Me.animatedImage, New Point(20, 0))

  '下面文本显示不出来
  e.Graphics.DrawString("您好", New Font("Arial", 12, FontStyle.Bold), Brushes.AliceBlue, 0, 0)
  End Sub
end class

------解决方案--------------------
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  

'Get the next frame ready for rendering.
ImageAnimator.UpdateFrames(animatedImage)

'Draw the next frame in the animation.
e.Graphics.DrawImage(Me.animatedImage, New Point(20, 0))

'下面文本显示不出来
e.Graphics.DrawString("您好", New Font("Arial", 12, FontStyle.Bold), Brushes.AliceBlue, 0, 0)
MyBase.OnPaint(e)'这句话应该放在过程的最后面
End Sub
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: