Can anyone explain to me what the second parameter is? MSDN didn't explain it too well.. err, it went over my head.
Say I want to take text from one of my text boxes and click a button "Copy to Clipboard"
Printable View
Can anyone explain to me what the second parameter is? MSDN didn't explain it too well.. err, it went over my head.
Say I want to take text from one of my text boxes and click a button "Copy to Clipboard"
why that's a handle....
just kidding...
it works something like this... if this does not work email me tomorrow at [email protected]
I will send you a sample that works...
if( OpenClipboard( myhwnd ) ){
HGLOBAL hgb = GlobalAlloc(
GMEM_MOVEABLE, // allocation attributes
100 // number of bytes to allocate
);
char* pdata;
pdata = (char*) GlobalLock(hgb);
strcpy(pdata, "my text");
SetClipboardData( CF_TEXT, hgb);
GlobalUnlock(hgb);
}
Code:if( OpenClipboard() )
{
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, sFxName.GetLength() + 1);
if( hGlobal )
{
char *psz = (char *)GlobalLock( hGlobal );
strcpy(psz, sFxName.GetBuffer( sFxName.GetLength() ) );
sFxName.ReleaseBuffer();
SetClipboardData(CF_TEXT, hGlobal);
}
CloseClipboard();
}