| Methods Index |
Subclass: None
CClipboard is used to cut and paste data to and from the native- system clipboard. A CClipboard is not a visible object; it is a representation of the native clipboard. The CClipboard has methods to obtain streams for putting and getting data to and from the native clipboard. These clipboard streams must be used to stream to and from the CClipboard. The clipboard can be opened in either read or write mode but not both.
CClipboard you need to create a CClipboard object in either CB_READ or CB_WRITE mode. If the mode is CB_READ, data will be read from the native clipboard when an input stream is retrieved. If the mode is CB_WRITE, the data will be put on the native clipboard when the CClipboard object is destroyed or if the Flush( ) method is called.To stream data to or from the native clipboard, retrieve a stream object of the appropriate type from the
CClipboard object.Here is an example:
CClipboard aCB; //CBWRITE mode is the defaultSince we have left scope, the
CClipboardApplOStream * aApplStr =
aCB.GetApplOStream("MYMN"); //MYMN is the name of
the data
CClipboardTextOStream * aTextStr = aCB.GetTextOStream();
CClipboardPictOStream * aPictStr = aCB.GetPictOStream();
*aApplStr << MyBinaryData; // Streaming out binary data
*aTextStr << "My Text"; // Streaming out text
*aPictStr << myPict; // Streaming out a PICTURE
CClipboard was deleted and the data was flushed to the system clipboard. We could have also called aCB.Flush(); to flush the data to the clipboard.You can follow a similar path to read data from the native clipboard. Remember, the data will be retrieved from the clipboard when the instream is asked for.
CClipboard aCB(CB_READ);
CClipboardApplIStream * aApplStr =
aCB.GetApplIStream("MYMN"); // MYMN is the name of
the data
CClipboardTextIStream * aTextStr = aCB.GetTextIStream();
CClipboardPictIStream * aPictStr = aCB.GetPictIStream();
*aApplStr myNewBinaryData; // Streaming in binary data
*aTextStr myTextBuf; // Streaming in text
*aPictStr myNewPict; // Streaming in a PICTURE
CClipboard(CBMode theMode = CB_WRITE);
CClipboard constructor is CB_WRITE. The CClipboard can be constructed in read mode by passing CB_READ.
~CClipboard( );
CClipboard has the CB_WRITE mode, the data will be flushed to the native clipboard when the destructor is called.
CClipboardTextIStream * GetTextIStream( );
CClipboardTextOStream * GetTextOStream( );
CClipboardApplIStream * GetApplIStream(const char * theName);
CClipboardApplOStream * GetApplOStream(const char * theName);
CClipboardPictIStream * GetPictIStream( );
PICTURE input stream.
CClipboardPictOStream * GetPictOStream( );
PICTURE output stream.
static BOOLEAN HasFormat(CB_FORMAT format, char * theName = NULL);
CB_TEXT, CB_APPL, and CB_PICT.
void Flush( );
CClipboard has the mode CB_WRITE, then the data will be written to the native clipboard. Alternatively, if the mode if CB_READ, any data on the native clipboard will be read into the CClipboard.
CBMode GetMode( );
CClipboard. The returned mode will be CB_READ or CB_WRITE.