• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1740
  • Last Modified:

assign multiple objects to the clipboard

I want to assign multiple objects to the clipboard, i.e.
bitmaps, records, of any number, and be able to read them all back.  I also want to register my custom clipboard formats with the system when my program is installed.
How do i do this?
1 Solution
I think the following answers your question, or at least is a start. If there isn't enough here to get you going properly, add a comment, and I'll try to add more.

To assign multiple objects :
Clipboard.SetAsHandle( Type1 , Handle1 )
Clipboard.SetAsHandle( Type2 , Handle2 )

You can get the data back off the clipboard using GetAsHandle, after testing what is there using the function Clipboard.HasFormat


  MyFormat : integer;
  MyData   : THandle;

MyFormat := RegisterClipboardFormat( 'Testing' )


if ( Clipboard.HasFormat( MyFormat ) ) then
  MyData := Clipboard.GetAsHandle( MyFormat );

You'll need to allocate some global memory with GlobalAlloc / GlobalLock for the handle, and put your data in it.

To register formats :
You need to use the RegisterClipboardFormat function, which returns an integer identifier, or zero on fail
MyFirstFormat := RegisterClipboardFormat( 'My clipboard type' );

You can do this wherever you want. ( Doing it twice with the same format description string will return the same integer value )

Units can have an 'initialization' section which is run once only, if the unit is used anywhere in your application. At the end of the implementation section ( after all your functions and procedures ; just before the final end. ) do :


Type1 := RegisterClipboardFormat( 'First one' );


HeapsterAuthor Commented:
I actually managed to sort this out for myself, so i've
graded your answer as acceptable. Cheers.Paul.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now