Gifolecontrol 1.0.2 Function Description

Source: Internet
Author: User

Gifolecontrol can insert images, including BMP, JPG, and PNG. The image size is not limited. The key point is that GIF animation can be inserted in RichEdit. Currently, swf format cannot be inserted. At the same time, you can directly display tooltip In the inserted image and GIF to facilitate the application.

 

The interface defined by gifolecontrol is as follows:

 

Interface igifctrl: idispatch {
[Propput, Bindable, requestedit, ID (dispid_bordercolor)]
Hresult bordercolor ([in] ole_color CLR );
[Propget, Bindable, requestedit, ID (dispid_bordercolor)]
Hresult bordercolor ([out, retval] ole_color * pclr );
[Propget, Bindable, requestedit, ID (dispid_hwnd)]
Hresult hwnd ([out, retval] long_ptr * phwnd );
[ID (1), helpstring ("method loadfromfile")] hresult loadfromfile ([in] BSTR bstrfilename );
[ID (2), helpstring ("method loadfromfilesized")] hresult loadfromfilesized ([in] BSTR bstrfilename, [in] int nheight );
[ID (3)] hresult getrect ([out] rect * RC );
[ID (4)] hresult showhint ();
[ID (5)] hresult sethostwindow ([in] Long hwndhostwindow, [in] int nnotyfymode );
[ID (6)] hresult loadflash ([in] BSTR bstrfilename, [in] BSTR bstrflashvars, [in] int nwidth, [in] int nheight );
[ID (7)] hresult settooltip ([in] BSTR bstrhint );
[ID (8)] hresult gettooltip ([out, retval] BSTR * bstrhint );
[ID (9)] hresult getfilepath ([out, retval] BSTR * bstpath );
};

 

 

Classes generated after ActiveX import:

//////////////////////////////////////// /// // <Br/> // cgifctrl Wrapper class </P> <p> class cgifctrl: public cwnd <br/>{< br/> protected: <br/> declare_dyncreate (cgifctrl) <br/> Public: <br/> CLSID const & getclsid () <br/> {<br/> static CLSID const CLSID <br/> = {0xc44ec05f, 0x86a8, 0x0000c, {0xba, 0xcd, 0xf8, 0xdd, 0x18, 0x6c, 0xfc, 0x46 }}; <br/> return CLSID; <br/>}< br/> virtual bool create (lpctstr lpszclassname, <br/> lpctstr lpszwindowname, DWORD dwstyle, <br/> const rect & rect, <br/> cwnd * pparentwnd, uint NID, <br/> ccreatecontext * pcontext = NULL) <br/> {return createcontrol (getclsid (), lpszwindowname, dwstyle, rect, pparentwnd, NID) ;}</P> <p> bool create (lpctstr lpszwindowname, DWORD dwstyle, <br/> const rect & rect, cwnd * pparentwnd, uint NID, <br/> cfile * ppersist = NULL, bool bstorage = false, <br/> BSTR bstrlickey = NULL) <br/> {return createcontrol (getclsid (), lpszwindowname, dwstyle, rect, pparentwnd, NID, <br/> ppersist, bstorage, bstrlickey );} </P> <p> // attributes <br/> Public: </P> <p> // Operations <br/> public: <br/> void setbordercolor (unsigned long newvalue); <br/> unsigned long getbordercolor (); <br/> long gethwnd (); <br/> void loadfromfile (maid); <br/> void loadfromfilesized (maid, long nheight ); <br/> // method 'getrect 'not emitted because of invalid return type or parameter type <br/> // method 'onmsg' not emitted because of invalid return type or parameter type <br/> void showhint (); <br/> void sethostwindow (long hwndhostwindow, long nnotyfymode); <br/> void loadflash (lpctstr bstrfilename, lpctstr bstrflashvars, long nwidth, long nheight ); <br/> void settooltip (lpctstr bstrhint); <br/> cstring gettooltip (); <br/> cstring getfilepath (); <br/>}; <br/>

 

Through the COM component, the demo is as follows:

 

The following describes how to use the control, including: 1. Use it in the dialog box; 2. Use it in RichEdit.

1. In the dialog box, use:

First, register the control gifolecontrol. dll, copy gifolecontrol. DLL to the system directory, and then use the command regsvr32 gifolecontrol. DLL to register the control.

In the dialog box resource editor, right-click and select "insert ActiveX control", select "gifctrl class", and insert the control. Right-click the inserted ActiveX Control and select "add variable" to generate the corresponding packaging class and corresponding instance, so that you can call the object method.

2. Use in RichEdit

The methods used in RichEdit are basically the same as those in the previous article. You only need to replace the corresponding classes and function calls. However, you can directly use the interface and interface guid definition here. The specific code is as follows:

 

 Iricheditole * lpricheditole = m_rich.getiricheditole (); <br/> If (null = lpricheditole) <br/>{< br/> return; <br/>}</P> <p> istorage * lpstorage = NULL; <br/> ioleobject * lpoleobject = NULL; <br/> lplockbytes = NULL; <br/> ioleclientsite * lpoleclientsite = NULL; <br/> igifctrl * lpdynamicgif = NULL; <br/> CLSID; <br/> reobject; </P> <p> hresult hr; </P> <p> hR =: cocreateinstance (CLSID _ Gifctrl, 0, clsctx_inproc, <br/> iid_igifctrl, <br/> (lpvoid *) & lpdynamicgif); </P> <p> int n = getlasterror (); <br/> If (lpdynamicgif = NULL) <br/>{</P> <p> return; <br/>}</P> <p> If (failed (HR) <br/>{</P> <p> return; <br/>}< br/> cstring szpath = m_path; // ("C: // 21.gif"); <br/> BSTR Path = szpath. allocsysstring (); <br/> try <br/> {<br/> lpdynamicgif-> loadfromfile (PATH ); <br/> bstr p = LPD Ynamicgif-> getfilepath (); </P> <p >}< br/> catch (...) <br/>{< br/> afxthrowoleexception (HR); <br/>}</P> <p> If (failed (HR )) <br/>{< br/> afxthrowoleexception (HR ); <br/>}// interface for obtaining OLE objects </P> <p> hR = lpdynamicgif-> QueryInterface (iid_ioleobject, (void **) & lpoleobject ); <br/> If (failed (HR) <br/>{< br/> afxthrowoleexception (HR); <br/>}< br/> olesetcontainedobject (lpoleobject, true); <br/> // obtain CLSID <br/> hR = lpol Eobject-> getuserclassid (& CLSID); <br/> If (failed (HR) <br/>{< br/> afxthrowoleexception (HR ); <br/>}</P> <p> hR =: createilockbytesonhglobal (null, true, & lplockbytes ); // create a lockbyte object <br/> If (failed (HR) <br/>{< br/> afxthrowoleexception (HR ); <br/>}< br/> assert (lplockbytes! = NULL); <br/> hR =: stgcreatedocfileonilockbytes (lplockbytes, <br/> stgm_1__exclusive | stgm_create | stgm_readwrite, <br/> 0, & lpstorage ); <br/> If (failed (HR) <br/>{< br/> verify (lplockbytes-> release () = 0 ); <br/> lplockbytes = NULL; <br/> afxthrowoleexception (HR); <br/>}< br/> olesetcontainedobject (lpoleobject, true ); <br/> lpricheditole-> getclientsite (& lpoleclientsite); <br/> zeromemory (& reobject, sizeof (reobject); // Initialize an object <br/> reobject. cbstruct = sizeof (reobject); <br/> reobject. CLSID = CLSID; <br/> reobject. CP = reo_cp_selection; <br/> reobject. dvaspect = dvaspect_content; <br/> reobject. dwflags = reo_belowbaseline; <br/> reobject. poleobj = lpoleobject; <br/> reobject. polesite = lpoleclientsite; <br/> reobject. pstg = lpstorage; <br/> reobject. dwuser = (DWORD) lpdynamicgif; </P> <p> lpoleobject-> setclientsite (lpoleclientsite); <br/> lpdynamicgif-> sethostwindow (long) m_rich.getsafehwnd (), 1); </P> <p> lpoleobject-> doverb (oleiverb_show, null, lpoleclientsite,-1, m_hwnd, null ); </P> <p> cstring szpath2 ("22222222222"); </P> <p> BSTR path2 = szpath2.allocsysstring (); </P> <p> lpdynamicgif-> settooltip (path2); // set the GIF toolt </P> <p> lpdynamicgif-> showhint (); </P> <p> szpath2.allocsysstring (); <br/> hR = lpricheditole-> insertobject (& reobject); </P> <p> If (failed (HR )) <br/>{< br/> afxthrowoleexception (HR); <br/>}</P> <p> redrawwindow (); // refresh the form </P> <p >}< br/> catch (cexception * E) <br/>{< br/> E-> Delete (); <br/>}</P> <p> lpricheditole-> release (); <br/> lpricheditole = NULL;

 

 

Demo download: http://sv004d.mofile.com/7125120180791962/RGlzazEvNTQvNTQyNzI4MTQyMC83Lzc0OTQ0NjQwNjA4NjQ1Nw../TestGif.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.