首页 >> 电脑教程 >> 网络编程 >> 正文

CRichEditCtrl实现MSN/QQ动画表情

[ 来源:互联网 | 本篇文章热度: | 收藏本文 ]
 ZhouWei.Net关键字导读:网络编程  编程
   
 首先对标题说明一下,在MSN中,聊天的窗口可能是一个自定义的类。站长资源网的网友们用Spy ++可以看看。对与自定义窗口,可以使用CreateWindow, SetWindowLong或者是SubclassWindow实现,不过这不是我现在讨论的话题。   好, 先看看效果再说:
CRichEditCtrl实现MSN/QQ动画表情
  关于这个的实现。我们首先应当明了,我们必须实现一个OLE对象。而且这个对象能够播放GIF.对于播放GIF,代码已经很多了。
  有了这个就完了么?当然不是。你还有写一个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
#import "D:\\Program files\\tencent\\qq\\ImageOle.dll" named_guids  named_guids 表示让编译器为我把对应库的GUID和声明对应起来。我们就可以用CLSID_GifAnimator引用对应的接口了。不用那一长串的东西。然后它就会为我们生成两个文件。

更多文章 站长资源网-MSN图像  MSN专题  QQ表情-有问题上站长资源网
ImageOle.tlh
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
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
74//
75// Wrapper method implementations
76//
77#include "d:\myproject\msger\debug\ImageOle.tli"
78
79} // namespace ImageOleLib
80#pragma pack(pop)

更多文章 站长资源网-MSN图像  MSN专题  QQ表情-有问题
首页 上一页 1 2 3 4 下一页 尾页
   
打印
网络编程  编程

>> 相关资讯:

上一篇:        下一篇: