Solved

assign multiple objects to the clipboard

Posted on 1997-07-31
2
1,735 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:Heapster
2 Comments
 
LVL 12

Accepted Solution

by:
andrewjb earned 200 total points
ID: 1340227
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.Open
Clipboard.SetAsHandle( Type1 , Handle1 )
Clipboard.SetAsHandle( Type2 , Handle2 )
etc.
Clipboard.Close

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

e.g.

var
  MyFormat : integer;
  MyData   : THandle;

MyFormat := RegisterClipboardFormat( 'Testing' )

...

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

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
e.g.
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 :

initialization

Type1 := RegisterClipboardFormat( 'First one' );
etc.

End.


0
 
LVL 1

Author Comment

by:Heapster
ID: 1340228
I actually managed to sort this out for myself, so i've
graded your answer as acceptable. Cheers.Paul.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question