Solved

assign multiple objects to the clipboard

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

760 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

18 Experts available now in Live!

Get 1:1 Help Now