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 "));