Solved

assign multiple objects to the clipboard

Posted on 1997-07-31
2
1,733 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now