Hi,
I need to copy several files to the clipboard at the same time. How can I do this ?
Clipboard.SetFileDropList()
#include "FiveWin.ch"
#define CF_HDROP 15
function Main()
local oWnd, hDrop
DEFINE WINDOW oWnd
MsgInfo( OpenClipboard( oWnd:hWnd ) )
MsgInfo( SetClipboardData( CF_HDROP, { "tutor1.prg", "tutor02.prg", "tutor03.prg" } ) )
hDrop = GetClpData( CF_HDROP )
XBROWSER DragQueryFiles( hDrop )
CloseClipboard()
oWnd:End()
return nil
HB_FUNC( SETCLIPBOARDDATA )
{
WORD wType = hb_parni( 1 );
ULONG ulLen;
HGLOBAL hMem;
void far * pMem;
HBITMAP hDuplBmp;
if( hb_pcount() > 1 )
{
switch( wType )
{
case CF_TEXT:
case CF_UNICODETEXT:
ulLen = hb_parclen( 2 );
hMem = GlobalAlloc( GHND, ulLen + 1 );
if( ! hMem )
{
hb_retl( 0 );
return;
}
pMem = GlobalLock( hMem );
memcpy( ( char * ) pMem, ( char * ) hb_parc( 2 ), ulLen );
GlobalUnlock( hMem );
// hb_retl( ( BOOL ) SetClipboardData( CF_TEXT, hMem ) );
hb_retl( SetClipboardData( wType, hMem ) != NULL );
break;
case CF_BITMAP:
/*
// commented out : 2021-03-07
hb_retl( SetClipboardData( CF_BITMAP,
DuplicateBitmap( ( HBITMAP ) fw_parH( 2 ) ) ) != NULL );
*/
// substituted code : 2021-03-07
hDuplBmp = DuplicateBitmap( ( HBITMAP ) fw_parH( 2 ) );
hb_retl( SetClipboardData( CF_BITMAP,hDuplBmp ) != NULL );
DelResource( hDuplBmp ); // This is required because DuplicateBitmap() Registers the resource (internal to FWH)
// See: https://docs.microsoft.com/en-us/window ... pboarddata
// Should we delete the object hDuplBmp ?
DeleteObject( hDuplBmp );
break;
case CF_HDROP:
{
PHB_ITEM pArray = hb_param( 2, HB_IT_ARRAY );
ULONG ulFiles = hb_arrayLen( pArray );
ULONG ulBufSize = sizeof(DROPFILES);
ULONG i;
DROPFILES * pDropFiles;
TCHAR * pData;
for( i = 1; i <= ulFiles; i++ )
ulBufSize += ( hb_arrayGetCLen( pArray, i ) + 1 ) * sizeof(TCHAR);
ulBufSize += sizeof(TCHAR); // For the final NULL character
hMem = GlobalAlloc( GHND, ulBufSize );
if( ! hMem )
{
hb_retl( 0 );
return;
}
pMem = GlobalLock( hMem );
pDropFiles = ( DROPFILES * ) pMem;
pDropFiles->pFiles = sizeof(DROPFILES);
pDropFiles->pt.x = pDropFiles->pt.y = 0;
pDropFiles->fNC = FALSE;
pDropFiles->fWide = sizeof(TCHAR) == sizeof(WCHAR) ? TRUE : FALSE;
pData = ( TCHAR * ) ( ( BYTE * ) pMem + sizeof(DROPFILES) );
for( i = 1; i <= ulFiles; i++ )
{
hb_strncpy( pData, hb_arrayGetCPtr( pArray, i ), hb_arrayGetCLen( pArray, i ) );
pData += hb_arrayGetCLen( pArray, i ) + 1;
}
*pData = '\0';
GlobalUnlock( hMem );
hb_retl( SetClipboardData( CF_HDROP, hMem ) != NULL );
}
break;
#ifdef __FLAT__
#ifndef UNICODE
case CF_ENHMETAFILE:
break;
#endif
#endif
}
}
}
FW_CopyToClipboard( aFiles ) --> lSuccess
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 18 guests