First of all, a title indicate that in the MSN, the chat window may be a custom class. The big house can take a look at SPY .
For your custom window, you can use CreateWindow, SetWindowlong or SubclassWindow, but this is not
It is the topic I am discussing now.
Ok, let's take a look again:
The main thing I achieve is: (1) Font format; (b) hyperlink; (3) background picture; (4) animation expressions
About this implementation. We should first be clear, we must implement an OLE object. And this object can play GIF.
For playing GIF, the code has been much. More famous is the GIF89A who encapsulates, it's not bad, I like that cpictureex.
Can be found in Vchelp.
Is there this, is it? of course not. You still have to write an OLE / COM object. Implement IoleObject, etc.
Are you using ATL or MFC?
Oh, I am useless. In this directory% Program file% / tencent / qq /, you can see an imageole.dll, she is
You miss the night!
Ok, let's take a look at his true face. How to see? X ray? Of course not --ole / com viewer.
Click On "All Objects",
View Typelib ... Open the file, you can see:
[
UUID (0C1CF2DF-05A3-4FEF-8CD4-F5CFC4355A16),
Helpstring ("Igifanimator Interface",
Dual,
Nonextensible
]
Dispinterface gifanimator {
Properties:
Methods:
[ID (0x00000001), Helpstring ("Method LoadFromFile")]]]
void loadingfromfile ([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);
}
This interface is what we want. You can test it with ActiveX Control Test Container. Still tube.
So how do you use it in our program? I don't have so much time, give the code first, have time to say, forgive me.
1 lplockbytes lplockbytes = null;
2 scode sc;
3 hResult hr;
4 // Print to Richedit 'S iClientSite
5 lpoleclientsite m_lpclients;
6 // a Smart Point to Ianimator
7 igifanimatorptr m_lpanimator;
8 // PTR 2 Storage
9 LPStorage M_LPStorage;
10 // The Object 2 B INSERT 2
11 lpoleObject m_lpobject;
12
13 // CREATE LOCKBYTES
14 sc = :: createilockbytesonhglobal (null, true, & lplockbytes);
15 IF (sc! = S_ok)
16 AFXTHROWEEXCEPTION (SC);
17 Assert (lplockbytes! = Null);
18
19 // Use Lockbytes to Create Storage
20 sc = :: StegcreatedocfileonIlockBytes (lplockbytes,
21 STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, & M_LPSTORAGE
22 IF (sc! = S_ok)
twenty three {
24 Verify (LPLOCKBYTES-> Release () == 0);
25 lplockbytes = null;
26 AFXTHROWEEXCEPTION (SC);
27}
28 Assert (m_lpstorage! = Null);
29
30 // Get The Clientsite of the Very Richeditctrl
31 getiricheditole () -> getClientSite;
32 Assert (m_lpclientsite! = Null);
33
34 TRY
35 {
36 // Initlize COM Interface
37 hr = :: CoinitializeEx (null, coinit_apartmentthread);
38 IF (Failed (HR))
39 _COM_ISSUE_ERROR (HR);
40
41 // Get Gifanimator Object
42 // here, I buy a smart point, so i do not need to free it
43 hr = m_lpanimator.createInstance (CLSID_GIFANIMATOR);
44 IF (Failed (HR))
45 _COM_ISSUE_ERROR (HR);
46 // Com Operation NEED BSTR, SO Get A BSTR
47 BSTR path = strpicpath.allocsystring ();
48
49 // Load the GIF
50 hr = m_lpanimator-> loadingfromfile (path);
51 IF (Failed (HR))
52_Com_issue_ERROR (HR);
53
54 trace0 (m_lpanimator-> getfilepath ());
55
56 // get the ioleObject
57 hr = m_lpanimator.queryinterface (IID_ID_IOLOBJECT, (VOID **) & m_lpobject);
58 IF (Failed (HR))
59 _COM_ISSUE_ERROR (HR);
60
61 // set it 2 b inserted
62 OleSetContainedObject (M_LPObject, true);
63
64 // 2 INSERT in 2 Richedit, You NEED A STRUCT OF REOBJECT
65 Reobject Reobject;
66 ZeromeMory (& Reobject, Sizeof (Reobject));
67
68 reobject.cbstruct = sizeof (reobject); 69 CLSID CLSID;
70 sc = m_lpobject-> getuserclassid (& clsid);
71 IF (sc! = S_ok)
72 AFXTHROWEEXCEPTION (SC);
73 // set CLSID
74 reobject.clsid = CLSID;
75 // can be selfiterated
76 reerct.cp = reo_cp_selection;
77 // Content, But Not Static
78 reerct.dvaspect = dvaspect_content;
79 // Goes in The Same Line of Text Line
80 reobject.dwflags = reo_belowbaseline; // reo_resizable |
81 reerject.dwuser = 0;
82 // The Very Object
83 reerject.poleobj = m_lpobject;
84 // Client Site Contain The Object
85 reobject.polesite = m_lpclients;
86 // The Storage
87 reobject.pstg = m_lpStorage;
88
89 Sizel Sizel;
90 sizel.cx = sizel.cy = 0;
91 reobject.sizel = sizel;
92 hwnd hwnd = this-> m_hwnd;
93 // SEL All Text
94 // :: SendMessage (HWndRT, EM_SETSEL, 0, -1);
95 // DWORD DWSTART, DWEND;
96 //: SendMessage (HWndRT, Em_getsel, (WPARAM) & DWStart, (LPARAM);
97 // :: SendMessage (HWndRT, EM_SETSEL, DWEND 1, DWEND 1);
98 // INSERT AFTER THE LINE OF TEXT
99 getiricheditole () -> INSERTOBJECT (& REOBJECT);
100 :: SendMessage (HWndRT, EM_Scrollcaret, (wparam) 0, (LPARAM) 0);
101 Variant_Bool Ret;
102 // Do Frame Changing
103 RET = m_lpanimator-> TriggerFramechange ();
104 // show it
105 m_lpobject-> doverb (oleiverb_uiactivate, null, m_lpclientsite, 0, m_hwnd, null);
106 m_lpobject-> doverb (oleiverb_show, null, m_lpclientsite, 0, m_hwnd, null);
107
108 // RedRaw the window to show animation
109 redrawwindow ();
110
111 if (m_lpclientsite)
112 {
113 m_lpclients -> release ();
114 m_lpclientsite = NULL;
115}
116 if (m_lpObject) 117 {
118 m_lpobject-> release ();
119 m_lpobject = NULL;
120}
121 IF (M_LPStorage)
122 {
123 M_LPStorage-> Release ();
124 m_lpStorage = null;
125}
126
127 sysfreeestring (path);
128}
129 catch (_COM_ERROR E)
130 {
131 AFXMessageBox (E.ErrorMessage ());
132 :: Couninitialize ();
133} Oh, at the core code, I still have a long time.愧!