|
OWLNext 6.32
|
#include <clipboar.h>
Public Member Functions | |
| TClipboard (HWND hWnd, bool mustOpen=true) | |
| ~TClipboard () | |
| void | CloseClipboard () |
| bool | OpenClipboard (HWND hWnd) |
| operator bool () const | |
| HANDLE | GetClipboardData (uint format) const |
| HWND | GetOpenClipboardWindow () const |
| HWND | GetClipboardOwner () const |
| HWND | GetClipboardViewer () const |
| int | GetClipboardFormatName (uint format, TCHAR *formatName, int maxCount) const |
| int | GetPriorityClipboardFormat (uint *priorityList, int count) const |
| int | CountClipboardFormats () const |
| bool | IsClipboardFormatAvailable (uint format) const |
| bool | EmptyClipboard () |
| uint | RegisterClipboardFormat (const tstring &formatName) const |
| HANDLE | SetClipboardData (uint format, HANDLE handle) |
| HWND | SetClipboardViewer (HWND hWnd) const |
Static Public Attributes | |
| static LPCTSTR | DefaultProtocol = _T("StdFileEditing") |
The clipboard class encapsulates the methods for the clipboard object of Windows.
TClipboard encapsulates and manipulates Clipboard data. You can open, close, empty, and paste data in a variety of data formats between the Clipboard and the open window. An object on the Clipboard can exist in a variety of Clipboard formats, which range from bitmaps to text.
Usually, the window is in charge of manipulating Clipboard interactions between the window and the Clipboard. It does this by responding to messages sent between the Clipboard owner and the application. The following ObjectWindows event-handling functions encapsulate these Clipboard messages: EvRenderFormat - Responds to a WM_RENDERFORMAT message sent to the Clipboard owner if a specific Clipboard format that an application has requested hasn't been rendered. After the Clipboard owner renders the data in the requested format, it callsSetClipboardData to place the data on the Clipboard. EvRenderAllFormats - Responds to a message sent to the Clipboard owner if the Clipboard owner has delayed rendering a Clipboard format. After the Clipboard owner renders data in all of possible formats, it calls SetClipboardData.
The following example tests to see If there is a palette on the Clipboard. If one exists, TClipboard retrieves the palette, realizes it, and then closes the Clipboard.
if (clipboard.IsClipboardFormatAvailable(CF_PALETTE)) { newPal = new TPalette(TPalette(clipboard)); // make a copy UpdatePalette(true); } // Try DIB format first if (clipboard.IsClipboardFormatAvailable(CF_DIB)) { newDib = new TDib(TDib(clipboard)); // make a copy newBitmap = new TBitmap(*newDib, newPal); // newPal==0 is OK // try metafile Second // } else if (clipboard.IsClipboardFormatAvailable(CF_METAFILEPICT)) { if (!newPal) newPal = new TPalette((HPALETTE)GetStockObject(DEFAULT_PALETTE)); newBitmap = new TBitmap(TMetaFilePict(clipboard), *newPal, GetClientRect().Size()); ... // Gets a bitmap , keeps it, and sets up data on the clipboard. // delete Bitmap; Bitmap = newBitmap; if (!newDib) newDib = new TDib(*newBitmap, newPal); #endif // ???? delete Dib; Dib = newDib; delete Palette; Palette = newPal ? newPal : new TPalette(*newDib); Palette->GetObject(Colors); PixelWidth = Dib->Width(); PixelHeight = Dib->Height(); AdjustScroller(); SetCaption("(Clipboard)"); clipboard.CloseClipboard();
| owl::TClipboard::TClipboard | ( | HWND | hWnd, |
| bool | mustOpen = true |
||
| ) |
Constructs a clipboard object to grab the clipboard given a window handle. This is the preferred method of getting the clipboard; Throws an exception on open failure if mustOpen is true (default) mustOpen can be passed as false for compatability
References OpenClipboard().
| owl::TClipboard::~TClipboard | ( | ) |
Destruct a clipboard object & close the clipboard if open.
References CloseClipboard().
| void owl::TClipboard::CloseClipboard | ( | ) |
If the Clipboard is opened (IsOpen is true), closes the Clipboard. Closing the Clipboard allows other applications to access the Clipboard.
| int owl::TClipboard::CountClipboardFormats | ( | ) | const [inline] |
Returns a count of the number of types of data formats the Clipboard can use.
| bool owl::TClipboard::EmptyClipboard | ( | ) | [inline] |
Clears the Clipboard and frees any handles to the Clipboard's data. Returns true if the Clipboard is empty, or false if an error occurs.
| HANDLE owl::TClipboard::GetClipboardData | ( | uint | Format | ) | const [inline] |
Retrieves data from the Clipboard in the format specified by format.The following formats are supported:
CF_BITMAP Data is in a bitmap formatCF_DIB Data is memoryCF_DIF Data is in a Data Interchange Format (DIF).CF_DSPMETAFILEPICT Data is in a metafile format.CF_DSPTEXT Data is in a text format.CF_METAFILEPICT Data is in a metafile structure.CF_OEMTEXT Data is an array of text characters in OEM character set.CF_OWNERDISPLAT Data is in a special format that the application must display.CF_PALETTE Data is in a color palette format.CF_PENDATA Data is used for pen format.CF_RIFF Data is in Resource Interchange File Format (RIFF).CF_SYLK Data is in symbolic Link format (SYLK).CF_TEXT Data is stored as an array of text characters.CF_TIFF Data is in Tag Image File Format (TIFF).CF_WAVE Data is in a sound wave format. | int owl::TClipboard::GetClipboardFormatName | ( | uint | Format, |
| TCHAR * | FormatName, | ||
| int | MaxCount | ||
| ) | const [inline] |
Retrieves the name of the registered format specified by format and copies the format to the buffer pointed to by formatName. maxCount specifies the maximum length of the name of the format. If the name is longer than maxCount, it is truncated.
| HWND owl::TClipboard::GetClipboardOwner | ( | ) | const [inline] |
Retrieves the handle of the window that currently owns the Clipboard, otherwise returns NULL.
| HWND owl::TClipboard::GetClipboardViewer | ( | ) | const [inline] |
Retrieves the handle of the first window in the Clipboard-view chain. Returns NULL if there is no viewer.
| HWND owl::TClipboard::GetOpenClipboardWindow | ( | ) | const [inline] |
Retrieves the handle of the window that currently has the Clipboard open. If the Clipboard is not open, the return value is NULL. Once the Clipboard is opened, applications cannot modify the data.
| int owl::TClipboard::GetPriorityClipboardFormat | ( | uint * | priorityList, |
| int | count | ||
| ) | const [inline] |
Returns the first Clipboard format in a list. priorityList points to an array that contains a list of the Clipboard formats arranged in order of priority. See GetClipboardData for the Clipboard formats.
| bool owl::TClipboard::IsClipboardFormatAvailable | ( | uint | format | ) | const [inline] |
Indicates if the format specified in format exists for use in the Clipboard. See GetClipBoardData for a description of Clipboard data formats. The following code tests if the Clipboard can support the specified formats:
void TBmpViewWindow::CePaste(TCommandEnabler& ce) { TClipboard& clipboard = OpenClipboard(); ce.Enable( clipboard && ( clipboard.IsClipboardFormatAvailable(CF_METAFILEPICT) || clipboard.IsClipboardFormatAvailable(CF_DIB) || clipboard.IsClipboardFormatAvailable(CF_BITMAP) ) ); clipboard.CloseClipboard();
| bool owl::TClipboard::OpenClipboard | ( | HWND | hWnd | ) |
Opens the Clipboard and associates it with the window specified in Wnd. Other applications cannot change the Clipboard data until the Clipboard is closed. Returns true if successful; otherwise, returns false.
| owl::TClipboard::operator bool | ( | ) | const [inline] |
Return true if the clipboard is currently owned by this application.
| uint owl::TClipboard::RegisterClipboardFormat | ( | const tstring & | formatName | ) | const [inline] |
Registers a new Clipboard format. formatName points to a character string that identifies the new format. If the format can be registered, the return value indicates the registered format. If the format can't be registered, the return value is 0. Once the format is registered, it can be used as a valid format in which to render the data.
| HANDLE owl::TClipboard::SetClipboardData | ( | uint | Format, |
| HANDLE | Handle | ||
| ) | [inline] |
Copy the data onto the clipboard in the format.
Sets a handle to the block of data at the location indicated by handle. format specifies the format of the data block. The Clipboard must have been opened before the data handle is set. format can be any one of the valid Clipboard formats (for example, CF_BITMAP or CF_DIB). See GetClipboardData for a list of these formats. handle is a handle to the memory location where the data data is stored. If successful, the return value is a handle to the data; if an error occurs, the return value is 0. Before the window is updated with the Clipboard data, the Clipboard must be closed.
| HWND owl::TClipboard::SetClipboardViewer | ( | HWND | Wnd | ) | const [inline] |
Adds the window specified by Wnd to the chain of windows that WM_DRAWCLIPBOARD notifies whenever the contents of the Clipboard change.
LPCTSTR owl::TClipboard::DefaultProtocol = _T("StdFileEditing") [static] |
Points to a string that specifies the name of the protocol the client needs. The default protocol is "StdFileEditing," which is the name of the object linking and embedding protocol.
1.7.4