Copy several files to the clipboard
Copy several files to the clipboard
Hi,
I need to copy several files to the clipboard at the same time. How can I do this ?
I need to copy several files to the clipboard at the same time. How can I do this ?
Re: Copy several files to the clipboard
It looks like you need to use the function Clipboard.SetFileDropList() But how to do it under FWH I do not know
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Copy several files to the clipboard
This is dot NET.Clipboard.SetFileDropList()
FWH has not yet provided this.
This will be provided soon.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Copy several files to the clipboard
Thanks, I get it !
Is it possible in FWH to write multiple files to the clipboard at the moment ?
Is it possible in FWH to write multiple files to the clipboard at the moment ?
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Copy several files to the clipboard
Dear Yuri,
Here you have a working example:
You have to modify FWH\source\winapi\clpbrd.c this way:
Here you have a working example:
Code: Select all | Expand
#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
Code: Select all | Expand
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/windows/win32/api/winuser/nf-winuser-setclipboarddata
// 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
}
}
}
Re: Copy several files to the clipboard
Thank you, Antonio, this is what I need!!!
Re: Copy several files to the clipboard
And how to activate the changes in clpbrd.c? Do I need to rebuild the library (which one) or is there another way?
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Copy several files to the clipboard
Simply modify clpbrd.c, compile it and link the resulting OBJ to your EXE
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Copy several files to the clipboard
From the next version FWH2305 onwards, you can simply call:
Code: Select all | Expand
FW_CopyToClipboard( aFiles ) --> lSuccess
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Copy several files to the clipboard
Thank you, this is good news !