MSN / QQ 中的CRichEditCtrl (四) —— 动画表情(Full Source Code)

Full Source Code Here : 

http://www.codeproject.com/richedit/AnimatedEmoticon.asp

首先对标题说明一下,在MSN中,聊天的窗口可能是一个自定义的类。大家用Spy ++可以看看。
对与自定义窗口,可以使用CreateWindow, SetWindowLong或者是SubclassWindow实现,不过这不
是我现在讨论的话题。

好, 先看看效果再说:


我实现的主要就是:(一)字体格式; (二)超链接;(三)背景图片;(四)动画表情



关于这个的实现。我们首先应该明了,我们必须实现一个OLE对象。而且这个对象能够播放GIF.
对于播放GIF,代码已经很多了。比较有名气的就是那个谁封装的Gif89a,还不错,我喜欢那个CPictureEx.
可以在vchelp找到。
有了这个就完了么?当然不是。你还有写一个OLE/COM对象。实现IOleObject等。
你是用ATL还是MFC呢?
呵呵,我什么也没有用。在这个目录下%program file%/tencent/qq/,你可以看到一个ImageOle.dll,她就是
你日夜思念的人!
好吧,让我们来看看他的真面目。怎么看?X Ray? 当然不是——OLE/COM Viewer.
Click on “All Objects”,

View TypeLib... 打开那个文件,你可以看到:
[
  uuid(0C1CF2DF-05A3-4FEF-8CD4-F5CFC4355A16),
  helpstring("IGifAnimator Interface"),
  dual,
  nonextensible
]
dispinterface IGifAnimator {
    properties:
    methods:
        [id(0x00000001), helpstring("method LoadFromFile")]
        void LoadFromFile([in] BSTR FileName);
        [id(0x00000002), helpstring("method TriggerFrameChange")]
        VARIANT_BOOL TriggerFrameChange();
        [id(0x00000003), helpstring("method GetFilePath")]
        BSTR GetFilePath();
        [id(0x00000004), helpstring("method ShowText")]
        void ShowText([in] BSTR Text);
};

这个接口就是我们要的。你可以用ActiveX Control Test Container测试一下。还挺管用的。

那么怎么在我们的程序中使用呢?我也没有那么多的时间,先给出代码吧,有时间再说啊,见谅。
首先我们导入ImageOle.dll
1#import "D://Program files//tencent//qq//ImageOle.dll" named_guids

 named_guids 表示让编译器为我把对应库的GUID和声明对应起来。我们就可以用CLSID_GifAnimator引用对应的接口了。不用那一长串的东西。然后它就会为我们生成两个文件。
ImageOle.tlh

<script type="text/javascript"> function ToggleSourceCodeRegion(regionNumber) { var divRegion = document.getElementById('region' + regionNumber); var divRegionBlock = document.getElementById('regionBlock' + regionNumber); if (divRegion.style.display == 'inline') { divRegion.style.display = 'none'; divRegionBlock.style.display = 'inline'; } else { divRegion.style.display = 'inline'; divRegionBlock.style.display = 'none'; } } </script> 

1// Created by Microsoft (R) C/C++ Compiler Version 12.00.8168.0 (9de7951a).
2//
3// d:/myproject/msger/debug/ImageOle.tlh
4//
5// C++ source equivalent of Win32 type library D://Program files//tencent//qq//ImageOle.dll
6// compiler-generated file created 10/25/04 at 22:00:58 - DO NOT EDIT!
7#pragma once
8#pragma pack(push, 8)
9#include <comdef.h>
10
11namespace ImageOleLib {
12
13//
14// Forward references and typedefs
15//
16
17struct /* coclass */ GifAnimator;
18struct __declspec(uuid("0c1cf2df-05a3-4fef-8cd4-f5cfc4355a16"))
19/* dual interface */ IGifAnimator;
20
21//
22// Smart pointer typedef declarations
23//
24
25_COM_SMARTPTR_TYPEDEF(IGifAnimator, __uuidof(IGifAnimator));
26
27//
28// Type library items
29//
30
31struct __declspec(uuid("06ada938-0fb0-4bc0-b19b-0a38ab17f182"))
32GifAnimator;
33    // [ default ] interface IGifAnimator
34
35struct __declspec(uuid("0c1cf2df-05a3-4fef-8cd4-f5cfc4355a16"))
36IGifAnimator : IDispatch
37{
38    //
39    // Wrapper methods for error-handling
40    //
41
42    HRESULT LoadFromFile (
43        _bstr_t FileName );
44    VARIANT_BOOL TriggerFrameChange ( );
45    _bstr_t GetFilePath ( );
46    HRESULT ShowText (
47        _bstr_t Text );
48
49    //
50    // Raw methods provided by interface
51    //
52
53    virtual HRESULT __stdcall raw_LoadFromFile (
54        BSTR FileName ) = 0;
55    virtual HRESULT __stdcall raw_TriggerFrameChange (
56        VARIANT_BOOL * pbChanged ) = 0;
57    virtual HRESULT __stdcall raw_GetFilePath (
58        BSTR * pFilePath ) = 0;
59    virtual HRESULT __stdcall raw_ShowText (
60        BSTR Text ) = 0;
61};
62
63//
64// Named GUID constants initializations
65//
66
67extern "C" const GUID __declspec(selectany) LIBID_ImageOleLib =
68    {0x710993a2,0x4f87,0x41d7,{0xb6,0xfe,0xf5,0xa2,0x03,0x68,0x46,0x5f}};
69extern "C" const GUID __declspec(selectany) CLSID_GifAnimator =
70    {0x06ada938,0x0fb0,0x4bc0,{0xb1,0x9b,0x0a,0x38,0xab,0x17,0xf1,0x82}};
71extern "C" const GUID __declspec(selectany) IID_IGifAnimator =
72    {0x0c1cf2df,0x05a3,0x4fef,{0x8c,0xd4,0xf5,0xcf,0xc4,0x35,0x5a,0x16}};
73
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 79
    评论
CRichEditCtrl是一个强大的编辑控件,类似于QQ的文本输入框。它提供了许多丰富的功能和属性,使用户可以在文本框进行各种编辑操作。 首先,CRichEditCtrl支持格式化文本的输入和显示。用户可以在文本框输入普通文本、图像、表格等多种内容,并且可以对这些内容进行格式化,如设置字体、字号、颜色、对齐方式等,使文本呈现出更加丰富多样的样式。 其次,CRichEditCtrl还支持富文本编辑。用户可以在文本框进行插入和删除操作,如插入链接、插入图片、插入超链接等。同时,用户还可以对文本进行复制、粘贴和剪切等操作,实现对文本内容的高效编辑和管理。 此外,CRichEditCtrl还提供了撤销和重做功能,使用户可以方便地撤销之前的编辑操作,并重新执行已经撤销的操作。这样,用户就可以随时回退到之前的状态,确保编辑操作的准确性和完整性。 最后,CRichEditCtrl还支持自动完成和输入提示功能。用户在输入文本时,CRichEditCtrl可以自动提供半透明的输入提示窗口,显示可能的补充内容,如常用词汇、表情符号等,帮助用户快速输入并提高输入效率。 综上所述,CRichEditCtrl类似于QQ的编辑控件,它具有强大的编辑功能、支持富文本编辑和格式化显示、提供撤销和重做功能,同时还支持自动完成和输入提示。这使得用户可以在文本输入时体验到更多的便捷和灵活性。
评论 79
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值