SetClipboardData
Description
Places data on the clipboard in a specified clipboard format.
Syntax
HANDLE SetClipboardData( UINT uFormat, HANDLE hMem )
Parameters
- uFormat
- [input] Specifies a standard or registered clipboard format, like CF_TEXT, CF_DIB etc.
- hMem
- [input] Handle to the data in the specified format.
Return
If the function succeeds, the return value is the handle to the data. If the function fails, the return value is NULL.
Examples
EX1
int SetClipboardData_ex1()
{
string str = "Hello World";
int nMemSize = str.GetLength() + 1;// need terminating zero
HANDLE hData = GlobalAlloc(GHND,nMemSize);
LPSTR lpData = (LPSTR)GlobalLock(hData);
lstrcpyn(lpData, str, nMemSize);
GlobalUnlock(hData);
if(OpenClipboard(NULL))
{
EmptyClipboard();
SetClipboardData(CF_TEXT,hData);
CloseClipboard();
}
return 1;
}
Remark
This function places data on the clipboard in a specified clipboard format.
The window must be the current clipboard owner, and the application must have called the OpenClipboard function.
Before calling SetClipboardData, an application must open the clipboard by using the OpenClipboard function.
The hMem data will be passed to the clipboard, which means that the application must create this data and not to lock and not to free it after giving it to the clipboard.
See Also
GetClipboardData
header to Include
origin.h
Reference
|