在richedit控件中插入动态GIF

这是CSDN的VC论坛上的一个老FAQ了。我在写自定义在RichEdit中插入对象的图标(http://www.blogcn.com/user3/jiangsheng/blog/1319738.html)这片文章的时候就是想用这个技术做动画GIF的,但是怎么判断一个内嵌在RichEdit的对象是GIF这个问题一直没有解决。好在QQ附带的一个控件支持动画GIF,可以插入这个对象来解决问题。

首先需要一个定时器来定时更新GIF。

public: System::Void OnLoad(System::Object^  sender, System::EventArgs^  e)
   {
   this->typingRichTextBox->RichTextShortcutsEnabled=false;
   this->timer1->Start();
   }

private: System::Void OnFormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e)
   {
    this->timer1->Stop();
    this->frameClosing=true;
   }

然后在定时器的处理函数里面通知GIF控件更新显示。

private: System::Void OnTimer1Elapsed(System::Object^  sender, System::Timers::ElapsedEventArgs^  e)
   {
    if(this->frameClosing==false)
    UnmanagedGifTriggerFrameChange(this->contentRichTextBox->Handle.ToInt32());
   }

最后的工作就是插入GIF了

private: System::Void smileToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
   {
    insertemotion(sender,e,"c://Program Files//Tencent//QQ//Face//20.gif");
   }

private: System::Void insertemotion(System::Object^  sender, System::EventArgs^  e,String ^ gifPath)
   {
   System::Windows::Forms::RichTextBox^  ptypingRichTextBox=this->typingRichTextBox;
 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值