Page 1 of 2

Clipboard size

PostPosted: Wed Jun 18, 2008 6:47 pm
by Dietmar Jahnel
We have a problem when very long text (> 100.000 characters) is copied to the clipboard - only part of it can be pasted.

What can be done?
Is there a limit of the clipboard?

Thanks for help,
Dietmar

PostPosted: Sat Jun 21, 2008 10:50 am
by Antonio Linares
Dietmar,

The clipboard should be able to support up to 2GB strings or more (limited by max available memory).

Are you copying from a richedit control ?

PostPosted: Sun Jun 22, 2008 9:10 am
by Dietmar Jahnel
no I'm using FGet (with many modifications for our use)

with
oClp:SetText( cText )
oClp:GetText( )

I can see that only part of very long texts are copied.
I there a limit by Windows? (same results with xP and vista)

Thanks,
Dietmar

PostPosted: Sun Jun 22, 2008 6:14 pm
by James Bott
If you Google "clipboard maximum size" you will get a lot of different opinions on this. It seems most people say that the limit was 32K in 16bit but in 32bit the maximum is limited to available memory which can, of course, vary from time to time even on the same computer. So, I think you are always going to have some problems with copying large amounts of text.

James

PostPosted: Sun Jun 22, 2008 9:31 pm
by Detlef Hoefner
Dietmar,

just an idea and not tested.
Test your text string for binary zeroes.

Clipper and xHarbour can handle these characters in a string.
But in c language a '\0', which is chr( 0 ) terminates a string.

May be that this causes your problem ?

Regards,
Detlef

PostPosted: Wed Dec 10, 2008 8:34 am
by PatrickWeisser
Hello Dietmar,

Did you ever get this issue resolved? I'm having a problem with the Windows Clipboard only accepting about 20k of text. I'm using FWH 8.10 and Windows XP. As a test I modified the PlaceSomeText() function of the TestClip.prg sample as follows:

Code: Select all  Expand view
function PlaceSomeText()

   local cText := Space( 30 )

   //if MsgGet( "Ok...", "Write something!", @cText )
   //   oClp:SetText( cText )
   //endif

   oClp:SetText( Replicate( "ABCDEFGHIJ" + Chr( 13 ) + Chr( 10 ), 100000 ) )

   nMsgBox( "Number of bytes in clipboard: " + Str( Len( oClp:GetText() ) ) )

return nil



When I run it and select Use The Clipboard, Place Some Text, I get 20,352 in the result:

[img]
http://www.donorquest.com/images/TestClp.jpg
[/img]

It should be 1,200,000 bytes based on replicating the string "ABCDEFGHIJ" (plus CR-LF) 100,000 times.

I have tried it on two different XP machines and still get the same result.

Thanks,

-Patrick

PostPosted: Wed Dec 10, 2008 8:37 am
by Antonio Linares
Patrick,

We are going to test it in a few minutes... :-)

PostPosted: Wed Dec 10, 2008 9:05 am
by Antonio Linares
Patrick,

You are right, it seems as its size is limited (around 32 Ks).

The text that you want to copy, where will it be used from ? I mean, will it be used from the same application, or from another application ?

PostPosted: Wed Dec 10, 2008 9:50 am
by PatrickWeisser
Antonio,

The text will be used in another application. The particular feature I am implementing copies delimited email addresses to the Clipboard so that they may be pasted in the TO: or BCC: block of an email message using whatever email software our customer prefers to use. There may be a better way of allowing our customers to do a mass email to a select group of their constituents, so I'm open to suggestions. However, having full access to the Windows Clipboard is very important and not something I would want to worry about having a limit on. I'm able to copy and paste many megabytes worth of text from my editor to a FWH memo field, and from a memo field back to the Clipboard and my editor, so I don't think it's a Windows limitation. My feeling is that it must be something with Harbour or FiveWin. It's not extremely urgent right now, but I would sure like to have full functionality at some point.

Thanks,

-Patrick

PostPosted: Wed Dec 10, 2008 10:02 am
by PatrickWeisser
My guess is that there is probably a 32-bit parameter somewhere in the mix that indicates the size of the text buffer to be copied to the Clipboard, but the parameter is being truncated to 16-bits at some point by some old 16-bit code.

PostPosted: Wed Dec 10, 2008 10:04 am
by Antonio Linares
Patrick,

We have been googling for clipboard size (limit) and it seems as there is such limitation :-(

PostPosted: Wed Dec 10, 2008 2:23 pm
by James Bott
Patrick,

The particular feature I am implementing copies delimited email addresses to the Clipboard so that they may be pasted in the TO: or BCC: block of an email message using whatever email software our customer prefers to use. There may be a better way of allowing our customers to do a mass email to a select group of their constituents, so I'm open to suggestions.


You can use the MAPI or SMTP classes to do this. MAPI will send them to the currently installed MAPI compliant mail client software (like Outlook), and SMTP will send it directly to the mail server.

I would suggest SMTP for mass emails. They will have to have access to an SMTP server.

Regards,
James

PostPosted: Wed Dec 10, 2008 5:43 pm
by PatrickWeisser
Thanks James, I will take a look at the FWH Samples ProxOut.prg and TestSmtp.prg (and TestMail.prg for the MAPI) to see if they offer the functionality our customers need for this particular feature.

Antonio - If there is indeed a limit of 20k on the ClipBoard in Win32, why am I able to copy many megabytes worth of text between NotePad and other text editors using the Windows ClipBoard, or indeed between a memo field of a FiveWin application and NotePad?

Thanks,

-Patrick

PostPosted: Wed Dec 10, 2008 5:58 pm
by James Bott
Patrick,

I should mention that if your users need to compose a message, then perhaps MAPI is your best solution. You can send the TO or BC list to the MAPI client and bring up the message edit screen so they can then type in their message.

If you are sending a pre-written message then SMTP is probably the best way. One button click can handle the entire process.

Regards,
James

PostPosted: Wed Dec 10, 2008 6:11 pm
by Antonio Linares
Patrick,

You are totally right. It was a bug in our code (from 16 bits times) :-)

Now it is working fine. These are the required changes in FWH\source\clpbrd.c function SETCLIPBOARDDATA():
Code: Select all  Expand view
   ...
   ULONG ulLen;   // instead of WORD

   ...
         case CF_TEXT:
              ulLen = _parclen( 2 );
              hMem = GlobalAlloc( GHND, ulLen + 1 );
              if( ! hMem )
              {
                 _retl( 0 );
                 return;
              }

              pMem = GlobalLock( hMem );
              _bcopy( ( char * ) pMem, _parc( 2 ), ulLen );
              GlobalUnlock( hMem );
              _retl( ( BOOL ) SetClipboardData( CF_TEXT, hMem ) );
              break;
...

You can download the modified clpbrd.obj from here:
http://www.mediafire.com/?sharekey=de51 ... 2c0c6b2158
Link it as another OBJ of your app, or replace it in FiveHC.lib.

Thanks! :-)