Use the serialization mechanism to use the OLE clipboard in the document view structure

Source: Internet
Author: User
Tags object serialization
Http://www.fmdstudio.net (FMD)

Use the serialization mechanism to use the OLE clipboard in the document view structure

I. serialization support

The cobject-derived object is supported by adding specific macro statements in the class declaration and implementation sections to add serialization.

Declare_serial (csomeobject)

Implement_serial (csomeobject, csomebase, 1)

Reload the serialize member function to write the stored and read processes of objects.
Loading data ......

Ole replication of binary objects
// Create a memory file csharedfile; // create a document object for writing
Carchive AR (& file, carchive: Store); // serialization function of the object for Ar
Somobjects. serialize (AR );
Ar. Close ();
Coledatasource * pdatasource = NULL;
Try {// create an ole data source pdatasource = new coledatasource; // specify the memory file to the data source pdatasource-> cacheglobaldata (m_cfdraw, file. detach (); // set the clipboard pdatasource-> setclipboard ();} catch_all (e) {Delete pdatasource; throw_last ();} end_catch_all

3. Ole pasting of Objects
// Create the OLE Data Object coledataobject dataobject; // connect to the clipboard dataobject. attachclipboard (); If (dataobject. isdataavailable (m_cfdraw) // determine whether the specified format exists {// obtain the memory file pointer cfile * pfile = dataobject. getfiledata (m_cfdraw); If (pfile! = NULL) {// create the Document Object carchive AR (pfile, carchive: load) for reading; try {// call the object serialization function for AR. Graphylist. serialize (AR) ;}catch_all (e) {ar. Close (); Delete pfile; throw_last () ;}end_catch_all ar. Close (); Delete pfile ;}}

Iv. Format

When using the OLE clipboard, you must register your own format

Declare and define a static structure where appropriate (the following uses cgraphdrawdoc as an example)

Static clipformat m_cfdraw;

Clipformat cgraphdrawdoc: m_cfdraw = NULL;

// Register the format when initializing the program.

Cgraphdrawdoc: m_cfdraw = (clipformat) registerclipboardformat (_ T ("FMD graphdraw "));

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.